-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15783 from jmchilton/object_store_ui_followup_2
Convert more of the object store selection client to TypeScript.
- Loading branch information
Showing
23 changed files
with
495 additions
and
375 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 61 additions & 68 deletions
129
client/src/components/History/CurrentHistory/SelectPreferredStore.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,69 @@ | ||
<script lang="ts" setup> | ||
import { computed, ref } from "vue"; | ||
import axios from "axios"; | ||
import SelectObjectStore from "@/components/ObjectStore/SelectObjectStore.vue"; | ||
import { prependPath } from "@/utils/redirect"; | ||
import { errorMessageAsString } from "@/utils/simple-error"; | ||
const props = defineProps({ | ||
userPreferredObjectStoreId: { | ||
type: String, | ||
default: null, | ||
}, | ||
history: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}); | ||
const error = ref<string | null>(null); | ||
const selectedObjectStoreId = ref(props.history.preferred_object_store_id); | ||
const newDatasetsDescription = "New dataset outputs from tools and workflows executed in this history"; | ||
const galaxySelectionDefaultTitle = "Use Galaxy Defaults"; | ||
const galaxySelectionDefaultDescription = | ||
"Selecting this will reset Galaxy to default behaviors configured by your Galaxy administrator."; | ||
const userSelectionDefaultTitle = "Use Your User Preference Defaults"; | ||
const userSelectionDefaultDescription = | ||
"Selecting this will cause the history to not set a default and to fallback to your user preference defined default."; | ||
const defaultOptionTitle = computed(() => { | ||
if (props.userPreferredObjectStoreId) { | ||
return userSelectionDefaultTitle; | ||
} else { | ||
return galaxySelectionDefaultTitle; | ||
} | ||
}); | ||
const defaultOptionDescription = computed(() => { | ||
if (props.userPreferredObjectStoreId) { | ||
return userSelectionDefaultDescription; | ||
} else { | ||
return galaxySelectionDefaultDescription; | ||
} | ||
}); | ||
const emit = defineEmits<{ | ||
(e: "updated", id: string | null): void; | ||
}>(); | ||
async function handleSubmit(preferredObjectStoreId: string | null) { | ||
const payload = { preferred_object_store_id: preferredObjectStoreId }; | ||
const url = prependPath(`api/histories/${props.history.id}`); | ||
try { | ||
await axios.put(url, payload); | ||
} catch (e) { | ||
error.value = errorMessageAsString(e); | ||
} | ||
selectedObjectStoreId.value = preferredObjectStoreId; | ||
emit("updated", preferredObjectStoreId); | ||
} | ||
</script> | ||
<template> | ||
<SelectObjectStore | ||
:parent-error="error" | ||
:parent-error="error || undefined" | ||
:for-what="newDatasetsDescription" | ||
:selected-object-store-id="selectedObjectStoreId" | ||
:default-option-title="defaultOptionTitle" | ||
:default-option-description="defaultOptionDescription" | ||
@onSubmit="handleSubmit" /> | ||
</template> | ||
|
||
<script> | ||
import axios from "axios"; | ||
import SelectObjectStore from "components/ObjectStore/SelectObjectStore"; | ||
import { prependPath } from "utils/redirect"; | ||
import { errorMessageAsString } from "utils/simple-error"; | ||
export default { | ||
components: { | ||
SelectObjectStore, | ||
}, | ||
props: { | ||
userPreferredObjectStoreId: { | ||
type: String, | ||
default: null, | ||
}, | ||
history: { | ||
type: Object, | ||
required: true, | ||
}, | ||
}, | ||
data() { | ||
const selectedObjectStoreId = this.history.preferred_object_store_id; | ||
return { | ||
error: null, | ||
selectedObjectStoreId: selectedObjectStoreId, | ||
newDatasetsDescription: "New dataset outputs from tools and workflows executed in this history", | ||
popoverPlacement: "left", | ||
galaxySelectionDefaultTitle: "Use Galaxy Defaults", | ||
galaxySelectionDefaultDescription: | ||
"Selecting this will reset Galaxy to default behaviors configured by your Galaxy administrator.", | ||
userSelectionDefaultTitle: "Use Your User Preference Defaults", | ||
userSelectionDefaultDescription: | ||
"Selecting this will cause the history to not set a default and to fallback to your user preference defined default.", | ||
}; | ||
}, | ||
computed: { | ||
defaultOptionTitle() { | ||
if (this.userPreferredObjectStoreId) { | ||
return this.userSelectionDefaultTitle; | ||
} else { | ||
return this.galaxySelectionDefaultTitle; | ||
} | ||
}, | ||
defaultOptionDescription() { | ||
if (this.userPreferredObjectStoreId) { | ||
return this.userSelectionDefaultDescription; | ||
} else { | ||
return this.galaxySelectionDefaultDescription; | ||
} | ||
}, | ||
}, | ||
methods: { | ||
async handleSubmit(preferredObjectStoreId) { | ||
const payload = { preferred_object_store_id: preferredObjectStoreId }; | ||
const url = prependPath(`api/histories/${this.history.id}`); | ||
try { | ||
await axios.put(url, payload); | ||
} catch (e) { | ||
this.error = errorMessageAsString(e); | ||
} | ||
this.selectedObjectStoreId = preferredObjectStoreId; | ||
this.$emit("updated", preferredObjectStoreId); | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.