Skip to content

Commit c317565

Browse files
committed
Skip configuration steps if we don't need them
1 parent 9e812fa commit c317565

File tree

4 files changed

+41
-8
lines changed

4 files changed

+41
-8
lines changed

app/components/Entity/components/ConfigureWorkflowInputs/components/Main/components/Stepper/components/Step/PairedEndStep/pairedEndStep.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ export const PairedEndStep = ({
1717
entryLabel,
1818
index,
1919
onConfigure,
20-
onLaunchGalaxy,
21-
status,
2220
}: StepProps): JSX.Element => {
2321
const ena = useENA<ReadRun>();
2422
const table = useTable(ena.data);

app/components/Entity/components/ConfigureWorkflowInputs/components/Main/components/Stepper/components/Step/hooks/UseLaunchGalaxy/useLaunchGalaxy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const useLaunchGalaxy = ({
1313
workflow,
1414
}: Props): UseLaunchGalaxy => {
1515
const { data: landingUrl, isLoading: loading, run } = useAsync<string>();
16-
const configuredValue = getConfiguredValues(configuredInput);
16+
const configuredValue = getConfiguredValues(configuredInput, workflow);
1717
const disabled = !configuredValue;
1818

1919
const onLaunchGalaxy = useCallback(async (): Promise<void> => {

app/components/Entity/components/ConfigureWorkflowInputs/components/Main/components/Stepper/components/Step/hooks/UseLaunchGalaxy/utils.ts

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,41 @@
11
import { ConfiguredInput } from "../../../../../../../../../../../../views/WorkflowInputsView/hooks/UseConfigureInputs/types";
2+
import { Workflow } from "../../../../../../../../../../../../apis/catalog/brc-analytics-catalog/common/entities";
3+
import { WORKFLOW_PARAMETER_VARIABLE } from "../../../../../../../../../../../../apis/catalog/brc-analytics-catalog/common/schema-entities";
24
import { ConfiguredValue } from "./types";
35

46
/**
57
* Returns the configured values from the configured input.
68
* @param configuredInput - Configured input.
9+
* @param workflow - Workflow to check required parameters.
710
* @returns Configured values.
811
*/
912
export function getConfiguredValues(
10-
configuredInput: ConfiguredInput
13+
configuredInput: ConfiguredInput,
14+
workflow: Workflow
1115
): ConfiguredValue | undefined {
1216
const { geneModelUrl, readRuns, referenceAssembly } = configuredInput;
13-
if (!geneModelUrl || !readRuns || !referenceAssembly) return;
17+
18+
// If workflow is not available yet, return undefined
19+
if (!workflow?.parameters) return undefined;
20+
21+
// Check which parameters are required by the workflow
22+
const requiresReference = workflow.parameters.some(
23+
(param) => param.variable === WORKFLOW_PARAMETER_VARIABLE.ASSEMBLY_FASTA_URL
24+
);
25+
const requiresGTF = workflow.parameters.some(
26+
(param) => param.variable === WORKFLOW_PARAMETER_VARIABLE.GENE_MODEL_URL
27+
);
28+
const requiresFASTQ = workflow.parameters.some(
29+
(param) =>
30+
param.variable === WORKFLOW_PARAMETER_VARIABLE.SANGER_READ_RUN_PAIRED ||
31+
param.variable === WORKFLOW_PARAMETER_VARIABLE.SANGER_READ_RUN_SINGLE
32+
);
33+
34+
// Only check for required values
35+
if (requiresReference && !referenceAssembly) return;
36+
if (requiresGTF && !geneModelUrl) return;
37+
if (requiresFASTQ && !readRuns) return;
38+
1439
return {
1540
geneModelUrl,
1641
readRuns,

app/components/Entity/components/ConfigureWorkflowInputs/components/Main/components/Stepper/stepper.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,19 @@ export const Stepper = ({ workflow, ...props }: Props): JSX.Element => {
88
const requiresGTF = workflow.parameters.some(
99
(param) => param.variable === WORKFLOW_PARAMETER_VARIABLE.GENE_MODEL_URL
1010
);
11-
const steps = requiresGTF
12-
? STEPS
13-
: STEPS.filter((step) => step.key !== "geneModelUrl");
11+
const requiresFASTQ = workflow.parameters.some(
12+
(param) =>
13+
param.variable === WORKFLOW_PARAMETER_VARIABLE.SANGER_READ_RUN_PAIRED ||
14+
param.variable === WORKFLOW_PARAMETER_VARIABLE.SANGER_READ_RUN_SINGLE
15+
);
16+
17+
let steps = STEPS;
18+
if (!requiresGTF) {
19+
steps = steps.filter((step) => step.key !== "geneModelUrl");
20+
}
21+
if (!requiresFASTQ) {
22+
steps = steps.filter((step) => step.key !== "readRuns");
23+
}
1424
const { activeStep, onContinue, onEdit } = useStepper(steps);
1525
return (
1626
<StyledStepper activeStep={activeStep} {...STEPPER_PROPS}>

0 commit comments

Comments
 (0)