Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort roles in role dropdown according to backend #11922

Merged
merged 3 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog/unreleased/bugfix-fix-order-in-roles-drop-down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ We've fixed an issue where the order of roles in the roles drop down was not cor
Now the roles are sorted as delegated by the backend.

https://github.com/owncloud/web/pull/11916
https://github.com/owncloud/web/pull/11922
https://github.com/owncloud/web/issues/11915
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ import {
computed,
ref,
unref,
Ref
Ref,
watch
} from 'vue'
import { useAbility, useUserStore } from '@ownclouders/web-pkg'
import { Resource } from '@ownclouders/web-client'
Expand Down Expand Up @@ -149,9 +150,7 @@ export default defineComponent({
roles = availableExternalRoles
}

return [...unref(roles)].sort(
(role1, role2) => role1['@libre.graph.weight'] - role2['@libre.graph.weight']
)
return unref(roles)
})

let initialSelectedRole: ShareRole
Expand Down Expand Up @@ -187,6 +186,16 @@ export default defineComponent({
emit('optionChange', unref(selectedRole))
}

watch(
() => props.isExternal,
() => {
if (!unref(hasExistingShareRole)) {
// when no role exists and the external flag changes, we need to reset the selected role
selectedRole.value = unref(availableRoles)[0]
}
}
)

return {
ability,
user,
Expand Down
14 changes: 12 additions & 2 deletions packages/web-pkg/src/components/SideBar/FileSideBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,12 @@ export default defineComponent({

const rolesArray = Object.values(sharesStore.graphRoles)
availableInternalShareRoles.value =
rolesArray.filter((r) => allowedRoles?.map(({ id }) => id).includes(r.id)) || []
allowedRoles?.map((r) => {
return {
...r,
icon: rolesArray.find((role) => role.id === r.id)?.icon
}
}) || []

// load external share roles
if (appsStore.isAppEnabled('open-cloud-mesh')) {
Expand All @@ -243,7 +248,12 @@ export default defineComponent({
)

availableExternalShareRoles.value =
rolesArray.filter((r) => allowedRoles?.map(({ id }) => id).includes(r.id)) || []
allowedRoles?.map((r) => {
return {
...r,
icon: rolesArray.find((role) => role.id === r.id)?.icon
}
}) || []
}

// use cache for indirect shares
Expand Down