Skip to content

Commit

Permalink
Avoid running tools on immutable histories
Browse files Browse the repository at this point in the history
  • Loading branch information
davelopez committed May 27, 2024
1 parent 23bb000 commit 29e78f2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion client/src/components/Tool/ToolForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
<b-alert :show="messageShow" :variant="messageVariant">
{{ messageText }}
</b-alert>
<b-alert v-if="!showLoading && !canMutateHistory" show variant="warning">
{{ immutableHistoryMessage }}
</b-alert>
<LoadingSpan v-if="showLoading" message="Loading Tool" />
<div v-if="showEntryPoints">
<ToolEntryPoints v-for="job in entryPoints" :key="job.id" :job-id="job.id" />
Expand Down Expand Up @@ -87,6 +90,7 @@
<ButtonSpinner
id="execute"
title="Run Tool"
:disabled="!canMutateHistory"
class="btn-sm"
:wait="showExecuting"
:tooltip="tooltip"
Expand All @@ -96,6 +100,7 @@
<ButtonSpinner
title="Run Tool"
class="mt-3 mb-3"
:disabled="!canMutateHistory"
:wait="showExecuting"
:tooltip="tooltip"
@onClick="onExecute(config, currentHistoryId)" />
Expand All @@ -117,6 +122,7 @@ import { useHistoryItemsStore } from "stores/historyItemsStore";
import { useJobStore } from "stores/jobStore";
import { refreshContentsWrapper } from "utils/data";
import { canMutateHistory } from "@/api";
import { useConfigStore } from "@/stores/configurationStore";
import { useHistoryStore } from "@/stores/historyStore";
import { useUserStore } from "@/stores/userStore";
Expand Down Expand Up @@ -196,11 +202,13 @@ export default {
{ label: "populate", value: "populate" },
{ label: "bundle", value: "bundle" },
],
immutableHistoryMessage:
"This history is immutable and you cannot run tools in it. Please switch to a different history.",
};
},
computed: {
...mapState(useUserStore, ["currentUser"]),
...mapState(useHistoryStore, ["currentHistoryId"]),
...mapState(useHistoryStore, ["currentHistoryId", "currentHistory"]),
...mapState(useHistoryItemsStore, ["lastUpdateTime"]),
toolName() {
return this.formConfig.name;
Expand All @@ -212,6 +220,9 @@ export default {
return id.endsWith(version) ? id : `${id}/${version}`;
},
tooltip() {
if (!this.canMutateHistory) {
return this.immutableHistoryMessage;
}
return `Run tool: ${this.formConfig.name} (${this.formConfig.version})`;
},
errorContentPretty() {
Expand All @@ -234,6 +245,9 @@ export default {
initialized() {
return this.formData !== undefined;
},
canMutateHistory() {
return this.currentHistory && canMutateHistory(this.currentHistory);
},
},
watch: {
currentHistoryId() {
Expand Down

0 comments on commit 29e78f2

Please sign in to comment.