diff --git a/enterprise/frontend/src/routes/(app)/+layout.svelte b/enterprise/frontend/src/routes/(app)/+layout.svelte index 81840955c..15782f99b 100644 --- a/enterprise/frontend/src/routes/(app)/+layout.svelte +++ b/enterprise/frontend/src/routes/(app)/+layout.svelte @@ -1,5 +1,4 @@ @@ -48,11 +53,13 @@ - {#if data.licenseStatus.status === 'expired'} - { 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_NOTIFY_DAYS = Object.hasOwn(env, 'PUBLIC_LICENSE_EXPIRATION_NOTIFY_DAYS') + ? env.PUBLIC_LICENSE_EXPIRATION_NOTIFY_DAYS + : 7; + return { featureFlags: locals.featureFlags, clientSettings, licenseStatus, LICENSE_EXPIRATION_NOTIFY_DAYS }; }; diff --git a/frontend/messages/en.json b/frontend/messages/en.json index 2a5b8e1b5..b8cf7b63c 100644 --- a/frontend/messages/en.json +++ b/frontend/messages/en.json @@ -789,6 +789,7 @@ "questionPlural": "Questions", "fillMetadataURL": "Option 1: Fill the metadata url", "fillSSOSLOURLx509cert": "Option 2: Fill the SSO URL, SLO URL and x509cert", + "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 57c64c240..0afbc8a92 100644 --- a/frontend/messages/fr.json +++ b/frontend/messages/fr.json @@ -789,6 +789,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", diff --git a/frontend/src/lib/components/ModelTable/ModelTable.svelte b/frontend/src/lib/components/ModelTable/ModelTable.svelte index 74e12572d..4b4867594 100644 --- a/frontend/src/lib/components/ModelTable/ModelTable.svelte +++ b/frontend/src/lib/components/ModelTable/ModelTable.svelte @@ -87,7 +87,7 @@ const user = $page.data.user; - $: canCreateObject = Object.hasOwn(user.permissions, `add_${model?.name}`); + $: canCreateObject = user?.permissions && Object.hasOwn(user.permissions, `add_${model?.name}`); 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;