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

fix: [M3-8685] - Users unable to update timezone #11034

Merged
merged 4 commits into from
Oct 2, 2024

Conversation

bnussman-akamai
Copy link
Member

Description 📝

Preview 📷

Before After
Screen.Recording.2024-10-01.at.5.14.04.PM.mov
Screen.Recording.2024-10-01.at.5.12.59.PM.mov

How to test 🧪

As an Author I have considered 🤔

  • 👀 Doing a self review
  • ❔ Our contribution guidelines
  • 🤏 Splitting feature into small PRs
  • ➕ Adding a changeset
  • 🧪 Providing/Improving test coverage
  • 🔐 Removing all sensitive information from the code and PR description
  • 🚩 Using a feature flag to protect the release
  • 👣 Providing comprehensive reproduction steps
  • 📑 Providing or updating our documentation
  • 🕛 Scheduling a pair reviewing session
  • 📱 Providing mobile support
  • ♿ Providing accessibility support

@bnussman-akamai bnussman-akamai added the Bug Fixes for regressions or bugs label Oct 1, 2024
@bnussman-akamai bnussman-akamai self-assigned this Oct 1, 2024
@bnussman-akamai bnussman-akamai requested a review from a team as a code owner October 1, 2024 21:16
@bnussman-akamai bnussman-akamai requested review from hana-akamai and cpathipa and removed request for a team October 1, 2024 21:16
@bnussman-akamai bnussman-akamai changed the title fix: Users unable to update timezone fix: [M3-8685] - Users unable to update timezone Oct 1, 2024
}

updateProfile({ timezone: String(timezoneValue) }).then(() => {
Copy link
Member Author

Choose a reason for hiding this comment

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

The is the cause of the bug. timezoneValue is an object and we "cast" it to a string, causing us to send {"timezone": "[Object object]"} to the API

const label = formatOffset(tz);
return { label, value: tz.name };
});
.map((tz) => {
Copy link
Member Author

Choose a reason for hiding this comment

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

I was able to consolidate the two maps into one

const minutes = (Math.abs(offset) % 60).toLocaleString(undefined, {
minimumIntegerDigits: 2,
useGrouping: false,
});
const hours = Math.floor(Math.abs(offset) / 60);
const isPositive = Math.abs(offset) === offset ? '+' : '-';

return `\(GMT ${isPositive}${hours}:${minutes}\) ${label}`;
return `(GMT ${isPositive}${hours}:${minutes}) ${label}`;
Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think the \s are necessary. I removed them

Comment on lines -18 to -27
interface Timezone {
label: string;
name: string;
offset: number;
}

export interface TimezoneOption<T = string, L = string> {
label: L;
value: T;
}
Copy link
Member Author

Choose a reason for hiding this comment

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

We don't need these extra types. We can lean on TypeScript's inference to get a solution that is even more typesafe!


if (!profile) {
return <CircleProgress />;
}

return (
<>
{loggedInAsCustomer ? (
<StyledLoggedInAsCustomerNotice data-testid="admin-notice">
Copy link
Member Author

Choose a reason for hiding this comment

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

Removed this one-off component in favor of a simple Notice just to clean things up a bit

<StyledLoggedInAsCustomerNotice data-testid="admin-notice">
<Typography variant="h2">
While you are logged in as a customer, all times, dates, and graphs
will be displayed in your browser&rsquo;s timezone ({timezone}).
Copy link
Member Author

Choose a reason for hiding this comment

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

This copy was just factually incorrect.

"all times, dates, and graphs will be displayed in your browser's timezone" has been corrected to say "all times, dates, and graphs will be displayed in the user's timezone "

Comment on lines -100 to -107
slotProps={{
popper: {
sx: {
maxHeight: '285px',
overflow: 'hidden',
},
},
}}
Copy link
Member Author

Choose a reason for hiding this comment

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

I was able to clean up a lot of these one-off styles by using the fullWidth prop instead

sx={{ width: '416px' }}
/>
</Stack>
<ActionsPanel
Copy link
Member Author

Choose a reason for hiding this comment

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

Replaced the ActionsPanel with a Button. I think a plain Button is more fitting here.

Copy link

github-actions bot commented Oct 1, 2024

Coverage Report:
Base Coverage: 86.98%
Current Coverage: 86.98%

@bnussman-akamai bnussman-akamai changed the base branch from develop to staging October 1, 2024 21:53
@bnussman-akamai bnussman-akamai requested a review from a team as a code owner October 1, 2024 21:53
@bnussman-akamai bnussman-akamai requested review from AzureLatte and removed request for a team October 1, 2024 21:53
abailly-akamai
abailly-akamai previously approved these changes Oct 2, 2024
Copy link
Contributor

@abailly-akamai abailly-akamai left a comment

Choose a reason for hiding this comment

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

Thanks!

Confirmed the bug ad the resolution ✅
Other changes make sense to me and do not add any regression on my end

</>
);
};

const StyledRootContainer = styled('div', {
label: 'StyledRootContainer',
const TimezoneFormContainer = styled('div', {
Copy link
Contributor

@abailly-akamai abailly-akamai Oct 2, 2024

Choose a reason for hiding this comment

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

It's a nit, but I think we should continue to name Styled Components with "Styled", it makes it so much easier for developers to quickly identify components that are purely meant to apply styles and and have no other function.

Doesn't need to be changed for this PR but something to consider.

Copy link
Member Author

@bnussman-akamai bnussman-akamai Oct 2, 2024

Choose a reason for hiding this comment

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

Ahh got it. I always thought that prefixing the component with "Styled" was kind of an anti-pattern but I see what you mean. Will keep this in mind going forward!

@abailly-akamai
Copy link
Contributor

@bnussman-akamai the e2e failure appears to be relevant here

Screenshot 2024-10-02 at 09 25 10

cpathipa
cpathipa previously approved these changes Oct 2, 2024
Copy link
Contributor

@cpathipa cpathipa left a comment

Choose a reason for hiding this comment

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

Confirming on the bug timezone is successfully updating.

@bnussman-akamai
Copy link
Member Author

bnussman-akamai commented Oct 2, 2024

Thanks for catching that @abailly-akamai

Should be fixed by d7ce808

I removed the autoHighlight prop on the Autocomplete in attempt to clean things up, which caused it to behave differently (caused it to not automatically select the first option). I re-added that, which should fix the test.

coliu-akamai
coliu-akamai previously approved these changes Oct 2, 2024
Copy link
Contributor

@coliu-akamai coliu-akamai left a comment

Choose a reason for hiding this comment

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

✅ confirmed can now update my timezone
✅ confirmed previously failing e2e passing locally now

thanks for the fix + cleanup! 🧹

Copy link
Contributor

@jdamore-linode jdamore-linode left a comment

Choose a reason for hiding this comment

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

Thanks for the catch and fix, @bnussman-akamai!

Copy link
Contributor

@abailly-akamai abailly-akamai left a comment

Choose a reason for hiding this comment

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

Thanks! Approving pending e2e passing

@coliu-akamai
Copy link
Contributor

all checks have passed - will be merging to staging! ty everyone 🚀

@coliu-akamai coliu-akamai merged commit ca5d0c9 into linode:staging Oct 2, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Fixes for regressions or bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants