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

Allow EmptyStatePanel actions to be of a different variant #20763

Merged
merged 9 commits into from
Jul 17, 2024

Conversation

jelly
Copy link
Member

@jelly jelly commented Jul 15, 2024

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:

image

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

image

No logs found now shows:

image

@jelly jelly requested a review from martinpitt July 15, 2024 14:31
Copy link
Member

@martinpitt martinpitt left a 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" }) => {
Copy link
Member

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?

Copy link
Member Author

@jelly jelly Jul 16, 2024

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")}
Copy link
Member

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/systemd/logsJournal.jsx Show resolved Hide resolved
@@ -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('')} />}
Copy link
Member

Choose a reason for hiding this comment

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

overly long line?

@jelly jelly force-pushed the empty-state-secondary branch from 0b6a69f to 17275e0 Compare July 16, 2024 09:48
@jelly jelly changed the title Make EmptyStatePanel actions a link by default Allow EmptyStatePanel actions to be of a different variant Jul 16, 2024
@jelly jelly force-pushed the empty-state-secondary branch 3 times, most recently from bb84c30 to 0101699 Compare July 16, 2024 15:37
@jelly jelly requested a review from martinpitt July 17, 2024 07:03
martinpitt
martinpitt previously approved these changes Jul 17, 2024
Copy link
Member

@martinpitt martinpitt left a comment

Choose a reason for hiding this comment

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

Thanks! Good cleanups!

pkg/systemd/logsJournal.jsx Outdated Show resolved Hide resolved
jelly added 9 commits July 17, 2024 11:23
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.
@garrett
Copy link
Member

garrett commented Jul 17, 2024

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.

image

@@ -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}
Copy link
Contributor

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}
Copy link
Contributor

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" />}
Copy link
Contributor

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.

@martinpitt martinpitt merged commit 516c155 into cockpit-project:main Jul 17, 2024
75 of 77 checks passed
@jelly jelly deleted the empty-state-secondary branch July 17, 2024 13:09
@martinpitt martinpitt mentioned this pull request Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants