From 1be5572f101f0f7dc20e1068772bd09a7bd0718c Mon Sep 17 00:00:00 2001 From: james-union <105876962+james-union@users.noreply.github.com> Date: Wed, 29 Jun 2022 12:20:27 -0400 Subject: [PATCH] fix: Relaunch form does not persist security context values when changed (#527) fix: use execution security context in relaunch; #none Signed-off-by: James --- .../ExecutionDetails/RelaunchExecutionForm.tsx | 2 ++ .../Launch/LaunchForm/LaunchWorkflowForm.tsx | 16 +++++++++++----- .../src/components/Launch/LaunchForm/types.ts | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/packages/zapp/console/src/components/Executions/ExecutionDetails/RelaunchExecutionForm.tsx b/packages/zapp/console/src/components/Executions/ExecutionDetails/RelaunchExecutionForm.tsx index f1bdaa2a2..dc351cd14 100644 --- a/packages/zapp/console/src/components/Executions/ExecutionDetails/RelaunchExecutionForm.tsx +++ b/packages/zapp/console/src/components/Executions/ExecutionDetails/RelaunchExecutionForm.tsx @@ -117,6 +117,7 @@ const RelaunchWorkflowForm: React.FC = (props) => { const { initialParameters } = useRelaunchWorkflowFormState(props); const { closure: { workflowId }, + spec: { securityContext }, } = props.execution; return ( @@ -127,6 +128,7 @@ const RelaunchWorkflowForm: React.FC = (props) => { onClose={props.onClose} referenceExecutionId={props.execution.id} workflowId={workflowId} + securityContext={securityContext} /> ) : null} diff --git a/packages/zapp/console/src/components/Launch/LaunchForm/LaunchWorkflowForm.tsx b/packages/zapp/console/src/components/Launch/LaunchForm/LaunchWorkflowForm.tsx index 2a1027542..3a0ec9b55 100644 --- a/packages/zapp/console/src/components/Launch/LaunchForm/LaunchWorkflowForm.tsx +++ b/packages/zapp/console/src/components/Launch/LaunchForm/LaunchWorkflowForm.tsx @@ -26,6 +26,7 @@ export const LaunchWorkflowForm: React.FC = (props) => service, workflowSourceSelectorState, } = useLaunchWorkflowFormState(props); + const { securityContext } = props; const styles = useStyles(); const baseState = state as BaseInterpretedLaunchState; @@ -57,6 +58,15 @@ export const LaunchWorkflowForm: React.FC = (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 ( <> @@ -97,11 +107,7 @@ export const LaunchWorkflowForm: React.FC = (props) => {isEnterInputsState(baseState) ? ( diff --git a/packages/zapp/console/src/components/Launch/LaunchForm/types.ts b/packages/zapp/console/src/components/Launch/LaunchForm/types.ts index b3ace5b7d..7c3ff2f52 100644 --- a/packages/zapp/console/src/components/Launch/LaunchForm/types.ts +++ b/packages/zapp/console/src/components/Launch/LaunchForm/types.ts @@ -65,6 +65,7 @@ export interface WorkflowInitialLaunchParameters extends BaseInitialLaunchParame export interface LaunchWorkflowFormProps extends BaseLaunchFormProps { workflowId: NamedEntityIdentifier; + securityContext?: Core.ISecurityContext; initialParameters?: WorkflowInitialLaunchParameters; }