Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { assistantValuesEqual } from "@lzc/contracts";
import {
type EditorDraft,
editorIssues,
Expand Down Expand Up @@ -81,6 +82,7 @@ export function Configurations({
onLoad,
onPrepare,
compact = false,
dirty = true,
}: {
session: Session | null;
draft: EditorDraft | null;
Expand All @@ -89,6 +91,7 @@ export function Configurations({
onLoad: (draft: EditorDraft, binding: ConfigurationBinding) => void;
onPrepare: (selection: DeploymentSelection) => void;
compact?: boolean;
dirty?: boolean;
}) {
const [configurations, setConfigurations] = useState<Summary[]>([]);
const [busy, setBusy] = useState(false);
Expand All @@ -103,6 +106,8 @@ export function Configurations({
string,
string
> | null>(null);
const currentDraft = useRef({ draft, dirty });
currentDraft.current = { draft, dirty };
const active = useRef(false);
const controller = useRef<AbortController | null>(null);
const listRequest = useRef(0);
Expand Down Expand Up @@ -380,15 +385,6 @@ export function Configurations({
value0: item.name,
})}
onClick={() => {
if (
draft &&
!window.confirm(
t(
"Aktuellen Entwurf durch die gespeicherte Konfiguration ersetzen?",
),
)
)
return;
void perform(async () => {
const response = await checked(
await fetch(`/api/v1/configurations/${item.id}`, {
Expand All @@ -399,11 +395,23 @@ export function Configurations({
configuration: StoredConfiguration;
};
const loaded = readEditorDraft(configuration.draft);
if (!controller.current?.signal.aborted)
onLoad(loaded, {
id: configuration.id,
revision: configuration.revision,
});
if (controller.current?.signal.aborted) return;
const current = currentDraft.current;
if (
current.draft &&
current.dirty &&
!assistantValuesEqual(current.draft, loaded) &&
!window.confirm(
t(
"Aktuellen Entwurf durch die gespeicherte Konfiguration ersetzen?",
),
)
)
return;
onLoad(loaded, {
id: configuration.id,
revision: configuration.revision,
});
});
}}
>
Expand Down
4 changes: 3 additions & 1 deletion landing-zone-configurator/app/apps/web/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ function App() {
type="button"
className={configurationView ? "nav-item active" : "nav-item"}
aria-current={configurationView ? "page" : undefined}
onClick={() => setView("repositories")}
onClick={() => setView(draft ? "editor" : "repositories")}
>
{t("Konfigurationen")}
</button>
Expand Down Expand Up @@ -772,6 +772,7 @@ function App() {
session={session}
draft={draft}
binding={configurationBinding}
dirty={draftDirty}
compact
onSaved={saveConfigurationBinding}
onLoad={loadConfiguration}
Expand Down Expand Up @@ -990,6 +991,7 @@ function App() {
session={session}
draft={draft}
binding={configurationBinding}
dirty={draftDirty}
compact={view === "editor"}
onSaved={saveConfigurationBinding}
onPrepare={openDeployment}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ for (const kind of ["personal", "organisation"]) {
await page
.getByRole("button", { name: "Konfigurationen", exact: true })
.click();
await page.getByRole("button", { name: /weiterbearbeiten$/ }).click();

await page
.getByRole("button", { name: "4 Plattform", exact: true })
.click();
Expand Down
3 changes: 2 additions & 1 deletion landing-zone-configurator/app/e2e/common-editor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,8 @@ test("shared configuration saves, reopens and restores in the account workspace"
"Gemeinsamer Fork-Entwurf",
);
await page
.getByRole("button", { name: "Konfigurationen", exact: true })
.getByRole("navigation", { name: "Brotkrumennavigation", exact: true })
.getByRole("link", { name: "Konfigurationen", exact: true })
.click();
await page.getByRole("button", { name: /Deployment vorbereiten/ }).click();
await expect(page.getByRole("alert")).toContainText(
Expand Down
59 changes: 25 additions & 34 deletions landing-zone-configurator/app/e2e/configurator.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,20 @@ import {
} from "../scripts/assistant-scenarios.js";
import { expect, type Page, test } from "./fixtures";

// Storage workflows use the editor breadcrumb; the primary navigation now resumes editing.
async function openConfigurationStorage(page: Page) {
const listLink = page
.getByRole("navigation", { name: "Brotkrumennavigation", exact: true })
.getByRole("link", { name: "Konfigurationen", exact: true });
if (!(await listLink.isVisible())) {
await page
.getByRole("navigation", { name: "Hauptnavigation", exact: true })
.getByRole("button", { name: "Konfigurationen", exact: true })
.click();
}
if (await listLink.isVisible()) await listLink.click();
}

async function holdAssistantCompletion(page: Page, path: string) {
await page.addInitScript((endpoint) => {
const original = window.fetch.bind(window);
Expand Down Expand Up @@ -2173,9 +2187,7 @@ test("database configurations save, reopen, protect revisions and delete without
.getByRole("textbox", { name: "Name der Konfiguration", exact: true })
.fill("Ohne GitHub gespeichert");
await expect(name).toHaveValue("Ohne GitHub gespeichert");
await page
.getByRole("button", { name: "Konfigurationen", exact: true })
.click();
await openConfigurationStorage(page);
const storage = page.getByRole("region", {
name: "Gespeicherte Konfigurationen",
});
Expand Down Expand Up @@ -2234,9 +2246,7 @@ test("database configurations save, reopen, protect revisions and delete without
await page
.getByRole("textbox", { name: "Name der Konfiguration", exact: true })
.fill("Aktualisiert ohne GitHub");
await page
.getByRole("button", { name: "Konfigurationen", exact: true })
.click();
await openConfigurationStorage(page);
await storage
.getByRole("button", { name: "Konfiguration speichern", exact: true })
.click();
Expand Down Expand Up @@ -3034,9 +3044,7 @@ test("edit, validate and download an isolated standalone copy", async ({
() => document.documentElement.scrollWidth <= window.innerWidth,
),
).toBe(true);
await page
.getByRole("button", { name: "Konfigurationen", exact: true })
.click();
await openConfigurationStorage(page);
await page
.getByRole("button", { name: "Neue Konfiguration", exact: true })
.click();
Expand All @@ -3046,9 +3054,7 @@ test("edit, validate and download an isolated standalone copy", async ({
await expect(page.locator(".topology")).toContainText(
"Public · public-exmpl",
);
await page
.getByRole("button", { name: "Konfigurationen", exact: true })
.click();
await openConfigurationStorage(page);
await page
.getByRole("button", {
name: "Meine Testumgebung weiterbearbeiten",
Expand Down Expand Up @@ -3205,9 +3211,7 @@ test("URLs and browser back/forward preserve an in-progress draft", async ({
exact: true,
}),
).toBeVisible();
await page
.getByRole("button", { name: "Konfigurationen", exact: true })
.click();
await openConfigurationStorage(page);
await expect(page).toHaveURL(/\/configurations$/);
await page.goBack();
await expect(page).toHaveURL(/\/configurations\/edit\/projects$/);
Expand Down Expand Up @@ -3346,9 +3350,7 @@ test("select a fork, reopen a config and resolve a save conflict as a new copy",
await expect(page.getByLabel("Name der Konfiguration")).toHaveValue(
"Meine neue Kopie",
);
await page
.getByRole("button", { name: "Konfigurationen", exact: true })
.click();
await openConfigurationStorage(page);
await page
.getByRole("button", { name: "Im Fork speichern", exact: true })
.click();
Expand All @@ -3357,9 +3359,7 @@ test("select a fork, reopen a config and resolve a save conflict as a new copy",
await expect(page.getByLabel("Name der Konfiguration")).toHaveValue(
"Meine neue Kopie",
);
await page
.getByRole("button", { name: "Konfigurationen", exact: true })
.click();
await openConfigurationStorage(page);
await page.getByRole("button", { name: "Neue Kopie vorbereiten" }).click();
await page
.getByRole("button", { name: "Im Fork speichern", exact: true })
Expand Down Expand Up @@ -3388,9 +3388,7 @@ test("select a fork, reopen a config and resolve a save conflict as a new copy",
await page.goto("/templates");
await expect(page.getByText("@alice", { exact: true })).toBeVisible();
await expect(page).toHaveURL(/\/templates$/);
await page
.getByRole("button", { name: "Konfigurationen", exact: true })
.click();
await openConfigurationStorage(page);
await expect(
page.getByRole("button", {
name: "Meine neue Kopie weiterbearbeiten",
Expand Down Expand Up @@ -4366,10 +4364,7 @@ test.describe("explicit saved-plan approval", () => {
).toHaveAttribute("aria-selected", "true");
expect(saves).toBe(0);
expect(cloudMutations).toEqual([]);
await page
.getByRole("navigation", { name: "Hauptnavigation", exact: true })
.getByRole("button", { name: "Konfigurationen", exact: true })
.click();
await openConfigurationStorage(page);
await page
.getByRole("button", {
name: "Meine Plattform weiterbearbeiten",
Expand Down Expand Up @@ -4402,9 +4397,7 @@ test.describe("explicit saved-plan approval", () => {
.getByRole("button", { name: "Arbeitsbereich öffnen: Persönlich" })
.click();
await expect(page).toHaveURL(/\/workspaces$/);
await page
.getByRole("button", { name: "Konfigurationen", exact: true })
.click();
await openConfigurationStorage(page);
await page
.getByRole("button", {
name: "Meine Plattform geändert weiterbearbeiten",
Expand All @@ -4431,9 +4424,7 @@ test.describe("explicit saved-plan approval", () => {
path: testInfo.outputPath("configuration-flow.png"),
fullPage: true,
});
await page
.getByRole("button", { name: "Konfigurationen", exact: true })
.click();
await openConfigurationStorage(page);
await page
.getByRole("button", { name: "Neue Konfiguration", exact: true })
.click();
Expand Down
2 changes: 1 addition & 1 deletion landing-zone-configurator/app/e2e/organisation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3294,7 +3294,7 @@ for (const { publishing, applied, renewProof, executing } of [
await page
.getByRole("button", { name: "Konfigurationen", exact: true })
.click();
await page.getByRole("button", { name: /weiterbearbeiten$/ }).click();

await page
.getByRole("button", {
name: "5 Template-Entwürfe",
Expand Down
Loading
Loading