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

improve patterns selector #1248

Merged
merged 4 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions web/package/agama-web-ui.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu May 23 07:28:44 UTC 2024 - Josef Reidinger <jreidinger@suse.com>

- Fix showing count in pattern search and also improve visuals
when there are no matching text (gh#openSUSE/agama#1248)

-------------------------------------------------------------------
Wed May 22 14:26:18 UTC 2024 - Josef Reidinger <jreidinger@suse.com>

Expand Down
11 changes: 8 additions & 3 deletions web/src/components/software/PatternSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ function PatternSelector({ patterns, onSelectionChanged = noop }) {
</div>
);

const selector = sortGroups(groups).map((groupName) => {
let selector = sortGroups(groups).map((groupName) => {
const selectedIds = groups[groupName].filter((p) => p.selectedBy !== SelectedBy.NONE).map((p) =>
p.name
);
Expand All @@ -166,6 +166,12 @@ function PatternSelector({ patterns, onSelectionChanged = noop }) {
);
});

if (selector.length === 0) {
selector = (
<b>{_("None of the patterns match the text.")}</b>
);
}
jreidinger marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

@dgdavid dgdavid May 23, 2024

Choose a reason for hiding this comment

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

NP:

Sorry, I didn't realize before, but it is actually not needed to redefine the selector variable. You can just change {selector} to {selector.length ? selector : <NoResultFoundThing />} below. But don't worry and keep it as it is to minimize the conflicts with the new-ui branch.


return (
<>
<Section aria-label={_("Software summary and filter options")}>
Expand All @@ -176,8 +182,7 @@ function PatternSelector({ patterns, onSelectionChanged = noop }) {
value={searchValue}
onChange={(_event, value) => setSearchValue(value)}
onClear={() => setSearchValue("")}
// do not display the counter when search filter is empty
resultsCount={searchValue === "" ? 0 : groups.length}
resultsCount={visiblePatterns.length}
/>
</Section>

Expand Down
Loading