Skip to content

Commit abf840b

Browse files
committed
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 <[email protected]>
1 parent f7c46b6 commit abf840b

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
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', '0') === '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/components/SystemTagsCreationControl.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ export default {
3939
4040
data() {
4141
return {
42-
systemTagsCreationRestrictedToAdmin: loadState('settings', 'restrictSystemTagsCreationToAdmin', '1') === '1',
42+
// By default, system tags creation is not restricted to admins
43+
systemTagsCreationRestrictedToAdmin: loadState('settings', 'restrictSystemTagsCreationToAdmin', '0') === '1',
4344
}
4445
},
4546
methods: {

apps/systemtags/src/files_actions/bulkSystemTagsAction.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import { FileAction } from '@nextcloud/files'
99
import { isPublicShare } from '@nextcloud/sharing/public'
1010
import { spawnDialog } from '@nextcloud/dialogs'
1111
import { t } from '@nextcloud/l10n'
12+
import { getCurrentUser } from '@nextcloud/auth'
13+
import { loadState } from '@nextcloud/initial-state'
1214

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

@@ -34,6 +36,11 @@ export const action = new FileAction({
3436

3537
// If the app is disabled, the action is not available anyway
3638
enabled(nodes) {
39+
// By default, everyone can create system tags
40+
if (loadState('settings', 'restrictSystemTagsCreationToAdmin', '0') === '1' && getCurrentUser()?.isAdmin !== true) {
41+
return false
42+
}
43+
3744
if (isPublicShare()) {
3845
return false
3946
}

0 commit comments

Comments
 (0)