Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: select first invalid step on viewing flow, and select trigger on viewing run #4010

Merged
merged 5 commits into from Feb 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -9,6 +9,7 @@ import { BuilderSelectors } from '../builder.selector';
import { LeftSideBarType, RightSideBarType } from '../../../model';
import { RunDetailsService } from '../../../service/run-details.service';
import { MatSnackBar } from '@angular/material/snack-bar';
import { FlowsActions } from '../../flow';

@Injectable()
export class CanvasEffects {
Expand Down Expand Up @@ -84,18 +85,18 @@ export class CanvasEffects {
},
{ dispatch: false }
);
setRun$ = createEffect(() => {
openLeftSideBarToShowRun$ = createEffect(() => {
return this.actions$.pipe(
ofType(canvasActions.setRun),
concatLatestFrom(() => [
this.store.select(BuilderSelectors.selectCurrentFlow),
this.store.select(BuilderSelectors.selectCurrentFlowRun),
]),
tap(([{ run }, currentRun]) => {
if (run.id !== currentRun?.id) {
this.runDetailsService.currentStepResult$.next(undefined);
}
}),
switchMap(([run]) => {
switchMap(() => {
return of(
canvasActions.setLeftSidebar({
sidebarType: LeftSideBarType.SHOW_RUN,
Expand All @@ -104,4 +105,37 @@ export class CanvasEffects {
})
);
});

selectTriggerOnTestRunEnd$ = createEffect(() => {
return this.actions$.pipe(
ofType(canvasActions.setRun),
switchMap(({ run }) => {
if (run.status !== 'RUNNING') {
return of(canvasActions.selectStepByName({ stepName: 'trigger' }));
}
return EMPTY;
})
);
});

selectTriggerOnViewingRun$ = createEffect(() => {
return this.actions$.pipe(
ofType(canvasActions.viewRun),
switchMap(() => {
return of(canvasActions.selectStepByName({ stepName: 'trigger' }));
})
);
});

selectTriggerOnOpeningBuilder$ = createEffect(() => {
return this.actions$.pipe(
ofType(canvasActions.setInitial),
switchMap(({ run }) => {
if (run) {
return of(canvasActions.selectStepByName({ stepName: 'trigger' }));
}
return of(FlowsActions.selectFirstInvalidStep());
})
);
});
}
Expand Up @@ -103,7 +103,7 @@ export class FlowsEffects {
concatLatestFrom(() =>
this.store.select(BuilderSelectors.selectCurrentFlow)
),
switchMap(([action, flow]) => {
switchMap(([_, flow]) => {
const invalidSteps = flowHelper
.getAllSteps(flow.version.trigger)
.filter((s) => !s.valid);
Expand All @@ -114,11 +114,7 @@ export class FlowsEffects {
})
);
}
return of(
canvasActions.selectStepByName({
stepName: flow.version.trigger.name,
})
);
return EMPTY;
})
);
});
Expand Down