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

Support schema-grouped descriptors on operand details page #6103

Merged
merged 1 commit into from Jul 27, 2020

Conversation

TheRealJon
Copy link
Member

@TheRealJon TheRealJon commented Jul 24, 2020

Implement descriptor groups based on shared root path segment.

screenshot-localhost_9000-2020 07 24-17_23_25

Story: https://issues.redhat.com/browse/CONSOLE-2283
Sub-task: https://issues.redhat.com/browse/CONSOLE-2308

@openshift-ci-robot openshift-ci-robot added the component/core Related to console core functionality label Jul 24, 2020
@openshift-ci-robot openshift-ci-robot added the component/olm Related to OLM label Jul 24, 2020
@spadgett
Copy link
Member

/kind enhancement
/assign

@openshift-ci-robot
Copy link
Contributor

@spadgett: The label(s) kind/enhancement cannot be applied, because the repository doesn't have them

In response to this:

/kind enhancement
/assign

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.

@spadgett spadgett added this to the v4.6 milestone Jul 27, 2020
Copy link
Member

@spadgett spadgett left a 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

Comment on lines +19 to +45
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}
/>
);
Copy link
Member

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.

Suggested change
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 ? (
Copy link
Member

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.

Suggested change
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;
Copy link
Member

Choose a reason for hiding this comment

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

nit: prefer optional chaining

Suggested change
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) ?? {};
Copy link
Member

Choose a reason for hiding this comment

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

👍

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Jul 27, 2020
@openshift-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 27, 2020
@spadgett
Copy link
Member

/kind feature

@openshift-ci-robot openshift-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Jul 27, 2020
@openshift-merge-robot openshift-merge-robot merged commit c9ed2bb into openshift:master Jul 27, 2020
@spadgett spadgett linked an issue Dec 7, 2020 that may be closed by this pull request
@TheRealJon TheRealJon deleted the CONSOLE-2308 branch January 28, 2022 14:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/core Related to console core functionality component/olm Related to OLM kind/feature Categorizes issue or PR as related to a new feature. lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow grouping field in CR view
4 participants