fix: name selected map area actions
This commit is contained in:
parent
7251cec05e
commit
57ed1dc70f
@ -1,5 +1,5 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { objectZoneId } from "../../lib/locationMapUtils";
|
||||
import { getMapObjectDisplayLabel, objectZoneId } from "../../lib/locationMapUtils";
|
||||
|
||||
export const MAP_DISPLAY_CONTROLS = [
|
||||
["showZones", "Zones"],
|
||||
@ -134,6 +134,8 @@ export function SelectedMapObjectForm({
|
||||
onDuplicateObject,
|
||||
onDeleteObject,
|
||||
}) {
|
||||
const selectedObjectLabel = getMapObjectDisplayLabel(selectedObject);
|
||||
|
||||
return (
|
||||
<div className="location-map-object-form">
|
||||
<label className="location-map-field-row">
|
||||
@ -187,8 +189,23 @@ export function SelectedMapObjectForm({
|
||||
</button>
|
||||
</div>
|
||||
<div className="location-map-editor-actions">
|
||||
<button type="button" onClick={onDuplicateObject} disabled={saving}>Duplicate</button>
|
||||
<button type="button" className="danger" onClick={onDeleteObject} disabled={saving}>Delete</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={onDuplicateObject}
|
||||
disabled={saving}
|
||||
aria-label={`Duplicate area ${selectedObjectLabel}`}
|
||||
>
|
||||
Duplicate
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="danger"
|
||||
onClick={onDeleteObject}
|
||||
disabled={saving}
|
||||
aria-label={`Delete area ${selectedObjectLabel}`}
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
@ -357,11 +357,11 @@ test("admin creates a map from zones, saves a draft, and publishes it", async ({
|
||||
|
||||
await page.getByRole("textbox", { name: "Label" }).fill("Bread Wall");
|
||||
await expect(page.locator(".location-map-sheet-header strong")).toHaveText("Bread Wall");
|
||||
await page.getByRole("button", { name: "Duplicate" }).click();
|
||||
await page.getByRole("button", { name: "Duplicate area Bread Wall" }).click();
|
||||
await expect(page.getByRole("textbox", { name: "Label" })).toHaveValue("Bread Wall Copy");
|
||||
await page.getByLabel("Linked zone").selectOption("502");
|
||||
await page.getByRole("textbox", { name: "Label" }).fill("Temporary Freezer");
|
||||
await page.getByRole("button", { name: "Delete" }).click();
|
||||
await page.getByRole("button", { name: "Delete area Temporary Freezer" }).click();
|
||||
await confirmSlide(page);
|
||||
await expect(page.locator(".location-map-object", { hasText: "Temporary Freezer" })).toHaveCount(0);
|
||||
|
||||
@ -1113,7 +1113,7 @@ test("closes stale map delete confirmation after switching locations", async ({
|
||||
await page.goto("/stores/100/locations/10/map");
|
||||
await page.getByRole("button", { name: "Continue Editing" }).click();
|
||||
await page.getByRole("button", { name: "Map area Eastvale Bakery" }).click();
|
||||
await page.getByRole("button", { name: "Delete" }).click();
|
||||
await page.getByRole("button", { name: "Delete area Eastvale Bakery" }).click();
|
||||
await expect(page.getByRole("heading", { name: "Delete Eastvale Bakery?" })).toBeVisible();
|
||||
|
||||
await page.evaluate(() => {
|
||||
@ -2136,11 +2136,11 @@ test("admin cleared map area labels keep linked zone action names", async ({ pag
|
||||
await page.getByRole("button", { name: "Map area Bakery", exact: true }).click();
|
||||
await expect(page.getByRole("textbox", { name: "Label" })).toHaveValue("");
|
||||
|
||||
await page.getByRole("button", { name: "Delete" }).click();
|
||||
await page.getByRole("button", { name: "Delete area Bakery" }).click();
|
||||
await expect(page.getByRole("heading", { name: "Delete Bakery?" })).toBeVisible();
|
||||
await page.getByRole("button", { name: "Cancel" }).click();
|
||||
|
||||
await page.getByRole("button", { name: "Duplicate" }).click();
|
||||
await page.getByRole("button", { name: "Duplicate area Bakery" }).click();
|
||||
await expect(page.getByRole("textbox", { name: "Label" })).toHaveValue("Bakery Copy");
|
||||
await expect(page.getByRole("button", { name: "Map area Bakery Copy" })).toBeVisible();
|
||||
await expect(page.getByRole("button", { name: "Map area Area Copy" })).toHaveCount(0);
|
||||
@ -2182,7 +2182,7 @@ test("admin restores selected map area through duplicate undo and redo", async (
|
||||
await page.getByRole("button", { name: "Map area Bakery" }).click();
|
||||
await expect(page.locator(".location-map-object.is-selected")).toHaveAttribute("data-object-key", "1355");
|
||||
|
||||
await page.getByRole("button", { name: "Duplicate" }).click();
|
||||
await page.getByRole("button", { name: "Duplicate area Bakery" }).click();
|
||||
await expect(page.getByRole("textbox", { name: "Label" })).toHaveValue("Bakery Copy");
|
||||
await expect(page.locator(".location-map-object.is-selected")).toContainText("Bakery Copy");
|
||||
|
||||
@ -2471,8 +2471,8 @@ test("admin save progress locks draft controls", async ({ page }) => {
|
||||
await expect(page.getByRole("button", { name: "Add Area" })).toBeDisabled();
|
||||
await expect(page.getByRole("button", { name: "View Draft" })).toHaveCount(0);
|
||||
await expect(page.getByRole("button", { name: "Undo" })).toBeDisabled();
|
||||
await expect(page.getByRole("button", { name: "Duplicate" })).toBeDisabled();
|
||||
await expect(page.getByRole("button", { name: "Delete" })).toBeDisabled();
|
||||
await expect(page.getByRole("button", { name: "Duplicate area Saving Bakery" })).toBeDisabled();
|
||||
await expect(page.getByRole("button", { name: "Delete area Saving Bakery" })).toBeDisabled();
|
||||
await expect(page.getByRole("textbox", { name: "Label" })).toBeDisabled();
|
||||
|
||||
releaseSave();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user