From 90749c94c23ef7d1312f4e767423e1608685638d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marina=20L=C3=B3pez?= Date: Thu, 28 Sep 2023 13:48:18 +0200 Subject: [PATCH] feat(workflows): u#2860 t#4029 update workflow event --- .../data-access/+state/actions/project.actions.ts | 2 +- .../data-access/+state/effects/project.effects.ts | 5 ----- .../+state/reducers/project.reducer.ts | 7 +++++-- .../kanban-header/kanban-header.component.html | 2 ++ .../kanban-header/kanban-header.component.ts | 4 +++- .../data-access/+state/reducers/kanban.reducer.ts | 13 ++++++++----- .../project-feature-shell.component.ts | 9 +++++++++ .../+state/effects/story-detail.effects.spec.ts | 2 ++ .../+state/reducers/story-detail.reducer.ts | 15 +++++++++++++++ javascript/libs/data/src/lib/story.model.mock.ts | 2 ++ javascript/libs/data/src/lib/story.model.ts | 2 +- 11 files changed, 48 insertions(+), 15 deletions(-) diff --git a/javascript/apps/taiga/src/app/modules/project/data-access/+state/actions/project.actions.ts b/javascript/apps/taiga/src/app/modules/project/data-access/+state/actions/project.actions.ts index b52ce1af1..f8c9f970f 100644 --- a/javascript/apps/taiga/src/app/modules/project/data-access/+state/actions/project.actions.ts +++ b/javascript/apps/taiga/src/app/modules/project/data-access/+state/actions/project.actions.ts @@ -134,7 +134,6 @@ export const projectApiActions = createActionGroup({ 'create Workflow Error': emptyProps(), 'Update Workflow Success': props<{ workflow: Workflow; - oldSlug: Workflow['slug']; }>(), }, }); @@ -169,6 +168,7 @@ export const projectEventActions = createActionGroup({ 'Remove Member': props<{ membership: Membership; workspace: string }>(), 'Update Member': props<{ membership: Membership }>(), 'Create Workflow': props<{ workflow: Workflow }>(), + 'Update Workflow': props<{ workflow: Workflow }>(), 'Create comment': props<{ storyRef: Story['ref']; comment: UserComment }>(), 'Status reorder': props<{ id: Status['id']; diff --git a/javascript/apps/taiga/src/app/modules/project/data-access/+state/effects/project.effects.ts b/javascript/apps/taiga/src/app/modules/project/data-access/+state/effects/project.effects.ts index d3d1f4b31..58fc97ab9 100644 --- a/javascript/apps/taiga/src/app/modules/project/data-access/+state/effects/project.effects.ts +++ b/javascript/apps/taiga/src/app/modules/project/data-access/+state/effects/project.effects.ts @@ -224,16 +224,11 @@ export class ProjectEffects { .updateWorkflow(action.name, action.slug, project.id) .pipe( map((updatedWorkflow) => { - // void this.router.navigate( - // [`project/${project.id}/${project.slug}/kanban/${updatedWorkflow.slug}`], - // { replaceUrl: true } - // ); this.location.go( `project/${project.id}/${project.slug}/kanban/${updatedWorkflow.slug}` ); return ProjectActions.projectApiActions.updateWorkflowSuccess({ workflow: updatedWorkflow, - oldSlug: action.slug, }); }) ); diff --git a/javascript/apps/taiga/src/app/modules/project/data-access/+state/reducers/project.reducer.ts b/javascript/apps/taiga/src/app/modules/project/data-access/+state/reducers/project.reducer.ts index 84d595eab..2b3aed4af 100644 --- a/javascript/apps/taiga/src/app/modules/project/data-access/+state/reducers/project.reducer.ts +++ b/javascript/apps/taiga/src/app/modules/project/data-access/+state/reducers/project.reducer.ts @@ -114,10 +114,13 @@ export const reducer = createImmerReducer( ), on( ProjectActions.projectApiActions.updateWorkflowSuccess, - (state, { workflow, oldSlug }): ProjectState => { + ProjectActions.projectEventActions.updateWorkflow, + (state, { workflow }): ProjectState => { if (state.currentProjectId) { const workflows = state.projects[state.currentProjectId].workflows; - const workflowIndex = workflows.findIndex((it) => it.slug === oldSlug); + const workflowIndex = workflows.findIndex( + (it) => it.id === workflow.id + ); workflows[workflowIndex].name = workflow.name; workflows[workflowIndex].slug = workflow.slug; } diff --git a/javascript/apps/taiga/src/app/modules/project/feature-kanban/components/kanban-header/kanban-header.component.html b/javascript/apps/taiga/src/app/modules/project/feature-kanban/components/kanban-header/kanban-header.component.html index c23886ec5..ecd18cb3a 100644 --- a/javascript/apps/taiga/src/app/modules/project/feature-kanban/components/kanban-header/kanban-header.component.html +++ b/javascript/apps/taiga/src/app/modules/project/feature-kanban/components/kanban-header/kanban-header.component.html @@ -33,10 +33,12 @@ [(open)]="openWorkflowOptions">