Web: make SelectResource.tsx component leaner#51698
Merged
Conversation
f5de1b5 to
4088012
Compare
avatus
approved these changes
Jan 31, 2025
flyinghermit
approved these changes
Jan 31, 2025
rudream
approved these changes
Jan 31, 2025
kimlisa
added a commit
that referenced
this pull request
Feb 14, 2025
* Web: Move resource specs into resource directory * Web: move code out into separate files
ravicious
reviewed
Feb 14, 2025
| onSelectResource(resourceSpec); | ||
| }; | ||
|
|
||
| let resourceCardProps: ComponentPropsWithoutRef<'button' | typeof Link>; |
Member
There was a problem hiding this comment.
This does not work as expected, as Link is an untyped React component, so the props of it are just {[x: string]: any}. I tried removing unnecessary wrapping of Link in #51842 (as in StyledButtonLink can be exported directly as Link) and converting it to .tsx, but got stuck at this.
Ultimately handling the as prop is quite complex. Instead of assigning specific props to a var, perhaps it'd be easier to assign all children of ResourceCard to a separate var. Then the component could end with something like this:
if (something) {
return <ResourceCard {...sharedProps} foo="bar"…>{$children}</ResourceCard>
} else if (somethingElse) {
return <ResourceCard as={Link} {...sharedProps} baz="quux">{$children}</ResourceCard>
}This way we don't have to deal with providing a type for as at all and type should get inferred correctly.
carloscastrojumo
pushed a commit
to carloscastrojumo/teleport
that referenced
this pull request
Feb 19, 2025
* Web: Move resource specs into resource directory * Web: move code out into separate files
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
part of the
improve resource enrollment pageworkAll this PR does is make the
SelectResource.tsxleaner by moving things into own files and directories (so it's easier to work with).No implementation logic has been changed (just copy and pasta and some renames)