-
Notifications
You must be signed in to change notification settings - Fork 1.3k
systemd: Expose primary service actions as direct buttons #23207
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
Open
andreahlert
wants to merge
1
commit into
cockpit-project:main
Choose a base branch
from
andreahlert:fix-service-actions-visibility
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| # Proposal: Expose primary service actions as direct buttons | ||
|
|
||
| **Related issue:** fixes #23060 | ||
|
|
||
| ## Problem | ||
|
|
||
| When a user opens a service detail page in Cockpit, the primary actions — **Start, Stop, Restart, Reload** — are hidden inside a three-dots (kebab) menu. Users frequently don't find them, as reported in #23060: | ||
|
|
||
| > *"I don't see any way to control the service. How come there's no way to start or stop or restart a service through the UI?"* | ||
| > — @kaiyoma | ||
|
|
||
| The user only discovered the actions after realizing they were tucked away in an overflow menu, concluding: *"hiding things in a three-dots menu is perhaps a bit silly."* | ||
|
|
||
| ## Proposed solution | ||
|
|
||
| Expose **primary actions** as direct `Button` components in the service header, while keeping **secondary actions** (Mask, Pin, Edit, Delete) inside the existing kebab menu. | ||
|
|
||
| ### Primary actions (direct buttons) | ||
| - **Start** — when service is inactive | ||
| - **Stop** — when service is active | ||
| - **Restart** — when service is active | ||
| - **Reload** — when service is active and supports reload | ||
|
|
||
| ### Secondary actions (kebab menu) | ||
| - Mask / Unmask | ||
| - Pin / Unpin | ||
| - Edit (custom timers) | ||
| - Delete (custom timers) | ||
| - Clear 'Failed to start' | ||
|
|
||
| ## UX rationale | ||
|
|
||
| This follows the PatternFly design guideline that **primary actions should be immediately visible**, while secondary or destructive actions can live in overflow menus. The service detail page has ample horizontal space on desktop, so there's no layout constraint forcing these actions into a menu. | ||
|
|
||
| ## Implementation sketch | ||
|
|
||
| ### `pkg/systemd/service-details.jsx` | ||
|
|
||
| 1. **Split `ServiceActions` into two components:** | ||
| - `ServicePrimaryActions` — renders Start/Stop/Restart/Reload as `Button` variants | ||
| - `ServiceActions` (renamed/refactored) — keeps Mask/Pin/Edit/Delete in the kebab menu | ||
|
|
||
| 2. **Update the render site (line ~714):** | ||
| ```jsx | ||
| { showAction && ( | ||
| <> | ||
| { !masked && !isStatic && ( | ||
| <Switch ... /> | ||
| )} | ||
| <ServicePrimaryActions ... /> | ||
| <ServiceSecondaryActions ... /> | ||
| </> | ||
| )} | ||
| ``` | ||
|
|
||
| 3. **Button variant mapping:** | ||
| - `Start` → `variant="primary"` | ||
| - `Restart` → `variant="secondary"` | ||
| - `Reload` → `variant="secondary"` | ||
| - `Stop` → `variant="danger"` (destructive action) | ||
|
|
||
| ## Visual mockup (before → after) | ||
|
|
||
| ### Before (current) | ||
| ``` | ||
| [Service Name] [Enable/Disable Switch] [⋮] | ||
| Start | ||
| Restart | ||
| Stop | ||
| -------- | ||
| Mask | ||
| Pin | ||
| ``` | ||
|
|
||
| ### After (proposed) | ||
| ``` | ||
| [Service Name] [Enable/Disable Switch] [Start] [Restart] [Stop] [⋮] | ||
| Mask | ||
| Pin | ||
| ``` | ||
|
|
||
| ## Scope & reversibility | ||
|
|
||
| - **Files touched:** `pkg/systemd/service-details.jsx`, potentially `service-details.scss` | ||
| - **Tests:** Update existing pixel tests and integration tests that look for the kebab menu | ||
| - **Risk:** Low — purely UI reorganization, no logic changes to systemd interaction | ||
| - **Reversible:** Yes — single commit revert | ||
|
|
||
| ## Next steps | ||
|
|
||
| 1. Await maintainer feedback on the approach | ||
| 2. If approved, implement the split and update tests | ||
| 3. Request pixel-test update from maintainers (CI-generated) | ||
|
|
||
| --- | ||
| *Author: @<your-github-username>* | ||
| *Based on discussion in #23060* | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,6 +111,44 @@ const ServiceConfirmDialog = ({ id, title, message, confirmText, confirmAction } | |
| * - disabled | ||
| * Button is disabled | ||
| */ | ||
| /** | ||
| * Primary service actions rendered as direct buttons (not in kebab menu). | ||
| * Addresses issue #23060: service actions are too hidden. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this comment can be dropped |
||
| */ | ||
| const ServicePrimaryActions = ({ masked, active, failed, canReload, actionCallback, disabled }) => { | ||
| if (masked) | ||
| return null; | ||
|
|
||
| return ( | ||
| <Flex spaceItems={{ default: 'spaceItemsSm' }}> | ||
| {active ? ( | ||
| <> | ||
| {canReload && ( | ||
| <Button variant="secondary" isDisabled={disabled} onClick={() => actionCallback("ReloadUnit")}> | ||
| {_("Reload")} | ||
| </Button> | ||
| )} | ||
| <Button variant="secondary" isDisabled={disabled} onClick={() => actionCallback("RestartUnit")}> | ||
| {_("Restart")} | ||
| </Button> | ||
| <Button variant="danger" isDisabled={disabled} onClick={() => actionCallback("StopUnit")}> | ||
| {_("Stop")} | ||
| </Button> | ||
| </> | ||
| ) : ( | ||
| <Button variant="primary" isDisabled={disabled} onClick={() => actionCallback("StartUnit")}> | ||
| {_("Start")} | ||
| </Button> | ||
| )} | ||
| {failed && ( | ||
| <Button variant="link" isDisabled={disabled} onClick={() => actionCallback("ResetFailedUnit", [])}> | ||
| {_("Clear failed")} | ||
| </Button> | ||
| )} | ||
| </Flex> | ||
| ); | ||
| }; | ||
|
|
||
| const ServiceActions = ({ masked, active, failed, canReload, actionCallback, editActionCallback, deleteActionCallback, fileActionCallback, disabled, isPinned, pinUnitCallback }) => { | ||
| const Dialogs = useDialogs(); | ||
|
|
||
|
|
@@ -711,6 +749,9 @@ export class ServiceDetails extends React.Component { | |
| onChange={this.onOnOffSwitch} /> | ||
| </Tooltip> | ||
| } | ||
| <ServicePrimaryActions { ...{ active, failed, masked } } canReload={this.props.unit.CanReload} | ||
| actionCallback={this.unitAction} | ||
| disabled={this.state.waitsAction || this.state.waitsFileAction} /> | ||
| <ServiceActions { ...{ active, failed, enabled, masked } } canReload={this.props.unit.CanReload} | ||
| actionCallback={this.unitAction} fileActionCallback={this.unitFileAction} | ||
| editActionCallback={isCustom && isTimer && this.state.cockpitManaged ? this.editTimerAction : null} | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
whatever this file is please drop it from the commit