From 177daa60274e3ef750ce13e25dd5673ccc6f6c23 Mon Sep 17 00:00:00 2001 From: melinoix Date: Wed, 23 Oct 2024 10:04:23 +0200 Subject: [PATCH 01/17] display toast on login when license is nearing expiration - not finish --- .../routes/(authentication)/login/Greetings.svelte | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/enterprise/frontend/src/routes/(authentication)/login/Greetings.svelte b/enterprise/frontend/src/routes/(authentication)/login/Greetings.svelte index c76445ade..4ebb12f13 100644 --- a/enterprise/frontend/src/routes/(authentication)/login/Greetings.svelte +++ b/enterprise/frontend/src/routes/(authentication)/login/Greetings.svelte @@ -4,9 +4,16 @@ import { onMount } from 'svelte'; let clientSettings: Record; + let licenseStatus: Record; + let warning: boolean = false; onMount(async () => { clientSettings = await fetch('/settings/client-settings').then((res) => res.json()); + licenseStatus = await fetch('/api/license-status').then((res) => res.json()); + + if (licenseStatus?.status === "active" && licenseStatus?.days_left <= 7) { + warning = true; + } }); @@ -26,4 +33,10 @@ {/if} + + {#if warning} +
+ License is nearing expiration +
+ {/if} From ea2ae19127d1677a96d01521138fc7685096d9a0 Mon Sep 17 00:00:00 2001 From: melinoix Date: Fri, 25 Oct 2024 07:30:13 +0200 Subject: [PATCH 02/17] Added persistance & env variable --- .../frontend/src/routes/(app)/+layout.svelte | 35 ++++++++++++++++++- .../frontend/src/routes/(app)/+layout.ts | 10 ++++++ .../frontend/src/routes/(app)/sessionStore.ts | 5 +++ .../(authentication)/login/Greetings.svelte | 12 ------- frontend/messages/en.json | 3 +- 5 files changed, 51 insertions(+), 14 deletions(-) create mode 100644 enterprise/frontend/src/routes/(app)/+layout.ts create mode 100644 enterprise/frontend/src/routes/(app)/sessionStore.ts diff --git a/enterprise/frontend/src/routes/(app)/+layout.svelte b/enterprise/frontend/src/routes/(app)/+layout.svelte index a7c3b763e..15ef65c76 100644 --- a/enterprise/frontend/src/routes/(app)/+layout.svelte +++ b/enterprise/frontend/src/routes/(app)/+layout.svelte @@ -1,5 +1,5 @@ diff --git a/enterprise/frontend/src/routes/(app)/+layout.ts b/enterprise/frontend/src/routes/(app)/+layout.ts new file mode 100644 index 000000000..13e5f47c7 --- /dev/null +++ b/enterprise/frontend/src/routes/(app)/+layout.ts @@ -0,0 +1,10 @@ +import { env } from '$env/dynamic/public'; + +export const load = () => { + const LICENSE_EXPIRATION_DAYS = Object.hasOwn(env, 'PUBLIC_LICENSE_EXPIRATION_DAYS') + ? env.PUBLIC_LICENSE_EXPIRATION_DAYS + : 30; + return { + LICENSE_EXPIRATION_DAYS + }; +}; diff --git a/enterprise/frontend/src/routes/(app)/sessionStore.ts b/enterprise/frontend/src/routes/(app)/sessionStore.ts new file mode 100644 index 000000000..881bdce21 --- /dev/null +++ b/enterprise/frontend/src/routes/(app)/sessionStore.ts @@ -0,0 +1,5 @@ +import { persisted } from 'svelte-persisted-store'; + +export const toastShown = persisted('toast_shown', false, { + storage: 'session' +}); diff --git a/enterprise/frontend/src/routes/(authentication)/login/Greetings.svelte b/enterprise/frontend/src/routes/(authentication)/login/Greetings.svelte index 4ebb12f13..d2a81c31a 100644 --- a/enterprise/frontend/src/routes/(authentication)/login/Greetings.svelte +++ b/enterprise/frontend/src/routes/(authentication)/login/Greetings.svelte @@ -4,16 +4,10 @@ import { onMount } from 'svelte'; let clientSettings: Record; - let licenseStatus: Record; - let warning: boolean = false; onMount(async () => { clientSettings = await fetch('/settings/client-settings').then((res) => res.json()); - licenseStatus = await fetch('/api/license-status').then((res) => res.json()); - if (licenseStatus?.status === "active" && licenseStatus?.days_left <= 7) { - warning = true; - } }); @@ -33,10 +27,4 @@ {/if} - - {#if warning} -
- License is nearing expiration -
- {/if} diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 0d40638a5..9c4914b15 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -782,5 +782,6 @@ "questionSingular": "Question", "questionPlural": "Questions", "fillMetadataURL": "Option 1: Fill the metadata url", - "fillSSOSLOURLx509cert": "Option 2: Fill the SSO URL, SLO URL and x509cert" + "fillSSOSLOURLx509cert": "Option 2: Fill the SSO URL, SLO URL and x509cert", + "licenceToast": "Be careful, you have only {days_left} days before the end of your license." } From f26f33249e26cc2aab9401f884453573a2fb77d7 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Thu, 21 Nov 2024 11:28:22 +0100 Subject: [PATCH 03/17] feat: improve mapping inference additional information --- backend/core/models.py | 2 ++ frontend/messages/en.json | 4 +++- .../[id=uuid]/+page.svelte | 18 ++++++++++++++++++ .../[id=uuid]/edit/+page.svelte | 18 ++++++++++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/backend/core/models.py b/backend/core/models.py index ea1f89097..80c04dcee 100644 --- a/backend/core/models.py +++ b/backend/core/models.py @@ -2612,6 +2612,8 @@ def compute_requirement_assessments_results( "str": str(ref), "id": str(ref.id), "coverage": mapping.coverage, + "score": ref.score, + "observation": ref.observation }, # "mappings": [mapping.id for mapping in mappings], } diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 7eae4709f..4a9082d82 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -864,5 +864,7 @@ "existingMeasures": "Existing measures", "youCanSetPasswordHere": "You can set your password here", "forgotPassword": "Forgot password", - "ssoSettingsUpdated": "SSO settings updated" + "ssoSettingsUpdated": "SSO settings updated", + "scoreSemiColon": "Score:", + "mappingInferenceHelpText": "These variables are fixed and will not change according to the source requirement" } diff --git a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte index 7f757b20c..584608558 100644 --- a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte +++ b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte @@ -192,6 +192,7 @@ {m.mappingInference()}

+ {m.mappingInferenceHelpText()}
  • @@ -220,6 +221,23 @@ {safeTranslate(mappingInference.result)}

    + {#if mappingInference.sourceRequirementAssessment.score} +

    + {m.scoreSemiColon()} + + {mappingInference.sourceRequirementAssessment.score} + +

    + {/if} + {#if mappingInference.sourceRequirementAssessment.observation} +

    + {m.observationSemiColon()} + {mappingInference.sourceRequirementAssessment.observation} +

    + {/if} {#if mappingInference.annotation}

    {m.annotationColon()} diff --git a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte index c9da5a0f9..9755174b5 100644 --- a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte +++ b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte @@ -327,6 +327,7 @@ {m.mappingInference()}

    + {m.mappingInferenceHelpText()}
    • @@ -353,6 +354,23 @@ {safeTranslate(mappingInference.result)}

      + {#if mappingInference.sourceRequirementAssessment.score} +

      + {m.scoreSemiColon()} + + {mappingInference.sourceRequirementAssessment.score} + +

      + {/if} + {#if mappingInference.sourceRequirementAssessment.observation} +

      + {m.observationSemiColon()} + {mappingInference.sourceRequirementAssessment.observation} +

      + {/if} {#if mappingInference.annotation}

      {m.annotationColon()} From 8fbb5f2dc17b4fdf6270efe03389297e9aefeac0 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Thu, 21 Nov 2024 11:28:55 +0100 Subject: [PATCH 04/17] chore: format --- backend/core/models.py | 2 +- .../requirement-assessments/[id=uuid]/+page.svelte | 14 ++++++++------ .../[id=uuid]/edit/+page.svelte | 14 ++++++++------ 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/backend/core/models.py b/backend/core/models.py index 80c04dcee..49739f90b 100644 --- a/backend/core/models.py +++ b/backend/core/models.py @@ -2613,7 +2613,7 @@ def compute_requirement_assessments_results( "id": str(ref.id), "coverage": mapping.coverage, "score": ref.score, - "observation": ref.observation + "observation": ref.observation, }, # "mappings": [mapping.id for mapping in mappings], } diff --git a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte index 584608558..5cf149894 100644 --- a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte +++ b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte @@ -192,7 +192,9 @@ {m.mappingInference()}

      - {m.mappingInferenceHelpText()} + {m.mappingInferenceHelpText()}
      • @@ -224,16 +226,16 @@ {#if mappingInference.sourceRequirementAssessment.score}

        {m.scoreSemiColon()} - + {mappingInference.sourceRequirementAssessment.score}

        {/if} {#if mappingInference.sourceRequirementAssessment.observation} -

        +

        {m.observationSemiColon()} {mappingInference.sourceRequirementAssessment.observation}

        diff --git a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte index 9755174b5..d8c801152 100644 --- a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte +++ b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte @@ -327,7 +327,9 @@ {m.mappingInference()}

        - {m.mappingInferenceHelpText()} + {m.mappingInferenceHelpText()}
        • @@ -357,16 +359,16 @@ {#if mappingInference.sourceRequirementAssessment.score}

          {m.scoreSemiColon()} - + {mappingInference.sourceRequirementAssessment.score}

          {/if} {#if mappingInference.sourceRequirementAssessment.observation} -

          +

          {m.observationSemiColon()} {mappingInference.sourceRequirementAssessment.observation}

          From b6576d7c245ba2dbafa3d32a3621dd3d10af87a2 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene <90701924+Mohamed-Hacene@users.noreply.github.com> Date: Thu, 21 Nov 2024 11:37:25 +0100 Subject: [PATCH 05/17] =?UTF-8?q?chore:=20update=20translations=20with=20F?= =?UTF-8?q?ink=20=F0=9F=90=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/messages/ar.json | 4 +++- frontend/messages/de.json | 4 +++- frontend/messages/en.json | 2 +- frontend/messages/es.json | 4 +++- frontend/messages/fr.json | 4 +++- frontend/messages/hi.json | 4 +++- frontend/messages/it.json | 4 +++- frontend/messages/nl.json | 4 +++- frontend/messages/pl.json | 4 +++- frontend/messages/pt.json | 4 +++- frontend/messages/ro.json | 4 +++- frontend/messages/sv.json | 4 +++- frontend/messages/ur.json | 4 +++- 13 files changed, 37 insertions(+), 13 deletions(-) diff --git a/frontend/messages/ar.json b/frontend/messages/ar.json index cb07753a8..6ce175daa 100644 --- a/frontend/messages/ar.json +++ b/frontend/messages/ar.json @@ -858,5 +858,7 @@ "tags": "العلامات", "addTag": "إضافة علامة", "tagsHelpText": "تُستخدم العلامات لتصنيف العناصر وتصفيتها. يمكنك إضافة علامات في قسم \"إضافي\"", - "forgotPassword": "هل نسيت كلمة السر" + "forgotPassword": "هل نسيت كلمة السر", + "scoreSemiColon": "نتيجة:", + "mappingInferenceHelpText": "هذه المتغيرات ثابتة ولن تتغير اعتمادًا على المصدر." } diff --git a/frontend/messages/de.json b/frontend/messages/de.json index b7f339d14..192654b27 100644 --- a/frontend/messages/de.json +++ b/frontend/messages/de.json @@ -857,5 +857,7 @@ "tags": "Schlagwörter", "addTag": "Tag hinzufügen", "tagsHelpText": "Tags werden zum Kategorisieren und Filtern der Elemente verwendet. Sie können Tags im Abschnitt Extra hinzufügen", - "forgotPassword": "Passwort vergessen" + "forgotPassword": "Passwort vergessen", + "scoreSemiColon": "Punktzahl:", + "mappingInferenceHelpText": "Diese Variablen sind fest und ändern sich je nach Quelle nicht." } diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 4a9082d82..649863755 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -866,5 +866,5 @@ "forgotPassword": "Forgot password", "ssoSettingsUpdated": "SSO settings updated", "scoreSemiColon": "Score:", - "mappingInferenceHelpText": "These variables are fixed and will not change according to the source requirement" + "mappingInferenceHelpText": "These variables are fixed and will not change depending on the source." } diff --git a/frontend/messages/es.json b/frontend/messages/es.json index ab4e031a1..7583751c0 100644 --- a/frontend/messages/es.json +++ b/frontend/messages/es.json @@ -857,5 +857,7 @@ "tags": "Etiquetas", "addTag": "Agregar etiqueta", "tagsHelpText": "Las etiquetas se utilizan para categorizar y filtrar los elementos. Puedes agregar etiquetas en la sección Extra", - "forgotPassword": "Has olvidado tu contraseña" + "forgotPassword": "Has olvidado tu contraseña", + "scoreSemiColon": "Puntaje:", + "mappingInferenceHelpText": "Estas variables son fijas y no cambiarán dependiendo de la fuente." } diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index 64029f31c..df379043d 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -864,5 +864,7 @@ "existingMeasures": "Mesures existantes", "youCanSetPasswordHere": "Vous pouvez définir votre mot de passe ici", "forgotPassword": "Mot de passe oublié", - "ssoSettingsUpdated": "Paramètres SSO mis à jour" + "ssoSettingsUpdated": "Paramètres SSO mis à jour", + "scoreSemiColon": "Score:", + "mappingInferenceHelpText": "Ces variables sont fixes et ne changeront pas en fonction de la source." } diff --git a/frontend/messages/hi.json b/frontend/messages/hi.json index 46d799ee9..3f1609eae 100644 --- a/frontend/messages/hi.json +++ b/frontend/messages/hi.json @@ -857,5 +857,7 @@ "tags": "टैग", "addTag": "टैग जोड़ें", "tagsHelpText": "टैग का उपयोग आइटम को वर्गीकृत और फ़िल्टर करने के लिए किया जाता है। आप अतिरिक्त अनुभाग में टैग जोड़ सकते हैं", - "forgotPassword": "पासवर्ड भूल गए" + "forgotPassword": "पासवर्ड भूल गए", + "scoreSemiColon": "अंक:", + "mappingInferenceHelpText": "ये चर निश्चित हैं और स्रोत के आधार पर परिवर्तित नहीं होंगे।" } diff --git a/frontend/messages/it.json b/frontend/messages/it.json index 0f4ce9a0e..0ba84f8a8 100644 --- a/frontend/messages/it.json +++ b/frontend/messages/it.json @@ -857,5 +857,7 @@ "tags": "Etichette", "addTag": "Aggiungi tag", "tagsHelpText": "I tag vengono utilizzati per categorizzare e filtrare gli elementi. Puoi aggiungere tag nella sezione Extra", - "forgotPassword": "Ha dimenticato la password" + "forgotPassword": "Ha dimenticato la password", + "scoreSemiColon": "Punto:", + "mappingInferenceHelpText": "Queste variabili sono fisse e non cambiano a seconda della fonte." } diff --git a/frontend/messages/nl.json b/frontend/messages/nl.json index adbe6dea2..a71993899 100644 --- a/frontend/messages/nl.json +++ b/frontend/messages/nl.json @@ -857,5 +857,7 @@ "tags": "Labels", "addTag": "Tag toevoegen", "tagsHelpText": "Tags worden gebruikt om de items te categoriseren en te filteren. U kunt tags toevoegen in de sectie Extra", - "forgotPassword": "Wachtwoord vergeten" + "forgotPassword": "Wachtwoord vergeten", + "scoreSemiColon": "Punt:", + "mappingInferenceHelpText": "Deze variabelen zijn vast en veranderen niet, afhankelijk van de bron." } diff --git a/frontend/messages/pl.json b/frontend/messages/pl.json index 44c357ad4..93de8ea82 100644 --- a/frontend/messages/pl.json +++ b/frontend/messages/pl.json @@ -857,5 +857,7 @@ "tags": "Tagi", "addTag": "Dodaj tag", "tagsHelpText": "Tagi służą do kategoryzowania i filtrowania elementów. Możesz dodać tagi w sekcji Extra", - "forgotPassword": "Zapomniałem hasła" + "forgotPassword": "Zapomniałem hasła", + "scoreSemiColon": "Wynik:", + "mappingInferenceHelpText": "Te zmienne są stałe i nie zmieniają się w zależności od źródła." } diff --git a/frontend/messages/pt.json b/frontend/messages/pt.json index 4019d7f32..26574841d 100644 --- a/frontend/messages/pt.json +++ b/frontend/messages/pt.json @@ -857,5 +857,7 @@ "tags": "Etiquetas", "addTag": "Adicionar etiqueta", "tagsHelpText": "As tags são usadas para categorizar e filtrar os itens. Você pode adicionar tags na seção Extra", - "forgotPassword": "Esqueceu sua senha" + "forgotPassword": "Esqueceu sua senha", + "scoreSemiColon": "Pontuação:", + "mappingInferenceHelpText": "Essas variáveis são fixas e não mudarão dependendo da fonte." } diff --git a/frontend/messages/ro.json b/frontend/messages/ro.json index b5a3bf290..df49db0e1 100644 --- a/frontend/messages/ro.json +++ b/frontend/messages/ro.json @@ -857,5 +857,7 @@ "tags": "Etichete", "addTag": "Adăugați etichetă", "tagsHelpText": "Etichetele sunt folosite pentru a clasifica și filtra articolele. Puteți adăuga etichete în secțiunea Extra", - "forgotPassword": "Aţi uitat parola" + "forgotPassword": "Aţi uitat parola", + "scoreSemiColon": "Scor:", + "mappingInferenceHelpText": "Aceste variabile sunt fixe și nu se vor modifica în funcție de sursă." } diff --git a/frontend/messages/sv.json b/frontend/messages/sv.json index f6dd37618..4dae9785d 100644 --- a/frontend/messages/sv.json +++ b/frontend/messages/sv.json @@ -861,5 +861,7 @@ "existingMeasures": "Befintliga kontroller", "youCanSetPasswordHere": "Du kan ställa in ditt lösenord här", "forgotPassword": "Glömt lösenord", - "ssoSettingsUpdated": "SSO-inställningar uppdaterade" + "ssoSettingsUpdated": "SSO-inställningar uppdaterade", + "scoreSemiColon": "Göra:", + "mappingInferenceHelpText": "Dessa variabler är fasta och kommer inte att ändras beroende på källan." } diff --git a/frontend/messages/ur.json b/frontend/messages/ur.json index 7b5197f9b..56fb1e1c0 100644 --- a/frontend/messages/ur.json +++ b/frontend/messages/ur.json @@ -857,5 +857,7 @@ "tags": "ٹیگز", "addTag": "ٹیگ شامل کریں۔", "tagsHelpText": "ٹیگز اشیاء کی درجہ بندی اور فلٹر کرنے کے لیے استعمال ہوتے ہیں۔ آپ اضافی سیکشن میں ٹیگ شامل کر سکتے ہیں۔", - "forgotPassword": "پاس ورڈ بھول گئے۔" + "forgotPassword": "پاس ورڈ بھول گئے۔", + "scoreSemiColon": "سکور:", + "mappingInferenceHelpText": "یہ متغیرات طے شدہ ہیں اور ماخذ کے لحاظ سے تبدیل نہیں ہوں گے۔" } From 43ea62bf6bdb39383611b48cb93b38d15b476126 Mon Sep 17 00:00:00 2001 From: Nassim Tabchiche Date: Sat, 23 Nov 2024 20:36:03 +0100 Subject: [PATCH 06/17] Add null checks to user permissions checks --- frontend/src/lib/components/ModelTable/ModelTable.svelte | 4 +++- .../src/lib/components/SideBar/SideBarNavigation.svelte | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/frontend/src/lib/components/ModelTable/ModelTable.svelte b/frontend/src/lib/components/ModelTable/ModelTable.svelte index 4e2265f60..6bfbe873b 100644 --- a/frontend/src/lib/components/ModelTable/ModelTable.svelte +++ b/frontend/src/lib/components/ModelTable/ModelTable.svelte @@ -88,7 +88,9 @@ const user = $page.data.user; - $: canCreateObject = Object.hasOwn(user.permissions, `add_${model?.name}`); + $: canCreateObject = user?.permissions + ? Object.hasOwn(user.permissions, `add_${model?.name}`) + : false; import { URL_MODEL_MAP } from '$lib/utils/crud'; import { listViewFields } from '$lib/utils/table'; diff --git a/frontend/src/lib/components/SideBar/SideBarNavigation.svelte b/frontend/src/lib/components/SideBar/SideBarNavigation.svelte index 375fe0f5b..d062cb2ef 100644 --- a/frontend/src/lib/components/SideBar/SideBarNavigation.svelte +++ b/frontend/src/lib/components/SideBar/SideBarNavigation.svelte @@ -28,14 +28,15 @@ // Check and filter the sub-items based on user permissions const filteredSubItems = item.items.filter((subItem) => { if (subItem.exclude) { - return subItem.exclude.some((role) => !user.roles.includes(role)); + return subItem.exclude.some((role) => user?.roles && !user.roles.includes(role)); } else if (subItem.permissions) { - return subItem.permissions.some((permission) => - Object.hasOwn(user.permissions, permission) + return subItem.permissions?.some( + (permission) => user?.permissions && Object.hasOwn(user.permissions, permission) ); } else if (Object.hasOwn(URL_MODEL_MAP, subItem.href.split('/')[1])) { const model = URL_MODEL_MAP[subItem.href.split('/')[1]]; - const canViewObject = Object.hasOwn(user.permissions, `view_${model.name}`); + const canViewObject = + user?.permissions && Object.hasOwn(user.permissions, `view_${model.name}`); return canViewObject; } return false; From 9c0a585cc1d4e26a40e2abe63e66138586341aa7 Mon Sep 17 00:00:00 2001 From: Nassim Tabchiche Date: Sat, 23 Nov 2024 21:57:26 +0100 Subject: [PATCH 07/17] Move settings affectation to root +layout.server.ts --- enterprise/frontend/src/routes/(app)/+layout.ts | 10 ---------- enterprise/frontend/src/routes/+layout.server.ts | 6 +++++- 2 files changed, 5 insertions(+), 11 deletions(-) delete mode 100644 enterprise/frontend/src/routes/(app)/+layout.ts diff --git a/enterprise/frontend/src/routes/(app)/+layout.ts b/enterprise/frontend/src/routes/(app)/+layout.ts deleted file mode 100644 index 13e5f47c7..000000000 --- a/enterprise/frontend/src/routes/(app)/+layout.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { env } from '$env/dynamic/public'; - -export const load = () => { - const LICENSE_EXPIRATION_DAYS = Object.hasOwn(env, 'PUBLIC_LICENSE_EXPIRATION_DAYS') - ? env.PUBLIC_LICENSE_EXPIRATION_DAYS - : 30; - return { - LICENSE_EXPIRATION_DAYS - }; -}; diff --git a/enterprise/frontend/src/routes/+layout.server.ts b/enterprise/frontend/src/routes/+layout.server.ts index a81245f44..3b22757d7 100644 --- a/enterprise/frontend/src/routes/+layout.server.ts +++ b/enterprise/frontend/src/routes/+layout.server.ts @@ -1,6 +1,7 @@ import type { LayoutServerLoad } from './$types'; import type { GlobalSettings } from '$lib/utils/types'; import { BASE_API_URL } from '$lib/utils/constants'; +import { env } from '$env/dynamic/public'; export const load: LayoutServerLoad = async ({ fetch, locals }) => { let clientSettings: GlobalSettings; @@ -16,5 +17,8 @@ export const load: LayoutServerLoad = async ({ fetch, locals }) => { clientSettings.settings.favicon_hash = ''; clientSettings.settings.name = ''; } - return { featureFlags: locals.featureFlags, clientSettings, licenseStatus }; + const LICENSE_EXPIRATION_DAYS = Object.hasOwn(env, 'PUBLIC_LICENSE_EXPIRATION_DAYS') + ? env.PUBLIC_LICENSE_EXPIRATION_DAYS + : 30; + return { featureFlags: locals.featureFlags, clientSettings, licenseStatus, LICENSE_EXPIRATION_DAYS }; }; From 8140a824ada4cb44eac1bb44b0a46ebe62b44dd3 Mon Sep 17 00:00:00 2001 From: Nassim Tabchiche Date: Sat, 23 Nov 2024 22:03:11 +0100 Subject: [PATCH 08/17] Use && instead of ternary if --- frontend/src/lib/components/ModelTable/ModelTable.svelte | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frontend/src/lib/components/ModelTable/ModelTable.svelte b/frontend/src/lib/components/ModelTable/ModelTable.svelte index 6bfbe873b..d50ad50a6 100644 --- a/frontend/src/lib/components/ModelTable/ModelTable.svelte +++ b/frontend/src/lib/components/ModelTable/ModelTable.svelte @@ -88,9 +88,7 @@ const user = $page.data.user; - $: canCreateObject = user?.permissions - ? Object.hasOwn(user.permissions, `add_${model?.name}`) - : false; + $: canCreateObject = user?.permissions && Object.hasOwn(user.permissions, `add_${model?.name}`); import { URL_MODEL_MAP } from '$lib/utils/crud'; import { listViewFields } from '$lib/utils/table'; From b6d2c78613d6942cfd4e8891b367d94aae11e9f9 Mon Sep 17 00:00:00 2001 From: Nassim Tabchiche Date: Sat, 23 Nov 2024 22:41:10 +0100 Subject: [PATCH 09/17] Refine and tidy license expiration toast display logic --- .../frontend/src/routes/(app)/+layout.svelte | 38 +++++++------------ .../frontend/src/routes/(app)/sessionStore.ts | 5 --- .../frontend/src/routes/(app)/stores.ts | 5 +++ .../frontend/src/routes/+layout.server.ts | 6 +-- frontend/messages/en.json | 2 +- 5 files changed, 23 insertions(+), 33 deletions(-) delete mode 100644 enterprise/frontend/src/routes/(app)/sessionStore.ts create mode 100644 enterprise/frontend/src/routes/(app)/stores.ts diff --git a/enterprise/frontend/src/routes/(app)/+layout.svelte b/enterprise/frontend/src/routes/(app)/+layout.svelte index 4b1a99834..b678db3f2 100644 --- a/enterprise/frontend/src/routes/(app)/+layout.svelte +++ b/enterprise/frontend/src/routes/(app)/+layout.svelte @@ -1,20 +1,18 @@ diff --git a/enterprise/frontend/src/routes/(app)/sessionStore.ts b/enterprise/frontend/src/routes/(app)/sessionStore.ts deleted file mode 100644 index 881bdce21..000000000 --- a/enterprise/frontend/src/routes/(app)/sessionStore.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { persisted } from 'svelte-persisted-store'; - -export const toastShown = persisted('toast_shown', false, { - storage: 'session' -}); diff --git a/enterprise/frontend/src/routes/(app)/stores.ts b/enterprise/frontend/src/routes/(app)/stores.ts new file mode 100644 index 000000000..a27e6afe2 --- /dev/null +++ b/enterprise/frontend/src/routes/(app)/stores.ts @@ -0,0 +1,5 @@ +import { persisted } from 'svelte-persisted-store'; + +export const licenseAboutToExpireToastShown = persisted('licence_about_to_expire_toast_shown', false, { + storage: 'session' +}); diff --git a/enterprise/frontend/src/routes/+layout.server.ts b/enterprise/frontend/src/routes/+layout.server.ts index 3b22757d7..f053de10c 100644 --- a/enterprise/frontend/src/routes/+layout.server.ts +++ b/enterprise/frontend/src/routes/+layout.server.ts @@ -17,8 +17,8 @@ export const load: LayoutServerLoad = async ({ fetch, locals }) => { clientSettings.settings.favicon_hash = ''; clientSettings.settings.name = ''; } - const LICENSE_EXPIRATION_DAYS = Object.hasOwn(env, 'PUBLIC_LICENSE_EXPIRATION_DAYS') - ? env.PUBLIC_LICENSE_EXPIRATION_DAYS + const LICENSE_EXPIRATION_NOTIFY_DAYS = Object.hasOwn(env, 'PUBLIC_LICENSE_EXPIRATION_NOTIFY_DAYS') + ? env.PUBLIC_LICENSE_EXPIRATION_NOTIFY_DAYS : 30; - return { featureFlags: locals.featureFlags, clientSettings, licenseStatus, LICENSE_EXPIRATION_DAYS }; + return { featureFlags: locals.featureFlags, clientSettings, licenseStatus, LICENSE_EXPIRATION_NOTIFY_DAYS }; }; diff --git a/frontend/messages/en.json b/frontend/messages/en.json index d3ed38f48..61887f395 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -790,7 +790,7 @@ "questionPlural": "Questions", "fillMetadataURL": "Option 1: Fill the metadata url", "fillSSOSLOURLx509cert": "Option 2: Fill the SSO URL, SLO URL and x509cert", - "licenceToast": "Be careful, you have only {days_left} days before the end of your license.", + "licenseAboutToExpireWarning": "Be careful, you have only {days_left} days before the end of your license.", "proof": "Proof", "privacy": "Privacy", "safety": "Safety", From 5d9496a6ddb63f03e966887af5427c41a922be9b Mon Sep 17 00:00:00 2001 From: eric-intuitem <71850047+eric-intuitem@users.noreply.github.com> Date: Sun, 24 Nov 2024 21:19:10 +0100 Subject: [PATCH 10/17] improve layout / default value default value for expiration warning: 7 days --- .../frontend/src/routes/(app)/+layout.svelte | 20 +++++-------------- .../frontend/src/routes/+layout.server.ts | 2 +- frontend/messages/en.json | 2 +- frontend/messages/fr.json | 1 + 4 files changed, 8 insertions(+), 17 deletions(-) diff --git a/enterprise/frontend/src/routes/(app)/+layout.svelte b/enterprise/frontend/src/routes/(app)/+layout.svelte index b678db3f2..609d63095 100644 --- a/enterprise/frontend/src/routes/(app)/+layout.svelte +++ b/enterprise/frontend/src/routes/(app)/+layout.svelte @@ -10,7 +10,6 @@ import { deleteCookie, getCookie } from '$lib/utils/cookies'; import { clientSideToast, pageTitle } from '$lib/utils/stores'; import * as m from '$paraglide/messages'; - import { getFlash } from 'sveltekit-flash-message'; import type { LayoutData } from './$types'; import { licenseAboutToExpireToastShown } from './stores'; @@ -42,24 +41,10 @@ const licenseExpirationNotifyDays = data.LICENSE_EXPIRATION_NOTIFY_DAYS; const licenseStatus: Record = data.licenseStatus; - const flash = getFlash(page); const licenseAboutToExpire = licenseStatus?.status === 'active' && licenseStatus?.days_left <= licenseExpirationNotifyDays; - function showMessage() { - if (!$licenseAboutToExpireToastShown) { - $flash = { - type: 'info', - message: m.licenseAboutToExpireWarning({ days_left: licenseStatus.days_left }) - }; - $licenseAboutToExpireToastShown = true; - } - } - - $: if (licenseAboutToExpire && !$licenseAboutToExpireToastShown) { - showMessage(); - } @@ -76,6 +61,11 @@ {m.licenseExpiredMessage()} {/if} + {#if licenseAboutToExpire } + + {/if} { } const LICENSE_EXPIRATION_NOTIFY_DAYS = Object.hasOwn(env, 'PUBLIC_LICENSE_EXPIRATION_NOTIFY_DAYS') ? env.PUBLIC_LICENSE_EXPIRATION_NOTIFY_DAYS - : 30; + : 7; return { featureFlags: locals.featureFlags, clientSettings, licenseStatus, LICENSE_EXPIRATION_NOTIFY_DAYS }; }; diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 61887f395..3214d2bcd 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -790,7 +790,7 @@ "questionPlural": "Questions", "fillMetadataURL": "Option 1: Fill the metadata url", "fillSSOSLOURLx509cert": "Option 2: Fill the SSO URL, SLO URL and x509cert", - "licenseAboutToExpireWarning": "Be careful, you have only {days_left} days before the end of your license.", + "licenseAboutToExpireWarning": "You have only {days_left} days before the end of your license.", "proof": "Proof", "privacy": "Privacy", "safety": "Safety", diff --git a/frontend/messages/fr.json b/frontend/messages/fr.json index 64029f31c..583788fd3 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -790,6 +790,7 @@ "questionPlural": "Questions", "fillMetadataURL": "Option 1 : Remplissez l'URL des métadonnées", "fillSSOSLOURLx509cert": "Option 2 : Remplissez l'URL SSO, l'URL SLO et le certificat x509", + "licenseAboutToExpireWarning": "Il reste {days_left} jours avant l'expiration de votre licence.", "noExpirationDateSet": "Aucune date d'expiration définie", "sumpageTotal": "total", "sumpageActive": "actif", From c916abe413e9e1590cde08888b0ec86bcd92c5ee Mon Sep 17 00:00:00 2001 From: Nassim Tabchiche Date: Mon, 25 Nov 2024 00:28:32 +0100 Subject: [PATCH 11/17] Tidy layout --- .../frontend/src/routes/(app)/+layout.svelte | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/enterprise/frontend/src/routes/(app)/+layout.svelte b/enterprise/frontend/src/routes/(app)/+layout.svelte index 609d63095..15782f99b 100644 --- a/enterprise/frontend/src/routes/(app)/+layout.svelte +++ b/enterprise/frontend/src/routes/(app)/+layout.svelte @@ -4,14 +4,12 @@ import '../../app.postcss'; import { browser } from '$app/environment'; - import { page } from '$app/stores'; import Breadcrumbs from '$lib/components/Breadcrumbs/Breadcrumbs.svelte'; import SideBar from '$lib/components/SideBar/SideBar.svelte'; import { deleteCookie, getCookie } from '$lib/utils/cookies'; import { clientSideToast, pageTitle } from '$lib/utils/stores'; import * as m from '$paraglide/messages'; import type { LayoutData } from './$types'; - import { licenseAboutToExpireToastShown } from './stores'; export let data: LayoutData; @@ -44,7 +42,6 @@ const licenseAboutToExpire = licenseStatus?.status === 'active' && licenseStatus?.days_left <= licenseExpirationNotifyDays; - @@ -56,16 +53,13 @@ - {#if data.licenseStatus.status === 'expired'} - Date: Mon, 25 Nov 2024 00:30:40 +0100 Subject: [PATCH 12/17] Remove unused store --- enterprise/frontend/src/routes/(app)/stores.ts | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 enterprise/frontend/src/routes/(app)/stores.ts diff --git a/enterprise/frontend/src/routes/(app)/stores.ts b/enterprise/frontend/src/routes/(app)/stores.ts deleted file mode 100644 index a27e6afe2..000000000 --- a/enterprise/frontend/src/routes/(app)/stores.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { persisted } from 'svelte-persisted-store'; - -export const licenseAboutToExpireToastShown = persisted('licence_about_to_expire_toast_shown', false, { - storage: 'session' -}); From eaf6436bf2c5dcd2cfc5f223f3db4718d43ef686 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Mon, 25 Nov 2024 14:14:55 +0100 Subject: [PATCH 13/17] feat: copy score and observation for full coverage --- backend/core/models.py | 66 +++++++++++++------ .../[id=uuid]/+page.svelte | 17 ----- .../[id=uuid]/edit/+page.svelte | 17 ----- 3 files changed, 45 insertions(+), 55 deletions(-) diff --git a/backend/core/models.py b/backend/core/models.py index 49739f90b..33105d301 100644 --- a/backend/core/models.py +++ b/backend/core/models.py @@ -2568,56 +2568,77 @@ def compute_requirement_assessments_results( RequirementAssessment.Result.PARTIALLY_COMPLIANT, RequirementAssessment.Result.COMPLIANT, ) + + def assign_attributes(target, attributes): + """ + Helper function to assign attributes to a target object. + Only assigns if the attribute is not None. + """ + keys = ["result", "status", "score", "is_scored", "observation"] + for key, value in zip(keys, attributes): + if value is not None: + setattr(target, key, value) + for requirement_assessment in self.requirement_assessments.all(): mappings = mapping_set.mappings.filter( target_requirement=requirement_assessment.requirement ) inferences = [] refs = [] + + # Filter for full coverage relationships if applicable if mappings.filter( relationship__in=RequirementMapping.FULL_COVERAGE_RELATIONSHIPS ).exists(): mappings = mappings.filter( relationship__in=RequirementMapping.FULL_COVERAGE_RELATIONSHIPS ) + for mapping in mappings: source_requirement_assessment = RequirementAssessment.objects.get( compliance_assessment=source_assessment, requirement=mapping.source_requirement, ) - inferred_result, inferred_status = requirement_assessment.infer_result( + inferred_result = requirement_assessment.infer_result( mapping=mapping, source_requirement_assessment=source_requirement_assessment, ) - if inferred_result in result_order: - inferences.append((inferred_result, inferred_status)) + if inferred_result.get("result") in result_order: + inferences.append( + ( + inferred_result.get("result"), + inferred_result.get("status"), + inferred_result.get("score"), + inferred_result.get("is_scored"), + inferred_result.get("observation"), + ) + ) refs.append(source_requirement_assessment) + if inferences: if len(inferences) == 1: - requirement_assessment.result = inferences[0][0] - if inferences[0][1]: - requirement_assessment.status = inferences[0][1] + selected_inference = inferences[0] ref = refs[0] else: - lowest_result = min( + selected_inference = min( inferences, key=lambda x: result_order.index(x[0]) ) - requirement_assessment.result = lowest_result[0] - if lowest_result[1]: - requirement_assessment.status = lowest_result[1] - ref = refs[inferences.index(lowest_result)] + ref = refs[inferences.index(selected_inference)] + + assign_attributes(requirement_assessment, selected_inference) + requirement_assessment.mapping_inference = { "result": requirement_assessment.result, "source_requirement_assessment": { "str": str(ref), "id": str(ref.id), "coverage": mapping.coverage, - "score": ref.score, - "observation": ref.observation, }, # "mappings": [mapping.id for mapping in mappings], } + requirement_assessments.append(requirement_assessment) + return requirement_assessments def progress(self) -> int: @@ -2715,24 +2736,27 @@ def get_requirement_description(self) -> str: def infer_result( self, mapping: RequirementMapping, source_requirement_assessment: Self - ) -> str | None: + ) -> dict | None: if mapping.coverage == RequirementMapping.Coverage.FULL: - return ( - source_requirement_assessment.result, - source_requirement_assessment.status, - ) + return { + "result": source_requirement_assessment.result, + "status": source_requirement_assessment.status, + "score": source_requirement_assessment.score, + "is_scored": source_requirement_assessment.is_scored, + "observation": source_requirement_assessment.observation, + } if mapping.coverage == RequirementMapping.Coverage.PARTIAL: if source_requirement_assessment.result in ( RequirementAssessment.Result.COMPLIANT, RequirementAssessment.Result.PARTIALLY_COMPLIANT, ): - return (RequirementAssessment.Result.PARTIALLY_COMPLIANT, None) + return {"result": RequirementAssessment.Result.PARTIALLY_COMPLIANT} if ( source_requirement_assessment.result == RequirementAssessment.Result.NON_COMPLIANT ): - return (RequirementAssessment.Result.NON_COMPLIANT, None) - return (None, None) + return {"result": RequirementAssessment.Result.NON_COMPLIANT} + return {} def create_applied_controls_from_suggestions(self) -> list[AppliedControl]: applied_controls: list[AppliedControl] = [] diff --git a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte index 5cf149894..f93a8e3fc 100644 --- a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte +++ b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte @@ -223,23 +223,6 @@ {safeTranslate(mappingInference.result)}

          - {#if mappingInference.sourceRequirementAssessment.score} -

          - {m.scoreSemiColon()} - - {mappingInference.sourceRequirementAssessment.score} - -

          - {/if} - {#if mappingInference.sourceRequirementAssessment.observation} -

          - {m.observationSemiColon()} - {mappingInference.sourceRequirementAssessment.observation} -

          - {/if} {#if mappingInference.annotation}

          {m.annotationColon()} diff --git a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte index d8c801152..38a1039ea 100644 --- a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte +++ b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte @@ -356,23 +356,6 @@ {safeTranslate(mappingInference.result)}

          - {#if mappingInference.sourceRequirementAssessment.score} -

          - {m.scoreSemiColon()} - - {mappingInference.sourceRequirementAssessment.score} - -

          - {/if} - {#if mappingInference.sourceRequirementAssessment.observation} -

          - {m.observationSemiColon()} - {mappingInference.sourceRequirementAssessment.observation} -

          - {/if} {#if mappingInference.annotation}

          {m.annotationColon()} From 1c8c6dac92634cdaeae9d874c778ce1bd85a8789 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Nov 2024 16:17:27 +0000 Subject: [PATCH 14/17] Bump @sveltejs/kit from 2.7.4 to 2.8.3 in /frontend Bumps [@sveltejs/kit](https://github.com/sveltejs/kit/tree/HEAD/packages/kit) from 2.7.4 to 2.8.3. - [Release notes](https://github.com/sveltejs/kit/releases) - [Changelog](https://github.com/sveltejs/kit/blob/main/packages/kit/CHANGELOG.md) - [Commits](https://github.com/sveltejs/kit/commits/@sveltejs/kit@2.8.3/packages/kit) --- updated-dependencies: - dependency-name: "@sveltejs/kit" dependency-type: direct:development ... Signed-off-by: dependabot[bot] --- frontend/package.json | 2 +- frontend/pnpm-lock.yaml | 46 ++++++++++++++++++++--------------------- 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/frontend/package.json b/frontend/package.json index dece4be16..600ffe61f 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -35,7 +35,7 @@ "@svelte-put/qr": "^1.2.1", "@sveltejs/adapter-auto": "^3.3.1", "@sveltejs/adapter-node": "^5.2.9", - "@sveltejs/kit": "^2.7.4", + "@sveltejs/kit": "^2.8.3", "@sveltejs/vite-plugin-svelte": "^3.1.2", "@tailwindcss/forms": "^0.5.9", "@tailwindcss/typography": "^0.5.15", diff --git a/frontend/pnpm-lock.yaml b/frontend/pnpm-lock.yaml index 52da25fff..19d26cf33 100644 --- a/frontend/pnpm-lock.yaml +++ b/frontend/pnpm-lock.yaml @@ -16,7 +16,7 @@ importers: version: 6.6.0 '@inlang/paraglide-sveltekit': specifier: 0.11.0 - version: 0.11.0(@sveltejs/kit@2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(babel-plugin-macros@3.1.0) + version: 0.11.0(@sveltejs/kit@2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(babel-plugin-macros@3.1.0) '@typescript-eslint/eslint-plugin': specifier: ^8.13.0 version: 8.13.0(@typescript-eslint/parser@8.13.0(eslint@9.14.0(jiti@1.21.6))(typescript@5.6.3))(eslint@9.14.0(jiti@1.21.6))(typescript@5.6.3) @@ -89,13 +89,13 @@ importers: version: 1.2.1(svelte@4.2.19) '@sveltejs/adapter-auto': specifier: ^3.3.1 - version: 3.3.1(@sveltejs/kit@2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6))) + version: 3.3.1(@sveltejs/kit@2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6))) '@sveltejs/adapter-node': specifier: ^5.2.9 - version: 5.2.9(@sveltejs/kit@2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6))) + version: 5.2.9(@sveltejs/kit@2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6))) '@sveltejs/kit': - specifier: ^2.7.4 - version: 2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)) + specifier: ^2.8.3 + version: 2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)) '@sveltejs/vite-plugin-svelte': specifier: ^3.1.2 version: 3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)) @@ -173,13 +173,13 @@ importers: version: 3.2.3(svelte@4.2.19) sveltekit-flash-message: specifier: ^2.4.4 - version: 2.4.4(@sveltejs/kit@2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19) + version: 2.4.4(@sveltejs/kit@2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19) sveltekit-rate-limiter: specifier: ^0.5.2 - version: 0.5.2(@sveltejs/kit@2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6))) + version: 0.5.2(@sveltejs/kit@2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6))) sveltekit-superforms: specifier: ^2.20.0 - version: 2.20.0(@sveltejs/kit@2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(@types/json-schema@7.0.15)(svelte@4.2.19)(typescript@5.6.3) + version: 2.20.0(@sveltejs/kit@2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(@types/json-schema@7.0.15)(svelte@4.2.19)(typescript@5.6.3) tailwindcss: specifier: ^3.4.14 version: 3.4.14 @@ -1309,8 +1309,8 @@ packages: peerDependencies: '@sveltejs/kit': ^2.4.0 - '@sveltejs/kit@2.7.4': - resolution: {integrity: sha512-3DOPQYck3CpAmPgGq/HuhJMCCz8GF0ukbompPJQ2zShoSzrEKW9iG/l0nZmaxMvuOO3NNLmZj8F3W9uzqmkNdw==} + '@sveltejs/kit@2.8.3': + resolution: {integrity: sha512-DVBVwugfzzn0SxKA+eAmKqcZ7aHZROCHxH7/pyrOi+HLtQ721eEsctGb9MkhEuqj6q/9S/OFYdn37vdxzFPdvw==} engines: {node: '>=18.13'} hasBin: true peerDependencies: @@ -4680,12 +4680,12 @@ snapshots: - babel-plugin-macros - debug - '@inlang/paraglide-sveltekit@0.11.0(@sveltejs/kit@2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(babel-plugin-macros@3.1.0)': + '@inlang/paraglide-sveltekit@0.11.0(@sveltejs/kit@2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(babel-plugin-macros@3.1.0)': dependencies: '@inlang/paraglide-js': 1.11.2(babel-plugin-macros@3.1.0) '@inlang/paraglide-vite': 1.2.74(babel-plugin-macros@3.1.0) '@lix-js/client': 2.2.1 - '@sveltejs/kit': 2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)) + '@sveltejs/kit': 2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)) commander: 12.1.0 dedent: 1.5.1(babel-plugin-macros@3.1.0) devalue: 4.3.3 @@ -5411,20 +5411,20 @@ snapshots: qrcode-generator: 1.4.4 svelte: 4.2.19 - '@sveltejs/adapter-auto@3.3.1(@sveltejs/kit@2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))': + '@sveltejs/adapter-auto@3.3.1(@sveltejs/kit@2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))': dependencies: - '@sveltejs/kit': 2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)) + '@sveltejs/kit': 2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)) import-meta-resolve: 4.1.0 - '@sveltejs/adapter-node@5.2.9(@sveltejs/kit@2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))': + '@sveltejs/adapter-node@5.2.9(@sveltejs/kit@2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))': dependencies: '@rollup/plugin-commonjs': 28.0.1(rollup@4.24.4) '@rollup/plugin-json': 6.1.0(rollup@4.24.4) '@rollup/plugin-node-resolve': 15.3.0(rollup@4.24.4) - '@sveltejs/kit': 2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)) + '@sveltejs/kit': 2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)) rollup: 4.24.4 - '@sveltejs/kit@2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6))': + '@sveltejs/kit@2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6))': dependencies: '@sveltejs/vite-plugin-svelte': 3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)) '@types/cookie': 0.6.0 @@ -8201,19 +8201,19 @@ snapshots: transitivePeerDependencies: - supports-color - sveltekit-flash-message@2.4.4(@sveltejs/kit@2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19): + sveltekit-flash-message@2.4.4(@sveltejs/kit@2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19): dependencies: - '@sveltejs/kit': 2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)) + '@sveltejs/kit': 2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)) svelte: 4.2.19 - sveltekit-rate-limiter@0.5.2(@sveltejs/kit@2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6))): + sveltekit-rate-limiter@0.5.2(@sveltejs/kit@2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6))): dependencies: '@isaacs/ttlcache': 1.4.1 - '@sveltejs/kit': 2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)) + '@sveltejs/kit': 2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)) - sveltekit-superforms@2.20.0(@sveltejs/kit@2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(@types/json-schema@7.0.15)(svelte@4.2.19)(typescript@5.6.3): + sveltekit-superforms@2.20.0(@sveltejs/kit@2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(@types/json-schema@7.0.15)(svelte@4.2.19)(typescript@5.6.3): dependencies: - '@sveltejs/kit': 2.7.4(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)) + '@sveltejs/kit': 2.8.3(@sveltejs/vite-plugin-svelte@3.1.2(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)))(svelte@4.2.19)(vite@5.4.10(@types/node@20.17.6)) devalue: 5.1.1 just-clone: 6.2.0 memoize-weak: 1.0.2 From 7f4c487be3ab81d3e63b9541ba7cba151e1d97a4 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Wed, 27 Nov 2024 12:10:06 +0100 Subject: [PATCH 15/17] style: fix coverage text color in additional information --- .../requirement-assessments/[id=uuid]/+page.svelte | 2 +- .../requirement-assessments/[id=uuid]/edit/+page.svelte | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte index f93a8e3fc..33163029d 100644 --- a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte +++ b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/+page.svelte @@ -208,7 +208,7 @@

          {m.coverageColon()} - + {safeTranslate( toCamelCase(mappingInference.sourceRequirementAssessment.coverage) )} diff --git a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte index 38a1039ea..8b247aecc 100644 --- a/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte +++ b/frontend/src/routes/(app)/(third-party)/requirement-assessments/[id=uuid]/edit/+page.svelte @@ -343,7 +343,7 @@

          {m.coverageColon()} - + {safeTranslate(mappingInference.sourceRequirementAssessment.coverage)}

          From 52b3c0c78251b1d51429a3ca2734409a1b189d47 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Wed, 27 Nov 2024 12:38:37 +0100 Subject: [PATCH 16/17] feat: apply mapping for not assessed/applicable requirements --- backend/core/models.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/backend/core/models.py b/backend/core/models.py index 5f0a25184..2751460d9 100644 --- a/backend/core/models.py +++ b/backend/core/models.py @@ -2778,6 +2778,8 @@ def compute_requirement_assessments_results( ) -> list["RequirementAssessment"]: requirement_assessments: list[RequirementAssessment] = [] result_order = ( + RequirementAssessment.Result.NOT_ASSESSED, + RequirementAssessment.Result.NOT_APPLICABLE, RequirementAssessment.Result.NON_COMPLIANT, RequirementAssessment.Result.PARTIALLY_COMPLIANT, RequirementAssessment.Result.COMPLIANT, @@ -2952,13 +2954,21 @@ def infer_result( self, mapping: RequirementMapping, source_requirement_assessment: Self ) -> dict | None: if mapping.coverage == RequirementMapping.Coverage.FULL: - return { - "result": source_requirement_assessment.result, - "status": source_requirement_assessment.status, - "score": source_requirement_assessment.score, - "is_scored": source_requirement_assessment.is_scored, - "observation": source_requirement_assessment.observation, - } + if (source_requirement_assessment.compliance_assessment.min_score == self.compliance_assessment.min_score and + source_requirement_assessment.compliance_assessment.max_score == self.compliance_assessment.max_score): + return { + "result": source_requirement_assessment.result, + "status": source_requirement_assessment.status, + "score": source_requirement_assessment.score, + "is_scored": source_requirement_assessment.is_scored, + "observation": source_requirement_assessment.observation, + } + else: + return { + "result": source_requirement_assessment.result, + "status": source_requirement_assessment.status, + "observation": source_requirement_assessment.observation, + } if mapping.coverage == RequirementMapping.Coverage.PARTIAL: if source_requirement_assessment.result in ( RequirementAssessment.Result.COMPLIANT, From 18e283d47bbd59cb1d4cb8c9e101f3ff729e8009 Mon Sep 17 00:00:00 2001 From: Mohamed-Hacene Date: Wed, 27 Nov 2024 12:38:55 +0100 Subject: [PATCH 17/17] chore: run format --- backend/core/models.py | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/backend/core/models.py b/backend/core/models.py index 2751460d9..188719ea2 100644 --- a/backend/core/models.py +++ b/backend/core/models.py @@ -2954,21 +2954,25 @@ def infer_result( self, mapping: RequirementMapping, source_requirement_assessment: Self ) -> dict | None: if mapping.coverage == RequirementMapping.Coverage.FULL: - if (source_requirement_assessment.compliance_assessment.min_score == self.compliance_assessment.min_score and - source_requirement_assessment.compliance_assessment.max_score == self.compliance_assessment.max_score): - return { - "result": source_requirement_assessment.result, - "status": source_requirement_assessment.status, - "score": source_requirement_assessment.score, - "is_scored": source_requirement_assessment.is_scored, - "observation": source_requirement_assessment.observation, - } - else: - return { - "result": source_requirement_assessment.result, - "status": source_requirement_assessment.status, - "observation": source_requirement_assessment.observation, - } + if ( + source_requirement_assessment.compliance_assessment.min_score + == self.compliance_assessment.min_score + and source_requirement_assessment.compliance_assessment.max_score + == self.compliance_assessment.max_score + ): + return { + "result": source_requirement_assessment.result, + "status": source_requirement_assessment.status, + "score": source_requirement_assessment.score, + "is_scored": source_requirement_assessment.is_scored, + "observation": source_requirement_assessment.observation, + } + else: + return { + "result": source_requirement_assessment.result, + "status": source_requirement_assessment.status, + "observation": source_requirement_assessment.observation, + } if mapping.coverage == RequirementMapping.Coverage.PARTIAL: if source_requirement_assessment.result in ( RequirementAssessment.Result.COMPLIANT,