Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[24.0] Fix anonymous user create, run and import workflows #17776

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 29 additions & 4 deletions client/src/components/Workflow/WorkflowListActions.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,35 @@ import { library } from "@fortawesome/fontawesome-svg-core";
import { faPlus, faUpload } from "@fortawesome/free-solid-svg-icons";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import { BButton } from "bootstrap-vue";
import { storeToRefs } from "pinia";
import { computed } from "vue";
import { useRouter } from "vue-router/composables";

import { useUserStore } from "@/stores/userStore";

library.add(faPlus, faUpload);

const router = useRouter();

const userStore = useUserStore();

const { isAnonymous } = storeToRefs(userStore);

const createButtonTitle = computed(() => {
if (isAnonymous.value) {
return "Log in to create workflow";
} else {
return "Create new workflow";
}
});
const importButtonTitle = computed(() => {
if (isAnonymous.value) {
return "Log in to import workflow";
} else {
return "Import workflow from URL or file";
}
});

function navigateToImport() {
router.push("/workflows/import");
}
Expand All @@ -23,21 +46,23 @@ function navigateToOldCreate() {
<div>
<BButton
id="workflow-create"
v-b-tooltip.hover
v-b-tooltip.hover.noninteractive
size="sm"
title="Create new workflow"
:title="createButtonTitle"
variant="outline-primary"
:disabled="isAnonymous"
@click="navigateToOldCreate">
<FontAwesomeIcon :icon="faPlus" />
Create
</BButton>

<BButton
id="workflow-import"
v-b-tooltip.hover
v-b-tooltip.hover.noninteractive
size="sm"
title="Import workflow from URL or file"
:title="importButtonTitle"
variant="outline-primary"
:disabled="isAnonymous"
@click="navigateToImport">
<FontAwesomeIcon :icon="faUpload" />
Import
Expand Down
16 changes: 14 additions & 2 deletions client/src/components/Workflow/WorkflowQuickView.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<script setup lang="ts">
import { type AxiosError } from "axios";
import { BAlert, BCard } from "bootstrap-vue";
import { ref, watch } from "vue";
import { storeToRefs } from "pinia";
import { computed, ref, watch } from "vue";

import { fromSimple } from "@/components/Workflow/Editor/modules/model";
import { getWorkflowFull, getWorkflowInfo } from "@/components/Workflow/workflows.services";
import { useDatatypesMapper } from "@/composables/datatypesMapper";
import { provideScopedWorkflowStores } from "@/composables/workflowStores";
import { useUserStore } from "@/stores/userStore";
import type { Workflow } from "@/stores/workflowStore";
import { assertDefined } from "@/utils/assertions";

Expand All @@ -20,8 +22,10 @@ const props = defineProps<{
id: string;
}>();

const userStore = useUserStore();
const { datatypesMapper } = useDatatypesMapper();

const { isAnonymous } = storeToRefs(userStore);
const { stateStore } = provideScopedWorkflowStores(props.id);

stateStore.scale = 0.75;
Expand All @@ -41,6 +45,14 @@ const workflowInfo = ref<
| undefined
>();

const runButtonTitle = computed(() => {
if (isAnonymous.value) {
return "Log in to run workflow";
} else {
return "Run workflow";
}
});

watch(
() => props.id,
async (id) => {
Expand Down Expand Up @@ -89,7 +101,7 @@ watch(
<span class="d-flex mb-2 flex-gapx-1">
<Heading h1 separator inline size="xl" class="flex-grow-1 mb-0"> Workflow Preview </Heading>

<WorkflowRunButton :id="props.id" full />
<WorkflowRunButton :id="props.id" :title="runButtonTitle" :disabled="isAnonymous" full />
</span>
</div>

Expand Down
8 changes: 7 additions & 1 deletion client/src/entry/analysis/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ export function getRouter(Galaxy) {
}),
},
/** Workflow editor */
{ path: "/workflows/edit", component: WorkflowEditorModule },
{
path: "/workflows/edit",
component: WorkflowEditorModule,
redirect: redirectAnon(),
},
/** Published resources routes */
{
path: "/published/history",
Expand Down Expand Up @@ -521,6 +525,7 @@ export function getRouter(Galaxy) {
{
path: "workflows/import",
component: WorkflowImport,
redirect: redirectAnon(),
},
{
path: "workflows/invocations",
Expand Down Expand Up @@ -563,6 +568,7 @@ export function getRouter(Galaxy) {
{
path: "workflows/run",
component: Home,
redirect: redirectAnon(),
props: (route) => ({
config: Galaxy.config,
query: { workflow_id: route.query.id },
Expand Down