Skip to content

Commit

Permalink
Merge pull request #40428 from nextcloud/artonge/fix/users_list_bugs
Browse files Browse the repository at this point in the history
Do not display userCount when it is equal to 0
  • Loading branch information
artonge authored Sep 15, 2023
2 parents 8014762 + 58229ad commit bf46c5b
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 10 deletions.
16 changes: 13 additions & 3 deletions apps/settings/src/components/Users/UserRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -250,11 +250,12 @@
:input-id="'manager' + uniqueId"
:close-on-select="true"
:disabled="isLoadingField"
:loading="idState.loading.manager"
:loading="idState.loadingPossibleManagers || idState.loading.manager"
label="displayname"
:options="idState.possibleManagers"
:placeholder="managerLabel"
class="select-vue"
@open="searchInitialUserManager"
@search="searchUserManager"
@option:selected="updateUserManager"
@input="updateUserManager" />
Expand Down Expand Up @@ -359,6 +360,7 @@ export default {
return {
selectedQuota: false,
rand: Math.random().toString(36).substring(2),
loadingPossibleManagers: false,
possibleManagers: [],
currentManager: '',
editing: false,
Expand Down Expand Up @@ -502,11 +504,13 @@ export default {
},

async beforeMount() {
await this.searchUserManager()

if (this.user.manager) {
await this.initManager(this.user.manager)
}

// Reset loading state before mounting the component.
// This is useful when we disable a user as the loading state cannot be properly reset upon promise resolution.
Object.keys(this.idState.loading).forEach(key => (this.idState.loading[key] = false))
},

methods: {
Expand Down Expand Up @@ -547,6 +551,12 @@ export default {
})
},

async searchInitialUserManager() {
this.idState.loadingPossibleManagers = true
await this.searchUserManager()
this.idState.loadingPossibleManagers = false
},

async searchUserManager(query) {
await this.$store.dispatch('searchUsers', { offset: 0, limit: 10, search: query }).then(response => {
const users = response?.data ? this.filterManagers(Object.values(response?.data.ocs.data.users)) : []
Expand Down
5 changes: 5 additions & 0 deletions apps/settings/src/store/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ const mutations = {
},
// update active/disabled counts, groups counts
updateUserCounts(state, { user, actionType }) {
// 0 is a special value
if (state.userCount === 0) {
return
}

const disabledGroup = state.groups.find(group => group.id === 'disabled')
switch (actionType) {
case 'enable':
Expand Down
2 changes: 1 addition & 1 deletion apps/settings/src/views/Users.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<AccountGroup :size="20" />
</template>
<template #counter>
<NcCounterBubble :type="!selectedGroupDecoded ? 'highlighted' : undefined">
<NcCounterBubble v-if="userCount" :type="!selectedGroupDecoded ? 'highlighted' : undefined">
{{ userCount }}
</NcCounterBubble>
</template>
Expand Down
4 changes: 2 additions & 2 deletions dist/settings-users-8351.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-users-8351.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/settings-vue-settings-apps-users-management.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/settings-vue-settings-apps-users-management.js.map

Large diffs are not rendered by default.

0 comments on commit bf46c5b

Please sign in to comment.