-
Notifications
You must be signed in to change notification settings - Fork 667
Update Inventory card design #2601
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
Conversation
rawagner
commented
Sep 5, 2019
- every item shows maximum of 3 most important statuses
- item title is link to resource page
- use skeleton loading

|
/hold |
|
Nice, looks great! 🎉 |
247309c to
1eac0d1
Compare
1eac0d1 to
6fcf25d
Compare
|
lgtm, blocked on missing 4.3 branch |
6fcf25d to
4518c7a
Compare
27981b1 to
ee7a63d
Compare
| @@ -13,3 +16,7 @@ export const getRouteStatusGroups: StatusGroupMapper = (resources) => ({ | |||
| export const DemoGroupIcon: React.FC<{}> = () => ( | |||
| <AddressBookIcon className="co-inventory-card__status-icon co-inventory-card__status-icon--warn" /> | |||
| ); | |||
|
|
|||
| export const ExpandedRoutes: React.FC<ExpandedComponentProps> = ({ resource }) => ( | |||
| <div>additional content for {resource.length} routes</div> | |||
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: shouldn't we capitalize the word "additional" ?
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.
Capitalized :)
| @@ -118,6 +121,8 @@ namespace ExtensionProperties { | |||
|
|
|||
| /** Function which will map various statuses to groups. */ | |||
| mapper: StatusGroupMapper; | |||
|
|
|||
| expandedComponentLoader?: LazyLoader<ExpandedComponentProps>; | |||
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.
Please avoid the Loader suffix.
The way how React components are referenced from extension's properties object shouldn't affect the property name. Let's keep things short and simple.
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.
ok, removed
| @@ -126,6 +131,9 @@ namespace ExtensionProperties { | |||
|
|
|||
| /** React component representing status group icon. */ | |||
| icon: React.ReactElement; | |||
|
|
|||
| /** Priority of inventory group */ | |||
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.
Please document the practical impact of this property, e.g. groups with higher prio are rendered before groups with lower prio. This is especially important in case of non-optional extension properties.
Also, does it make sense to have priority optional here? We should keep the mandatory set of extension properties small and use reasonable defaults whenever possible.
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.
Ok, i guess this is not really needed. I removed the whole priority thing.
The ordering of statuses are as follows:
error, warning, progress, ...whatever is defined by plugin, unknown
| display: flex; | ||
| font-size: 1rem; | ||
| justify-content: space-between; | ||
| padding: 1em var(--pf-c-card--child--PaddingRight) 1em var(--pf-c-card--child--PaddingLeft); | ||
| line-height: 1.5rem; | ||
| padding: 1rem var(--pf-c-card--child--PaddingRight) 1rem var(--pf-c-card--child--PaddingLeft); |
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.
Just curious, the var(x) expression is the standard CSS way of handling variables, equivalent to Sass $x expressions? If so, we should favor the new CSS way to handle variables, right?
Also, what is the rationale behind var(--pf-x) instead of non-prefixed var(pf-x) ?
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 couldnt find variable in scss form that I could use. Also patternfly-react is using these in same way.
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.
OK, so I guess $pf-stuff comes from PF3 (Sass) and var(--pf-stuff) comes from PF4, is that 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, correct
| &::after { | ||
| background-repeat: no-repeat; | ||
| content:""; | ||
| display:block; |
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: missing space after : in lines above, and possibly on other places too.
Since we don't use Stylelint (yet) we can't check this in an automated way.
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.
fixed
| flags = {}, | ||
| ExpandedComponent, | ||
| }) => { | ||
| const TitleComponent = React.useCallback((props) => ( |
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 interesting, why React.useCallback and not React.memo here?
Is it because of explicit dependency control declared through array [kind, namespace] ?
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 define dependencies for React.memo too. But React.memo returns value of memoized function, React.useCallback returns memoized function (not its 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.
Great, thanks for explaining this.
| export type StatusGroupMapper = ( | ||
| resources: K8sResourceKind[], | ||
| additionalResources?: {[key: string]: K8sResourceKind[]}, | ||
| ) => {[key in InventoryStatusGroup | string]: {filterType?: string, statusIDs: string[], count: number}}; |
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: please extract return type into separate type declaration.
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.
fixed
| count: number; | ||
| children?: React.ReactNode; | ||
| error: boolean; | ||
| TitleComponent?: React.ComponentType<any>; | ||
| ExpandedComponent?: React.ComponentType<any>; |
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: ComponentType<P = {}> has fallback to {} so do we really need an explicit any type parameter?
I think that {} is a better (more sensible) type fallback than any when it comes to React component props.
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.
ok, i wasnt sure which is better..using ComponentType<{}>
| } | ||
|
|
||
| export const inventoryStatusGroupPriority = { |
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.
When specifying priority value in the plugin, can we import this and do something like
inventoryStatusGroupPriority[InventoryStatusGroup.PROGRESS] + some_offsetinstead of hard-coded numbers everywhere? This also creates a link to base priority values and therefore improves the understanding of extension's impact.
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.
sounds good, using offest values now
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.
since I removed at at the end..this is irrelevant now
| const pvcsLoadError = _.get(resources.pvcs, 'loadError'); | ||
| const pvcsData = _.get(resources.pvcs, 'data', []) as K8sResourceKind[]; | ||
| const ExpandedComponent = React.useCallback(() => | ||
| <AsyncComponent loader={expandedComponentLoader} resource={resourceData} additionalResources={additionalResourcesData} /> |
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: the line seems too long, please split the JSX expression onto multiple lines.
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.
fixed
f417d56 to
48b3a2f
Compare
| @@ -118,6 +121,8 @@ namespace ExtensionProperties { | |||
|
|
|||
| /** Function which will map various statuses to groups. */ | |||
| mapper: StatusGroupMapper; | |||
|
|
|||
| expandedComponent?: LazyLoader<ExpandedComponentProps>; | |||
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.
Please add a brief description here.
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.
added
| display: flex; | ||
| font-size: 1rem; | ||
| justify-content: space-between; | ||
| padding: 1em var(--pf-c-card--child--PaddingRight) 1em var(--pf-c-card--child--PaddingLeft); | ||
| line-height: 1.5rem; | ||
| padding: 1rem var(--pf-c-card--child--PaddingRight) 1rem var(--pf-c-card--child--PaddingLeft); |
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.
OK, so I guess $pf-stuff comes from PF3 (Sass) and var(--pf-stuff) comes from PF4, is that right?
e245031 to
c519a4e
Compare
|
/lgtm |
|
/retest Please review the full test history for this PR and help us cut down flakes. |
|
/hold |
c519a4e to
bf479dd
Compare
- every item shows maximum of 3 most important statuses - item title is link to resource page - use skeleton loading - item can be expanded
bf479dd to
6e83d03
Compare
|
/hold cancel |
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mareklibra, rawagner, vojtechszocs The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |

