Skip to content

Commit bbef93d

Browse files
authored
Merge pull request #319 from nextcloud/restricted
create restricted instead of invisible tags in approval settings
2 parents 03d39e0 + bb5b55c commit bbef93d

File tree

5 files changed

+4
-20
lines changed

5 files changed

+4
-20
lines changed

lib/Controller/ConfigController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ public function __construct(
4040
* @param string $name of the new tag
4141
* @return DataResponse
4242
*/
43+
#[AuthorizedAdminSetting(settings: Admin::class)]
4344
public function createTag(string $name): DataResponse {
4445
$result = $this->utilsService->createTag($name);
4546
if (isset($result['error'])) {

lib/Service/UtilsService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ public function userHasAccessTo(int $fileId, ?string $userId): bool {
172172
*/
173173
public function createTag(string $name): array {
174174
try {
175-
$tag = $this->tagManager->createTag($name, false, false);
175+
$tag = $this->tagManager->createTag($name, true, false);
176176
return ['id' => $tag->getId()];
177177
} catch (TagAlreadyExistsException $e) {
178178
return ['error' => 'Tag already exists'];

lib/Settings/Admin.php

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,19 @@
1010
use OCA\Approval\AppInfo\Application;
1111
use OCP\AppFramework\Http\TemplateResponse;
1212

13-
use OCP\AppFramework\Services\IInitialState;
14-
use OCP\IGroupManager;
1513
use OCP\Settings\IDelegatedSettings;
1614

1715
class Admin implements IDelegatedSettings {
1816

1917
public function __construct(
2018
private string $appName,
21-
private IGroupManager $groupManager,
22-
private IInitialState $initialStateService,
23-
private ?string $userId,
2419
) {
2520
}
2621

2722
/**
2823
* @return TemplateResponse
2924
*/
3025
public function getForm(): TemplateResponse {
31-
$this->initialStateService->provideInitialState('is-admin', $this->groupManager->isAdmin($this->userId));
3226
return new TemplateResponse(Application::APP_ID, 'adminSettings');
3327
}
3428

src/components/AdminSettings.vue

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
<ApprovalRule v-for="(rule, id) in rules"
3131
:key="id"
3232
v-model:value="rules[id]"
33-
:is-admin="isAdmin"
3433
class="approval-rule"
3534
@input="onRuleInput(id, $event)"
3635
@add-tag="onAddTagClick">
@@ -55,7 +54,6 @@
5554
<div v-if="newRule" class="new-rule">
5655
<ApprovalRule
5756
v-model:value="newRule"
58-
:is-admin="isAdmin"
5957
:delete-rule-label="newRuleDeleteLabel"
6058
:focus="true"
6159
@add-tag="onAddTagClick">
@@ -91,10 +89,10 @@
9189
</template>
9290
{{ t('approval', 'New workflow') }}
9391
</NcButton>
94-
<div v-if="isAdmin" class="create-tag">
92+
<div class="create-tag">
9593
<label for="create-tag-input">
9694
<TagIcon :size="16" />
97-
{{ t('approval', 'Create new hidden tag') }}
95+
{{ t('approval', 'Create new restricted tag') }}
9896
</label>
9997
<input id="create-tag-input"
10098
ref="createTagInput"
@@ -129,7 +127,6 @@ import ApprovalRule from './ApprovalRule.vue'
129127
import { generateUrl } from '@nextcloud/router'
130128
import axios from '@nextcloud/axios'
131129
import { showSuccess, showError } from '@nextcloud/dialogs'
132-
import { loadState } from '@nextcloud/initial-state'
133130
134131
export default {
135132
name: 'AdminSettings',
@@ -148,7 +145,6 @@ export default {
148145
149146
data() {
150147
return {
151-
isAdmin: loadState('approval', 'is-admin'),
152148
showRules: true,
153149
newTagName: '',
154150
rules: {},

src/components/ApprovalRule.vue

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
{{ pendingLabel }}
2323
<div class="spacer" />
2424
<span
25-
v-if="isAdmin"
2625
:title="t('approval', 'Create new hidden tag')"
2726
class="add-tag-button"
2827
@click="$emit('add-tag')">
@@ -75,7 +74,6 @@
7574
{{ approvedLabel }}
7675
<div class="spacer" />
7776
<span
78-
v-if="isAdmin"
7977
:title="t('approval', 'Create new hidden tag')"
8078
class="add-tag-button"
8179
@click="$emit('add-tag')">
@@ -99,7 +97,6 @@
9997
{{ rejectedLabel }}
10098
<div class="spacer" />
10199
<span
102-
v-if="isAdmin"
103100
:title="t('approval', 'Create new hidden tag')"
104101
class="add-tag-button"
105102
@click="$emit('add-tag')">
@@ -163,10 +160,6 @@ export default {
163160
type: Boolean,
164161
default: false,
165162
},
166-
isAdmin: {
167-
type: Boolean,
168-
default: true,
169-
},
170163
},
171164
172165
emits: ['add-tag', 'input', 'update:value'],

0 commit comments

Comments
 (0)