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
Dev catalog- group by Operator #3758
Dev catalog- group by Operator #3758
Conversation
^ @openshift/team-devconsole-ux |
1c9ca32
to
7dc38a4
Compare
Summary of the points we discussed in our meeting:
|
9f90bd0
to
409eced
Compare
Done
Done
Added
Done. Using
Made the font regular. Using @serenamarie125 I have added a youtube link in the PR description. Please let me know if it looks good to you |
1c586dc
to
236e46e
Compare
8b72a4c
to
060f6c8
Compare
/cc @christianvogt |
|
||
const CATEGORY_URL_PARAM = 'category'; | ||
const KEYWORD_URL_PARAM = 'keyword'; | ||
export const FilterType = { |
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.
Use enum 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.
Better name it FilterTypes
.
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.
used const instead of enum because it's giving an error saying 'enum declarations' can only be used in a .ts file
cc @christianvogt
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.
oh haha... jsx... didn't pick up on that one :)
Time for an upgrade!
groupBy: 'groupBy', | ||
}; | ||
|
||
export const groupByTypes = { |
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.
Same as above.
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.
A better name for the enum would be GroupTypes
.
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.
Why not an enum?
export const FilterType = { | ||
category: 'category', | ||
keyword: 'keyword', | ||
groupBy: 'groupBy', |
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.
No need to use groupBy
everywhere.
groupBy: 'groupBy', | |
group: '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.
Grouping should not be a filter.
@@ -227,6 +235,17 @@ const filterByGroup = (items, filters) => { | |||
); | |||
}; | |||
|
|||
export const filterByGroupByDropdown = (items, groupBy) => { |
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.
export const filterByGroupByDropdown = (items, groupBy) => { | |
export const filterByGroup = (items, 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.
It's not really a filter though. It's a sort or grouping. I'd remove filter from this.
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.
Changed it to groupItems
if (groupBy === groupByTypes.Operator) { | ||
const installedOperators = _.filter(items, (item) => item.kind === 'InstalledOperator'); | ||
const nonOperators = _.filter(items, (item) => item.kind !== 'InstalledOperator'); | ||
const groupedOperators = _.groupBy(installedOperators, (item) => item.obj.csv.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.
Maybe we can sanitize the operator name somehow to make it look better on the UI. The title currently looks really odd.
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.
@rohitkrai03 Do you think the version is making it look odd? cc @serenamarie125
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.
@rohitkrai03 Let me know if this looks okay
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, this looks much better.
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.
Done
const installedOperators = _.filter(items, (item) => item.kind === 'InstalledOperator'); | ||
const nonOperators = _.filter(items, (item) => item.kind !== 'InstalledOperator'); | ||
const groupedOperators = _.groupBy(installedOperators, (item) => item.obj.csv.metadata.name); | ||
const groupAllItems = { ...groupedOperators, 'Non-Operators': nonOperators }; |
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.
Why add a hyphen in between when its a string?
const groupAllItems = { ...groupedOperators, 'Non-Operators': nonOperators }; | |
const groupAllItems = { ...groupedOperators, 'Non Operators': nonOperators }; |
@@ -310,10 +329,13 @@ const determineAvailableFilters = (initialFilters, items, filterGroups) => { | |||
return filters; | |||
}; | |||
|
|||
const getActiveFilters = (keywordFilter, groupFilters, activeFilters) => { | |||
const getActiveFilters = (keywordFilter, groupByFilter, groupFilters, activeFilters) => { |
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.
Oh, i see why you had to name it groupBy
everywhere.
groupBy: 'groupBy', | ||
}; | ||
|
||
export const groupByTypes = { |
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.
Why not an enum?
(value, key) => | ||
value.length > 0 && ( | ||
<> | ||
<div className="co-catalog-page__group-title"> |
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.
Use a standard header? h2
perhaps
className="catalog-tile-view-pf catalog-tile-view-pf-no-categories co-catalog-page__grid" | ||
> | ||
{_.map(value, (item) => ( | ||
<GalleryItem key={`gallery-${item.obj.metadata.uid}`}> |
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 isn't consistent with the other gallery item.
It's also duplicate code that should be extracted and reused.
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.
Moved this part to renderGalleryItem
and reusing it whereever required
</div> | ||
<Gallery | ||
gutter="sm" | ||
className="catalog-tile-view-pf catalog-tile-view-pf-no-categories co-catalog-page__grid" |
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.
Gallery shouldn't have co-catalog-page__grid
here.
) : ( | ||
<Gallery | ||
gutter="sm" | ||
className="catalog-tile-view-pf catalog-tile-view-pf-no-categories co-catalog-page__grid" |
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.
Move co-catalog-page__grid
to a parent div
so that this case and the grouping case use the same parent with this class.
if (filterType === FilterType.keyword) { | ||
updateURLParams(FilterType.keyword, `${value}`); | ||
} else if (filterType === FilterType.groupBy) { | ||
updateURLParams(FilterType.groupBy, `${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.
Grouping is not a filter and should be handled separately.
@@ -227,6 +235,17 @@ const filterByGroup = (items, filters) => { | |||
); | |||
}; | |||
|
|||
export const filterByGroupByDropdown = (items, groupBy) => { |
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.
It's not really a filter though. It's a sort or grouping. I'd remove filter from this.
activeFilters.groupBy.value = groupByFilter || ''; | ||
activeFilters.groupBy.active = !!groupByFilter; |
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'm confused. Group by does not actually filter anything, it only affects the visual appearance of the items.
This should not be mixed in with the filters on the page.
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.
@christianvogt Initially the ask was to display only the Installed Operators in groups. Later on when we decided to add the Non operators grouped together I should have updated the variable names which I missed
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.
moved it out of activeFilters
} else if (filterType === FilterType.groupBy) { | ||
_.set(activeFilters, 'groupBy.value', value); | ||
_.set(activeFilters, 'groupBy.active', !!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.
Grouping is not a filter.
export const FilterType = { | ||
category: 'category', | ||
keyword: 'keyword', | ||
groupBy: 'groupBy', |
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.
Grouping should not be a filter.
/assign @christianvogt I believe. |
3f4d64c
to
25a81b8
Compare
c0bb1d9
to
a47ee18
Compare
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.
/lgtm
/assign @christianvogt |
/test e2e-gcp-console |
/test analyze |
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 think we should look to also convert these to Typescript, but I believe there is a dependency on other public files, so perhaps that's out of scope for this work.
const selectedCategoryId = categoryParam || 'all'; | ||
|
||
const groupBy = searchParams.get('groupBy') || 'None'; |
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 use 'None'
quite a few times, please make it a constant to avoid the magic string disconnect.
<> | ||
<Title className="co-catalog-page__group-title" headingLevel="h2" size="lg"> | ||
{key} ({_.size(value)}) | ||
</Title> | ||
{this.renderItems(value, renderTile)} | ||
<br /> | ||
</> |
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 think this can be better represented with css rather than a br
. I think br
s are old fashioned and we lose the fidelity to control the gap.
Also, you lack the key
prop. Anytime you do map
you need to use the key
prop on returned JSX.
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 key prop
- removed
and added a css class to handle the space between the groups
a47ee18
to
10a7da9
Compare
10a7da9
to
d560995
Compare
@@ -467,10 +468,12 @@ const defaultFilters = { | |||
}, | |||
}; | |||
|
|||
const none = 'None'; |
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.
Not quite what I meant :) For one, this will fail the linter as it's defined after its use... For two, this won't help using two different variables to match. You either need to use this exclusively... or use the enum we talked about.
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.
Sorry for that. Now using groupByTypes.None
everywhere instead of 'None'
d560995
to
45dcc58
Compare
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.
/lgtm
/approve
I don't see any issues with the OperatorHub around this change. Looks good in the Catalog too. Will probably need a UX look-over at some point too.
/assign @christianvogt
/hold e2e tests are still failing, no need for the bot to hammer after it fails. |
/kind feature |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: andrewballantyne, christianvogt, debsmita1, rohitkrai03 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 |
/hold cancel |
/retest Please review the full test history for this PR and help us cut down flakes. |
This PR includes:
Group By
dropdown, in the Developer Catalog, withNone
andOperator
as optionsOperator
is selected then all the Installed Operators which are owned by a CSV are grouped together, and all the Non-Operators are grouped together separatelyRefer JIRA story: https://jira.coreos.com/browse/ODC-2452
Watch video here: https://youtu.be/lbXgLkb05uo
ToDo: