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

packagekit: Add "Reboot after completion" switch to update progress page #17500

Merged
merged 2 commits into from Jul 13, 2022

Conversation

martinpitt
Copy link
Member

@martinpitt martinpitt commented Jun 24, 2022

This allows users to start a manual update and queue a reboot without
having to babysit the progress.

Rework the progress page layout a bit:

  • Use a Grid layout, so that the update log has the same alignment than
    the progress bar.

  • Stop centering the "Cancel" button, which was a bit dubious wrt. PF
    recommendations anyway. Show it to the right of the progress bar
    instead.

  • Hide the cancel button instead of disabling it, once cancellation is
    not allowed any more.

  • Rename "Update log" to "View update log" to clarify what the action
    means.

  • Increase the spinner size, to make it easier to see.

https://bugzilla.redhat.com/show_bug.cgi?id=2056786


Software Updates: Optionally reboot after updating

The update progress page offers you to reboot the machine after applying updates succeeded. If the machine can be rebooted without careful planning, this avoids having to wait and do another interactive step.

image

@martinpitt martinpitt temporarily deployed to cockpit-dist June 24, 2022 19:51 Inactive
@martinpitt martinpitt temporarily deployed to cockpit-dist June 26, 2022 18:02 Inactive
@martinpitt
Copy link
Member Author

I fixed this one locally, just didn't push yet -- let's wait for the CSS fix.

@garrett
Copy link
Member

garrett commented Jun 27, 2022

Mockup:

updates-reboot

When you can no longer cancel, the button could just disappear (visibility: hidden, not display: none)

@garrett
Copy link
Member

garrett commented Jun 28, 2022

The button could still be set to disabled and we could have something like

.the-update-ui-thing-here .pf-c-button[disabled] {
   visibility: hidden;
}

(The names of the classes would probably be different, especially that first one. 😉)

Or better yet, add a special class to the button (like software-update-cancel in this example, but pick whatever would fit best with the existing CSS names), then still disable the button the normal PF way:

.software-update-cancel[disabled] {
   visibility: hidden;
}

@martinpitt
Copy link
Member Author

Meh, this is really painful. I'm trying to use a Flex to put the progress bar and cancel button side by side, and the closest I got was this mess:

image

(yes, other ways of nesting them looked even more broken). ProgressBar isn't really designed to contain actions associated to it. If we want to do that, I think we'll have to dissect the React component and reimplement it ourselves.

@garrett
Copy link
Member

garrett commented Jun 30, 2022

Either use a flex for just the progress bar and the cancel button, with align-items: baseline (there's a PF way of doing this too) and keep upgrade log out of it completely.

Or use grid for all the elements, but then the update log would have to span across the bottom cell.

I'd suggest using flex; it's simpler in this case.

@garrett
Copy link
Member

garrett commented Jun 30, 2022

Oh, I'm looking at the code and the status around the progress bar is implemented in HTML instead of a PF component?

                <div className="progress-description">
                    <Spinner isSVG size="sm" />
                    <strong>{ PK_STATUS_STRINGS[lastAction.status] || PK_STATUS_STRINGS[PK.Enum.STATUS_UPDATE] }</strong>
                    &nbsp;{lastAction.package}
                </div>
                <Progress title={formatTimeRemaining} value={percentage} />

This should be inside an element, separate from the others. It could/should probably be part of the PF component. (Although perhaps there's a reason it isn't? Is it because it needs to be updated and PF might allow for that?)

@garrett
Copy link
Member

garrett commented Jun 30, 2022

I tried this, but haven't been able to test it yet:

        <>
            <Flex className="progress-main-view">
                <FlexItem>
                    <div className="progress-description">
                        <Spinner isSVG size="sm" />
                        <strong>{PK_STATUS_STRINGS[lastAction.status] || PK_STATUS_STRINGS[PK.Enum.STATUS_UPDATE]}</strong>
                        &nbsp;{lastAction.package}
                    </div>
                    <Progress title={formatTimeRemaining} value={percentage} />
                </FlexItem>
                <FlexItem>{cancelButton}</FlexItem>
            </Flex>

            <Switch id="reboot-after" isChecked={rebootAfter}
                    label={ _("Reboot after completion") }
                    onChange={setRebootAfter} />

            <div className="update-log">
...

Update from pitti: Looks like this, almost the same (just the Update log is better):

127 0 0 2_9091_updates

@garrett
Copy link
Member

garrett commented Jun 30, 2022

Something like this:

  <Flex flexWrap={{ default: 'nowrap' }} alignItems={{ default: 'alignItemsFlexEnd'}}>
    <FlexItem grow={{ default: 'grow' }}>Progress</FlexItem>
    <FlexItem>Cancel</FlexItem>
  </Flex>

Update from pitti: That is already a lot more promising! The "Update log" begins to move to the right on wide screen sizes, so I captured a wide one. It's on the left margin on narrower widths.

127 0 0 2_9091_updates

Unfortunately I seem unable to capture a proper HTML/CSS dump of this. Chromium's "Save as" is broken (clicking it doesn't do anything), Firefox' "save complete webpage" reloads the page from the server and thus just gets a "cockpit is not installed" error message. So I copied the outer page HTML from the whole frame, updates.html.gz and updates.css.gz (gzipped so that I can attach them here).

