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

PLANNER-1515: Add Shift Roster #263

Conversation

Christopher-Chianelli
Copy link
Collaborator

No description provided.

Copy link
Member

@yurloc yurloc left a comment

Choose a reason for hiding this comment

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

Several questions, issues and suggestions inline.

In addition to that there are a few minor UX issues that would be nice to have fixed:

  • Dropdowns should disappear when an option is selected (unless it's a multi-selection dropdown). For example the spot selector on Shift screen, dropdowns in Create Shift dialog.
  • z-index of dropdowns in the Create Shift dialog is less than the dialog z-index => the dropdown is not fully visible.

The lint script is not being run during Maven build. Travis build should fail if npm run lint fails.

employee-rostering-frontend/src/types.ts Outdated Show resolved Hide resolved
employee-rostering-frontend/src/ui/Alerts.tsx Outdated Show resolved Hide resolved
employee-rostering-frontend/src/ui/Alerts.tsx Outdated Show resolved Hide resolved

componentDidUpdate(prevProps: Props, prevState: State) {
if (this.props.shift === undefined && prevProps.shift !== undefined) {
// eslint-disable-next-line react/no-did-update-set-state
Copy link
Member

@yurloc yurloc Jul 23, 2019

Choose a reason for hiding this comment

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

❔ Question

The reasons behind this warning seems legitimate. Did you try initializing the state from props in the constructor? Is there something that make this approach impossible?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The reason is transferring changed Prop values into state. Note the constructor does not get recalled if props are changed (clicking a shift set it as the 'selectedShift', which is passed to EditShiftModal (which is already created with an empty/null shift)).

@yurloc
Copy link
Member

yurloc commented Jul 25, 2019

@Christopher-Chianelli Please fix "problems" before merging. Questions and suggestions are optional.

Copy link
Collaborator Author

@Christopher-Chianelli Christopher-Chianelli left a comment

Choose a reason for hiding this comment

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

@yurloc Took your suggestions and fixed all "problems". I also introduced i18n for Alerts.

Copy link
Member

@yurloc yurloc left a comment

Choose a reason for hiding this comment

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

Let's keep state management and UI components separated.

employee-rostering-frontend/src/store/alert/operations.tsx Outdated Show resolved Hide resolved
i18nKey: string;
variant: "success" | "danger" | "warning" | "info";
params: any;
components?: React.ReactNode[];
Copy link
Member

Choose a reason for hiding this comment

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

All the above is OK but the components?: React.ReactNode[]; is something I strongly dislike based on what's recommended by Redux documentation. Please take a look at it and tell me what you think. Are there any good reasons for this approach that I might be missing? Is there a hidden issue that might prevent the separation (store: only app state, ui: only React components)?

reduxjs/redux#1793 (comment)

not that things like that are impossible. It's that they are non-idiomatic, and in the vast majority of use cases, not a good idea.

This is closest to my opinion. Based on what's recommended by the documentation and generally perceived as idiomatic I classify this (putting React nodes) as something we should avoid.

Nice article about Redux store structuring called re-ducks: https://www.freecodecamp.org/news/scaling-your-redux-app-with-ducks-6115955638be/.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The main reason there is an optional components tab is that some alert messages have structure that need to be preserved. In our case, the "See Stack Trace" button which links to an unique Stack Trace Dialog. The alternatives are to use Functions (another no-no), put a map somewhere that map strings/numbers to functions/components (which seems like bad design), put react components as state (another no-no). The best alternative is probably the map which would be linked to a new component, but in turn it will have a higher maintenance cost.

Copy link
Member

@yurloc yurloc Jul 29, 2019

Choose a reason for hiding this comment

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

Well, you are putting a React component (ServerSideExceptionDialog) into the app state, aren't you? It's inside showServerError() method on line 74. That is a no-no, do you agree?

I think the structure of a stack trace (lines plus caused-by hierarchy) is captured by ServerSideExceptionInfo so why not store just that in the state, without wrapping it into React code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The main issue is the "Link", which we need to tell the Alert Component is one way or another is a link instead of text. Currently testing out a solution that uses a map.

@Christopher-Chianelli
Copy link
Collaborator Author

@yurloc Replaced components with enum + object of basic values, which are used to map to components in Alerts.

Copy link
Member

@yurloc yurloc left a comment

Choose a reason for hiding this comment

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

Thanks Christopher! Looks much better. I'm glad that you've found a way how to keep JSX outside of the Redux store.

@Christopher-Chianelli Christopher-Chianelli merged commit 4d7d9f0 into kiegroup:react-spring-boot-refactor Jul 30, 2019
@Christopher-Chianelli Christopher-Chianelli deleted the PLANNER-1515 branch November 19, 2019 22:13
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