Skip to content

refactor(site): move workspace schedule controls to its own component #11281

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

Merged
merged 2 commits into from
Dec 20, 2023

Conversation

BrunoQuaresma
Copy link
Collaborator

Doing some refactoring to make this component easier to reuse on the new workspace page and avoid major conflicts in the future. Noticeable changes:

  • Move mutations to live inside of the component to avoid a prop-drilling hell
  • Move some computation logic to be inside of the component for the same previous reason

@BrunoQuaresma BrunoQuaresma requested review from Parkreiner and a team December 19, 2023 17:27
@BrunoQuaresma BrunoQuaresma self-assigned this Dec 19, 2023
Copy link
Member

@Parkreiner Parkreiner left a comment

Choose a reason for hiding this comment

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

This looks really good, and it already looks a lot cleaner!
Had some small nits for accessibility, and one question about an edge case for the deadline PUT requests

deadline,
);
const deadlinePlusEnabled = maxDeadlineIncrease >= 1;
const deadlineMinusEnabled = maxDeadlineDecrease >= 1;
Copy link
Member

Choose a reason for hiding this comment

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

Do we have a policy around deadlines? As in:

  1. Will it always be a value that's relative to the current time?
  2. And once a deadline is up, is it not able to be interacted with any way?

Mainly curious because I would've expected the conditions for each of the derived values to be different

Copy link
Member

Choose a reason for hiding this comment

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

Also, since it looks like these properties are only being used once each, do you think it'd be better to move them into the JSX output directly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

About your questions:

  1. Yes
  2. Not sure if I got it. Can you say a use case?

Honestly, I don't have too much context on this part and I have the same questions as you. @johnstcn probably can help us to understand this better.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

About JSX, I think I can better understand what it does by assigning this condition to a named variable.

Copy link
Member

Choose a reason for hiding this comment

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

Will it always be a value that's relative to the current time?

Yeah workspace deadline should generally be in the future. I could imagine rare situations where it's a few seconds in the past but those should be the exception.

And once a deadline is up, is it not able to be interacted with any way?

There might be a short window between the deadline expiring and the workspace actually being shut down in which you could theoretically still extend the deadline. But in general, I think it's fair to assume that once the deadline is up, workspace is stopping Very Soon.

onSubmit={(e) => {
e.preventDefault();
const formData = new FormData(e.currentTarget);
const hours = Number(formData.get("hours"));
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this needs to be fixed, but I just want to make sure I'm understanding what would happen with an accident like this:

  1. Someone moves things elements around, and the name field accidentally gets removed
  2. formData.get("hours") evaluates to null, and Number converts it into 0

It looks like it would make a PUT request with 0, which I'm guessing wouldn't break anything, but just want to make sure

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You are exactly right since increase or decrease something in 0 would result in the same value, but I love your analysis

@BrunoQuaresma BrunoQuaresma merged commit e2e56d7 into main Dec 20, 2023
@BrunoQuaresma BrunoQuaresma deleted the bq/refactor-schedule-controls branch December 20, 2023 11:46
@github-actions github-actions bot locked and limited conversation to collaborators Dec 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants