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

refactor: Move schedule to the header #2775

Merged
merged 9 commits into from
Jul 1, 2022
Merged

Conversation

BrunoQuaresma
Copy link
Collaborator

Closes #2749

Screen Shot 2022-07-01 at 10 07 40

Screen Shot 2022-07-01 at 10 07 29

You can better see it on Chromatic!

@BrunoQuaresma BrunoQuaresma requested a review from a team as a code owner July 1, 2022 13:26
@BrunoQuaresma BrunoQuaresma self-assigned this Jul 1, 2022
@BrunoQuaresma BrunoQuaresma enabled auto-merge (squash) July 1, 2022 13:52
@Kira-Pilot
Copy link
Member

I know I left a lot of comments but I think this is looking really spiffy. Love the redesign.

// so to avoid doing that every seconds - because of the workspace pooling - we
// are memoizing this component. More details:
// https://github.com/coder/coder/pull/2775#discussion_r912080377
const MemoizedWorkspaceScheduleButton = React.memo(WorkspaceScheduleButton)
Copy link
Member

Choose a reason for hiding this comment

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

@BrunoQuaresma I haven't used memo before - only useMemo - so this is new to me. Does this somehow update the Button component if the workspace changes? Also I know we are relying on Dayjs() in the component - we probably don't want the current moment to memoized, right? Otherwise it will get stale. IDK, maybe I'm misunderstanding how this works.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, looks like maybe the workspace will update the component because it is a prop, but not sure that the current time will get updated, so our comparisons might be off.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thinking better, memoization for this component does not solve anything since the workspace prop reference will change every second. useMemo also would not work directly, since I would have to pass the workspace to the deps array, and like before, the reference of this object changes every 1 second. Probably I think we can solve that by writing a custom comparison function but I really would like to avoid that until it is needed. Since it looks a bit more complex, is it ok to not have memoization at all for now?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, that's fair! Thanks for trying it out; I appreciate it!

@BrunoQuaresma BrunoQuaresma enabled auto-merge (squash) July 1, 2022 18:22
@BrunoQuaresma BrunoQuaresma merged commit 2d0ea00 into main Jul 1, 2022
@BrunoQuaresma BrunoQuaresma deleted the bq/move-schedule-to-header branch July 1, 2022 18:26
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.

Move the schedule to the new grouped button + popover
2 participants