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

apps: Warn if appstream data package is missing #19281

Merged
merged 2 commits into from
Oct 13, 2023

Conversation

leomoty
Copy link
Contributor

@leomoty leomoty commented Sep 4, 2023

Fixes #18454

Apps: Detect missing AppStream metadata

If the AppStream metadata is not installed, the "Apps" page cannot show available Cockpit extensions. The page detects this now, and offers the user to install the metadata.

image

image

Thanks to leomoty for designing this improvement!

@leomoty leomoty changed the title Application list may install appstream if missing apps: Application list may install appstream if missing Sep 4, 2023
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! This also needs an integration test. Do you want to work on that, or need some help?

pkg/apps/application-list.jsx Outdated Show resolved Hide resolved
pkg/apps/application-list.jsx Outdated Show resolved Hide resolved
pkg/apps/application-list.jsx Outdated Show resolved Hide resolved
@leomoty
Copy link
Contributor Author

leomoty commented Sep 4, 2023

Do you want to work on that, or need some help?

I would like to give it a try, I was writing this before:

    def testNoAppStream(self):
        b = self.browser
        m = self.machine

        m.execute("dnf remove -y appstream")

        self.login_and_go("/apps")

        b.click("#refresh")

        with b.wait_timeout(30):
          b.wait_in_text(".pf-v5-c-modal-box:contains('Install software')", "appstream will be installed")

@leomoty
Copy link
Contributor Author

leomoty commented Sep 4, 2023

Added an attempt assert for the Alert also, but VM says no:

image

it is not installable, so it doesn't hit my alert, should we handle unavailable_names as well, and if so, what would it do?

@leomoty
Copy link
Contributor Author

leomoty commented Sep 4, 2023

@martinpitt the only caveat is that I have no idea how to get appstream installed to test otherwise, but seems like everything else was already mocking anyways.

The refresh will remain blocked this way, btw.

pkg/apps/application-list.jsx Outdated Show resolved Hide resolved
@leomoty
Copy link
Contributor Author

leomoty commented Sep 4, 2023

Btw it breaks testBasic and TestWithUrlRoot due to its reliance on #refresh button.


Edit: solved

@leomoty leomoty force-pushed the apps-appstream-install branch 2 times, most recently from de7a136 to dca567b Compare September 4, 2023 22:19
@leomoty
Copy link
Contributor Author

leomoty commented Sep 4, 2023

Had some troubles with tox but fixed now, but overall I believe the only thing missing is my own question

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.

Sorry, I misunderstood the purpose of this yesterday. What this PR should do is to show the alert if the metapackages are absent. It should not modify the actual install procedure, as that is already happening. See the detailed comments below.

Added an attempt assert for the Alert also, but VM says no:

That's because you added a new test case which doesn't call self.createAppStreamRepoPackage() to mock the metapackages. But this should go away entirely.

Thanks!

test/verify/check-apps Outdated Show resolved Hide resolved
test/verify/check-apps Outdated Show resolved Hide resolved
test/verify/check-apps Outdated Show resolved Hide resolved
@leomoty
Copy link
Contributor Author

leomoty commented Sep 6, 2023

This should be rebased after #19283, to test I just changed the manifest.json locally to make rocky happy. I wasn't sure if there is any chance for it not to be present after a refresh, so just in case I made sure to retry it.

Let me know if you want further changes.

@leomoty leomoty changed the title apps: Application list may install appstream if missing apps: Warn if appstream data package is missing Sep 6, 2023
@leomoty
Copy link
Contributor Author

leomoty commented Sep 7, 2023

@martinpitt I've rebased on top of main, testOsMap fails locally for me, but I am not entirely sure why, i'll keep digging, but feel free to fix if obvious


Edit:
Actually I know, I broke the test, since it relied on rereading the info on every refresh

@leomoty
Copy link
Contributor Author

leomoty commented Sep 8, 2023

Still a bit clueless on how to fix it, i'd expect an enter_page("/apps") after updating os-release to work, but doesn't sound like it.

diff --git a/test/verify/check-apps b/test/verify/check-apps
index a269d89a4..4de52e955 100755
--- a/test/verify/check-apps
+++ b/test/verify/check-apps
@@ -170,6 +170,7 @@ class TestApps(packagelib.PackageCase):
 
         # unknown OS: nothing gets installed
         m.write("/etc/os-release", 'ID="unmapped"\nID_LIKE="mysterious"\nVERSION_ID="1"\n')
