forked from galaxyproject/galaxy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserPreferences.vue
More file actions
328 lines (285 loc) · 12.6 KB
/
UserPreferences.vue
File metadata and controls
328 lines (285 loc) · 12.6 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
<script setup lang="ts">
import axios from "axios";
import { BAlert, BModal } from "bootstrap-vue";
import {
faBell,
faBroadcastTower,
faCubes,
faFile,
faHdd,
faIdCard,
faKey,
faLock,
faPalette,
faRadiation,
faSignOut,
faUsers,
} from "font-awesome-6";
import { computed, onMounted, ref } from "vue";
import { getGalaxyInstance } from "@/app";
import { getUserPreferencesModel } from "@/components/User/UserPreferencesModel";
import { useConfig } from "@/composables/config";
import { useConfirmDialog } from "@/composables/confirmDialog";
import { useFileSourceTemplatesStore } from "@/stores/fileSourceTemplatesStore";
import { useObjectStoreTemplatesStore } from "@/stores/objectStoreTemplatesStore";
import localize from "@/utils/localization";
import { userLogoutAll } from "@/utils/logout";
import QueryStringParsing from "@/utils/query-string-parsing";
import { withPrefix } from "@/utils/redirect";
import BreadcrumbHeading from "@/components/Common/BreadcrumbHeading.vue";
import Heading from "@/components/Common/Heading.vue";
import UserBeaconSettings from "@/components/User/UserBeaconSettings.vue";
import UserDeletion from "@/components/User/UserDeletion.vue";
import UserDetailsElement from "@/components/User/UserDetailsElement.vue";
import UserPickTheme from "@/components/User/UserPickTheme.vue";
import UserPreferencesElement from "@/components/User/UserPreferencesElement.vue";
import UserPreferredObjectStore from "@/components/User/UserPreferredObjectStore.vue";
const breadcrumbItems = [{ title: "User Preferences" }];
const { confirm } = useConfirmDialog();
const { config, isConfigLoaded } = useConfig(true);
const objectStoreTemplatesStore = useObjectStoreTemplatesStore();
const fileSourceTemplatesStore = useFileSourceTemplatesStore();
const messageVariant = ref(null);
const message = ref(null);
const showBeaconModal = ref(false);
const showPreferredStorageModal = ref(false);
const showDeleteAccountModal = ref(false);
const showDataPrivateModal = ref(false);
const showThemPickerModal = ref(false);
const activePreferences = computed(() => {
const userPreferencesEntries = getUserPreferencesModel();
const enabledPreferences = Object.entries(userPreferencesEntries).filter(([, value]) => !value.disabled);
return Object.fromEntries(enabledPreferences);
});
const hasLogout = computed(() => {
if (isConfigLoaded.value) {
const Galaxy = getGalaxyInstance();
return !!Galaxy.session_csrf_token && !config.value.single_user;
} else {
return false;
}
});
const hasThemes = computed(() => {
if (isConfigLoaded.value) {
const themes = Object.keys(config.value.themes);
return themes.length > 1;
} else {
return false;
}
});
const userPermissionsUrl = computed(() => {
return withPrefix("/user/permissions");
});
async function makeDataPrivate() {
const confirmed = await confirm(
localize(
"WARNING: This will make all datasets (excluding library datasets) for which you have " +
"'management' permissions, in all of your histories " +
"private (including archived and purged), and will set permissions such that all " +
"of your new data in these histories is created as private. Any " +
"datasets within that are currently shared will need " +
"to be re-shared or published. Are you sure you " +
"want to do this?",
),
{
title: "Do you want to make all data private?",
okTitle: "Yes, make all data private",
cancelTitle: "No, do not make data private",
cancelVariant: "outline-primary",
centered: true,
},
);
if (confirmed) {
axios.post(withPrefix(`/history/make_private?all_histories=true`)).then(() => {
showDataPrivateModal.value = true;
});
}
}
async function signOut() {
const confirmed = await confirm(localize("Do you want to continue and sign out of all active sessions?"), {
title: "Sign out of all sessions",
okTitle: "Yes, sign out",
okVariant: "danger",
cancelTitle: "Cancel",
cancelVariant: "outline-primary",
// data-description cannot be set for this so falling back to
// setting a class for DOM inspection.
modalClass: "sign-out-modal",
centered: true,
});
if (confirmed) {
userLogoutAll();
}
}
function toggleThemeModal() {
showThemPickerModal.value = !showThemPickerModal.value;
}
function toggleBeaconModal() {
showBeaconModal.value = !showBeaconModal.value;
}
function togglePreferredStorageModal() {
showPreferredStorageModal.value = !showPreferredStorageModal.value;
}
function toggleUserDeletion() {
showDeleteAccountModal.value = !showDeleteAccountModal.value;
}
onMounted(async () => {
const msg = QueryStringParsing.get("message");
const status = QueryStringParsing.get("status");
if (msg && status) {
message.value = msg;
messageVariant.value = status;
}
objectStoreTemplatesStore.ensureTemplates();
fileSourceTemplatesStore.ensureTemplates();
});
</script>
<template>
<div class="d-flex flex-column">
<BreadcrumbHeading :items="breadcrumbItems" />
<Heading h2 size="sm">
Manage your user preferences on this page, including email address, password, and other settings.
</Heading>
<BAlert :variant="messageVariant" :show="!!message">
{{ message }}
</BAlert>
<UserDetailsElement />
<div class="d-flex flex-gapy-1 flex-column">
<div class="d-flex flex-wrap mb-4 user-preferences-cards">
<UserPreferencesElement
v-for="(link, index) in activePreferences"
:id="link.id"
:key="index"
:icon="link.icon"
:title="link.title"
:description="link.description"
:to="`/user/${index}`" />
<UserPreferencesElement
v-if="isConfigLoaded && !config.single_user"
id="edit-preferences-permissions"
:icon="faUsers"
title="Set Dataset Permissions for New Histories"
description="Grant others default access to newly created histories. Changes made here will only affect histories created after these settings have been stored."
to="/user/permissions" />
<UserPreferencesElement
id="edit-preferences-api-key"
:icon="faKey"
title="Manage Galaxy API Key"
description="Access your current Galaxy API key or create a new one."
to="/user/api_key" />
<UserPreferencesElement
id="edit-preferences-credentials"
:icon="faKey"
title="Manage Your Tools Credentials"
description="Manage your tools credentials groups for accessing external services."
to="/user/credentials" />
<UserPreferencesElement
id="edit-preferences-notifications"
:icon="faBell"
title="Manage Notifications"
description="Manage your notification settings."
to="/user/notifications/preferences" />
<UserPreferencesElement
v-if="isConfigLoaded && config.enable_oidc && !config.fixed_delegated_auth"
id="manage-third-party-identities"
:icon="faIdCard"
title="Manage Third-Party Identities"
description="Connect or disconnect access to your third-party identities."
to="/user/external_ids" />
<UserPreferencesElement
id="edit-preferences-custom-builds"
:icon="faCubes"
title="Manage Custom Builds"
description="Add or remove custom builds using history datasets."
to="/custom_builds" />
<UserPreferencesElement
v-if="hasThemes"
id="edit-preferences-theme"
:icon="faPalette"
title="Pick a Color Theme"
description="Click here to change the user interface color theme."
@click="toggleThemeModal" />
<UserPreferencesElement
v-if="isConfigLoaded && !config.single_user"
id="edit-preferences-make-data-private"
:icon="faLock"
title="Make All Data Private"
description="Click here to make all data private."
@click="makeDataPrivate" />
<UserPreferencesElement
v-if="isConfigLoaded && config.enable_beacon_integration"
id="edit-preferences-beacon"
:icon="faBroadcastTower"
title="Manage Beacon"
description="Contribute variants to Beacon"
@click="toggleBeaconModal" />
<UserPreferencesElement
v-if="isConfigLoaded && config.object_store_allows_id_selection"
id="manage-preferred-object-store"
:icon="faHdd"
title="Manage Your Preferred Galaxy Storage"
description="Select a Preferred Galaxy storage for the outputs of new jobs."
@click="togglePreferredStorageModal" />
<UserPreferencesElement
v-if="objectStoreTemplatesStore.hasTemplates"
id="manage-object-stores"
class="manage-object-stores"
:icon="faHdd"
title="Manage Your Galaxy Storage"
description="Add, remove, or update your personally configured Galaxy storage."
to="/object_store_instances/index" />
<UserPreferencesElement
v-if="fileSourceTemplatesStore.hasTemplates"
id="manage-file-sources"
class="manage-file-sources"
:icon="faFile"
title="Manage Your Repositories"
description="Add, remove, or update your personally configured location to find files from and write files to."
to="/file_source_instances/index" />
</div>
<div class="d-flex flex-wrap mb-4 user-preferences-cards">
<UserPreferencesElement
v-if="isConfigLoaded && !config.single_user && config.enable_account_interface"
id="delete-account"
danger-zone
:icon="faRadiation"
title="Delete Account"
description="Click here to delete your account."
@click="toggleUserDeletion" />
<UserPreferencesElement
v-if="hasLogout"
id="edit-preferences-sign-out"
danger-zone
:icon="faSignOut"
title="Sign Out of All Sessions"
description="Click here to sign out of all sessions."
@click="signOut" />
</div>
<BModal
v-model="showDataPrivateModal"
title="Datasets are now private"
title-class="font-weight-bold"
ok-only>
<span v-localize>
All of your histories and datasets have been made private. If you'd like to make all *future*
histories private please use the
</span>
<a :href="userPermissionsUrl">User Permissions</a>
<span v-localize>interface</span>.
</BModal>
<UserPickTheme v-if="hasThemes && showThemPickerModal" @reset="toggleThemeModal" />
<UserBeaconSettings
v-if="isConfigLoaded && config.enable_beacon_integration && showBeaconModal"
@reset="toggleBeaconModal" />
<UserPreferredObjectStore
v-if="isConfigLoaded && config.object_store_allows_id_selection && showPreferredStorageModal"
@reset="togglePreferredStorageModal" />
<UserDeletion v-if="showDeleteAccountModal" @reset="toggleUserDeletion" />
</div>
</div>
</template>
<style scoped lang="scss">
.user-preferences-cards {
container: cards-list / inline-size;
}
</style>