Skip to content

Commit

Permalink
feat: Update UI to respect tag creation permissions
Browse files Browse the repository at this point in the history
Added support for the `only_admin_can_create` flag in system tags.
The UI now hides the option to create tags when this flag is enabled, ensuring compliance with admin settings.

Signed-off-by: nfebe <[email protected]>
  • Loading branch information
nfebe authored and Altahrim committed Jan 14, 2025
1 parent 95cdc39 commit 001ec5a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/systemtags/src/components/SystemTags.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ import {
setTagForFile,
} from '../services/files.js'

import { loadState } from '@nextcloud/initial-state'

import type { Tag, TagWithId } from '../types.js'

export default Vue.extend({
Expand Down Expand Up @@ -188,6 +190,10 @@ export default Vue.extend({
this.sortedTags.unshift(createdTag)
this.selectedTags.push(createdTag)
} catch (error) {
if(loadState('settings', 'onlyAdminsCanCreateSystemTags', '1') === '1') {
showError(t('systemtags', 'System admin disabled tag creation. You can only use existing ones.'))
return
}
showError(t('systemtags', 'Failed to create tag'))
}
this.loading = false
Expand Down
6 changes: 6 additions & 0 deletions apps/systemtags/src/files_actions/bulkSystemTagsAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import { isPublicShare } from '@nextcloud/sharing/public'
import { spawnDialog } from '@nextcloud/dialogs'
import { t } from '@nextcloud/l10n'

import { loadState } from '@nextcloud/initial-state'

import TagMultipleSvg from '@mdi/svg/svg/tag-multiple.svg?raw'

/**
Expand All @@ -34,6 +36,10 @@ export const action = new FileAction({

// If the app is disabled, the action is not available anyway
enabled(nodes) {
if (loadState('settings', 'onlyAdminsCanCreateSystemTags', '1') === '1') {
return false
}

if (isPublicShare()) {
return false
}
Expand Down

0 comments on commit 001ec5a

Please sign in to comment.