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

UI - use new db user settings to persist user's host table column preferences #25185

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

Conversation

jacobshandling
Copy link
Contributor

@jacobshandling jacobshandling commented Jan 6, 2025

For #25032

Screenshot 2025-01-07 at 6 50 39 PM
  • Add new include_ui_settings query param to GET /me calls

  • Use new settings in response to set settings into UI context

  • On hosts page, use that context, if present, to set which columns are hidden. Fallback to a default set of hidden columns.

  • When updating visible columns, persist preference via PATCH to /users/:id with a new settings payload

  • Changes file added for user-visible changes in changes/

  • Manual QA for all new/changed functionality

Copy link

codecov bot commented Jan 6, 2025

Codecov Report

Attention: Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.

Project coverage is 63.84%. Comparing base (cac3e2f) to head (472498b).
Report is 24 commits behind head on main.

Files with missing lines Patch % Lines
frontend/context/app.tsx 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #25185      +/-   ##
==========================================
- Coverage   63.85%   63.84%   -0.01%     
==========================================
  Files        1616     1616              
  Lines      153833   153847      +14     
  Branches     3939     3993      +54     
==========================================
- Hits        98231    98229       -2     
- Misses      47789    47805      +16     
  Partials     7813     7813              
Flag Coverage Δ
frontend 53.20% <0.00%> (-0.08%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jacobshandling jacobshandling force-pushed the 25032-user-settings-frontend branch from 773cdf3 to cd8e467 Compare January 8, 2025 01:24
@jacobshandling jacobshandling marked this pull request as ready for review January 8, 2025 01:24
@jacobshandling jacobshandling requested a review from a team as a code owner January 8, 2025 01:24
@@ -675,27 +675,24 @@ const generateAvailableTableHeaders = ({
return allHostTableHeaders.reduce(
(columns: Column<IHost>[], currentColumn: Column<IHost>) => {
// skip over column headers that are not shown in free observer tier
if (isFreeTier && isOnlyObserver) {
if (isFreeTier) {
Copy link
Contributor Author

@jacobshandling jacobshandling Jan 8, 2025

Choose a reason for hiding this comment

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

All changes in this file are cleanup, no logic updates

Copy link
Contributor

@sgress454 sgress454 left a comment

Choose a reason for hiding this comment

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

Tested locally, works great 👍

Can you say more about the updates to the registration and team management pages?

Comment on lines -178 to -181
const hostHiddenColumns = localStorage.getItem("hostHiddenColumns");
const storedHiddenColumns = hostHiddenColumns
? JSON.parse(hostHiddenColumns)
: null;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit torn on this, as it means breaking existing functionality for users. I confirmed that we're not clearing localstorage on logout, so the columns do persist between sessions (just not between browsers, or in incognito mode). On the other hand we wouldn't want to support this forever as eventually everyone will be using the new strategy. If it sparks a riot we can put it back in a patch, but likely no one will notice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was my thinking too. We could include fallback behavior to use local storage, but I don't really see the scenario where the user has logged in, is actively using Fleet, and suddenly the server is somehow unavailable for this specific functionality.

Copy link
Contributor

Choose a reason for hiding this comment

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

I wasn't think of it as fallback behavior as much as, people right now have their columns set up and they're going to disappear when this deploys.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Aaah, I see

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need a UI migration 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could, in this initial rollout, check for local storage settings, and if present, immediately send them to the server to persist and set them as current UI context, then down the line remove that code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(or not remove it I suppose, but there would be no reason for anything to present in local storage after not too long)

Copy link
Contributor

Choose a reason for hiding this comment

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

We could, in this initial rollout, check for local storage settings, and if present, immediately send them to the server to persist and set them as current UI context, then down the line remove that code

This is probably the way. It seems a bit heavy handed but considering the original ask, we'd ideally like the user to see the columns they expect and then also see them in another browser / incognito mode, without having to do any action to trigger persistence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds like a plan

@jacobshandling
Copy link
Contributor Author

Can you say more about the updates to the registration and team management pages?

@sgress454 since they're already making calls to the /me endpoint, figured might as well update the settings context with those responses while we're getting them, nothing more specific than that.

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

Successfully merging this pull request may close these issues.

2 participants