diff --git a/client/src/components/History/CurrentHistory/SelectPreferredStore.vue b/client/src/components/History/CurrentHistory/SelectPreferredStore.vue
index 9d253ef03201..6c0511bce91d 100644
--- a/client/src/components/History/CurrentHistory/SelectPreferredStore.vue
+++ b/client/src/components/History/CurrentHistory/SelectPreferredStore.vue
@@ -6,6 +6,7 @@ import { prependPath } from "@/utils/redirect";
import { errorMessageAsString } from "@/utils/simple-error";
import SelectObjectStore from "@/components/ObjectStore/SelectObjectStore.vue";
+import { getPermissions, type PermissionsResponse, isHistoryPrivate, makePrivate } from "@/components/History/services";
const props = defineProps({
userPreferredObjectStoreId: {
@@ -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..440d4862bfbd 100644
--- a/client/src/components/History/HistoryDatasetPermissions.vue
+++ b/client/src/components/History/HistoryDatasetPermissions.vue
@@ -1,11 +1,10 @@
@@ -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] };
});