Skip to content

Commit 4d600b1

Browse files
committed
fix(settings): Display group displayName consistently when editing a user
Signed-off-by: Benjamin Frueh <[email protected]>
1 parent 2482f65 commit 4d600b1

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

apps/settings/src/components/Users/UserRow.vue

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,6 @@ export default {
588588
for (const group of groups) {
589589
this.$store.commit('addGroup', group)
590590
}
591-
this.selectedGroups = this.selectedGroups.map(selectedGroup => groups.find(group => group.id === selectedGroup.id) ?? selectedGroup)
592591
} catch (error) {
593592
logger.error(t('settings', 'Failed to load groups with details'), { error })
594593
}
@@ -605,7 +604,6 @@ export default {
605604
for (const group of groups) {
606605
this.$store.commit('addGroup', group)
607606
}
608-
this.selectedSubAdminGroups = this.selectedSubAdminGroups.map(selectedGroup => groups.find(group => group.id === selectedGroup.id) ?? selectedGroup)
609607
} catch (error) {
610608
logger.error(t('settings', 'Failed to load sub admin groups with details'), { error })
611609
}
@@ -794,7 +792,6 @@ export default {
794792
await this.$store.dispatch('addGroup', gid)
795793
const userid = this.user.id
796794
await this.$store.dispatch('addUserGroup', { userid, gid })
797-
this.userGroups.push({ id: gid, name: gid })
798795
} catch (error) {
799796
logger.error(t('settings', 'Failed to create group'), { error })
800797
}
@@ -820,7 +817,6 @@ export default {
820817
this.loading.groups = true
821818
try {
822819
await this.$store.dispatch('addUserGroup', { userid, gid })
823-
this.userGroups.push(group)
824820
} catch (error) {
825821
console.error(error)
826822
}
@@ -844,7 +840,6 @@ export default {
844840
userid,
845841
gid,
846842
})
847-
this.userGroups = this.userGroups.filter(group => group.id !== gid)
848843
this.loading.groups = false
849844
// remove user from current list if current list is the removed group
850845
if (this.$route.params.selectedGroup === gid) {
@@ -869,7 +864,6 @@ export default {
869864
userid,
870865
gid,
871866
})
872-
this.userSubAdminGroups.push(group)
873867
} catch (error) {
874868
console.error(error)
875869
}
@@ -891,7 +885,6 @@ export default {
891885
userid,
892886
gid,
893887
})
894-
this.userSubAdminGroups = this.userSubAdminGroups.filter(group => group.id !== gid)
895888
} catch (error) {
896889
console.error(error)
897890
} finally {

apps/settings/src/mixins/UserRowMixin.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,6 @@ export default {
4141
formattedFullTime,
4242
}
4343
},
44-
data() {
45-
return {
46-
selectedGroups: this.user.groups.map(id => ({ id, name: id })),
47-
selectedSubAdminGroups: this.user.subadmin.map(id => ({ id, name: id })),
48-
userGroups: this.user.groups.map(id => ({ id, name: id })),
49-
userSubAdminGroups: this.user.subadmin.map(id => ({ id, name: id })),
50-
}
51-
},
5244
computed: {
5345
showConfig() {
5446
return this.$store.getters.getShowConfig
@@ -129,5 +121,19 @@ export default {
129121
}
130122
return t('settings', 'Never')
131123
},
124+
125+
userGroups() {
126+
const allGroups = this.$store.getters.getGroups
127+
return this.user.groups
128+
.map((id) => allGroups.find((g) => g.id === id))
129+
.filter((group) => group !== undefined)
130+
},
131+
132+
userSubAdminGroups() {
133+
const allGroups = this.$store.getters.getGroups
134+
return this.user.subadmin
135+
.map((id) => allGroups.find((g) => g.id === id))
136+
.filter((group) => group !== undefined)
137+
},
132138
},
133139
}

0 commit comments

Comments
 (0)