-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Allow EmptyStatePanel actions to be of a different variant #20763
Conversation
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, nice cleanups! No strong opinion about the changed button type default, but is it worth silently breaking/changing all our projects for this?
(Also, still several test failures)
@@ -24,7 +24,7 @@ import { EmptyStateActions, EmptyState, EmptyStateBody, EmptyStateFooter, EmptyS | |||
import { Spinner } from "@patternfly/react-core/dist/esm/components/Spinner/index.js"; | |||
import "./cockpit-components-empty-state.css"; | |||
|
|||
export const EmptyStatePanel = ({ title, paragraph, loading, icon, action, isActionInProgress = false, onAction, secondary, headingLevel = "h1" }) => { | |||
export const EmptyStatePanel = ({ title, paragraph, loading, icon, action, isActionInProgress = false, onAction, actionVariant = "link", secondary, headingLevel = "h1" }) => { |
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.
Is the "most of the time" based on actual counting or gut feeling? We use this a lot, also in podman/machines, and I feel the other way around. I.e. keep the "primary" default, and make it link or secondary etc. in the new places where we need it?
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 indeed a backwards incompatible change, this whole panel is abused or used wrong :)
<EmptyStatePanel title={ cockpit.format(_("VM $0 does not exist on $1 connection"), cockpit.location.options.name, cockpit.location.options.connection) }
action={
<Button variant="link"
onClick={() => cockpit.location.go(["vms"])}>
{_("Go to VMs list")}
</Button>
}
So Garrett's two cents where, most of the time you want a link (primary should be the exception), but I am also fine to make this non-breaking, that is better imo.
action={ name ? _("Start service") : null } | ||
action={_("Start service")} |
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 was clearly meant to be nmService.name
-- if it doesn't exist, we can't start it.
pkg/users/accounts-list.js
Outdated
@@ -338,7 +338,7 @@ const GroupsList = ({ groups, accounts, isExpanded, setIsExpanded, min_gid, max_ | |||
rows={ filtered_groups.map(a => getGroupRow(a, accounts)) } | |||
loading={ groups.length && accounts.length ? '' : _("Loading...") } | |||
sortMethod={sortRows} | |||
emptyComponent={<EmptyStatePanel title={_("No matching results")} icon={SearchIcon} />} | |||
emptyComponent={<EmptyStatePanel title={_("No matching results")} icon={SearchIcon} action={_("Clear filter")} onAction={() => setCurrentTextFilter('')} />} |
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.
overly long line?
0b6a69f
to
17275e0
Compare
bb84c30
to
0101699
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.
Thanks! Good cleanups!
For actions such as clearing the search filter, the action is not a primary one but optional for such actions it is expected to be a link.
The `name` variable is implicitly defined as `window.name` which is deprecated but also likely unintended, instead it should check if the networkmanager service exists.
The property actionInProgressText does not exist and never has for the EmptyStatePanel so drop it. When the user clicks on `Load earlier entries` show the EmptyStatePanel in loading state.
Loading is false is the default property value.
Allow users to clear the current search filter from the EmptyStatePanel.
Looks great overall! Thanks for addressing this, @jelly As discussed in Matrix, let's revert the button at the end of the list, as it gets a bit lost with so much text above it. (This is one of those cases it could go either way, but the deemphasis makes it less obvious here.) Additionally, unrelated to the changes in this commit, we should do a follow-up fix for the headings here. When there's no content, there should also be no headings. |
0101699
to
f2943bf
Compare
@@ -75,7 +75,7 @@ const App = () => { | |||
<div id="networking-nm-crashed"> | |||
<EmptyStatePanel icon={ ExclamationCircleIcon } | |||
title={ _("NetworkManager is not running") } | |||
action={ name ? _("Start service") : null } | |||
action={nmService.exists ? _("Start service") : null} |
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 added line is not executed by any test.
@@ -99,7 +99,7 @@ const App = () => { | |||
<div id="networking-nm-disabled"> | |||
<EmptyStatePanel icon={ ExclamationCircleIcon } | |||
title={ _("Network devices and graphs require NetworkManager") } | |||
action={ name ? _("Enable service") : null } | |||
action={nmService.exists ? _("Enable service") : null} |
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 added line is not executed by any test.
@@ -338,7 +338,8 @@ const GroupsList = ({ groups, accounts, isExpanded, setIsExpanded, min_gid, max_ | |||
rows={ filtered_groups.map(a => getGroupRow(a, accounts)) } | |||
loading={ groups.length && accounts.length ? '' : _("Loading...") } | |||
sortMethod={sortRows} | |||
emptyComponent={<EmptyStatePanel title={_("No matching results")} icon={SearchIcon} />} | |||
emptyComponent={<EmptyStatePanel title={_("No matching results")} icon={SearchIcon} action={_("Clear filter")} | |||
onAction={() => setCurrentTextFilter('')} actionVariant="link" />} |
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 added line is not executed by any test.
This changes the EmptyStatePanel action to a link by default, retaining the primary button where the action is almost always guaranteed to be clicked (starting networkmanager for example).
Adds an action to the user/groups emptystate:
Makes the logs
load earlier data
show a spinner after clicking:Screencast.from.2024-07-15.16-30-12.webm
And further cleans up API usage, and a small typing improvement.
Empty state now shows a link
No logs found now shows: