Skip to content

Commit

Permalink
Init
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan committed Jan 18, 2023
1 parent 95d17f8 commit 1ad9a84
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 104 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<tr>
<th scope="col" class="oc-pr-s" v-text="$gettext('Role')" />
<td>
<span v-if="user.role" v-text="user.role.displayName" />
<span v-if="user.appRoleAssignments" v-text="roleDisplayName" />
</td>
</tr>
</table>
Expand All @@ -50,6 +50,10 @@ export default defineComponent({
users: {
type: Array,
required: true
},
roles: {
type: Array,
required: true
}
},
computed: {
Expand All @@ -66,8 +70,19 @@ export default defineComponent({
return this.$gettextInterpolate('%{count} users selected', {
count: this.users.length
})
},
roleDisplayName() {
const assignedRole = this.user.appRoleAssignments[0]
if (!assignedRole) {
return ''
}
return this.$gettext(
this.roles.find((role) => role.id === assignedRole.appRoleId)?.displayName || ''
)
}
}
},
})
</script>
<style lang="scss">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@
option-label="displayName"
:options="roles"
:clearable="false"
/>
>
<template #selected-option="item">
{{ getRoleName(item) }}
</template>
</oc-select>
<div class="oc-text-input-message"></div>
</div>
<quota-select
Expand Down Expand Up @@ -157,6 +161,10 @@ export default defineComponent({
formDataValue.valid = true
formDataValue.errorMessage = ''
})
},
getRoleName(item) {
console.log(item)
return 1
}
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
<avatar-image :width="32" :userid="item.id" :user-name="item.displayName" />
</template>
<template #role="{ item }">
<template v-if="item.role">{{ item.role.displayName }}</template>
<template v-if="item.appRoleAssignments">{{ getRoleDisplayName(item) }}</template>
</template>
<template #actions="{ item }">
<oc-button
Expand Down Expand Up @@ -93,6 +93,10 @@ export default defineComponent({
type: Array,
required: true
},
roles: {
type: Array,
required: true
},
selectedUsers: {
type: Array,
required: true
Expand Down Expand Up @@ -230,6 +234,17 @@ export default defineComponent({
const translated = this.$gettext('Select %{ user }')
return this.$gettextInterpolate(translated, { user: user.displayName }, true)
},
getRoleDisplayName(user) {
if (!user.appRoleAssignments.length) {
return ''
}
const assignedRole = user.appRoleAssignments[0]
return this.$gettext(
this.roles.find((role) => role.id === assignedRole.appRoleId)?.displayName || ''
)
}
}
})
Expand Down

This file was deleted.

28 changes: 10 additions & 18 deletions packages/web-app-admin-settings/src/views/Users.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<div v-else>
<UsersList
:users="users"
:roles="roles"
:class="{ 'users-table-squashed': sideBarOpen }"
:selected-users="selectedUsers"
:header-position="listHeaderPosition"
Expand Down Expand Up @@ -93,6 +94,7 @@ import { useGraphClient } from 'web-pkg/src/composables'
import AppTemplate from '../components/AppTemplate.vue'
import { useLoadTasks } from '../composables/loadTasks/useLoadTasks'
import { useSideBar } from 'web-pkg/src/composables/sideBar'
import { graph } from 'web-client/src/graph'
export default defineComponent({
name: 'UsersView',
Expand All @@ -108,21 +110,19 @@ export default defineComponent({
const users = ref([])
const groups = ref([])
const roles = ref([])
const userAssignments = ref({})
const accessToken = useAccessToken({ store })
const { graphClient } = useGraphClient()
const { loadRolesTask, loadUserRoleTask, addRoleAssignment } = useLoadTasks({
accessToken,
roles,
userAssignments
})
const loadGroupsTask = useTask(function* (signal) {
const groupsResponse = yield unref(graphClient).groups.listGroups()
groups.value = groupsResponse.data.value
})
const loadAppRolesTask = useTask(function* (signal) {
const applicationsResponse = yield unref(graphClient).applications.listApplications()
roles.value = applicationsResponse.data.value[0].appRoles
})
const loadResourcesTask = useTask(function* (signal) {
const usersResponse = yield unref(graphClient).users.listUsers('displayName')
users.value = usersResponse.data.value || []
Expand All @@ -132,15 +132,7 @@ export default defineComponent({
})
yield loadGroupsTask.perform()
yield loadRolesTask.perform()
for (const user of users.value) {
try {
yield loadUserRoleTask.perform({ user })
} catch (e) {
console.error(`Failed to load role for user '${user.displayName}'`)
}
}
yield loadAppRolesTask.perform()
})
const loadAdditionalUserDataTask = useTask(function* (signal, ref, user) {
Expand All @@ -155,7 +147,7 @@ export default defineComponent({
user.drive.quota = { total: 0 }
}
})
const addRoleAssignment = () => {}
return {
...useSideBar(),
addRoleAssignment,
Expand Down Expand Up @@ -208,7 +200,7 @@ export default defineComponent({
component: DetailsPanel,
default: true,
enabled: true,
componentAttrs: { users: this.selectedUsers }
componentAttrs: { users: this.selectedUsers, roles: this.roles }
},
{
app: 'EditPanel',
Expand Down
2 changes: 1 addition & 1 deletion packages/web-client/src/graph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const graph = (baseURI: string, axiosClient: AxiosInstance): Graph => {
false,
new Set<any>([orderBy]),
new Set<any>([]),
new Set<any>(['memberOf'])
new Set<any>(['memberOf', 'appRoleAssignments'])
)
},
groups: {
Expand Down

0 comments on commit 1ad9a84

Please sign in to comment.