fix: name selected map area actions

This commit is contained in:
Nico 2026-06-15 18:11:24 -07:00
parent 7251cec05e
commit 57ed1dc70f
2 changed files with 28 additions and 11 deletions

View File

@ -1,5 +1,5 @@
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { objectZoneId } from "../../lib/locationMapUtils"; import { getMapObjectDisplayLabel, objectZoneId } from "../../lib/locationMapUtils";
export const MAP_DISPLAY_CONTROLS = [ export const MAP_DISPLAY_CONTROLS = [
["showZones", "Zones"], ["showZones", "Zones"],
@ -134,6 +134,8 @@ export function SelectedMapObjectForm({
onDuplicateObject, onDuplicateObject,
onDeleteObject, onDeleteObject,
}) { }) {
const selectedObjectLabel = getMapObjectDisplayLabel(selectedObject);
return ( return (
<div className="location-map-object-form"> <div className="location-map-object-form">
<label className="location-map-field-row"> <label className="location-map-field-row">
@ -187,8 +189,23 @@ export function SelectedMapObjectForm({
</button> </button>
</div> </div>
<div className="location-map-editor-actions"> <div className="location-map-editor-actions">
<button type="button" onClick={onDuplicateObject} disabled={saving}>Duplicate</button> <button
<button type="button" className="danger" onClick={onDeleteObject} disabled={saving}>Delete</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>
</div> </div>
); );

View File

@ -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 page.getByRole("textbox", { name: "Label" }).fill("Bread Wall");
await expect(page.locator(".location-map-sheet-header strong")).toHaveText("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 expect(page.getByRole("textbox", { name: "Label" })).toHaveValue("Bread Wall Copy");
await page.getByLabel("Linked zone").selectOption("502"); await page.getByLabel("Linked zone").selectOption("502");
await page.getByRole("textbox", { name: "Label" }).fill("Temporary Freezer"); 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 confirmSlide(page);
await expect(page.locator(".location-map-object", { hasText: "Temporary Freezer" })).toHaveCount(0); 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.goto("/stores/100/locations/10/map");
await page.getByRole("button", { name: "Continue Editing" }).click(); await page.getByRole("button", { name: "Continue Editing" }).click();
await page.getByRole("button", { name: "Map area Eastvale Bakery" }).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 expect(page.getByRole("heading", { name: "Delete Eastvale Bakery?" })).toBeVisible();
await page.evaluate(() => { 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 page.getByRole("button", { name: "Map area Bakery", exact: true }).click();
await expect(page.getByRole("textbox", { name: "Label" })).toHaveValue(""); 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 expect(page.getByRole("heading", { name: "Delete Bakery?" })).toBeVisible();
await page.getByRole("button", { name: "Cancel" }).click(); 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("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 Bakery Copy" })).toBeVisible();
await expect(page.getByRole("button", { name: "Map area Area Copy" })).toHaveCount(0); 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 page.getByRole("button", { name: "Map area Bakery" }).click();
await expect(page.locator(".location-map-object.is-selected")).toHaveAttribute("data-object-key", "1355"); 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.getByRole("textbox", { name: "Label" })).toHaveValue("Bakery Copy");
await expect(page.locator(".location-map-object.is-selected")).toContainText("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: "Add Area" })).toBeDisabled();
await expect(page.getByRole("button", { name: "View Draft" })).toHaveCount(0); await expect(page.getByRole("button", { name: "View Draft" })).toHaveCount(0);
await expect(page.getByRole("button", { name: "Undo" })).toBeDisabled(); await expect(page.getByRole("button", { name: "Undo" })).toBeDisabled();
await expect(page.getByRole("button", { name: "Duplicate" })).toBeDisabled(); await expect(page.getByRole("button", { name: "Duplicate area Saving Bakery" })).toBeDisabled();
await expect(page.getByRole("button", { name: "Delete" })).toBeDisabled(); await expect(page.getByRole("button", { name: "Delete area Saving Bakery" })).toBeDisabled();
await expect(page.getByRole("textbox", { name: "Label" })).toBeDisabled(); await expect(page.getByRole("textbox", { name: "Label" })).toBeDisabled();
releaseSave(); releaseSave();