Skip to content

Commit

Permalink
fix(kanban): load kanban when story is open
Browse files Browse the repository at this point in the history
  • Loading branch information
cocotime committed Oct 3, 2023
1 parent ba70e24 commit db5a971
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
replaceStory,
setIntialPosition,
} from './kanban.reducer.helpers';
import { StoryDetailApiActions } from '~/app/modules/project/story-detail/data-access/+state/actions/story-detail.actions';

export interface KanbanState {
loadingWorkflow: boolean;
Expand Down Expand Up @@ -807,6 +808,17 @@ export const reducer = createImmerReducer(
state.workflow.slug = workflow.slug;
}

return state;
}
),
on(
StoryDetailApiActions.fetchWorkflowSuccess,
(state, { workflow }): KanbanState => {
if (!state.workflow) {
state.workflow = workflow;
state.currentWorkflowSlug = workflow.slug;
}

return state;
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
take,
} from 'rxjs';
import * as ProjectActions from '~/app/modules/project/data-access/+state/actions/project.actions';
import { selectWorkflow as selectWorkflowStoryDetail } from '~/app/modules/project/story-detail/data-access/+state/selectors/story-detail.selectors';
import {
selectCurrentProject,
selectMembers,
Expand Down Expand Up @@ -81,6 +82,7 @@ import { KanbanHeaderComponent } from './components/kanban-header/kanban-header.
interface ComponentState {
loadingWorkflow: KanbanState['loadingWorkflow'];
workflow: KanbanState['workflow'];
workflowStoryDetail: KanbanState['workflow'];
workflows: Workflow[];
invitePeopleModal: boolean;
showStoryDetail: boolean;
Expand Down Expand Up @@ -206,8 +208,16 @@ export class ProjectFeatureKanbanComponent {
combineLatest([
this.state.select('storyView'),
this.state.select('showStoryDetail'),
this.state.select('workflow'),
this.state.select('workflowStoryDetail'),
]),
([storyView, showStoryDetail]) => {
([storyView, showStoryDetail, workflow, workflowStoryDetail]) => {
if (showStoryDetail && !workflow && workflowStoryDetail?.slug) {
// when there is a story open we should init kanban this way
this.store.dispatch(
KanbanActions.initKanban({ workflow: workflowStoryDetail.slug })
);
}
if (showStoryDetail && storyView === 'side-view') {
this.setCloseShortcut();
this.shortcutsService.setScope('side-view');
Expand All @@ -218,6 +228,10 @@ export class ProjectFeatureKanbanComponent {
);
this.state.connect('storyView', this.store.select(selectStoryView));
this.state.connect('workflow', this.store.select(selectWorkflow));
this.state.connect(
'workflowStoryDetail',
this.store.select(selectWorkflowStoryDetail)
);
this.state.connect(
'columns',
this.store.select(kanbanFeature.selectColums)
Expand Down

0 comments on commit db5a971

Please sign in to comment.