Skip to content

Commit c847f45

Browse files
authored
feat(settings): check a model file on the ArchiMate settings (#2107)
* feat(settings): check a model file on the ArchiMate settings The ArchiMate section gets Check a model file: a file picker, the before-import and against-imported modes and a Check button, then a table per category with the counts, examples for the categories with losses and a summary that reads No losses found or names the lossy categories. Task 5 of architecture-round-trip-check (the Playwright spec is written, not run). Assisted-by: ClaudeCode:claude-opus-5-5 * docs(settings): spec tags on the round-trip check section Assisted-by: ClaudeCode:claude-opus-5-5
1 parent d531ef1 commit c847f45

13 files changed

Lines changed: 771 additions & 5 deletions

File tree

‎l10n/en.js‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2390,7 +2390,27 @@ OC.L10N.register(
23902390
"No SaaS subscriptions": "No SaaS subscriptions",
23912391
"Buying department": "Buying department",
23922392
"The department that bought this application, when it is not IT.": "The department that bought this application, when it is not IT.",
2393-
"Whether the department bought this application without IT being involved.": "Whether the department bought this application without IT being involved."
2393+
"Whether the department bought this application without IT being involved.": "Whether the department bought this application without IT being involved.",
2394+
"Relationships": "Relationships",
2395+
"View nodes": "View nodes",
2396+
"Property definitions": "Property definitions",
2397+
"Organization folders": "Organization folders",
2398+
"This model is not imported.": "This model is not imported.",
2399+
"No losses found": "No losses found",
2400+
"Losses in: {categories}": "Losses in: {categories}",
2401+
"The check failed": "The check failed",
2402+
"Check a model file": "Check a model file",
2403+
"See what an exchange file loses on its way through the import and the export.": "See what an exchange file loses on its way through the import and the export.",
2404+
"Model file to check": "Model file to check",
2405+
"Check mode": "Check mode",
2406+
"Before import (nothing is written)": "Before import (nothing is written)",
2407+
"Against the imported model": "Against the imported model",
2408+
"Checking…": "Checking…",
2409+
"Check": "Check",
2410+
"In the file": "In the file",
2411+
"After the round trip": "After the round trip",
2412+
"Extra": "Extra",
2413+
"Examples: {category}": "Examples: {category}"
23942414
},
23952415
"nplurals=2; plural=(n != 1);"
23962416
)

‎l10n/en.json‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2431,6 +2431,26 @@
24312431
"No SaaS subscriptions": "No SaaS subscriptions",
24322432
"Buying department": "Buying department",
24332433
"The department that bought this application, when it is not IT.": "The department that bought this application, when it is not IT.",
2434-
"Whether the department bought this application without IT being involved.": "Whether the department bought this application without IT being involved."
2434+
"Whether the department bought this application without IT being involved.": "Whether the department bought this application without IT being involved.",
2435+
"Relationships": "Relationships",
2436+
"View nodes": "View nodes",
2437+
"Property definitions": "Property definitions",
2438+
"Organization folders": "Organization folders",
2439+
"This model is not imported.": "This model is not imported.",
2440+
"No losses found": "No losses found",
2441+
"Losses in: {categories}": "Losses in: {categories}",
2442+
"The check failed": "The check failed",
2443+
"Check a model file": "Check a model file",
2444+
"See what an exchange file loses on its way through the import and the export.": "See what an exchange file loses on its way through the import and the export.",
2445+
"Model file to check": "Model file to check",
2446+
"Check mode": "Check mode",
2447+
"Before import (nothing is written)": "Before import (nothing is written)",
2448+
"Against the imported model": "Against the imported model",
2449+
"Checking…": "Checking…",
2450+
"Check": "Check",
2451+
"In the file": "In the file",
2452+
"After the round trip": "After the round trip",
2453+
"Extra": "Extra",
2454+
"Examples: {category}": "Examples: {category}"
24352455
}
24362456
}

‎l10n/nl.js‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2452,7 +2452,27 @@ OC.L10N.register(
24522452
"No SaaS subscriptions": "Geen SaaS-abonnementen",
24532453
"Buying department": "Inkopende afdeling",
24542454
"The department that bought this application, when it is not IT.": "De afdeling die deze applicatie heeft aangeschaft, als dat niet IT is.",
2455-
"Whether the department bought this application without IT being involved.": "Of de afdeling deze applicatie heeft aangeschaft zonder dat IT erbij betrokken was."
2455+
"Whether the department bought this application without IT being involved.": "Of de afdeling deze applicatie heeft aangeschaft zonder dat IT erbij betrokken was.",
2456+
"Relationships": "Relaties",
2457+
"View nodes": "Viewknopen",
2458+
"Property definitions": "Eigenschapdefinities",
2459+
"Organization folders": "Organisatiemappen",
2460+
"This model is not imported.": "Dit model is niet geïmporteerd.",
2461+
"No losses found": "Geen verliezen gevonden",
2462+
"Losses in: {categories}": "Verliezen in: {categories}",
2463+
"The check failed": "De controle is mislukt",
2464+
"Check a model file": "Een modelbestand controleren",
2465+
"See what an exchange file loses on its way through the import and the export.": "Zie wat een uitwisselbestand verliest op weg door de import en de export.",
2466+
"Model file to check": "Te controleren modelbestand",
2467+
"Check mode": "Controlemodus",
2468+
"Before import (nothing is written)": "Vóór de import (er wordt niets weggeschreven)",
2469+
"Against the imported model": "Tegen het geïmporteerde model",
2470+
"Checking…": "Bezig met controleren…",
2471+
"Check": "Controleren",
2472+
"In the file": "In het bestand",
2473+
"After the round trip": "Na de rondgang",
2474+
"Extra": "Extra",
2475+
"Examples: {category}": "Voorbeelden: {category}"
24562476
},
24572477
"nplurals=2; plural=(n != 1);"
24582478
)

‎l10n/nl.json‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2493,6 +2493,26 @@
24932493
"No SaaS subscriptions": "Geen SaaS-abonnementen",
24942494
"Buying department": "Inkopende afdeling",
24952495
"The department that bought this application, when it is not IT.": "De afdeling die deze applicatie heeft aangeschaft, als dat niet IT is.",
2496-
"Whether the department bought this application without IT being involved.": "Of de afdeling deze applicatie heeft aangeschaft zonder dat IT erbij betrokken was."
2496+
"Whether the department bought this application without IT being involved.": "Of de afdeling deze applicatie heeft aangeschaft zonder dat IT erbij betrokken was.",
2497+
"Relationships": "Relaties",
2498+
"View nodes": "Viewknopen",
2499+
"Property definitions": "Eigenschapdefinities",
2500+
"Organization folders": "Organisatiemappen",
2501+
"This model is not imported.": "Dit model is niet geïmporteerd.",
2502+
"No losses found": "Geen verliezen gevonden",
2503+
"Losses in: {categories}": "Verliezen in: {categories}",
2504+
"The check failed": "De controle is mislukt",
2505+
"Check a model file": "Een modelbestand controleren",
2506+
"See what an exchange file loses on its way through the import and the export.": "Zie wat een uitwisselbestand verliest op weg door de import en de export.",
2507+
"Model file to check": "Te controleren modelbestand",
2508+
"Check mode": "Controlemodus",
2509+
"Before import (nothing is written)": "Vóór de import (er wordt niets weggeschreven)",
2510+
"Against the imported model": "Tegen het geïmporteerde model",
2511+
"Checking…": "Bezig met controleren…",
2512+
"Check": "Controleren",
2513+
"In the file": "In het bestand",
2514+
"After the round trip": "Na de rondgang",
2515+
"Extra": "Extra",
2516+
"Examples: {category}": "Voorbeelden: {category}"
24972517
}
24982518
}

‎openspec/changes/architecture-round-trip-check/tasks.md‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@
5151
- **acceptance_criteria**:
5252
- GIVEN the admin settings page WHEN the ArchiMate section renders THEN Check a model file offers a file picker, the two modes and a Check button
5353
- GIVEN a result WHEN it renders THEN a row per category shows the counts, examples expand per category, and the summary names the categories with losses or reads "No losses found"
54-
- [ ] Implement
54+
- [x] Implement
5555
- [ ] Test (Playwright `archimate-round-trip-check.spec.ts`)
56+
- Built 21 Nov: `ArchiMateRoundTripCheck.vue` under the ArchiMate import and export (file picker, the two modes, Check, the table per category, examples per category with losses, the summary) over `src/utils/archiMateRoundTrip.js` (the upload request, rows and summary). Tests: `tests/vitest/archiMateRoundTrip.spec.js` and `tests/vitest/archiMateRoundTripCheck.spec.js`. The request lives in the util, not in `src/store/modules/settings.js`, because the section is its only reader. The Playwright spec `tests/e2e/workflows/archimate-round-trip-check.spec.ts` is written and not yet run against a live instance. English and Dutch strings are in `l10n/en.json` and `l10n/nl.json`.
5657

5758
### Task 6: Documentation and translations
5859
- **spec_ref**: openspec/changes/architecture-round-trip-check/specs/archimate-round-trip-check/spec.md#requirement-req-art-004-the-admin-settings-page-shall-show-the-round-trip-report

