Skip to content

Commit

Permalink
Cleanup object store selection client.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmchilton committed Feb 21, 2023
1 parent 1e926d1 commit 3742d6e
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 61 deletions.
17 changes: 7 additions & 10 deletions client/src/components/History/CurrentHistory/HistoryCounter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
@click="showPreferredObjectStoreModal = true">
<icon icon="hdd" />
</b-button>
<HistoryTargetPreferredObjectStorePopover
<PreferredStorePopover
:history-id="history.id"
:history-preferred-object-store-id="historyPreferredObjectStoreId"
:user="user">
</HistoryTargetPreferredObjectStorePopover>
</PreferredStorePopover>
<b-button-group>
<b-button
v-b-tooltip.hover
Expand Down Expand Up @@ -75,10 +75,9 @@
title-tag="h3"
size="sm"
hide-footer>
<HistorySelectPreferredObjectStore
<SelectPreferredStore
:user-preferred-object-store-id="user.preferred_object_store_id"
:history="history"
:root="root"
@updated="onUpdatePreferredObjectStoreId" />
</b-modal>
</b-button-group>
Expand All @@ -91,15 +90,14 @@ import prettyBytes from "pretty-bytes";
import { formatDistanceToNowStrict } from "date-fns";
import { usesDetailedHistoryMixin } from "./usesDetailedHistoryMixin.js";
import CurrentUser from "components/providers/CurrentUser";
import HistoryTargetPreferredObjectStorePopover from "./HistoryTargetPreferredObjectStorePopover";
import HistorySelectPreferredObjectStore from "./HistorySelectPreferredObjectStore";
import { getAppRoot } from "onload/loadConfig";
import PreferredStorePopover from "./PreferredStorePopover";
import SelectPreferredStore from "./SelectPreferredStore";
export default {
components: {
CurrentUser,
HistoryTargetPreferredObjectStorePopover,
HistorySelectPreferredObjectStore,
PreferredStorePopover,
SelectPreferredStore,
},
filters: {
niceFileSize(rawSize = 0) {
Expand All @@ -119,7 +117,6 @@ export default {
reloadButtonVariant: "link",
showPreferredObjectStoreModal: false,
historyPreferredObjectStoreId: this.history.preferred_object_store_id,
root: getAppRoot(),
};
},
mounted() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default {
},
historyPreferredObjectStoreId: {
type: String,
default: null,
},
user: { type: Object, required: true },
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { mount } from "@vue/test-utils";
import { getLocalVue } from "tests/jest/helpers";
import HistorySelectPreferredObjectStore from "./HistorySelectPreferredObjectStore";
import SelectPreferredStore from "./SelectPreferredStore";
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 = {
Expand All @@ -16,8 +15,8 @@ const TEST_HISTORY = {
};

function mountComponent() {
const wrapper = mount(HistorySelectPreferredObjectStore, {
propsData: { userPreferredObjectStoreId: null, history: TEST_HISTORY, root: TEST_ROOT },
const wrapper = mount(SelectPreferredStore, {
propsData: { userPreferredObjectStoreId: null, history: TEST_HISTORY },
localVue,
});
return wrapper;
Expand All @@ -30,7 +29,7 @@ const OBJECT_STORES = [
{ object_store_id: "object_store_2", badges: [], quota: { enabled: false } },
];

describe("HistorySelectPreferredObjectStore.vue", () => {
describe("SelectPreferredStore.vue", () => {
let axiosMock;

beforeEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<template>
<SelectObjectStore
:root="root"
:parent-error="error"
:for-what="newDatasetsDescription"
:selected-object-store-id="selectedObjectStoreId"
Expand All @@ -12,6 +11,7 @@
<script>
import axios from "axios";
import SelectObjectStore from "components/ObjectStore/SelectObjectStore";
import { prependPath } from "utils/redirect";
import { errorMessageAsString } from "utils/simple-error";
export default {
Expand All @@ -27,10 +27,6 @@ export default {
type: Object,
required: true,
},
root: {
type: String,
required: true,
},
},
data() {
const selectedObjectStoreId = this.history.preferred_object_store_id;
Expand Down Expand Up @@ -66,8 +62,9 @@ export default {
methods: {
async handleSubmit(preferredObjectStoreId) {
const payload = { preferred_object_store_id: preferredObjectStoreId };
const url = prependPath(`api/histories/${this.history.id}`);
try {
await axios.put(`${this.root}api/histories/${this.history.id}`, payload);
await axios.put(url, payload);
} catch (e) {
this.error = errorMessageAsString(e);
}
Expand Down
10 changes: 4 additions & 6 deletions client/src/components/ObjectStore/SelectObjectStore.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@click="handleSubmit(object_store.object_store_id)"
>{{ object_store.name }}
<ObjectStoreBadges :badges="object_store.badges" size="lg" :more-on-hover="false" />
<ProvidedQuotaSourceUsageBar :objectStore="object_store" :compact="true">
<ProvidedQuotaSourceUsageBar :object-store="object_store" :compact="true">
</ProvidedQuotaSourceUsageBar>
</b-button>
</b-button-group>
Expand Down Expand Up @@ -58,6 +58,7 @@

<script>
import axios from "axios";
import { prependPath } from "utils/redirect";
import LoadingSpan from "components/LoadingSpan";
import DescribeObjectStore from "components/ObjectStore/DescribeObjectStore";
import { errorMessageAsString } from "utils/simple-error";
Expand All @@ -72,10 +73,6 @@ export default {
ProvidedQuotaSourceUsageBar,
},
props: {
root: {
type: String,
required: true,
},
selectedObjectStoreId: {
type: String,
default: null,
Expand Down Expand Up @@ -125,8 +122,9 @@ is not stored in the correct place, contact your Galaxy adminstrator for more in
},
},
async mounted() {
const url = prependPath("api/object_store?selectable=true");
try {
const { data } = await axios.get(`${this.root}api/object_store?selectable=true`);
const { data } = await axios.get(url);
this.objectStores = data;
this.loading = false;
} catch (e) {
Expand Down
6 changes: 0 additions & 6 deletions client/src/components/User/UserPreferences.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@
<UserPreferredObjectStore
v-if="config && config.object_store_allows_id_selection"
:preferred-object-store-id="user.preferred_object_store_id"
:root="root"
:user-id="userId">
</UserPreferredObjectStore>
</CurrentUser>
Expand Down Expand Up @@ -131,8 +130,6 @@ import UserDeletion from "./UserDeletion";
import UserPreferencesElement from "./UserPreferencesElement";
import UserPreferredObjectStore from "./UserPreferredObjectStore";
import { getAppRoot } from "onload/loadConfig";
import "@fortawesome/fontawesome-svg-core";
import UserBeaconSettings from "./UserBeaconSettings";
Expand Down Expand Up @@ -182,9 +179,6 @@ export default {
const themes = Object.keys(Galaxy.config.themes);
return themes?.length > 1 ?? false;
},
root() {
return getAppRoot();
},
},
created() {
const message = QueryStringParsing.get("message");
Expand Down
3 changes: 1 addition & 2 deletions client/src/components/User/UserPreferredObjectStore.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import flushPromises from "flush-promises";
const localVue = getLocalVue(true);

const TEST_USER_ID = "myTestUserId";
const TEST_ROOT = "/";

function mountComponent() {
const wrapper = mount(UserPreferredObjectStore, {
propsData: { userId: TEST_USER_ID, root: TEST_ROOT },
propsData: { userId: TEST_USER_ID },
localVue,
stubs: { "b-popover": true },
});
Expand Down
17 changes: 7 additions & 10 deletions client/src/components/User/UserPreferredObjectStore.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
@show="resetModal"
@hidden="resetModal">
<SelectObjectStore
:root="root"
:parent-error="error"
:for-what="newDatasetsDescription"
:selected-object-store-id="selectedObjectStoreId"
:default-option-title="galaxySelectionDefalutTitle"
:default-option-description="galaxySelectionDefalutDescription"
:default-option-title="galaxySelectionDefaultTitle"
:default-option-description="galaxySelectionDefaultDescription"
@onSubmit="handleSubmit" />
</b-modal>
</div>
Expand All @@ -38,6 +37,7 @@

<script>
import axios from "axios";
import { prependPath } from "utils/redirect";
import Vue from "vue";
import { BModal, BRow, VBModal } from "bootstrap-vue";
import SelectObjectStore from "components/ObjectStore/SelectObjectStore";
Expand All @@ -52,10 +52,6 @@ export default {
SelectObjectStore,
},
props: {
root: {
type: String,
required: true,
},
userId: {
type: String,
required: true,
Expand All @@ -74,17 +70,18 @@ export default {
modalSize: "sm",
showModal: false,
selectedObjectStoreId: this.preferredObjectStoreId,
galaxySelectionDefalutTitle: "Use Galaxy Defaults",
galaxySelectionDefalutDescription:
galaxySelectionDefaultTitle: "Use Galaxy Defaults",
galaxySelectionDefaultDescription:
"Selecting this will reset Galaxy to default behaviors configured by your Galaxy administrator.",
};
},
methods: {
resetModal() {},
async handleSubmit(preferredObjectStoreId) {
const payload = { preferred_object_store_id: preferredObjectStoreId };
const url = prependPath("api/users/current");
try {
await axios.put(`${this.root}api/users/current`, payload);
await axios.put(url, payload);
} catch (e) {
this.error = errorMessageAsString(e);
}
Expand Down
3 changes: 0 additions & 3 deletions client/src/components/Workflow/Run/WorkflowRunFormSimple.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
<WorkflowStorageConfiguration
v-if="config.object_store_allows_id_selection"
:split-object-store="splitObjectStore"
:root="root"
:invocation-preferred-object-store-id="preferredObjectStoreId"
:invocation-intermediate-preferred-object-store-id="preferredIntermediateObjectStoreId"
@updated="onStorageUpdate">
Expand Down Expand Up @@ -60,7 +59,6 @@ import { isWorkflowInput } from "components/Workflow/constants";
import { errorMessageAsString } from "utils/simple-error";
import { allowCachedJobs } from "components/Tool/utilities";
import WorkflowStorageConfiguration from "./WorkflowStorageConfiguration";
import { getAppRoot } from "onload/loadConfig";
export default {
components: {
Expand All @@ -87,7 +85,6 @@ export default {
data() {
const newHistory = this.targetHistory == "new" || this.targetHistory == "prefer_new";
return {
root: getAppRoot(),
formData: {},
inputTypes: {},
sendToNewHistory: newHistory,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<template>
<SelectObjectStore
:root="root"
:for-what="newDatasetsDescription"
:selected-object-store-id="selectedObjectStoreId"
:default-option-title="defaultOptionTitle"
Expand All @@ -15,10 +14,6 @@ export default {
SelectObjectStore,
},
props: {
root: {
type: String,
required: true,
},
invocationPreferredObjectStoreId: {
type: String,
default: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ describe("WorkflowStorageConfiguration.vue", () => {

async function doMount(split) {
const propsData = {
root: "/root/",
splitObjectStore: split,
invocationPreferredObjectStoreId: null,
invocationPreferredIntermediateObjectStoreId: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
hide-footer>
<WorkflowSelectPreferredObjectStore
:invocation-preferred-object-store-id="selectedObjectStoreId"
:root="root"
@updated="onUpdate" />
</b-modal>
<b-button
Expand All @@ -42,7 +41,6 @@
hide-footer>
<WorkflowSelectPreferredObjectStore
:invocation-preferred-object-store-id="selectedIntermediateObjectStoreId"
:root="root"
@updated="onUpdateIntermediate" />
</b-modal>
</span>
Expand All @@ -58,10 +56,6 @@ export default {
WorkflowTargetPreferredObjectStorePopover,
},
props: {
root: {
type: String,
required: true,
},
splitObjectStore: {
type: Boolean,
required: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<ShowSelectedObjectStore
v-if="invocationPreferredObjectStoreId"
:preferred-object-store-id="invocationPreferredObjectStoreId"
forWhat="Galaxy will default to storing this tool run's output in">
for-what="Galaxy will default to storing this tool run's output in">
</ShowSelectedObjectStore>
<div v-else>
No selection has been made for this worklfow invocation. Defaults from history, user, or Galaxy will be
Expand Down

0 comments on commit 3742d6e

Please sign in to comment.