Skip to content

Commit

Permalink
Drop all Vue.set usage for vue3
Browse files Browse the repository at this point in the history
  • Loading branch information
dannon committed Oct 23, 2023
1 parent 2610671 commit d3c5506
Show file tree
Hide file tree
Showing 24 changed files with 47 additions and 53 deletions.
2 changes: 1 addition & 1 deletion client/src/components/DataDialog/DataDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export default {
if (item.isLeaf) {
_rowVariant = this.model.exists(item.id) ? "success" : "default";
}
Vue.set(item, "_rowVariant", _rowVariant);
item._rowVariant = _rowVariant;
}
},
/** Collects selected datasets in value array **/
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/FilesDialog/FilesDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function formatRows() {
else if (!item.isLeaf) {
_rowVariant = getIcon(isDirectorySelected(item.id), item.url);
}
Vue.set(item, "_rowVariant", _rowVariant);
item._rowVariant = _rowVariant;
}
allSelected.value = checkIfAllSelected();
if (currentDirectory.value?.url) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Form/FormDisplay.vue
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export default {
onCloneInputs() {
this.formInputs = JSON.parse(JSON.stringify(this.inputs));
visitInputs(this.formInputs, (input) => {
Vue.set(input, "error", null);
input.error = null;
});
this.onCreateIndex();
},
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/History/Content/GenericElement.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const expandCollections = ref({});
const expandDatasets = ref({});
function toggle(expansionMap: Record<string, boolean>, itemId: string) {
Vue.set(expansionMap, itemId, !expansionMap[itemId]);
expansionMap[itemId] = !expansionMap[itemId];
}
</script>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ export default {
rewatchHistory();
},
setInvisible(item) {
Vue.set(this.invisible, item.hid, true);
this.invisible[item.hid] = true;
},
onTagChange(item, newTags) {
item.tags = newTags;
Expand Down
5 changes: 2 additions & 3 deletions client/src/components/RuleBuilder/ColumnSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<script>
import Select2 from "components/Select2";
import _l from "utils/localization";
import Vue from "vue";
export default {
components: {
Expand Down Expand Up @@ -130,8 +129,8 @@ export default {
},
moveUp(value) {
const swapVal = this.target[value - 1];
Vue.set(this.target, value - 1, this.target[value]);
Vue.set(this.target, value, swapVal);
this.target[value - 1] = this.target[value];
this.target[value] = swapVal;
},
},
};
Expand Down
8 changes: 4 additions & 4 deletions client/src/components/ToolsList/ToolsListTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,12 @@ export default {
async fetchHelp(tool) {
await fetchData(`api/tools/${tool.id}/build`).then((response) => {
const help = response.help;
Vue.set(tool, "_showDetails", false); // maybe not needed
tool._showDetails = false; // maybe not needed
if (help && help != "\n") {
Vue.set(tool, "help", help);
Vue.set(tool, "summary", this.parseHelp(help));
tool.help = help;
tool.summary = this.parseHelp(help);
} else {
Vue.set(tool, "help", ""); // for cases where helpText == '\n'
tool.help = ""; // for cases where helpText == '\n'
}
});
},
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Upload/CompositeBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function inputExtension(newExtension) {
description: item.description || item.name,
optional: item.optional,
};
Vue.set(uploadItems.value, index, uploadModel);
uploadItems.value[index] = uploadModel;
});
}
restoreStatus();
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Upload/DefaultBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function eventAnnounce(index, file) {
fileSize: file.size,
fileUri: file.uri,
};
Vue.set(uploadItems.value, index, uploadModel);
uploadItems.value[index] = uploadModel;
}
/** Populates collection builder with uploaded files */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ function convertUTCtoLocal(utcTimeString: string) {
function addActionLink() {
if (!broadcastData.value.content.action_links) {
Vue.set(broadcastData.value.content, "action_links", []);
broadcastData.value.content.action_links = [];
}
broadcastData.value.content.action_links?.push({
Expand Down
3 changes: 1 addition & 2 deletions client/src/store/datasetExtFilesStore.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import axios from "axios";
import { getAppRoot } from "onload/loadConfig";
import Vue from "vue";

export const state = {
datasetExtFilesById: {},
Expand All @@ -23,7 +22,7 @@ const actions = {

const mutations = {
saveDatasetExtFiles: (state, { history_dataset_id, datasetExtFiles }) => {
Vue.set(state.datasetExtFilesById, history_dataset_id, datasetExtFiles);
state.datasetExtFilesById[history_dataset_id] = datasetExtFiles;
},
};

Expand Down
6 changes: 2 additions & 4 deletions client/src/store/historyStore/model/utilities.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import Vue from "vue";

/* This function merges the existing data with new incoming data. */
export function mergeArray(id, payload, items, itemKey) {
if (!items[id]) {
Vue.set(items, id, []);
items[id] = [];
}
const itemArray = items[id];
for (const item of payload) {
Expand All @@ -16,7 +14,7 @@ export function mergeArray(id, payload, items, itemKey) {
});
}
} else {
Vue.set(itemArray, itemIndex, item);
itemArray[itemIndex] = item;
}
}
}
6 changes: 3 additions & 3 deletions client/src/store/invocationStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ const actions = {

const mutations = {
saveInvocationForId: (state, { invocationId, invocationData }) => {
Vue.set(state.invocationDetailsById, invocationId, invocationData);
state.invocationDetailsById[invocationId] = invocationData;
},
saveInvocationJobsSummaryForId: (state, { invocationId, jobsSummary }) => {
Vue.set(state.invocationJobsSummaryById, invocationId, jobsSummary);
state.invocationJobsSummaryById[invocationId] = jobsSummary;
},
saveInvocationStepById: (state, { invocationStepId, invocationStepData }) => {
Vue.set(state.invocationStepById, invocationStepId, invocationStepData);
state.invocationStepById[invocationStepId] = invocationStepData;
},
};

Expand Down
2 changes: 1 addition & 1 deletion client/src/store/jobDestinationParametersStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const actions = {

const mutations = {
saveJobDestinationParamsForJobId: (state, { jobId, jobDestinationParams }) => {
Vue.set(state.jobDestinationParametersByJobId, jobId, jobDestinationParams);
state.jobDestinationParametersByJobId[jobId] = jobDestinationParams;
},
};

Expand Down
2 changes: 1 addition & 1 deletion client/src/stores/broadcastsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const useBroadcastsStore = defineStore("broadcastsStore", () => {
}

function dismissBroadcast(broadcast: BroadcastNotification) {
Vue.set(dismissedBroadcasts.value, broadcast.id, { expiration_time: broadcast.expiration_time });
dismissedBroadcasts.value[broadcast.id] = { expiration_time: broadcast.expiration_time };
}

function hasExpired(expirationTimeStr?: string) {
Expand Down
8 changes: 4 additions & 4 deletions client/src/stores/datasetStore.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineStore } from "pinia";
import Vue, { computed, ref } from "vue";
import { computed, ref } from "vue";

import { DatasetDetails, DatasetEntry, HistoryContentItemBase } from "./services";
import { fetchDatasetDetails } from "./services/dataset.service";
Expand All @@ -25,10 +25,10 @@ export const useDatasetStore = defineStore("datasetStore", () => {
});

async function fetchDataset(params: { id: string }) {
Vue.set(loadingDatasets.value, params.id, true);
loadingDatasets.value[params.id] = true;
try {
const dataset = await fetchDatasetDetails(params);
Vue.set(storedDatasets.value, dataset.id, dataset);
storedDatasets.value[dataset.id] = dataset;
return dataset;
} finally {
delete loadingDatasets.value[params.id];
Expand All @@ -40,7 +40,7 @@ export const useDatasetStore = defineStore("datasetStore", () => {
(entry) => entry.history_content_type === "dataset"
) as DatasetEntry[];
for (const dataset of datasetList) {
Vue.set(storedDatasets.value, dataset.id, dataset);
storedDatasets.value[dataset.id] = dataset;
}
}

Expand Down
2 changes: 1 addition & 1 deletion client/src/stores/history/historyItemsStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const useHistoryItemsStore = defineStore("historyItemsStore", {
if (relatedHid) {
payload.forEach((item) => {
const relationKey = `${historyId}-${relatedHid}-${item.hid}`;
Vue.set(state.relatedItems, relationKey, true);
state.relatedItems[relationKey] = true;
});
}
});
Expand Down
4 changes: 2 additions & 2 deletions client/src/stores/historyStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ export const useHistoryStore = defineStore("historyStore", () => {
}

function setFilterText(historyId: string, filterText: string) {
Vue.set(storedFilterTexts.value, historyId, filterText);
storedFilterTexts.value[historyId] = filterText;
}

function setHistory(history: HistorySummary) {
Vue.set(storedHistories.value, history.id, history);
storedHistories.value[history.id] = history;
}

function setHistories(histories: HistorySummary[]) {
Expand Down
4 changes: 2 additions & 2 deletions client/src/stores/jobMetricsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const useJobMetricsStore = defineStore("jobMetricsStore", () => {
const jobMetrics = (await axios.get<JobMetric[]>(path)).data;
const jobMetricsObject = datasetType == "hda" ? jobMetricsByHdaId : jobMetricsByLddaId;

Vue.set(jobMetricsObject.value, datasetId, jobMetrics);
jobMetricsObject.value[datasetId] = jobMetrics;
}

async function fetchJobMetricsForJobId(jobId: string) {
Expand All @@ -50,7 +50,7 @@ export const useJobMetricsStore = defineStore("jobMetricsStore", () => {
const path = prependPath(`api/jobs/${jobId}/metrics`);
const jobMetrics = (await axios.get<JobMetric[]>(path)).data;

Vue.set(jobMetricsByJobId.value, jobId, jobMetrics);
jobMetricsByJobId.value[jobId] = jobMetrics;
}

return {
Expand Down
2 changes: 1 addition & 1 deletion client/src/stores/jobStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const useJobStore = defineStore("jobStore", {
},
// Setters
saveJobForJobId(jobId: string, job: Job) {
Vue.set(this.jobs, jobId, job);
this.jobs[jobId] = job;
},
saveLatestResponse(response: ResponseVal) {
this.response = response;
Expand Down
6 changes: 3 additions & 3 deletions client/src/stores/toolStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,19 @@ export const useToolStore = defineStore("toolStore", () => {
}

function saveToolForId(toolId: string, toolData: Tool) {
Vue.set(toolsById.value, toolId, toolData);
toolsById.value[toolId] = toolData;
}

function saveToolResults(whooshQuery: string, toolsData: Array<string>) {
Vue.set(toolResults.value, whooshQuery, toolsData);
toolResults.value[whooshQuery] = toolsData;
}

function saveAllTools(toolsData: Record<string, Tool>) {
toolsById.value = toolsData;
}

function savePanelView(panelView: string, newPanel: { [id: string]: ToolSection | Tool }) {
Vue.set(panel.value, panelView, newPanel);
panel.value[panelView] = newPanel;
}

return {
Expand Down
2 changes: 1 addition & 1 deletion client/src/stores/workflowConnectionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const useConnectionStore = (workflowId: string) => {
this.stepToConnections = updateStepToConnections(this.connections);
},
markInvalidConnection(this: State, connectionId: string, reason: string) {
Vue.set(this.invalidConnections, connectionId, reason);
this.invalidConnections[connectionId] = reason;
},
dropFromInvalidConnections(this: State, connectionId: string) {
delete this.invalidConnections[connectionId];
Expand Down
14 changes: 6 additions & 8 deletions client/src/stores/workflowEditorStateStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,15 @@ export const useWorkflowStateStore = (workflowId: string) => {
actions: {
setInputTerminalPosition(stepId: number, inputName: string, position: InputTerminalPosition) {
if (!this.inputTerminals[stepId]) {
Vue.set(this.inputTerminals, stepId, {});
this.inputTerminals[stepId] = {};
}

Vue.set(this.inputTerminals[stepId]!, inputName, position);
this.inputTerminals[stepId]![inputName] = position;
},
setOutputTerminalPosition(stepId: number, outputName: string, position: OutputTerminalPosition) {
if (!this.outputTerminals[stepId]) {
Vue.set(this.outputTerminals, stepId, reactive({}));
this.outputTerminals[stepId] = reactive({});
}

Vue.set(this.outputTerminals[stepId]!, outputName, position);
this.outputTerminals[stepId]![outputName] = position;
},
deleteInputTerminalPosition(stepId: number, inputName: string) {
delete this.inputTerminals[stepId]?.[inputName];
Expand All @@ -88,13 +86,13 @@ export const useWorkflowStateStore = (workflowId: string) => {
this.scale = scale;
},
setStepPosition(stepId: number, position: UnwrapRef<UseElementBoundingReturn>) {
Vue.set(this.stepPosition, stepId, position);
this.stepPosition[stepId] = position;
},
deleteStepPosition(stepId: number) {
delete this.stepPosition[stepId];
},
setLoadingState(stepId: number, loading: boolean, error: string | undefined) {
Vue.set(this.stepLoadingState, stepId, { loading, error });
this.stepLoadingState[stepId] = { loading, error };
},
},
})();
Expand Down
10 changes: 5 additions & 5 deletions client/src/stores/workflowStepStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ export const useWorkflowStepStore = (workflowId: string) => {
addStep(newStep: NewStep): Step {
const stepId = newStep.id ? newStep.id : this.getStepIndex + 1;
const step = Object.freeze({ ...newStep, id: stepId } as Step);
Vue.set(this.steps, stepId.toString(), step);
this.steps[stepId.toString()] = step;
const connectionStore = useConnectionStore(workflowId);
stepToConnections(step).map((connection) => connectionStore.addConnection(connection));
this.stepExtraInputs[step.id] = getStepExtraInputs(step);
Expand Down Expand Up @@ -239,16 +239,16 @@ export const useWorkflowStepStore = (workflowId: string) => {
this.stepExtraInputs[step.id] = getStepExtraInputs(step);
},
changeStepMapOver(stepId: number, mapOver: CollectionTypeDescriptor) {
Vue.set(this.stepMapOver, stepId, mapOver);
this.stepMapOver[stepId] = mapOver;
},
resetStepInputMapOver(stepId: number) {
Vue.set(this.stepInputMapOver, stepId, {});
this.stepInputMapOver[stepId] = {};
},
changeStepInputMapOver(stepId: number, inputName: string, mapOver: CollectionTypeDescriptor) {
if (this.stepInputMapOver[stepId]) {
Vue.set(this.stepInputMapOver[stepId]!, inputName, mapOver);
this.stepInputMapOver[stepId]![inputName] = mapOver;
} else {
Vue.set(this.stepInputMapOver, stepId, { [inputName]: mapOver });
this.stepInputMapOver[stepId] = { [inputName]: mapOver };
}
},
addConnection(connection: Connection) {
Expand Down

0 comments on commit d3c5506

Please sign in to comment.