Skip to content

Web: Add filters and pinning support for Enroll Resources page#51893

Merged
kimlisa merged 3 commits intomasterfrom
lisa/ui-pin-guides
Feb 14, 2025
Merged

Web: Add filters and pinning support for Enroll Resources page#51893
kimlisa merged 3 commits intomasterfrom
lisa/ui-pin-guides

Conversation

@kimlisa
Copy link
Copy Markdown
Contributor

@kimlisa kimlisa commented Feb 5, 2025

RFD that also links to figma

  • requires Wrap discover guide preference "pinned" field inside a proto message #52017

  • converted search bar to be type and enter like it is everywhere else

  • added filter dropdowns to filter by resource kind and hosting platform

  • added pinning support where users can pin any guides and it will be saved in user preference

    • if user initially had no pin preferences, it'll render default pins

play with filter in story: https://localhost:9002/?path=/story/teleport-discover-selectresource--all-access

demo:

double checking if that's the intended behavior (where it resets to default if you remove all pins)

Screen.Recording.2025-02-05.at.12.29.37.PM.mov

changelog: Add filter drop-downs and pinning support for the "Enroll a New Resource" page in the web UI

TODO in another PR:

  • consolidate linux tiles into one, and add them as part of default pins
  • add URL query param support and remove the use of url loc state
  • add responsiveness (remove the 1000 min width requirement)

@thedevelopnik
Copy link
Copy Markdown
Contributor

thedevelopnik commented Feb 5, 2025

The expected behavior is that it should respect the user's choices and if they unpin everything not to re-pin things. The default pins are meant for new users coming in to the system to draw attention to good places to start. If they are not new users, know what they want, and have elected to remove those, I think putting them back would be frustrating.

@zmb3
Copy link
Copy Markdown
Collaborator

zmb3 commented Feb 5, 2025

Why does there seem to be a full-page refresh if you remove the last pin?

@kimlisa
Copy link
Copy Markdown
Contributor Author

kimlisa commented Feb 5, 2025

Why does there seem to be a full-page refresh if you remove the last pin?

@zmb3 it was manual refresh, to demonstrate that default pins came back on reload, after unpinning everything. but i'll be changing this behavior (which will be a backend change and will be in another PR)

Comment thread web/packages/shared/components/UnifiedResources/shared/PinButton.tsx Outdated
Comment thread web/packages/teleport/src/Discover/SelectResource/SelectResource.tsx Outdated
Comment thread web/packages/teleport/src/Discover/SelectResource/SelectResource.tsx Outdated
Comment thread web/packages/teleport/src/Discover/SelectResource/Tile.tsx Outdated
Comment thread web/packages/shared/components/UnifiedResources/shared/PinButton.tsx Outdated
@kimlisa kimlisa requested a review from avatus February 7, 2025 00:36
@kimlisa kimlisa force-pushed the lisa/ui-pin-guides branch from d049177 to 3761d0b Compare February 7, 2025 00:42
Copy link
Copy Markdown
Contributor

@gzdunek gzdunek left a comment

Choose a reason for hiding this comment

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

First pass.

Comment thread web/packages/teleport/src/Discover/SelectResource/SelectResource.tsx Outdated
Comment thread web/packages/teleport/src/Discover/SelectResource/SelectResource.tsx Outdated
Comment thread web/packages/teleport/src/Discover/SelectResource/Tile.tsx Outdated
Comment thread web/packages/teleport/src/Discover/SelectResource/utils/pins.ts Outdated
Copy link
Copy Markdown
Contributor

@gzdunek gzdunek left a comment

Choose a reason for hiding this comment

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

I will test it tomorrow.

<StyledInput
{updateDiscoverPreferenceAttempt.status === 'error' && (
<Danger mt={5} details={updateDiscoverPreferenceAttempt.statusText}>
Could not update pinned resources:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(the details are rendered in a separate line)

Suggested change
Could not update pinned resources:
Could not update pinned resources

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

i was following the unified resources design:
image

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe it's a leftover from time when Alert couldn't display a title, so we needed a colon to separate it from the content. Now it can be removed.

Comment thread web/packages/teleport/src/Discover/SelectResource/SelectResource.tsx Outdated
Comment thread web/packages/teleport/src/Discover/SelectResource/Tile.tsx Outdated
Comment thread web/packages/teleport/src/Discover/SelectResource/icons.tsx Outdated
Comment thread web/packages/teleport/src/Discover/SelectResource/resources/keywords.ts Outdated
Comment thread web/packages/teleport/src/Discover/SelectResource/resources/types.ts Outdated
},
} as UserPreferences;

if (setPreferenceAfterSuccess) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why do we need it? Is updating pins here different from updating them in unified resources?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it was to prevent any render change when fetch failed, without this flag the function updated local preference despite error which would make it appear to have been successful

