-
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.
- Loading branch information
Showing
51 changed files
with
2,453 additions
and
118 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
64 changes: 64 additions & 0 deletions
64
client/src/components/History/CurrentHistory/HistorySelectPreferredObjectStore.test.js
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 |
---|---|---|
@@ -0,0 +1,64 @@ | ||
import { mount } from "@vue/test-utils"; | ||
import { getLocalVue } from "jest/helpers"; | ||
import HistorySelectPreferredObjectStore from "./HistorySelectPreferredObjectStore"; | ||
import axios from "axios"; | ||
import MockAdapter from "axios-mock-adapter"; | ||
import flushPromises from "flush-promises"; | ||
|
||
const localVue = getLocalVue(true); | ||
|
||
const TEST_ROOT = "/"; | ||
const TEST_HISTORY_ID = "myTestHistoryId"; | ||
|
||
const TEST_HISTORY = { | ||
id: TEST_HISTORY_ID, | ||
preferred_object_store_id: null, | ||
}; | ||
|
||
function mountComponent() { | ||
const wrapper = mount(HistorySelectPreferredObjectStore, { | ||
propsData: { userPreferredObjectStoreId: null, history: TEST_HISTORY, root: TEST_ROOT }, | ||
localVue, | ||
}); | ||
return wrapper; | ||
} | ||
|
||
import { ROOT_COMPONENT } from "utils/navigation"; | ||
|
||
const OBJECT_STORES = [ | ||
{ object_store_id: "object_store_1", badges: [], quota: { enabled: false } }, | ||
{ object_store_id: "object_store_2", badges: [], quota: { enabled: false } }, | ||
]; | ||
|
||
describe("HistorySelectPreferredObjectStore.vue", () => { | ||
let axiosMock; | ||
|
||
beforeEach(async () => { | ||
axiosMock = new MockAdapter(axios); | ||
axiosMock.onGet("/api/object_store?selectable=true").reply(200, OBJECT_STORES); | ||
}); | ||
|
||
afterEach(async () => { | ||
axiosMock.restore(); | ||
}); | ||
|
||
it("updates object store to default on selection null", async () => { | ||
const wrapper = mountComponent(); | ||
await flushPromises(); | ||
const els = wrapper.findAll(ROOT_COMPONENT.preferences.object_store_selection.option_buttons.selector); | ||
expect(els.length).toBe(3); | ||
const galaxyDefaultOption = wrapper.find( | ||
ROOT_COMPONENT.preferences.object_store_selection.option_button({ object_store_id: "__null__" }).selector | ||
); | ||
expect(galaxyDefaultOption.exists()).toBeTruthy(); | ||
axiosMock | ||
.onPut(`/api/histories/${TEST_HISTORY_ID}`, expect.objectContaining({ preferred_object_store_id: null })) | ||
.reply(202); | ||
await galaxyDefaultOption.trigger("click"); | ||
await flushPromises(); | ||
const errorEl = wrapper.find(".object-store-selection-error"); | ||
expect(errorEl.exists()).toBeFalsy(); | ||
const emitted = wrapper.emitted(); | ||
expect(emitted["updated"][0][0]).toEqual(null); | ||
}); | ||
}); |
79 changes: 79 additions & 0 deletions
79
client/src/components/History/CurrentHistory/HistorySelectPreferredObjectStore.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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
<template> | ||
<SelectObjectStore | ||
:root="root" | ||
:parent-error="error" | ||
: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 { errorMessageAsString } from "utils/simple-error"; | ||
export default { | ||
components: { | ||
SelectObjectStore, | ||
}, | ||
props: { | ||
userPreferredObjectStoreId: { | ||
type: String, | ||
default: null, | ||
}, | ||
history: { | ||
type: Object, | ||
required: true, | ||
}, | ||
root: { | ||
type: String, | ||
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", | ||
galaxySelectionDefalutTitle: "Use Galaxy Defaults", | ||
galaxySelectionDefalutDescription: | ||
"Selecting this will reset Galaxy to default behaviors configured by your Galaxy administrator.", | ||
userSelectionDefalutTitle: "Use Your User Preference Defaults", | ||
userSelectionDefalutDescription: | ||
"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.userSelectionDefalutTitle; | ||
} else { | ||
return this.galaxySelectionDefalutTitle; | ||
} | ||
}, | ||
defaultOptionDescription() { | ||
if (this.userPreferredObjectStoreId) { | ||
return this.userSelectionDefalutDescription; | ||
} else { | ||
return this.galaxySelectionDefalutDescription; | ||
} | ||
}, | ||
}, | ||
methods: { | ||
async handleSubmit(preferredObjectStoreId) { | ||
const payload = { preferred_object_store_id: preferredObjectStoreId }; | ||
try { | ||
await axios.put(`${this.root}api/histories/${this.history.id}`, payload); | ||
} catch (e) { | ||
this.error = errorMessageAsString(e); | ||
} | ||
this.selectedObjectStoreId = preferredObjectStoreId; | ||
this.$emit("updated", preferredObjectStoreId); | ||
}, | ||
}, | ||
}; | ||
</script> |
48 changes: 48 additions & 0 deletions
48
client/src/components/History/CurrentHistory/HistoryTargetPreferredObjectStorePopover.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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<template> | ||
<b-popover :target="`history-storage-${historyId}`" triggers="hover" placement="bottomleft"> | ||
<template v-slot:title>Preferred Target Object Store</template> | ||
<p class="history-preferred-object-store-inherited" v-if="historyPreferredObjectStoreId"> | ||
This target object store has been set at the history level. | ||
</p> | ||
<p class="history-preferred-object-store-not-inherited" v-else> | ||
This target object store has been inherited from your user preferences (set in User -> Preferences -> | ||
Preferred Object Store). If that option is updated, this history will target that new default. | ||
</p> | ||
<ShowSelectedObjectStore | ||
v-if="preferredObjectStoreId" | ||
:preferred-object-store-id="preferredObjectStoreId" | ||
for-what="Galaxy will default to storing this history's datasets in "></ShowSelectedObjectStore> | ||
<div v-localize> | ||
Change this preference object store target by clicking on the storage button in the history panel. | ||
</div> | ||
</b-popover> | ||
</template> | ||
|
||
<script> | ||
import ShowSelectedObjectStore from "components/ObjectStore/ShowSelectedObjectStore"; | ||
export default { | ||
components: { | ||
ShowSelectedObjectStore, | ||
}, | ||
props: { | ||
historyId: { | ||
type: String, | ||
required: true, | ||
}, | ||
historyPreferredObjectStoreId: { | ||
type: String, | ||
}, | ||
user: { type: Object, required: true }, | ||
}, | ||
computed: { | ||
preferredObjectStoreId() { | ||
let id = this.historyPreferredObjectStoreId; | ||
if (!id) { | ||
id = this.user.preferred_object_store_id; | ||
} | ||
return id; | ||
}, | ||
}, | ||
}; | ||
</script> |
Oops, something went wrong.