Skip to content

Commit 7c4295c

Browse files
nfebeAltahrim
authored andcommitted
feat: Update UI to respect tag creation permissions
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 <fenn25.fn@gmail.com>
1 parent 8e59bf9 commit 7c4295c

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

apps/systemtags/src/components/SystemTags.vue

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ import {
5151
setTagForFile,
5252
} from '../services/files.js'
5353
54+
import { loadState } from '@nextcloud/initial-state'
55+
5456
import type { Tag, TagWithId } from '../types.js'
5557
5658
export default Vue.extend({
@@ -188,6 +190,10 @@ export default Vue.extend({
188190
this.sortedTags.unshift(createdTag)
189191
this.selectedTags.push(createdTag)
190192
} catch (error) {
193+
if(loadState('settings', 'restrictSystemTagsCreationToAdmin', '1') === '1') {
194+
showError(t('systemtags', 'System admin disabled tag creation. You can only use existing ones.'))
195+
return
196+
}
191197
showError(t('systemtags', 'Failed to create tag'))
192198
}
193199
this.loading = false

apps/systemtags/src/files_actions/bulkSystemTagsAction.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { isPublicShare } from '@nextcloud/sharing/public'
1010
import { spawnDialog } from '@nextcloud/dialogs'
1111
import { t } from '@nextcloud/l10n'
1212

13+
import { loadState } from '@nextcloud/initial-state'
14+
1315
import TagMultipleSvg from '@mdi/svg/svg/tag-multiple.svg?raw'
1416

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

3537
// If the app is disabled, the action is not available anyway
3638
enabled(nodes) {
39+
if (loadState('settings', 'restrictSystemTagsCreationToAdmin', '1') === '1') {
40+
return false
41+
}
42+
3743
if (isPublicShare()) {
3844
return false
3945
}

0 commit comments

Comments
 (0)