I could define another function similarly done for unified resources. Let me know what you prefer, i thought the flag made it more obvious that behavior can be different

also the pinned resources works a bit differently for unified resources, it keeps pinned resources in a cluster preference object which is a ref and it calls its own function to update, but the end behavior is the same though which is to render updated pinned state only after success

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure if this is worth making updatePreferences logic more complex. This function is used in many places, and the current behavior has worked fine so far - maybe it can stay the same here? My main concern is that it might not be obvious when setPreferenceAfterSuccess should be set.

Copy link
Copy Markdown
Contributor Author

@kimlisa kimlisa Feb 14, 2025

Choose a reason for hiding this comment

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

sure, i reverted the change and made a new function just for updating discover resource preference

@kimlisa kimlisa force-pushed the lisa/ui-pin-guides branch 2 times, most recently from e6833b3 to a30b299 Compare February 11, 2025 19:23
@kimlisa kimlisa requested a review from gzdunek February 11, 2025 19:23
Copy link
Copy Markdown
Contributor

@gzdunek gzdunek left a comment

Choose a reason for hiding this comment

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

With a few comments.

</Grid>
</Box>
)}
{filteredResources && filteredResources.length > 0 && (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
{filteredResources && filteredResources.length > 0 && (
{filteredResources.length > 0 && (

onChangeShowApp(showApp: boolean): void;
onSelectResource(selectedResourceSpec: SelectResourceSpec): void;
pinningSupport: PinningSupport;
onChangePinGuide(guideId: string): void;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We don't use guide in other props.

Suggested change
onChangePinGuide(guideId: string): void;
onChangePin(guideId: string): void;

<Flex alignItems="center" gap={2}>
<StyledText wantLargeTile={wantLargeTile}>{title}</StyledText>
{resourceSpec.hasAccess && (
<NewTabIcon color="text.muted" size={16} />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's use a predefined value ('small' in this case).

@@ -90,61 +111,125 @@ export function Tile({
// popup modal where it shows user to add app manually or automatically.
return (
<ResourceCard
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can add tabIndex={0} to make it navigable with keyboard.

},
} as UserPreferences;

if (setPreferenceAfterSuccess) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure if this is worth making updatePreferences logic more complex. This function is used in many places, and the current behavior has worked fine so far - maybe it can stay the same here? My main concern is that it might not be obvious when setPreferenceAfterSuccess should be set.

<StyledInput
{updateDiscoverPreferenceAttempt.status === 'error' && (
<Danger mt={5} details={updateDiscoverPreferenceAttempt.statusText}>
Could not update pinned resources:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I believe it's a leftover from time when Alert couldn't display a title, so we needed a colon to separate it from the content. Now it can be removed.

- Stop propagation and default behavior when clicking on pin button
- Add small or large icon option for discover icons
@kimlisa kimlisa enabled auto-merge February 14, 2025 05:50
@kimlisa kimlisa added this pull request to the merge queue Feb 14, 2025
Merged via the queue into master with commit 5c859a8 Feb 14, 2025
@kimlisa kimlisa deleted the lisa/ui-pin-guides branch February 14, 2025 06:13
@public-teleport-github-review-bot
Copy link
Copy Markdown

@kimlisa See the table below for backport results.

Branch Result
branch/v17 Failed

kimlisa added a commit that referenced this pull request Feb 14, 2025
* Minor changes

- Stop propagation and default behavior when clicking on pin button
- Add small or large icon option for discover icons

* Add pinning guide support

* Fix lint
carloscastrojumo pushed a commit to carloscastrojumo/teleport that referenced this pull request Feb 19, 2025
…tational#51893)

* Minor changes

- Stop propagation and default behavior when clicking on pin button
- Add small or large icon option for discover icons

* Add pinning guide support

* Fix lint
github-merge-queue Bot pushed a commit that referenced this pull request Feb 20, 2025
…52176)

* Web: make SelectResource.tsx component leaner (#51698)

* Web: Move resource specs into resource directory

* Web: move code out into separate files

* Web: define discover resource guide ids and add discover user preference field (#51672)

* Add discover resource preferences to user preferences

* Define hard coded guide id consts

* Set guide ids for resources

* Add test

* Address CRs

* Define a new type just for SelectResource.tsx which requires id field

* Wrap discover guide preference "pinned" field inside a proto message (#52017)

This allows us to use "nil" value to mean no discover
guide preferences set (which is used to set default
values in the web UI).

* Web: Add filters and pinning support for Enroll Resources page (#51893)

* Minor changes

- Stop propagation and default behavior when clicking on pin button
- Add small or large icon option for discover icons

* Add pinning guide support

* Fix lint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants