Skip to content

Commit 06c1058

Browse files
artongenextcloud-command
authored andcommitted
fix(user_ldap): Properly handle new config creation in settings
Signed-off-by: Louis Chmn <[email protected]>
1 parent 189e1fc commit 06c1058

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

apps/user_ldap/src/store/configs.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,21 @@ export const useLDAPConfigsStore = defineStore('ldap-configs', () => {
8080
*/
8181
async function removeConfig(configId: string) {
8282
const result = await deleteConfig(configId)
83+
8384
if (result === true) {
84-
delete ldapConfigs.value[configId]
85+
if (Object.keys(ldapConfigs.value).length === 1) {
86+
// Ensure at least one config exists before deleting the last one
87+
selectedConfigId.value = await create()
88+
// The new config id could be the same as the deleted one, so only delete if different
89+
if (selectedConfigId.value !== configId) {
90+
delete ldapConfigs.value[configId]
91+
}
92+
} else {
93+
// Select the first config that is not the deleted one
94+
selectedConfigId.value = Object.keys(ldapConfigs.value).filter((_configId) => configId !== _configId)[0]
95+
delete ldapConfigs.value[configId]
96+
}
8597
}
86-
87-
selectedConfigId.value = Object.keys(ldapConfigs.value)[0] ?? await create()
8898
}
8999

90100
return {

0 commit comments

Comments
 (0)