-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add optional component props to Roles component #51322
Conversation
777f0fc
to
12c4d7c
Compare
{roleDiffProps ? ( | ||
<roleDiffProps.RoleDiffComponent /> | ||
) : ( | ||
<Box maxWidth={promoImageWidth + 2 * 2} minWidth={300}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the diff is a bit wild on this one due to a lot of similar child components, but i didnt change anything with the structure of the Coming Soon box, just moved it into the tertiary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this part a separate component that is passed in as RoleDiffComponent
for the OSS version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can make it a separate component, sure. I didn't make it OSS only since e
clusters will still need this if TAG isn't enabled
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah fair enough. I think putting it in a separate component and importing it from e
makes it a bit more obvious what's happening on both the e and OSS side
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Ill update it
type RoleDiffProps = | ||
| { RoleDiffComponent?: undefined; updateRoleDiff?: undefined } | ||
| { | ||
RoleDiffComponent: React.FC; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ComponentType
{roleDiffProps ? ( | ||
<roleDiffProps.RoleDiffComponent /> | ||
) : ( | ||
<Box maxWidth={promoImageWidth + 2 * 2} minWidth={300}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this part a separate component that is passed in as RoleDiffComponent
for the OSS version?
// RoleDiffProps are an optonal set of props to render the role diff visualizer. | ||
// This type union will ensure that either all fields are undefined or all are supplied | ||
type RoleDiffProps = | ||
| { RoleDiffComponent?: undefined; updateRoleDiff?: undefined } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If roleDiffProps
is optional, why would I pass rollDiffProps={{}}
(which matches this type)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i think i might have overthought this one. updated to just make roleDiffProps
optional and typed the RoleDiffProps
normally
ccfeca0
to
0fafc92
Compare
</Flex> | ||
</Flex> | ||
); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just moved from the adapter component, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
@@ -48,15 +48,25 @@ import { RoleList } from './RoleList'; | |||
import templates from './templates'; | |||
import { State, useRoles } from './useRoles'; | |||
|
|||
export function RolesContainer() { | |||
// RoleDiffProps are an optonal set of props to render the role diff visualizer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// RoleDiffProps are an optonal set of props to render the role diff visualizer. | |
// RoleDiffProps are an optional set of props to render the role diff visualizer. |
// RoleDiffProps are an optonal set of props to render the role diff visualizer. | ||
type RoleDiffProps = { | ||
RoleDiffComponent: ComponentType; | ||
updateRoleDiff: (role: Role) => Promise<void>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a property that will be used in future, or something that you forgot to remove?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the updateRoleDiff
method is what will be passed down to RoleEditorAdapter
as a callback for when the standardModel
updates (or yaml is previewed)
@@ -320,6 +320,11 @@ export class FeatureRoles implements TeleportFeature { | |||
}; | |||
|
|||
showInDashboard = true; | |||
// getRoute allows child class extending this | |||
// parent class to refer to this parent's route. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that every feature class has this, but I'm still confused right now how the presence of this function makes the route
field more accessible. What's wrong with super.route
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
honestly idk. super.route wasn't functioning so i just followed prior work and moved on without diving in too deep. i did try that first tho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can only access super's methods, not properties (unless the route was defined in the constructor, then this.route
would work)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL. any class stuff ive ever done has ALWAYS had the stuff defined in the constructor so i guess thats why i never noticed
f1a01d3
to
cb23986
Compare
94d42c5
to
0cc8244
Compare
This PR enables us to add an optional RoleDiff component to the props for our Roles feature so that we can create an "e wrapper" around the Roles feature for enterprise specifically. Then we can pass the Role Diff visualizer into the E route.
0cc8244
to
c2ab0f2
Compare
This PR enables us to add an optional RoleDiff component to the props for our Roles feature so that we can create an "e wrapper" around the Roles feature for enterprise specifically. Then we can pass the Role Diff visualizer into the E route.
Adds support (for this stub) in https://github.com/gravitational/teleport.e/pull/5902