Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/backend/src/helpers/get-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ function addStaticSubsteps(
} else {
computedStep.substeps.push(testStep)
}

return computedStep
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@ export function CheckAgainButton(props: CheckAgainButtonProps) {
const { isUnstyledInfobox, onClick, isLoading, isDisabled, step } = props
const isFormSgTrigger =
step.appKey === 'formsg' && step.key === 'newSubmission'
const isFormSgAction =
step.appKey === 'formsg' && step.key === 'mrfSubmission'

if (isFormSgTrigger) {
return <FormSGCheckAgainButton {...props} />
}
if (isFormSgAction) {
return <FormSGCheckAgainButton {...props} />
}
return (
<Button
variant={isUnstyledInfobox ? 'solid' : 'outline'}
Expand Down
29 changes: 13 additions & 16 deletions packages/frontend/src/components/FlowStepTestController/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@ export default function FlowStepTestController(
} = useContext(EditorContext)
const formContext = useFormContext()

const { isIfThenStep, isTrigger, selectedActionOrTrigger, substeps } =
useStepMetadata(allApps, step)
const {
isIfThenStep,
isTrigger,
isMrfStep,
selectedActionOrTrigger,
substeps,
} = useStepMetadata(allApps, step)

const {
isTestSuccessful,
Expand Down Expand Up @@ -305,8 +310,8 @@ export default function FlowStepTestController(
</Button>
)}
</Flex>
{shouldShowSaveButton ? (
<Flex>
<Flex>
{shouldShowSaveButton && (
<Button
variant="outline"
// cant use responsive value for variant for some reason
Expand All @@ -322,16 +327,7 @@ export default function FlowStepTestController(
>
{!isDirty ? 'Saved' : 'Save without checking'}
</Button>
<CheckAgainButton
isUnstyledInfobox={isStepUnchecked}
onClick={handleSaveAndTest}
isLoading={isTestExecuting}
isDisabled={!isValid || readOnly}
step={step}
executionStepMetadata={currentTestExecutionStep?.metadata}
/>
</Flex>
) : (
)}
<CheckAgainButton
isUnstyledInfobox={isStepUnchecked}
onClick={handleSaveAndTest}
Expand All @@ -340,7 +336,7 @@ export default function FlowStepTestController(
step={step}
executionStepMetadata={currentTestExecutionStep?.metadata}
/>
)}
</Flex>
</Flex>
</Infobox>
<TestResult
Expand All @@ -362,7 +358,8 @@ export default function FlowStepTestController(
<HStack w="100%" justifyContent="flex-end">
{/* gathersg is a special case where there is a webhook url and the save step button
needs to be shown to save the encryption key */}
{(!step.webhookUrl || step.appKey === 'gathersg') && (
{((!step.webhookUrl && !isMrfStep) ||
step.appKey === 'gathersg') && (
<Button
isDisabled={readOnly || isSaving || !isDirty}
isLoading={isSaving}
Expand Down
14 changes: 10 additions & 4 deletions packages/frontend/src/components/FlowSubstep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type FlowSubstepProps = {
}

function FlowSubstep(props: FlowSubstepProps): JSX.Element {
const { isTrigger, substep, step, selectedActionOrTrigger } = props
const { substep, step, selectedActionOrTrigger } = props
const { getFlagValue } = useContext(LaunchDarklyContext)
const formContext = useFormContext()
const {
Expand Down Expand Up @@ -125,18 +125,24 @@ function FlowSubstep(props: FlowSubstepProps): JSX.Element {
const handleSaveAndTest = useCallback(
async (testRunMetadata?: Record<string, unknown>) => {
try {
await saveStep()
if (
!selectedActionOrTrigger ||
!('hiddenFromUser' in selectedActionOrTrigger) ||
selectedActionOrTrigger.hiddenFromUser !== true
) {
await saveStep()
}
await executeTestStep({ testRunMetadata })
} catch (error) {
console.error('Error saving and test step')
}
},
[saveStep, executeTestStep],
[selectedActionOrTrigger, executeTestStep, saveStep],
)

return (
<Box position="relative" display="flex" flexDirection="column">
{(!isTrigger || argsToDisplay.length > 0) && (
{argsToDisplay.length > 0 && (
<Box flex="1" p={0} pb={4}>
<Stack w="100%" spacing={4}>
{argsToDisplay.map((argument) => (
Expand Down
3 changes: 3 additions & 0 deletions packages/frontend/src/hooks/useStepMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ interface UseStepMetadataResult {
stepName: string
substeps: ISubstep[]
shouldShowDragHandle?: boolean
isMrfStep: boolean
}

export function useStepMetadata(
Expand All @@ -31,6 +32,7 @@ export function useStepMetadata(
const isCompleted = step?.status === 'completed'
const isTrigger = step?.type === 'trigger'
const isIfThenStep = step ? checkIfThenStep(step) : false
const isMrfStep = step?.key === 'mrfSubmission'

const apps: IApp[] = allApps?.filter((app: IApp) =>
isTrigger ? !!app.triggers?.length : !!app.actions?.length,
Expand Down Expand Up @@ -88,6 +90,7 @@ export function useStepMetadata(
hasConnection,
isCompleted,
isIfThenStep,
isMrfStep,
isTrigger,
position: step?.position ?? 0,
stepName: step?.config?.stepName
Expand Down