From a876a5c2da0d456cfa856cff6a14fbcb467d24e8 Mon Sep 17 00:00:00 2001 From: Phil Bastian Date: Thu, 22 Oct 2026 12:39:59 +0800 Subject: [PATCH] fix round-tripping endpoint amendments --- src/Frontend/src/resources/LicenseDetails.ts | 6 +++--- src/Frontend/src/stores/LicenseDetailsStore.spec.ts | 1 + src/Frontend/src/stores/LicenseDetailsStore.ts | 7 +++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Frontend/src/resources/LicenseDetails.ts b/src/Frontend/src/resources/LicenseDetails.ts index 3392a1b1e..12a5af57e 100644 --- a/src/Frontend/src/resources/LicenseDetails.ts +++ b/src/Frontend/src/resources/LicenseDetails.ts @@ -14,6 +14,7 @@ export interface ApiEndpoint { client_id: string; name: string; classification: EndpointClassification; + amended: boolean; endpoint_size: string; queues: ApiQueue[]; } @@ -51,15 +52,14 @@ export class Endpoint { amended: boolean; - constructor(clientId: string, name: string, queues: Queue[], classification: EndpointClassification, licensedSize: EndpointSize | null, availableSizes: EndpointSize[]) { + constructor(clientId: string, name: string, queues: Queue[], classification: EndpointClassification, amended: boolean, licensedSize: EndpointSize | null, availableSizes: EndpointSize[]) { this.clientId = clientId; this.name = name; this.queues = queues; this.classification = classification; + this.amended = amended; this.licensedSize = licensedSize; this.availableSizes = availableSizes; - - this.amended = false; } get totalAverageMonthlyThroughput() { diff --git a/src/Frontend/src/stores/LicenseDetailsStore.spec.ts b/src/Frontend/src/stores/LicenseDetailsStore.spec.ts index 905c656c6..8d2a13d1a 100644 --- a/src/Frontend/src/stores/LicenseDetailsStore.spec.ts +++ b/src/Frontend/src/stores/LicenseDetailsStore.spec.ts @@ -194,6 +194,7 @@ describe("LicenseDetailsStore", () => { client_id: "endpoint-1", name: "Sales", classification: EndpointClassification.Full, + amended: false, endpoint_size: "large", queues: [{ name_hash: "sales-hash", scope_hash: "", original_location: "endpoint-1" }], }, diff --git a/src/Frontend/src/stores/LicenseDetailsStore.ts b/src/Frontend/src/stores/LicenseDetailsStore.ts index 780847707..946e96a84 100644 --- a/src/Frontend/src/stores/LicenseDetailsStore.ts +++ b/src/Frontend/src/stores/LicenseDetailsStore.ts @@ -93,7 +93,7 @@ export const useLicenseDetailsStore = defineStore("LicenseDetailsStore", () => { // but the likelihood of this happening is infinitesimal so we're not handling it name = `${name}_1`.substring(name.length + 2 - 80); } - const endpoint = new Endpoint(crypto.randomUUID(), name, [], EndpointClassification.Full, null, endpointSizes.value); + const endpoint = new Endpoint(crypto.randomUUID(), name, [], EndpointClassification.Full, false, null, endpointSizes.value); addQueueToEndpoint(queue, endpoint); endpoints.value.push(endpoint); } @@ -103,6 +103,7 @@ export const useLicenseDetailsStore = defineStore("LicenseDetailsStore", () => { endpoint.queues.push(queue); unassignedQueues.value = unassignedQueues.value.filter((unassigned) => unassigned !== queue); + endpoint.amended = true; hasChanges.value = true; } @@ -167,7 +168,9 @@ export const useLicenseDetailsStore = defineStore("LicenseDetailsStore", () => { const sortedProducts = data.products.toSorted((p1, p2) => (p1.monthly_throughput ?? Number.MAX_VALUE) - (p2.monthly_throughput ?? Number.MAX_VALUE)); const sortedEndpointSizes = sortedProducts.map((product, i) => new EndpointSize(product.product_code, i > 0 ? (sortedProducts[i - 1].monthly_throughput ?? 0) + 1 : 0, product.monthly_throughput)); endpointSizes.value = sortedEndpointSizes; - endpoints.value = data.endpoints.map((metaEp) => new Endpoint(metaEp.client_id, metaEp.name, metaEp.queues.map(toQueue), metaEp.classification, sortedEndpointSizes.find((es) => es.name === metaEp.endpoint_size)!, sortedEndpointSizes)); + endpoints.value = data.endpoints.map( + (metaEp) => new Endpoint(metaEp.client_id, metaEp.name, metaEp.queues.map(toQueue), metaEp.classification, metaEp.amended, sortedEndpointSizes.find((es) => es.name === metaEp.endpoint_size)!, sortedEndpointSizes) + ); infrastructureQueues.value = data.infrastructure_queues.map(toQueue); excludedQueues.value = data.excluded_queues.map(toQueue); /* only used for save, not load */