I can load updates.html into a new browser tab, and aside from the wrong fonts this looks quite faithful.

@martinpitt
Copy link
Member Author

@garrett : I updated your two comments from above. Is that helpful in any way?

@garrett
Copy link
Member

garrett commented Jun 30, 2022

The first suggestion is exactly the same as the second suggestion, BTW. The second one is abstracted and has some alignment and size attributes. The first drops the wrapper though, whereas the second one needs to be within it, I guess and is why it's going too wide in your screenshot?

In other words: Go with the second; make sure it's within the wrapper (as it looks like it isn't). I didn't consider the CSS and layout overall when suggesting the things, as I can't even look at it (as all updates are just too fast and I cannot pause them).

@martinpitt
Copy link
Member Author

@garrett: The main difference is the grow={{ default: 'grow' }} bit, which causes the progress bar to be reasonably wide again, instead of being squeezed so narrow.

@martinpitt
Copy link
Member Author

This is an absolute nuisance to develop on right now, due to the broken page reload. That gets stuck forever on the "Initializing.." empty state, instead of properly re-attaching to a running upgrade. That's also quite a major regression, so I'm going to look at that one first.

@martinpitt
Copy link
Member Author

I sent PR #17517 for the issue above, and also included the general code cleanups, so that this one will become less noisy. I'd like to block on that, so that developing this change gets easy. Right now you'll have to restart the VM and re-upload the changed code for each iteration.

@martinpitt
Copy link
Member Author

@garrett : I tweaked the CSS for the cancel button and reboot switch to be center-aligned, and updated the screenshot.

@martinpitt martinpitt requested a review from garrett July 11, 2022 12:39
@martinpitt martinpitt temporarily deployed to cockpit-dist July 11, 2022 12:40 Inactive
@martinpitt
Copy link
Member Author

@garrett : This can be tested with sitting here:

--- test/verify/check-packagekit
+++ test/verify/check-packagekit
@@ -975,6 +978,7 @@ ExecStart=/usr/local/bin/{packageName}
         b.wait_visible("#app div.pf-c-progress__bar")
         # auto-reboot is off by default
         b.wait_visible("#reboot-after:not(:checked)")
+        sit()
         b.click("#reboot-after")
         b.wait_visible("#reboot-after:checked")

and running

test/verify/check-packagekit -stv TestUpdates.testRebootAfterSuccess

Due to the recent fix, the page can now be reloaded, or you can even log in from another browser. This makes tools/webpack-watch -r c packagekit work against the running VM from the test, and thus it's a lot simpler and faster to iterate.

@garrett
Copy link
Member

garrett commented Jul 11, 2022

So the cancel button is underneath when I look at this PR?

Also, the update log expander is outside of the constraint and should be inside (aligned to the same place as the start of the progress bar).

image

@martinpitt
Copy link
Member Author

@garrett : Right; I've fought with the cancel button for two hours to try and get it to the right of the progress bar in a sensible manner. I got all kinds of "ridiculously broken" and then gave up and left it where it is.

Agreed about the update log -- that's the status quo (I didn't touch that), I am happy to look at that in a separate PR. It's not super-easy to do (that whole page is a big soup of flex and custom layout..).

@garrett
Copy link
Member

garrett commented Jul 11, 2022

Agreed about the update log -- that's the status quo (I didn't touch that), I am happy to look at that in a separate PR. It's not super-easy to do (that whole page is a big soup of flex and custom layout..).

This makes it sound like it's using nested flexes and should really be using a grid overall. (We'd need a grid object toplevel and then all major components at the immediate next-level.) With a lot of items, especially more than just in a line, grid is usually less fiddly to get what's wanted.

