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
Support schema-grouped descriptors on operand details page #6103
Support schema-grouped descriptors on operand details page #6103
Conversation
Implement descriptor groups based on shared root path segment. Story: https://issues.redhat.com/browse/CONSOLE-2283 Sub-task: https://issues.redhat.com/browse/CONSOLE-2308
/kind enhancement |
@spadgett: The label(s) In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
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.
Thanks @TheRealJon. I had a few small comments, but nothing major. I'll go ahead and tag for merge.
/lgtm
switch (type) { | ||
case DescriptorType.spec: | ||
return ( | ||
<SpecDescriptorDetailsItem | ||
description={description} | ||
descriptor={descriptor} | ||
label={label} | ||
model={model} | ||
obj={obj} | ||
onError={onError} | ||
fullPath={fullPath} | ||
value={value} | ||
/> | ||
); | ||
case DescriptorType.status: | ||
return ( | ||
<StatusDescriptorDetailsItem | ||
description={description} | ||
descriptor={descriptor} | ||
label={label} | ||
model={model} | ||
obj={obj} | ||
onError={onError} | ||
fullPath={fullPath} | ||
value={value} | ||
/> | ||
); |
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.
Assuming the props are the same you could avoid some duplication with the following. TypeScript should still check the props.
switch (type) { | |
case DescriptorType.spec: | |
return ( | |
<SpecDescriptorDetailsItem | |
description={description} | |
descriptor={descriptor} | |
label={label} | |
model={model} | |
obj={obj} | |
onError={onError} | |
fullPath={fullPath} | |
value={value} | |
/> | |
); | |
case DescriptorType.status: | |
return ( | |
<StatusDescriptorDetailsItem | |
description={description} | |
descriptor={descriptor} | |
label={label} | |
model={model} | |
obj={obj} | |
onError={onError} | |
fullPath={fullPath} | |
value={value} | |
/> | |
); | |
const descriptorProps = { description, descriptor, label, model, obj, onError, fullPath, value }; | |
switch (type) { | |
case DescriptorType.spec: | |
return <SpecDescriptorDetailsItem {...descriptorProps} />; | |
case DescriptorType.status: | |
return <StatusDescriptorDetailsItem {...descriptorProps} />; |
); | ||
const description = root?.[0]?.description || propertySchema?.description; | ||
const label = root?.[0]?.displayName || propertySchema?.title || _.startCase(groupName); | ||
return descendants?.length > 0 ? ( |
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 would do this instead so I don't have to think about what undefined > 0
evaluates to.
return descendants?.length > 0 ? ( | |
return descendants?.length ? ( |
.set(StatusCapability.k8sResourcePrefix, K8sResourceLink) | ||
.set(StatusCapability.hidden, null); | ||
export const StatusDescriptorDetailsItem: React.FC<StatusCapabilityProps> = (props) => { | ||
const capability = _.get(props.descriptor, ['x-descriptors', 0], null) as StatusCapability; |
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.
nit: prefer optional chaining
const capability = _.get(props.descriptor, ['x-descriptors', 0], null) as StatusCapability; | |
const capability = props.descriptor?.['x-descriptors']?.[0] as StatusCapability; |
if (descriptor.path === 'conditions') { | ||
return descriptorAccumulator; | ||
} | ||
].find((def) => def.name === crd?.metadata?.name) ?? {}; |
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.
👍
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: spadgett, TheRealJon The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/kind feature |
Implement descriptor groups based on shared root path segment.
Story: https://issues.redhat.com/browse/CONSOLE-2283
Sub-task: https://issues.redhat.com/browse/CONSOLE-2308