Skip to content

Commit

Permalink
fix: cannot read properties of undefined (#506)
Browse files Browse the repository at this point in the history
fix: nullref

Signed-off-by: Carina Ursu <[email protected]>

Co-authored-by: Carina Ursu <[email protected]>
  • Loading branch information
ursucarina and ursucarina authored Jun 10, 2022
1 parent 9c453eb commit d38b98b
Showing 1 changed file with 26 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Button } from '@material-ui/core';
import * as React from 'react';
import { ResourceIdentifier, Identifier, Variable } from 'models/Common/types';
import { ResourceIdentifier, Identifier } from 'models/Common/types';
import { getTask } from 'models/Task/api';
import { LaunchFormDialog } from 'components/Launch/LaunchForm/LaunchFormDialog';
import { NodeExecutionIdentifier } from 'models/Execution/types';
Expand All @@ -20,32 +20,37 @@ export const ExecutionDetailsActions = (props: ExecutionDetailsActionsProps): JS
const { className, details, nodeExecutionId } = props;

const [showLaunchForm, setShowLaunchForm] = React.useState<boolean>(false);
const [taskInputsTypes, setTaskInputsTypes] = React.useState<
Record<string, Variable> | undefined
>();

const executionData = useNodeExecutionData(nodeExecutionId);
const [initialParameters, setInitialParameters] = React.useState<
TaskInitialLaunchParameters | undefined
>(undefined);

const id = details.taskTemplate?.id as ResourceIdentifier | undefined;
const executionData = useNodeExecutionData(nodeExecutionId);
const id = details.taskTemplate?.id;

React.useEffect(() => {
const fetchTask = async () => {
const task = await getTask(id as Identifier);
setTaskInputsTypes(task.closure.compiledTask.template?.interface?.inputs?.variables);
};
if (id) fetchTask();
}, [id]);
if (!id) {
return;
}

if (!id) {
return <></>;
}
(async () => {
const task = await getTask(id!);

const literals = executionData.value.fullInputs?.literals;
const literals = executionData.value.fullInputs?.literals;
const taskInputsTypes = task.closure.compiledTask.template?.interface?.inputs?.variables;

const initialParameters: TaskInitialLaunchParameters = {
values: literals && taskInputsTypes && literalsToLiteralValueMap(literals, taskInputsTypes),
taskId: id as Identifier | undefined,
};
const tempInitialParameters: TaskInitialLaunchParameters = {
values: literals && taskInputsTypes && literalsToLiteralValueMap(literals, taskInputsTypes),
taskId: id as Identifier | undefined,
};

setInitialParameters(tempInitialParameters);
})();
}, [details]);

if (!id || !initialParameters) {
return <></>;
}

const rerunOnClick = (e: React.MouseEvent<HTMLElement>) => {
e.stopPropagation();
Expand All @@ -60,7 +65,7 @@ export const ExecutionDetailsActions = (props: ExecutionDetailsActionsProps): JS
</Button>
</div>
<LaunchFormDialog
id={id}
id={id as ResourceIdentifier}
initialParameters={initialParameters}
showLaunchForm={showLaunchForm}
setShowLaunchForm={setShowLaunchForm}
Expand Down

0 comments on commit d38b98b

Please sign in to comment.