The order is really weird, wrong, and confusing with the cancel and the toggle button like this. 😢 Otherwise I'd say add it in an do some follow-ups. But it's just so wrong as-is that I think we shouldn't split it apart.

@garrett
Copy link
Member

garrett commented Jul 11, 2022

If you can get all the components into one level, I can construct a grid that works.

The grid would basically be:

progress cancel
action
log

(Log itself could be the expander + log, or we could have expander and log as separates parts of the grid. It doesn't matter.)

@martinpitt
Copy link
Member Author

martinpitt commented Jul 12, 2022

With a grid, it looks like this now while cancelling is allowed:

image

and once it's not allowed, the button disappears:

image

With isSmall button:

image

@martinpitt
Copy link
Member Author

@garrett : I updated the commit message and "official" (relnote) screenshot in the description, and the three screenshots above to the current grid-based design. WDYT?

@martinpitt martinpitt temporarily deployed to cockpit-dist July 12, 2022 10:35 Inactive
@martinpitt
Copy link
Member Author

oh, right -- this is a race condition now. We would need to somehow postpone the downloading, or drop that check.

@garrett
Copy link
Member

garrett commented Jul 12, 2022

@garrett : I updated the commit message and "official" (relnote) screenshot in the description, and the three screenshots above to the current grid-based design. WDYT?

Oh, did you try what I suggested on IRC?

Use smaller progress bar, add sm margin to the bottom. This would not just thin the bar, but replace some of its thickness with space. This means that the cancel button would probably line up a little better.

It'd look like this:

image

It's something like this (making sure you have the sizing utility classes loaded):

 <Progress size={ProgressSize.sm} className="pf-u-mb-sm" />

https://www.patternfly.org/v4/utilities/spacing

@martinpitt martinpitt temporarily deployed to cockpit-dist July 12, 2022 13:53 Inactive
@martinpitt
Copy link
Member Author

martinpitt commented Jul 13, 2022

@garrett : Thanks for the hint! That's how it looks with a small (thin) progress bar and the sm margin:

Screen Shot 2022-07-13 at 13 24 30

This is how it would look with standard progress size and just the sm border on the bottom:

Screen Shot 2022-07-13 at 13 26 53

and with xs margin + small progress:
Screen Shot 2022-07-13 at 13 30 26

@garrett
Copy link
Member

garrett commented Jul 13, 2022

Thanks!

I think this needs xs for the margin and use small for the progress bar and button.

The cancel button only works during the "download" phase. To gain
control over this, replace the first updated package (chocolate) in
testBasic with a FIFO, so that PackageKit's read() call will block.
Check that clicking cancel works, and gets you back to the main page
without any changes. Then clean up the FIFO hack, and do the update
properly. This already checks that the cancel button eventually gets
disabled.
This allows users to start a manual update and queue a reboot without
having to babysit the progress.

Rework the progress page layout a bit:

 - Use a Grid layout, so that the update log has the same alignment than
   the progress bar.

 - Stop centering the "Cancel" button, which was a bit dubious wrt. PF
   recommendations anyway. Show it to the right of the progress bar
   instead.

 - Make the Progress bar small and add a little bottom space, to center
   it with the Cancel button.

 - Hide the cancel button instead of disabling it, once cancellation is
   not allowed any more.

 - Rename "Update log" to "View update log" to clarify what the action
   means.

 - Increase the spinner size, to make it easier to see.

https://bugzilla.redhat.com/show_bug.cgi?id=2056786
@martinpitt martinpitt marked this pull request as ready for review July 13, 2022 11:36
@martinpitt
Copy link
Member Author

@garrett : Re-pushed with the implementation for the last screenshot (xs border, small progress and button). Thank you for your help!

@martinpitt martinpitt requested review from marusak and garrett and removed request for garrett July 13, 2022 11:37
@martinpitt martinpitt temporarily deployed to cockpit-dist July 13, 2022 11:41 Inactive
Copy link
Member

@marusak marusak left a comment

Choose a reason for hiding this comment

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

Not doing design review, I see you went through a few iteration already :) Thanks!

@martinpitt
Copy link
Member Author

This is an unrelated flake, but amplified due to the "3x affected retry". It's an incomplete naughty pattern match for a known crash. I'll look at it, but preferably outside of this PR, so retrying.

@martinpitt martinpitt merged commit 10aeb9f into cockpit-project:main Jul 13, 2022
@martinpitt martinpitt deleted the updates-reboot branch July 13, 2022 13:44
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.

None yet

3 participants