Skip to content

Commit 06bb2f1

Browse files
committed
wip: Add admin toggle to disable systemtag
Signed-off-by: nfebe <fenn25.fn@gmail.com>
1 parent 1e6005e commit 06bb2f1

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<!--
2+
- SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
3+
- SPDX-License-Identifier: AGPL-3.0-or-later
4+
-->
5+
6+
<template>
7+
<div id="system-tags-settings"
8+
class="section">
9+
<h2 class="inlineblock">
10+
{{ t('settings', 'System Tags') }}
11+
</h2>
12+
13+
<p class="settings-hint">
14+
{{ t('settings', 'Enable or disable system tag creation for non-admin users.') }}
15+
</p>
16+
17+
<NcCheckboxRadioSwitch type="switch"
18+
:checked.sync="initialSystemTagsEnabledByDefault"
19+
@update:checked="onSystemTagsDefaultChange">
20+
{{ t('settings', 'Enable') }}
21+
</NcCheckboxRadioSwitch>
22+
</div>
23+
</template>
24+
25+
<script>
26+
import { loadState } from '@nextcloud/initial-state'
27+
import { showError } from '@nextcloud/dialogs'
28+
29+
import { validateBoolean } from '../../utils/validate.js'
30+
import logger from '../../logger.ts'
31+
32+
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
33+
34+
const systemTagsEnabledByDefault = true //loadState('settings', 'systemTagsEnabledByDefault', true)
35+
36+
export default {
37+
name: 'SystemTagsSettings',
38+
39+
components: {
40+
NcCheckboxRadioSwitch,
41+
},
42+
43+
data() {
44+
return {
45+
initialSystemTagsEnabledByDefault: systemTagsEnabledByDefault,
46+
}
47+
},
48+
49+
methods: {
50+
async onSystemTagsDefaultChange(isEnabled) {
51+
if (validateBoolean(isEnabled)) {
52+
await this.updateSystemTagsDefault(isEnabled)
53+
}
54+
},
55+
56+
async updateSystemTagsDefault(isEnabled) {
57+
try {
58+
const responseData = await saveSystemTagsDefault(isEnabled)
59+
this.handleResponse({
60+
isEnabled,
61+
status: responseData.ocs?.meta?.status,
62+
})
63+
} catch (e) {
64+
this.handleResponse({
65+
errorMessage: t('settings', 'Unable to update systemTags default setting'),
66+
error: e,
67+
})
68+
}
69+
},
70+
71+
handleResponse({ isEnabled, status, errorMessage, error }) {
72+
if (status === 'ok') {
73+
this.initialSystemTagsEnabledByDefault = isEnabled
74+
} else {
75+
showError(errorMessage)
76+
logger.error(errorMessage, error)
77+
}
78+
},
79+
},
80+
}
81+
</script>

apps/settings/src/main-admin-basic-settings.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import logger from './logger.ts'
1212

1313
import ProfileSettings from './components/BasicSettings/ProfileSettings.vue'
1414
import BackgroundJob from './components/BasicSettings/BackgroundJob.vue'
15+
import SystemTagsSettings from './components/BasicSettings/SystemTagsSettings.vue'
1516

1617
__webpack_nonce__ = getCSPNonce()
1718

@@ -33,3 +34,8 @@ if (profileEnabledGlobally) {
3334
const ProfileSettingsView = Vue.extend(ProfileSettings)
3435
new ProfileSettingsView().$mount('#vue-admin-profile-settings')
3536
}
37+
38+
const SystemTagsSettingsView = Vue.extend(SystemTagsSettings)
39+
new SystemTagsSettingsView().$mount('#vue-admin-system-tags-settings')
40+
41+
console.log('Main admin basic settings loaded')

apps/settings/templates/settings/admin/server.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@
1717
<?php if ($_['profileEnabledGlobally']) : ?>
1818
<div id="vue-admin-profile-settings"></div>
1919
<?php endif; ?>
20+
21+
<div id="vue-admin-system-tags-settings"></div>

0 commit comments

Comments
 (0)