+        b.enter_page("/apps")
         b.click("#refresh")
         # the progress bar is too fast to reliably catch it
         time.sleep(1)
@@ -178,6 +179,7 @@ class TestApps(packagelib.PackageCase):
 
         # known OS: appstream-data-tst gets installed from the map
         m.write("/etc/os-release", 'ID="derivative"\nID_LIKE="spicy testy"\nVERSION_ID="1"\n')
+        b.enter_page("/apps")
         b.click("#refresh")
         with b.wait_timeout(30):
             b.wait_visible(".app-list #app-1")

The first one seems to work, but if I were to guess it is just because of expecting the empty state

@martinpitt
Copy link
Member

@leomoty sorry, this week was really hectic, we had an IRL team sprint. I'll review this on Monday.

test/verify/check-apps Outdated Show resolved Hide resolved
@martinpitt
Copy link
Member

@leomoty
Copy link
Contributor Author

leomoty commented Sep 8, 2023

@leomoty sorry, this week was really hectic, we had an IRL team sprint. I'll review this on Monday.

I saw the group picture, pretty cool! Don't worry, thanks for putting up with me :)

pkg/apps/application-list.jsx Outdated Show resolved Hide resolved
@martinpitt
Copy link
Member

I split out the first two commits to PR #19416, as that should get fixed ASAP and there's more design bikeshedding here.

@martinpitt martinpitt removed the blocked Don't land until something else happens first (see task list) label Sep 29, 2023
This gets added to `data` in the middle of `check_missing_packages()`
anyway, so declare it right away. Also document it, as it's part of the
result and e.g. `install_missing_packages()` assumes that this field
exists.
@martinpitt
Copy link
Member

Sorry, took me a while to get back to this, but I addressed @mvollmer 's feedback.

@leomoty
Copy link
Contributor Author

leomoty commented Oct 11, 2023

Okay, now in retrospect I do understand what @mvollmer was asking, that makes sense.

jelly
jelly previously approved these changes Oct 12, 2023
? <EmptyStatePanel title={ _("No applications installed or available.") } />
? <EmptyStatePanel title={ _("No applications installed or available.") }
paragraph={data_missing_msg}
action={_("Install application information")} onAction={refresh} />
Copy link
Member

Choose a reason for hiding this comment

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

Should this button always be here, even if data_missing_msg is null?

Copy link
Member

Choose a reason for hiding this comment

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

Ouch, thanks for spotting! Fixed, and added a test (which took a bit of work to test a negative)

@mvollmer
Copy link
Member

image

Do we want to have some whitespace between the Alert and the Card?

@martinpitt
Copy link
Member

Do we want to have some whitespace between the Alert and the Card?

Can't hurt, done. I updated the screenshot in the description. I also fixed the button issue you spotted above, and did some minor cleanups.

@@ -28,6 +28,10 @@
overflow: hidden;
}

.ct-missing-metainfo-alert {
margin-block-end: 1rem;
Copy link
Member

Choose a reason for hiding this comment

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

Arg, CSS! :-) What about <Stack hasGutter>? But I am far from the authority here.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the hint! Indeed that's nicer.

I needed to update this again anyway, I found that PackageKit behaved very poorly and blocked the check for a long time. I found out how to do that properly (lightning fast now, and also easier).

mvollmer
mvollmer previously approved these changes Oct 12, 2023
Introduce a new packagekit.js helper check_uninstalled_packages() which
is a lightweight version of check_missing_packages() that avoids the
expensive Refresh call.

If there are no installed nor available apps, show an explanation and an
action button in the empty state, otherwise show an alert with an
"Install" button on top of the installed apps. Use the latter in
TestApps.testBasic, as the top right "Refresh" button is already covered
by other test cases.

Fixes cockpit-project#18454

Thanks to leomoty <leomoty@gmail.com> for the idea and initial
implementation!
Comment on lines +129 to +130
} catch (e) {
console.warn("Failed to check missing AppStream metadata packages:", e.toString());
Copy link
Contributor

Choose a reason for hiding this comment

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

These 2 added lines are not executed by any test. Details

Copy link
Member

@mvollmer mvollmer left a comment

Choose a reason for hiding this comment

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

Thanks!

@martinpitt martinpitt merged commit 57c930c into cockpit-project:main Oct 13, 2023
98 checks passed
@leomoty leomoty deleted the apps-appstream-install branch October 21, 2023 17:08
@jelly jelly removed the release-note label Nov 1, 2023
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.

applications: Show more available applications
5 participants