Skip to content

Commit

Permalink
refactor: return workflow landing url instead of id (#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterckx committed Oct 22, 2024
1 parent c22929a commit 62fa088
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
} from "@databiosphere/findable-ui/lib/components/Links/common/entities";
import { Card } from "@mui/material";
import { WORKFLOW_IDS_BY_ANALYSIS_METHOD } from "app/apis/catalog/brc-analytics-catalog/common/constants";
import { getWorkflowLandingId } from "app/utils/galaxy-api";
import { getWorkflowLandingUrl } from "app/utils/galaxy-api";
import { useState } from "react";
import { ANALYSIS_METHOD } from "../../../../apis/catalog/brc-analytics-catalog/common/entities";
import {
Expand All @@ -22,9 +22,6 @@ export interface AnalysisMethodProps extends CardProps {
genomeVersionAssemblyId: string;
}

const WORKFLOW_LANDING_URL_PREFIX =
"https://test.galaxyproject.org/workflow_landings/";

export const AnalysisMethod = ({
analysisMethod,
genomeVersionAssemblyId,
Expand All @@ -46,11 +43,10 @@ export const AnalysisMethod = ({
onClick={async (): Promise<void> => {
if (!workflowId) return;
setUrlIsLoading(true);
const url =
WORKFLOW_LANDING_URL_PREFIX +
encodeURIComponent(
await getWorkflowLandingId(workflowId, genomeVersionAssemblyId)
);
const url = await getWorkflowLandingUrl(
workflowId,
genomeVersionAssemblyId
);
setUrlIsLoading(false);
window.open(
url,
Expand Down
16 changes: 10 additions & 6 deletions app/utils/galaxy-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ interface WorkflowLanding {
uuid: string;
}

const WORKFLOW_LANDINGS_URL =
const WORKFLOW_LANDINGS_API_URL =
"https://test.galaxyproject.org/api/workflow_landings";

const WORKFLOW_LANDING_URL_PREFIX =
"https://test.galaxyproject.org/workflow_landings/";

/**
* Get the ID of the workflow landing page for the given genome workflow.
* Get the URL of the workflow landing page for the given genome workflow.
* @param workflowId - Value for the `workflow_id` parameter sent to the API.
* @param referenceGenome - Genome version/assembly ID.
* @returns workflow landing UUID.
* @returns workflow landing URL.
*/
export async function getWorkflowLandingId(
export async function getWorkflowLandingUrl(
workflowId: string,
referenceGenome: string
): Promise<string> {
Expand All @@ -30,11 +33,12 @@ export async function getWorkflowLandingId(
workflow_id: workflowId,
workflow_target_type: "trs_url",
};
const res = await ky.post<WorkflowLanding>(WORKFLOW_LANDINGS_URL, {
const res = await ky.post<WorkflowLanding>(WORKFLOW_LANDINGS_API_URL, {
json: body,
retry: {
methods: ["post"],
},
});
return (await res.json()).uuid;
const id = (await res.json()).uuid;
return WORKFLOW_LANDING_URL_PREFIX + encodeURIComponent(id);
}

0 comments on commit 62fa088

Please sign in to comment.