‎src/utils/archiMateRoundTrip.js‎

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
/**
2+
* SPDX-FileCopyrightText: 2026 Conduction B.V. <info@conduction.nl>
3+
* SPDX-License-Identifier: EUPL-1.2
4+
*/
5+
/**
6+
* Client side of the ArchiMate round-trip check: the request to
7+
* `POST /api/archimate/round-trip-check` and the rows and summary the admin
8+
* settings page shows from its report.
9+
*
10+
* @spec openspec/changes/architecture-round-trip-check/specs/archimate-round-trip-check/spec.md#requirement-req-art-004-the-admin-settings-page-shall-show-the-round-trip-report
11+
*/
12+
13+
import axios from '@nextcloud/axios'
14+
import { translate as t } from '@nextcloud/l10n'
15+
import { generateUrl } from '@nextcloud/router'
16+
17+
/** Convert the file and generate it back; nothing is written. */
18+
export const MODE_BEFORE_IMPORT = 'before-import'
19+
20+
/** Generate the file back from the stored objects of its model. */
21+
export const MODE_AGAINST_IMPORTED = 'against-imported'
22+
23+
/**
24+
* The categories of the report, in the order the server reports them.
25+
*
26+
* @type {string[]}
27+
*/
28+
export const CATEGORIES = ['elements', 'relationships', 'views', 'viewNodes', 'propertyDefinitions', 'organizations']
29+
30+
/**
31+
* The translated name of a report category.
32+
*
33+
* @param {string} category The category key.
34+
* @return {string}
35+
*
36+
* @spec openspec/changes/architecture-round-trip-check/specs/archimate-round-trip-check/spec.md#requirement-req-art-004-the-admin-settings-page-shall-show-the-round-trip-report
37+
*/
38+
export function categoryLabel(category) {
39+
const labels = {
40+
elements: t('stackiq', 'Elements'),
41+
relationships: t('stackiq', 'Relationships'),
42+
views: t('stackiq', 'Views'),
43+
viewNodes: t('stackiq', 'View nodes'),
44+
propertyDefinitions: t('stackiq', 'Property definitions'),
45+
organizations: t('stackiq', 'Organization folders'),
46+
}
47+
return labels[category] ?? category
48+
}
49+
50+
/**
51+
* One row per category: the counts and the examples.
52+
*
53+
* @param {object} report The report the server answered.
54+
* @return {Array<{key: string, label: string, source: number, result: number, missing: number, extra: number, changed: number, examples: Array<object>, lossy: boolean}>}
55+
*
56+
* @spec openspec/changes/architecture-round-trip-check/specs/archimate-round-trip-check/spec.md#requirement-req-art-004-the-admin-settings-page-shall-show-the-round-trip-report
57+
*/
58+
export function roundTripRows(report) {
59+
const categories = report?.categories ?? {}
60+
return CATEGORIES.filter((key) => categories[key] !== undefined).map((key) => {
61+
const category = categories[key]
62+
const missing = Number(category.missing ?? 0)
63+
const extra = Number(category.extra ?? 0)
64+
const changed = Number(category.changed ?? 0)
65+
return {
66+
key,
67+
label: categoryLabel(key),
68+
source: Number(category.source ?? 0),
69+
result: Number(category.result ?? 0),
70+
missing,
71+
extra,
72+
changed,
73+
examples: Array.isArray(category.examples) ? category.examples : [],
74+
lossy: missing + extra + changed > 0,
75+
}
76+
})
77+
}
78+
79+
/**
80+
* The summary line: "No losses found", the categories with losses, or that the model is not imported.
81+
*
82+
* @param {object} report The report the server answered.
83+
* @return {string}
84+
*
85+
* @spec openspec/changes/architecture-round-trip-check/specs/archimate-round-trip-check/spec.md#requirement-req-art-004-the-admin-settings-page-shall-show-the-round-trip-report
86+
*/
87+
export function roundTripSummary(report) {
88+
if (report?.imported === false) {
89+
return t('stackiq', 'This model is not imported.')
90+
}
91+
const lossy = roundTripRows(report).filter((row) => row.lossy).map((row) => row.label)
92+
if (lossy.length === 0) {
93+
return t('stackiq', 'No losses found')
94+
}
95+
return t('stackiq', 'Losses in: {categories}', { categories: lossy.join(', ') })
96+
}
97+
98+
/**
99+
* Upload a file to the round-trip check and answer its report.
100+
*
101+
* @param {File} file The exchange file.
102+
* @param {string} mode MODE_BEFORE_IMPORT or MODE_AGAINST_IMPORTED.
103+
* @return {Promise<object>} The report.
104+
* @throws {Error} With the server's message when the check fails.
105+
*
106+
* @spec openspec/changes/architecture-round-trip-check/specs/archimate-round-trip-check/spec.md#requirement-req-art-004-the-admin-settings-page-shall-show-the-round-trip-report
107+
*/
108+
export async function checkRoundTrip(file, mode) {
109+
const formData = new FormData()
110+
formData.append('archiMateFile', file)
111+
formData.append('mode', mode)
112+
try {
113+
const response = await axios.post(generateUrl('/apps/stackiq/api/archimate/round-trip-check'), formData)
114+
return response.data
115+
} catch (error) {
116+
throw new Error(error?.response?.data?.message || t('stackiq', 'The check failed'), { cause: error })
117+
}
118+
}

‎src/views/settings/sections/ArchiMateImportExport.vue‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,8 @@
640640
</NcButton>
641641
</div>
642642
</div>
643+
644+
<ArchiMateRoundTripCheck />
643645
</div>
644646

645647
<!-- Info Content Slot -->
@@ -692,6 +694,7 @@ import Download from 'vue-material-design-icons/Download.vue'
692694
import Refresh from 'vue-material-design-icons/Refresh.vue'
693695
// Components
694696
import AlwaysVisibleSection from '../../../components/AlwaysVisibleSection.vue'
697+
import ArchiMateRoundTripCheck from './ArchiMateRoundTripCheck.vue'
695698
import { settingsStore } from '../../../store/store.js'
696699
import {
697700
cancelImport,
@@ -786,6 +789,7 @@ export default {
786789
787790
components: {
788791
AlwaysVisibleSection,
792+
ArchiMateRoundTripCheck,
789793
NcButton,
790794
NcNoteCard,
791795
NcLoadingIcon,

0 commit comments

Comments
 (0)