-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49514 from nextcloud/feat/restrict-tag-creation
- Loading branch information
Showing
28 changed files
with
324 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
78 changes: 78 additions & 0 deletions
78
apps/systemtags/src/components/SystemTagsCreationControl.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<!-- | ||
- SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors | ||
- SPDX-License-Identifier: AGPL-3.0-or-later | ||
--> | ||
|
||
<template> | ||
<div id="system-tags-creation-control"> | ||
<h4 class="inlineblock"> | ||
{{ t('settings', 'System tag creation') }} | ||
</h4> | ||
|
||
<p class="settings-hint"> | ||
{{ t('settings', 'If enabled, regular accounts will be restricted from creating new tags but will still be able to assign and remove them from their files.') }} | ||
</p> | ||
|
||
<NcCheckboxRadioSwitch type="switch" | ||
:checked.sync="systemTagsCreationRestrictedToAdmin" | ||
@update:checked="updateSystemTagsDefault"> | ||
{{ t('settings', 'Restrict tag creation to admins only') }} | ||
</NcCheckboxRadioSwitch> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { loadState } from '@nextcloud/initial-state' | ||
import { showError, showSuccess } from '@nextcloud/dialogs' | ||
import { t } from '@nextcloud/l10n' | ||
import logger from '../logger.ts' | ||
import { updateSystemTagsAdminRestriction } from '../services/api.js' | ||
|
||
import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js' | ||
|
||
export default { | ||
name: 'SystemTagsCreationControl', | ||
|
||
components: { | ||
NcCheckboxRadioSwitch, | ||
}, | ||
|
||
data() { | ||
return { | ||
// By default, system tags creation is not restricted to admins | ||
systemTagsCreationRestrictedToAdmin: loadState('settings', 'restrictSystemTagsCreationToAdmin', '0') === '1', | ||
} | ||
}, | ||
methods: { | ||
t, | ||
async updateSystemTagsDefault(isRestricted: boolean) { | ||
try { | ||
const responseData = await updateSystemTagsAdminRestriction(isRestricted) | ||
console.debug('updateSystemTagsDefault', responseData) | ||
this.handleResponse({ | ||
isRestricted, | ||
status: responseData.ocs?.meta?.status, | ||
}) | ||
} catch (e) { | ||
this.handleResponse({ | ||
errorMessage: t('settings', 'Unable to update setting'), | ||
error: e, | ||
}) | ||
} | ||
}, | ||
|
||
handleResponse({ isRestricted, status, errorMessage, error }) { | ||
if (status === 'ok') { | ||
this.systemTagsCreationRestrictedToAdmin = isRestricted | ||
showSuccess(t('settings', `System tag creation is now ${isRestricted ? 'restricted to administrators' : 'allowed for everybody'}`)) | ||
return | ||
} | ||
|
||
if (errorMessage) { | ||
showError(errorMessage) | ||
logger.error(errorMessage, error) | ||
} | ||
}, | ||
}, | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ SPDX-FileCopyrightText: jden <[email protected]> | |
SPDX-FileCopyrightText: inherits developers | ||
SPDX-FileCopyrightText: escape-html developers | ||
SPDX-FileCopyrightText: defunctzombie | ||
SPDX-FileCopyrightText: debounce developers | ||
SPDX-FileCopyrightText: atomiks | ||
SPDX-FileCopyrightText: Varun A P | ||
SPDX-FileCopyrightText: Tobias Koppers @sokra | ||
|
@@ -114,6 +115,9 @@ This file is generated from multiple sources. Included packages: | |
- @nextcloud/logger | ||
- version: 3.0.2 | ||
- license: GPL-3.0-or-later | ||
- @nextcloud/password-confirmation | ||
- version: 5.3.1 | ||
- license: MIT | ||
- @nextcloud/paths | ||
- version: 2.2.1 | ||
- license: GPL-3.0-or-later | ||
|
@@ -183,6 +187,9 @@ This file is generated from multiple sources. Included packages: | |
- css-loader | ||
- version: 7.1.2 | ||
- license: MIT | ||
- debounce | ||
- version: 2.2.0 | ||
- license: MIT | ||
- define-data-property | ||
- version: 1.1.4 | ||
- license: MIT | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.