mirror of
https://github.com/nextcloud/server.git
synced 2026-06-07 07:43:18 -04:00
Merge pull request #41949 from nextcloud/backport/stable28/40169
[stable28] enh(settings): Load from disabled users endpoint
This commit is contained in:
commit
b10f72fccc
9 changed files with 66 additions and 15 deletions
|
|
@ -223,6 +223,14 @@ export default {
|
|||
return this.$store.getters.getUsersLimit
|
||||
},
|
||||
|
||||
disabledUsersOffset() {
|
||||
return this.$store.getters.getDisabledUsersOffset
|
||||
},
|
||||
|
||||
disabledUsersLimit() {
|
||||
return this.$store.getters.getDisabledUsersLimit
|
||||
},
|
||||
|
||||
usersCount() {
|
||||
return this.users.length
|
||||
},
|
||||
|
|
@ -297,12 +305,19 @@ export default {
|
|||
async loadUsers() {
|
||||
this.loading.users = true
|
||||
try {
|
||||
await this.$store.dispatch('getUsers', {
|
||||
offset: this.usersOffset,
|
||||
limit: this.usersLimit,
|
||||
group: this.selectedGroup !== 'disabled' ? this.selectedGroup : '',
|
||||
search: this.searchQuery,
|
||||
})
|
||||
if (this.selectedGroup === 'disabled') {
|
||||
await this.$store.dispatch('getDisabledUsers', {
|
||||
offset: this.disabledUsersOffset,
|
||||
limit: this.disabledUsersLimit,
|
||||
})
|
||||
} else {
|
||||
await this.$store.dispatch('getUsers', {
|
||||
offset: this.usersOffset,
|
||||
limit: this.usersLimit,
|
||||
group: this.selectedGroup,
|
||||
search: this.searchQuery,
|
||||
})
|
||||
}
|
||||
logger.debug(`${this.users.length} total user(s) loaded`)
|
||||
} catch (error) {
|
||||
logger.error('Failed to load users', { error })
|
||||
|
|
|
|||
|
|
@ -63,6 +63,8 @@ const state = {
|
|||
minPasswordLength: 0,
|
||||
usersOffset: 0,
|
||||
usersLimit: 25,
|
||||
disabledUsersOffset: 0,
|
||||
disabledUsersLimit: 25,
|
||||
userCount: 0,
|
||||
showConfig: {
|
||||
showStoragePath: false,
|
||||
|
|
@ -83,6 +85,9 @@ const mutations = {
|
|||
state.usersOffset += state.usersLimit
|
||||
state.users = users
|
||||
},
|
||||
updateDisabledUsers(state, _usersObj) {
|
||||
state.disabledUsersOffset += state.disabledUsersLimit
|
||||
},
|
||||
setPasswordPolicyMinLength(state, length) {
|
||||
state.minPasswordLength = length !== '' ? length : 0
|
||||
},
|
||||
|
|
@ -237,6 +242,7 @@ const mutations = {
|
|||
resetUsers(state) {
|
||||
state.users = []
|
||||
state.usersOffset = 0
|
||||
state.disabledUsersOffset = 0
|
||||
},
|
||||
|
||||
setShowConfig(state, { key, value }) {
|
||||
|
|
@ -264,6 +270,12 @@ const getters = {
|
|||
getUsersLimit(state) {
|
||||
return state.usersLimit
|
||||
},
|
||||
getDisabledUsersOffset(state) {
|
||||
return state.disabledUsersOffset
|
||||
},
|
||||
getDisabledUsersLimit(state) {
|
||||
return state.disabledUsersLimit
|
||||
},
|
||||
getUserCount(state) {
|
||||
return state.userCount
|
||||
},
|
||||
|
|
@ -373,6 +385,30 @@ const actions = {
|
|||
})
|
||||
},
|
||||
|
||||
/**
|
||||
* Get disabled users with full details
|
||||
*
|
||||
* @param {object} context store context
|
||||
* @param {object} options destructuring object
|
||||
* @param {number} options.offset List offset to request
|
||||
* @param {number} options.limit List number to return from offset
|
||||
* @return {Promise<number>}
|
||||
*/
|
||||
async getDisabledUsers(context, { offset, limit }) {
|
||||
const url = generateOcsUrl('cloud/users/disabled?offset={offset}&limit={limit}', { offset, limit })
|
||||
try {
|
||||
const response = await api.get(url)
|
||||
const usersCount = Object.keys(response.data.ocs.data.users).length
|
||||
if (usersCount > 0) {
|
||||
context.commit('appendUsers', response.data.ocs.data.users)
|
||||
context.commit('updateDisabledUsers', response.data.ocs.data.users)
|
||||
}
|
||||
return usersCount
|
||||
} catch (error) {
|
||||
context.commit('API_FAILURE', error)
|
||||
}
|
||||
},
|
||||
|
||||
getGroups(context, { offset, limit, search }) {
|
||||
search = typeof search === 'string' ? search : ''
|
||||
const limitParam = limit === -1 ? '' : `&limit=${limit}`
|
||||
|
|
|
|||
|
|
@ -682,7 +682,7 @@ class User_LDAP extends BackendUtility implements IUserBackend, UserInterface, I
|
|||
return $enabled;
|
||||
}
|
||||
|
||||
public function getDisabledUserList(int $offset = 0, ?int $limit = null): array {
|
||||
public function getDisabledUserList(?int $limit = null, int $offset = 0): array {
|
||||
throw new \Exception('This is implemented directly in User_Proxy');
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -463,7 +463,7 @@ class User_Proxy extends Proxy implements IUserBackend, UserInterface, IUserLDAP
|
|||
return $this->handleRequest($uid, 'setUserEnabled', [$uid, $enabled, $queryDatabaseValue, $setDatabaseValue]);
|
||||
}
|
||||
|
||||
public function getDisabledUserList(int $offset = 0, ?int $limit = null): array {
|
||||
public function getDisabledUserList(?int $limit = null, int $offset = 0): array {
|
||||
return array_map(
|
||||
fn (OfflineUser $user) => $user->getOCName(),
|
||||
array_slice(
|
||||
|
|
|
|||
4
dist/settings-users-8351.js
vendored
4
dist/settings-users-8351.js
vendored
File diff suppressed because one or more lines are too long
2
dist/settings-users-8351.js.map
vendored
2
dist/settings-users-8351.js.map
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -52,5 +52,5 @@ interface IProvideEnabledStateBackend {
|
|||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getDisabledUserList(int $offset = 0, ?int $limit = null): array;
|
||||
public function getDisabledUserList(?int $limit = null, int $offset = 0): array;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue