diff --git a/apps/client/src/components/ServicesConfig.vue b/apps/client/src/components/ServicesConfig.vue
index 313af40290..825d4bfe1d 100644
--- a/apps/client/src/components/ServicesConfig.vue
+++ b/apps/client/src/components/ServicesConfig.vue
@@ -30,7 +30,8 @@ function refTheValues(services: ProjectService[]) {
const updated = ref
({})
-function update(data: { value: string, key: string, plugin: string }) {
+function update(data: { value: string | boolean, key: string, plugin: string }) {
+ if (typeof data.value === 'boolean') return
if (!updated.value[data.plugin]) updated.value[data.plugin] = {}
updated.value[data.plugin][data.key] = data.value
}
@@ -175,11 +176,12 @@ function reload() {
kind: item.kind,
description: item.description,
name: item.title,
+ label: undefined,
// @ts-ignore Sisi il y a potentiellement un placeholder
placeholder: item.placeholder || '',
disabled: !item.permissions[permissionTarget].write,
}"
- @update="(value: string) => update({ key: item.key, value, plugin: service.name })"
+ @update="(value: string | boolean) => update({ key: item.key, value, plugin: service.name })"
/>
update({ key: item.key, value, plugin: service.name })"
+ @update="(value: string | boolean) => update({ key: item.key, value, plugin: service.name })"
/>
diff --git a/apps/client/src/router/index.ts b/apps/client/src/router/index.ts
index ef28e203f8..87e2a2209e 100644
--- a/apps/client/src/router/index.ts
+++ b/apps/client/src/router/index.ts
@@ -259,8 +259,8 @@ router.beforeEach(async (to, _from, next) => {
!validPath.includes(to.name)
&& userStore.isLoggedIn
) {
- await systemStore.listSystemSettings('maintenance')
- if (systemStore.systemSettings?.maintenance === 'on' && userStore.adminPerms === 0n) return next('/maintenance')
+ await systemStore.listSystemSettings()
+ if (systemStore.systemSettings?.maintenance === 'true' && userStore.adminPerms === 0n) return next('/maintenance')
}
next()
diff --git a/apps/client/src/stores/system-settings.spec.ts b/apps/client/src/stores/system-settings.spec.ts
index b79946b03e..6fda1346c6 100644
--- a/apps/client/src/stores/system-settings.spec.ts
+++ b/apps/client/src/stores/system-settings.spec.ts
@@ -4,7 +4,7 @@ import { apiClient } from '../api/xhr-client.js'
import { useSystemSettingsStore } from './system-settings.js'
const listSystemSettings = vi.spyOn(apiClient.SystemSettings, 'listSystemSettings')
-const upsertSystemSetting = vi.spyOn(apiClient.SystemSettings, 'upsertSystemSetting')
+const upsertSystemSettings = vi.spyOn(apiClient.SystemSettings, 'upsertSystemSettings')
describe('system Settings Store', () => {
beforeEach(() => {
@@ -15,41 +15,29 @@ describe('system Settings Store', () => {
})
it('should get system settings list by api call', async () => {
- const data = [
- { key: 'maintenace', value: 'on' },
- { key: 'theme', value: 'dsfr' },
- { key: 'organisation', value: 'miom' },
- ]
- listSystemSettings.mockReturnValueOnce(Promise.resolve({ status: 200, body: data }))
+ const sytemSettings = { maintenace: 'true', theme: 'dsfr', organisation: 'miom' }
+ // @ts-expect-error TS2345
+ listSystemSettings.mockReturnValueOnce(Promise.resolve({ status: 200, body: sytemSettings }))
const systemSettingsStore = useSystemSettingsStore()
await systemSettingsStore.listSystemSettings()
- expect(systemSettingsStore.systemSettings).toEqual(data)
+ expect(systemSettingsStore.systemSettings).toEqual(sytemSettings)
expect(listSystemSettings).toHaveBeenCalledTimes(1)
})
it('should upsert a system setting by api call', async () => {
- const data = [
- { key: 'maintenace', value: 'on' },
- { key: 'theme', value: 'dsfr' },
- { key: 'organisation', value: 'miom' },
- ]
- const newSystemSetting = { key: 'organisation', value: 'mj' }
- const newData = [
- { key: 'maintenace', value: 'on' },
- { key: 'theme', value: 'dsfr' },
- { key: 'organisation', value: 'mj' },
- ]
-
- upsertSystemSetting.mockReturnValueOnce(Promise.resolve({ status: 201, body: newSystemSetting }))
+ const sytemSettings = { maintenace: 'true', theme: 'dsfr', organisation: 'miom' }
+ const newSystemSettings = { maintenace: 'true', theme: 'dsfr', organisation: 'mj' }
+
+ // @ts-expect-error TS2345
+ upsertSystemSettings.mockReturnValueOnce(Promise.resolve({ status: 201, body: newSystemSettings }))
const systemSettingsStore = useSystemSettingsStore()
- systemSettingsStore.systemSettings = data
+ systemSettingsStore.systemSettings = sytemSettings
- const res = await systemSettingsStore.upsertSystemSetting(data)
+ await systemSettingsStore.upsertSystemSettings(sytemSettings)
- expect(res).toEqual(newSystemSetting)
- expect(systemSettingsStore.systemSettings).toEqual(newData)
- expect(upsertSystemSetting).toHaveBeenCalledTimes(1)
+ expect(systemSettingsStore.systemSettings).toEqual(newSystemSettings)
+ expect(upsertSystemSettings).toHaveBeenCalledTimes(1)
})
})
diff --git a/apps/client/src/stores/system-settings.ts b/apps/client/src/stores/system-settings.ts
index 6fb9e34394..8a9c97a607 100644
--- a/apps/client/src/stores/system-settings.ts
+++ b/apps/client/src/stores/system-settings.ts
@@ -1,29 +1,26 @@
-import { defineStore } from 'pinia'
import type {
SystemSettings,
+ UpsertSystemSettingsBody,
} from '@cpn-console/shared'
+import { defineStore } from 'pinia'
import { apiClient, extractData } from '@/api/xhr-client.js'
export const useSystemSettingsStore = defineStore('systemSettings', () => {
const systemSettings = ref