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

initial changes for Gantt-like feature #430

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Conversation

luckyTamme
Copy link

For my bachelor thesis, I will implement a Gantt-like timeline view for processes that should work synchronously with bpmn diagram modulation. to keep the impact on the main project as small as possible and not to obstruct any ongoing developments, most work will happen in the new bpmn-timeline.tsx component.

In order to render either the bpmn-timeline or the existing bpmn-modeler, some adjustments to the process page.tsx and wrapper had to be made.

Because the toggle for switching to the timeline-mode should be inside the toolbar, a new state-store had to be introduced. There might be a more elegant way of realising this and with less overhead, but this was the best way I could implement it due to the page.tsx being a server component and how the client component structure with children inside wrapper.tsx works.

Comment on lines 57 to 60
const { timelineViewActive, disableTimelineView } = useTimelineViewStore((state) => ({
timelineViewActive: state.timelineViewActive,
disableTimelineView: state.disableTimelineView,
}));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To use multiple props from a zustand store, you should just have one line for each. Otherwise you re-create the selector output on every state change, even unrelated ones.

Comment on lines 245 to 246
const childrenArray = Children.toArray(children);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you expect certain children to be present in a certain order, you should just use named props. children is supposed to be a bit like a black box and there is no real way to limit the type.

Comment on lines 101 to 104
// always show bpmn-js modeler when opening a process
useEffect(() => {
disableTimelineView();
}, [processId]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably reset the store when the timeline component unmounts instead of this.

@@ -45,7 +49,14 @@ const Process = async ({ params: { processId, environmentId }, searchParams }: P
process={{ ...process, bpmn: selectedVersionBpmn as string }}
versions={process.versions}
versionName={selectedVersion?.name}
timelineViewFeatureEnabled={timelineViewFeatureEnabled} // required for .env feature flag
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just as a note: you can use env vars in client components by prefixing them with NEXT_PUBLIC_ , but we can leave this since we might combine it with DB config values.

import { useEnvironment } from './auth-can';
import { Element, Parent } from 'diagram-js/lib/model/Types';
import { useEffect, useRef, useState } from 'react';
import useTimelineViewStore from '@/app/(dashboard)/[environmentId]/processes/[processId]/use-timeline-view-store';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can move the store into the lib folder, if it is being used in multiple locations. This static import path to the page folder is more at risk of change in the future.

@luckyTamme
Copy link
Author

@OhKai thank you for the feedback. I've implemented the changes suggested by you and opted to change the env variable as well, as in its current usage it improves clarity in my opinion.

@OhKai
Copy link
Contributor

OhKai commented Jan 21, 2025

@luckyTamme Can you try to resolve the merge conflicts, so I can merge this PR? If you run into problems, I can help you with that.

@luckyTamme
Copy link
Author

@OhKai I'll do some changes that I've talked with Kai about and will resolve the conflicts end of this week / next week.

@luckyTamme
Copy link
Author

@OhKai the changes are implemented and all merge conflicts resolved. excuse my messy commit history, I had some issues with my local setup 😅

@luckyTamme
Copy link
Author

Hi @OhKai, can we merge my changes or are changes required?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants