From c1b7f65387926b3bbda42e5916540941a2004924 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Mon, 18 Mar 2024 16:05:21 -0400 Subject: [PATCH 1/2] Prompt user to change default history permissions... ... if picking a private object store for that history. --- .../CurrentHistory/SelectPreferredStore.vue | 22 ++++++++++- .../History/HistoryDatasetPermissions.vue | 10 ++--- client/src/components/History/services.ts | 38 +++++++++++++++++++ .../ObjectStore/SelectObjectStore.vue | 11 ++++-- client/src/composables/datasetPermissions.ts | 11 ++++-- 5 files changed, 79 insertions(+), 13 deletions(-) diff --git a/client/src/components/History/CurrentHistory/SelectPreferredStore.vue b/client/src/components/History/CurrentHistory/SelectPreferredStore.vue index 9d253ef03201..2386f1048e1a 100644 --- a/client/src/components/History/CurrentHistory/SelectPreferredStore.vue +++ b/client/src/components/History/CurrentHistory/SelectPreferredStore.vue @@ -2,6 +2,7 @@ import axios from "axios"; import { computed, ref } from "vue"; +import { getPermissions, isHistoryPrivate, makePrivate, type PermissionsResponse } from "@/components/History/services"; import { prependPath } from "@/utils/redirect"; import { errorMessageAsString } from "@/utils/simple-error"; @@ -48,7 +49,26 @@ const emit = defineEmits<{ (e: "updated", id: string | null): void; }>(); -async function handleSubmit(preferredObjectStoreId: string | null) { +async function handleSubmit(preferredObjectStoreId: string | null, isPrivate: boolean) { + if (isPrivate) { + const { data } = await getPermissions(props.history.id); + const permissionResponse = data as PermissionsResponse; + const historyPrivate = await isHistoryPrivate(permissionResponse); + if (!historyPrivate) { + if ( + confirm( + "Your history is set to create sharable datasets, but the target object store is private? Change the history configuration so new datasets are private by default?" + ) + ) { + try { + await makePrivate(props.history.id, permissionResponse); + } catch { + error.value = "Failed to update default permissions for history."; + } + } + } + } + const payload = { preferred_object_store_id: preferredObjectStoreId }; const url = prependPath(`api/histories/${props.history.id}`); try { diff --git a/client/src/components/History/HistoryDatasetPermissions.vue b/client/src/components/History/HistoryDatasetPermissions.vue index 34be5cb1f9bf..a16403068b2f 100644 --- a/client/src/components/History/HistoryDatasetPermissions.vue +++ b/client/src/components/History/HistoryDatasetPermissions.vue @@ -1,9 +1,9 @@ @@ -81,7 +84,7 @@ async function handleSubmit(preferredObjectStoreId: string) { :object-store="objectStore" :variant="variant(objectStore.object_store_id)" class="preferred-object-store-select-button" - @click="handleSubmit(objectStore.object_store_id)" /> + @click="handleSubmit(objectStore)" /> diff --git a/client/src/composables/datasetPermissions.ts b/client/src/composables/datasetPermissions.ts index 60139a598107..5b5ae3057612 100644 --- a/client/src/composables/datasetPermissions.ts +++ b/client/src/composables/datasetPermissions.ts @@ -10,7 +10,7 @@ interface InputOption { roleValue: number; } -interface Input { +export interface Input { value: number[]; options: [string, number][]; } @@ -46,6 +46,12 @@ export function initRefs() { }; } +export function permissionInputParts(inputs: Input[]) { + const manageInput: Input = inputs[0] as Input; + const accessInput: Input = inputs[1] as Input; + return { manageInput, accessInput }; +} + export function updateRefs( inputs: Input[], managePermissionsOptions: Ref, @@ -53,8 +59,7 @@ export function updateRefs( managePermissions: Ref, accessPermissions: Ref ) { - const manageInput: Input = inputs[0] as Input; - const accessInput: Input = inputs[1] as Input; + const { manageInput, accessInput } = permissionInputParts(inputs); managePermissionsOptions.value = manageInput.options.map((v: [string, number]) => { return { roleName: v[0], roleValue: v[1] }; }); From c2bd0d66f7d1c11af35bdb5388912e4502b93ac6 Mon Sep 17 00:00:00 2001 From: John Chilton Date: Tue, 19 Mar 2024 15:32:20 -0400 Subject: [PATCH 2/2] Update client/src/components/History/CurrentHistory/SelectPreferredStore.vue Co-authored-by: Dannon --- .../components/History/CurrentHistory/SelectPreferredStore.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/src/components/History/CurrentHistory/SelectPreferredStore.vue b/client/src/components/History/CurrentHistory/SelectPreferredStore.vue index 2386f1048e1a..c284718a162b 100644 --- a/client/src/components/History/CurrentHistory/SelectPreferredStore.vue +++ b/client/src/components/History/CurrentHistory/SelectPreferredStore.vue @@ -57,7 +57,7 @@ async function handleSubmit(preferredObjectStoreId: string | null, isPrivate: bo if (!historyPrivate) { if ( confirm( - "Your history is set to create sharable datasets, but the target object store is private? Change the history configuration so new datasets are private by default?" + "Your history is set to create sharable datasets, but the target storage location is private. Change the history configuration so new datasets are private by default?" ) ) { try {