aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornfebe <fenn25.fn@gmail.com>2025-01-13 15:49:37 +0100
committernfebe <fenn25.fn@gmail.com>2025-01-22 20:13:28 +0100
commitabf840bc18d05203cde86348d6981a8895792d13 (patch)
tree94dc523700abef067b960cbff759e56385b4ae4e
parentf7c46b68094eb2c33d3f56ec79aa09e197b017ac (diff)
downloadnextcloud-server-abf840bc18d05203cde86348d6981a8895792d13.tar.gz
nextcloud-server-abf840bc18d05203cde86348d6981a8895792d13.zip
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>
-rw-r--r--apps/systemtags/src/components/SystemTags.vue6
-rw-r--r--apps/systemtags/src/components/SystemTagsCreationControl.vue3
-rw-r--r--apps/systemtags/src/files_actions/bulkSystemTagsAction.ts7
3 files changed, 15 insertions, 1 deletions
diff --git a/apps/systemtags/src/components/SystemTags.vue b/apps/systemtags/src/components/SystemTags.vue
index 1f2b38bf10a..f65a68dfd90 100644
--- a/apps/systemtags/src/components/SystemTags.vue
+++ b/apps/systemtags/src/components/SystemTags.vue
@@ -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({
@@ -188,6 +190,10 @@ export default Vue.extend({
this.sortedTags.unshift(createdTag)
this.selectedTags.push(createdTag)
} catch (error) {
+ if(loadState('settings', 'restrictSystemTagsCreationToAdmin', '0') === '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
diff --git a/apps/systemtags/src/components/SystemTagsCreationControl.vue b/apps/systemtags/src/components/SystemTagsCreationControl.vue
index 11d49288843..d0af07d4cd0 100644
--- a/apps/systemtags/src/components/SystemTagsCreationControl.vue
+++ b/apps/systemtags/src/components/SystemTagsCreationControl.vue
@@ -39,7 +39,8 @@ export default {
data() {
return {
- systemTagsCreationRestrictedToAdmin: loadState('settings', 'restrictSystemTagsCreationToAdmin', '1') === '1',
+ // By default, system tags creation is not restricted to admins
+ systemTagsCreationRestrictedToAdmin: loadState('settings', 'restrictSystemTagsCreationToAdmin', '0') === '1',
}
},
methods: {
diff --git a/apps/systemtags/src/files_actions/bulkSystemTagsAction.ts b/apps/systemtags/src/files_actions/bulkSystemTagsAction.ts
index b0d68ef65ca..c764db98f29 100644
--- a/apps/systemtags/src/files_actions/bulkSystemTagsAction.ts
+++ b/apps/systemtags/src/files_actions/bulkSystemTagsAction.ts
@@ -9,6 +9,8 @@ import { FileAction } from '@nextcloud/files'
import { isPublicShare } from '@nextcloud/sharing/public'
import { spawnDialog } from '@nextcloud/dialogs'
import { t } from '@nextcloud/l10n'
+import { getCurrentUser } from '@nextcloud/auth'
+import { loadState } from '@nextcloud/initial-state'
import TagMultipleSvg from '@mdi/svg/svg/tag-multiple.svg?raw'
@@ -34,6 +36,11 @@ export const action = new FileAction({
// If the app is disabled, the action is not available anyway
enabled(nodes) {
+ // By default, everyone can create system tags
+ if (loadState('settings', 'restrictSystemTagsCreationToAdmin', '0') === '1' && getCurrentUser()?.isAdmin !== true) {
+ return false
+ }
+
if (isPublicShare()) {
return false
}