Skip to content

Commit

Permalink
Parameterize public and secret props in workflow landing component
Browse files Browse the repository at this point in the history
Chose to make the url query param `client_secret` to match the API
parameter.
  • Loading branch information
mvdbeek committed Oct 20, 2024
1 parent a611aa9 commit b96ccae
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 12 deletions.
43 changes: 32 additions & 11 deletions client/src/components/Landing/WorkflowLanding.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ import WorkflowRun from "@/components/Workflow/Run/WorkflowRun.vue";
interface Props {
uuid: string;
secret?: string;
public?: boolean;
}
const props = withDefaults(defineProps<Props>(), {
secret: undefined,
public: false,
});
const workflowId = ref<string | null>(null);
Expand All @@ -34,19 +36,38 @@ watch(
currentUser,
async () => {
if (isAnonymous.value) {
router.push(`/login/start?redirect=/workflow_landings/${props.uuid}`);
router.push(
`/login/start?redirect=/workflow_landings/${props.uuid}?public=${props.public}&client_secret=${props.secret}`
);
} else if (currentUser.value) {
const { data, error } = await GalaxyApi().GET("/api/workflow_landings/{uuid}", {
params: {
path: { uuid: props.uuid },
},
});
if (data) {
workflowId.value = data.workflow_id;
instance.value = data.workflow_target_type === "workflow";
requestState.value = data.request_state;
let claim;
let claimError;
if (props.public) {
const { data, error } = await GalaxyApi().GET("/api/workflow_landings/{uuid}", {
params: {
path: { uuid: props.uuid },
},
});
claim = data;
claimError = error;
} else {
errorMessage.value = errorMessageAsString(error);
const { data, error } = await GalaxyApi().POST("/api/workflow_landings/{uuid}/claim", {
params: {
path: { uuid: props.uuid },
},
body: {
client_secret: props.secret,
},
});
claim = data;
claimError = error;
}
if (claim) {
workflowId.value = claim.workflow_id;
instance.value = claim.workflow_target_type === "workflow";
requestState.value = claim.request_state;
} else {
errorMessage.value = errorMessageAsString(claimError);
}
}
},
Expand Down
6 changes: 5 additions & 1 deletion client/src/entry/analysis/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,11 @@ export function getRouter(Galaxy) {
{
path: "workflow_landings/:uuid",
component: WorkflowLanding,
props: true,
props: (route) => ({
uuid: route.params.uuid,
public: !!route.query.public,
secret: route.query.client_secret,
}),
},
{
path: "user",
Expand Down

0 comments on commit b96ccae

Please sign in to comment.