Skip to content
This repository was archived by the owner on Nov 23, 2026. It is now read-only.
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
5 changes: 5 additions & 0 deletions changelog/unreleased/enhancement-check-vault-permission.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Enhancement: Check vault permission

When the user has the `VaultMode.ReadWriteEnabled.own` permission, the mode switch will be shown in the topbar.

https://github.com/owncloud/web/pull/13802
1 change: 1 addition & 0 deletions packages/web-client/src/helpers/resource/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export type AbilitySubjects =
| 'Role'
| 'Setting'
| 'Share'
| 'Vault'

export type Ability = MongoAbility<[AbilityActions, AbilitySubjects]>
export type AbilityRule = SubjectRawRule<AbilityActions, AbilitySubjects, any>
Expand Down
11 changes: 8 additions & 3 deletions packages/web-runtime/src/components/Topbar/TopBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class="oc-logo-image"
/>
</router-link>
<div v-if="!isEmbedModeEnabled" class="oc-flex oc-flex-middle">
<div v-if="!isEmbedModeEnabled && canAccessVault" class="oc-flex oc-flex-middle">
<oc-button
id="oc-topbar-mode-switch-btn"
class="oc-topbar-mode-switch"
Expand Down Expand Up @@ -95,7 +95,8 @@ import {
useOpenEmptyEditor,
useRouter,
useThemeStore,
useClipboardStore
useClipboardStore,
useAbility
} from '@ownclouders/web-pkg'
import { useGettext } from 'vue3-gettext'
import { isRuntimeRoute } from '../../router'
Expand Down Expand Up @@ -128,6 +129,7 @@ export default {
const extensionRegistry = useExtensionRegistry()
const { openEmptyEditor } = useOpenEmptyEditor()
const { clearClipboard } = useClipboardStore()
const ability = useAbility()

const authStore = useAuthStore()
const router = useRouter()
Expand Down Expand Up @@ -212,6 +214,8 @@ export default {
}
})

const canAccessVault = computed(() => ability.can('read-all', 'Vault'))

return {
configOptions,
contentOnLeftPortal,
Expand All @@ -229,7 +233,8 @@ export default {
hideAccountMenu,
isUniversalAccessEnabled,
modeOptions,
selectedMode
selectedMode,
canAccessVault
}
},
computed: {
Expand Down
3 changes: 2 additions & 1 deletion packages/web-runtime/src/services/auth/abilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ export const getAbilities = (
{ action: 'update-all', subject: 'Drive' }
],
'Drives.List.all': [{ action: 'read-all', subject: 'Drive' }],
'Drives.ReadWriteProjectQuota.all': [{ action: 'set-quota-all', subject: 'Drive' }]
'Drives.ReadWriteProjectQuota.all': [{ action: 'set-quota-all', subject: 'Drive' }],
'VaultMode.ReadWriteEnabled.own': [{ action: 'read-all', subject: 'Vault' }]
}

return Object.keys(abilities).reduce((acc, permission) => {
Expand Down