Skip to content

Commit

Permalink
fix: Relaunch form does not persist security context values when chan…
Browse files Browse the repository at this point in the history
…ged (#527)

fix: use execution security context in relaunch; #none

Signed-off-by: James <[email protected]>
  • Loading branch information
james-union authored Jun 29, 2022
1 parent e933f21 commit 1be5572
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ const RelaunchWorkflowForm: React.FC<RelaunchExecutionFormProps> = (props) => {
const { initialParameters } = useRelaunchWorkflowFormState(props);
const {
closure: { workflowId },
spec: { securityContext },
} = props.execution;

return (
Expand All @@ -127,6 +128,7 @@ const RelaunchWorkflowForm: React.FC<RelaunchExecutionFormProps> = (props) => {
onClose={props.onClose}
referenceExecutionId={props.execution.id}
workflowId={workflowId}
securityContext={securityContext}
/>
) : null}
</WaitForData>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const LaunchWorkflowForm: React.FC<LaunchWorkflowFormProps> = (props) =>
service,
workflowSourceSelectorState,
} = useLaunchWorkflowFormState(props);
const { securityContext } = props;

const styles = useStyles();
const baseState = state as BaseInterpretedLaunchState;
Expand Down Expand Up @@ -57,6 +58,15 @@ export const LaunchWorkflowForm: React.FC<LaunchWorkflowFormProps> = (props) =>
state.matches,
);

const roleInitialValue = React.useMemo(() => {
if (securityContext) return { securityContext };
return (
state.context.defaultAuthRole ||
selectedLaunchPlan?.data.spec.securityContext ||
selectedLaunchPlan?.data.spec.authRole
);
}, [securityContext, state.context.defaultAuthRole, selectedLaunchPlan]);

return (
<>
<LaunchFormHeader title={state.context.sourceId?.name} />
Expand Down Expand Up @@ -97,11 +107,7 @@ export const LaunchWorkflowForm: React.FC<LaunchWorkflowFormProps> = (props) =>
<AccordionDetails classes={{ root: styles.detailsWrapper }}>
{isEnterInputsState(baseState) ? (
<LaunchRoleInput
initialValue={
state.context.defaultAuthRole ||
selectedLaunchPlan?.data.spec.securityContext ||
selectedLaunchPlan?.data.spec.authRole
}
initialValue={roleInitialValue}
ref={roleInputRef}
showErrors={state.context.showErrors}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export interface WorkflowInitialLaunchParameters extends BaseInitialLaunchParame

export interface LaunchWorkflowFormProps extends BaseLaunchFormProps {
workflowId: NamedEntityIdentifier;
securityContext?: Core.ISecurityContext;
initialParameters?: WorkflowInitialLaunchParameters;
}

Expand Down

0 comments on commit 1be5572

Please sign in to comment.