-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathGeneral.vue
More file actions
98 lines (90 loc) · 2.41 KB
/
Copy pathGeneral.vue
File metadata and controls
98 lines (90 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<template>
<section class="card mb-4">
<div class="card-body">
<b-alert
v-if="!isLead"
variant="info"
show
class="mb-3"
>
<app-icon variant="info" />
Only workspace owners can change workspace settings.
</b-alert>
<form @submit.prevent="rename">
<label class="d-block mb-3">
Workspace Title
<input
v-model.trim="workspaceName"
class="form-control"
:disabled="!isLead"
>
</label>
<button
type="submit"
class="btn btn-primary"
:disabled="!isLead"
>
Rename
</button>
</form>
<hr>
<div class="form-check form-switch">
<input
id="autoFlagReview"
v-model="autoFlagReview"
type="checkbox"
class="form-check-input"
:disabled="!isLead"
@change="saveAutoFlagReview"
>
<label
class="form-check-label"
for="autoFlagReview"
>
Auto-flag contributor changesets for review
</label>
</div>
<small class="text-muted">
When enabled, changesets created by contributors (non-leads and non-validators)
will be automatically flagged for review in the review queue.
</small>
</div>
</section>
</template>
<script setup lang="ts">
import { toast } from 'vue3-toastify';
import { workspacesClient } from '~/services/index';
import type { Workspace } from '~/types/workspaces';
const workspace = inject<Workspace>('workspace')!;
const { isLead } = useWorkspaceRole();
const workspaceName = ref(workspace.title);
const autoFlagReview = ref(workspace.autoFlagReview ?? false);
async function rename() {
try {
await workspacesClient.updateWorkspace(workspace.id, {
title: workspaceName.value,
});
toast.success('Workspace renamed successfully.');
}
catch (e) {
if (e instanceof Error) {
toast.error('Rename failed: ' + e.message);
}
else {
toast.error('Rename failed: unexpected error');
}
}
}
async function saveAutoFlagReview() {
try {
await workspacesClient.updateWorkspace(workspace.id, {
autoFlagReview: autoFlagReview.value,
});
toast.success('Review settings saved.');
}
catch {
autoFlagReview.value = !autoFlagReview.value;
toast.error('Failed to save review settings.');
}
}
</script>