Commit graph

1574 commits

Author SHA1 Message Date
Allison Karlitskaya
78d5d35b38 esbuild-test-html-plugin: drop %builddir% expand
Some checks are pending
CodeQL / Analyze (push) Waiting to run
Differential ShellCheck / shellcheck (push) Waiting to run
Cockpit manifests / validate-manifests (push) Waiting to run
Cockpit manifests / validate-schemas (push) Waiting to run
This got removed from the template with e51cf81cd2 ("unit tests: Don't
load cockpit.js in the qunit HTML template") but we've been deadcode
expanding it ever since.  Drop it.
2026-11-03 10:46:22 +01:00
Allison Karlitskaya
bcbd5d0c01 cockpit-po-plugin: add a 'podir' option
This plugin assumes that the 'po' directory is located at `$SRCDIR/po`
or `./po` if `$SRCDIR` is unset.  That conflicts with our desire to be
able to run `build.js` from other directories and is also a little bit
"evil" in terms of hardcoding information about project layout.

Add an optional `podir` option to the plugin which should be set to the
`po/` path.  Set it from `build.js` for Cockpit itself.  For other users
of the plugin, we preserve the fallback of using `$SRCDIR/po` or `./po`
so that we don't break them on the next cockpitlib upgrade.  The
expectation is that everyone will migrate to providing the `podir`
option, however.
2026-11-03 10:46:22 +01:00
Allison Karlitskaya
027ec4d836 build.js: determine srcdir via import.meta.dirname
Between `build.js` and `file.js` we determine the location of `pkg` (and
various tools that we need to invoke) in one of two ways, neither of
them particularly good:

 - they're assumed to be relative to '.', which only works if ./build.js
   is invoked from the automake srcdir.  That happens to be the case
   when pkg/Makefile.am does the invocation (it does a 'cd' first) but
   it breaks if you try to run build.js manually from a different
   directory.

 - redundantly, if `$SRCDIR` is set, this will be used in some (but not
   all) places

Let's standardize on looking at `import.meta.dirname`.  This is how node
resolves imports, so it's pretty much guaranteed to be correct (or else
the script itself wouldn't be running in the first place).  This is
an absolute pathname derived from argv[1] as passed to node (ie:
build.js itself).

For the qunit plugin, `import.meta.dirname` is the path of the plugin
itself, which makes it perfect for finding the `.template.html.in` file
located immediately adjacent to itself, saving some path gymnastics.

During our computation to create `runtime-npm-modules.txt` we need to be
careful: pathnames are based on `import.meta.dirname` now and are
therefore always absolute: we need to adjust our logic for finding paths
starting with `node_modules` to consider the relative pathname.
2026-11-03 10:46:22 +01:00
Allison Karlitskaya
af3ec756f5 pkg/lib, build.js: DRY on 'dist/'
Stop hardcoding 'dist/' all over the place.  We already do it once in
the esbuild configuration blob, and that's enough.  The other places
(and particularly the plugins) should be reading it from there.

For the qunit plugin, remove a hardcoded instance of 'qunit/'.
2026-11-03 10:46:22 +01:00
Allison Karlitskaya
11b0b90ff1 esbuild-compress-plugin: fix a shadow
`path` is the `node:path` module, so avoid shadowing it with a local.
2026-11-03 10:46:22 +01:00
Marius Vollmer
f00c23a2b0 filechooser: Add "allowDirectories" option 2026-10-30 16:32:32 +02:00
dependabot[bot]
961da90ca3 Bump the patternfly group across 1 directory with 6 updates
Bumps the patternfly group with 6 updates in the / directory:

| Package | From | To |
| --- | --- | --- |
| [@patternfly/patternfly](https://github.com/patternfly/patternfly) | `6.6.1` | `6.7.0` |
| [@patternfly/react-core](https://github.com/patternfly/patternfly-react) | `6.6.2` | `6.7.0` |
| [@patternfly/react-icons](https://github.com/patternfly/patternfly-react) | `6.6.1` | `6.7.0` |
| @patternfly/react-styles | `6.6.1` | `6.7.0` |
| [@patternfly/react-table](https://github.com/patternfly/patternfly-react) | `6.6.2` | `6.7.0` |
| [@patternfly/react-tokens](https://github.com/patternfly/patternfly-react) | `6.6.1` | `6.7.0` |

Updates `@patternfly/patternfly` from 6.6.1 to 6.7.0
- [Release notes](https://github.com/patternfly/patternfly/releases)
- [Changelog](https://github.com/patternfly/patternfly/blob/main/release.config.js)
- [Commits](https://github.com/patternfly/patternfly/compare/patch-v6.6.1...v6.7.0)

Updates `@patternfly/react-core` from 6.6.2 to 6.7.0
- [Release notes](https://github.com/patternfly/patternfly-react/releases)
- [Commits](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-core@6.6.2...@patternfly/react-core@6.7.0)

Updates `@patternfly/react-icons` from 6.6.1 to 6.7.0
- [Release notes](https://github.com/patternfly/patternfly-react/releases)
- [Commits](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-icons@6.6.1...@patternfly/react-icons@6.7.0)

Updates `@patternfly/react-styles` from 6.6.1 to 6.7.0

Updates `@patternfly/react-table` from 6.6.2 to 6.7.0
- [Release notes](https://github.com/patternfly/patternfly-react/releases)
- [Commits](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-table@6.6.2...@patternfly/react-table@6.7.0)

Updates `@patternfly/react-tokens` from 6.6.1 to 6.7.0
- [Release notes](https://github.com/patternfly/patternfly-react/releases)
- [Commits](https://github.com/patternfly/patternfly-react/compare/@patternfly/react-tokens@6.6.1...@patternfly/react-tokens@6.7.0)

---
updated-dependencies:
- dependency-name: "@patternfly/patternfly"
  dependency-version: 6.7.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: patternfly
- dependency-name: "@patternfly/react-core"
  dependency-version: 6.7.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: patternfly
- dependency-name: "@patternfly/react-icons"
  dependency-version: 6.7.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: patternfly
- dependency-name: "@patternfly/react-styles"
  dependency-version: 6.7.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: patternfly
- dependency-name: "@patternfly/react-table"
  dependency-version: 6.7.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: patternfly
- dependency-name: "@patternfly/react-tokens"
  dependency-version: 6.7.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: patternfly
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-10-30 14:21:43 +01:00
Jelle van der Waa
0318caa14b lib: Apply strict equality everywhere 2026-10-27 12:18:28 +01:00
tomasmatus
84ecef72b4 cockpit.d.ts: type cockpit.hint 2026-10-22 11:01:18 +02:00
tomasmatus
f20c7445bb cockpit.d.ts: add types for base64_{encode | decode} functions 2026-10-22 11:01:18 +02:00
Jelle van der Waa
fc92dbf0a7 lib: Remove notification-message class
No longer used since c598803020.
2026-10-16 17:08:14 +02:00
Jelle van der Waa
d3fd8887e8 lib: Remove custom box-shadow from firewalld-request
This was added back when PatternFly 4 was used and there was no clear
visual separation of the alert and the page background. In PatternFly 6
alerts are distinct enough that we no longer need this.
2026-10-16 12:36:20 +02:00
Jelle van der Waa
c00c8f9ece lib: Move PackageKit API to internal PackageManager
Now that all consumers of the PackageKit api in pkg/lib are gone, the
last part can be moved over and pkg/lib/packagekit.js removed.
2026-10-15 16:41:38 +02:00
Jelle van der Waa
5f7dd05526 lib: Remove detect() from packagekit
The last consumer was pkg/storaged/client.js and that got removed in
b06198ae038c970a7089640fdcd.
2026-10-15 16:41:38 +02:00
Jelle van der Waa
51204bc9c1 lib: Move get_updates implementation to _internal
Now that nothing depends on it anymore after moving the Software updates
page to the PackageManager class.
2026-10-15 16:41:38 +02:00
Jelle van der Waa
90ad602ad8 lib: Remove update_packages()
Everything moved to PackageManager.update_packages().
2026-10-15 16:41:38 +02:00
Jelle van der Waa
10efdfe6a9 lib: Move PackageKit refresh to internal API
Everything moved to PackageManager.refresh().
2026-10-15 16:41:38 +02:00
Viktor Szépe
5ff1ec08a0
Fix typos throughout codebase (#23813)
Several typos and common misspellings of words exists throughout Cockpit. This fixes the spellings.
2026-10-14 14:02:30 +02:00
akawathe-rgb
58a8d759c6 systemd: Make chrony sources drop-in world-readable
chronyd runs as an unprivileged system user. With a tight umask,
Cockpit created /etc/chrony/sources.d and cockpit.sources as 750/640
root:root, so chronyd could not read NTP servers set in the UI.

Force 755/644 independently of the session umask, matching the
timesyncd fix. Cover it in testTimeServersChronyd with umask 077.

Resolves: RHEL-253609
Assisted-by: LLM
Co-authored-by: Freya Gustavsson <freya@venefilyn.se>
2026-10-13 11:28:36 +02:00
Jelle van der Waa
9d1fdf9f06 packagekit: Use PackageManager.update_packages for Software Updates
Use the `update_packages` abstraction in the Software Updates page so
Cockpit can support dnf5daemon as well. This does not re-use
`get_running_updates` emits the same callbacks in `update_packages` now.
This to prevent us racing with `update_packages` to obtain the
transaction or as alternative having to expose PackageKit's internal
transaction DBus path.
The extra code duplication in the end isn't that much to consider the
alternatives.
2026-10-13 08:44:15 +02:00
Jelle van der Waa
0c7e51b702 packagekit: Implement PackageManager.get_running_update()
Move the initial watching of updates to a new method which can be
implemented by PackageKit or DNF5Daemon. The current implementation
still returns a transaction_path which is PackageKit specific but for
now this is temporary until the next commit moves update_packages over
to the PackageManager API.

The DNF5Daemon implementation will have to wait until we have
update_packages() available.
2026-10-13 08:44:15 +02:00
Freya Gustavsson
2f57692b9c storaged: Support UTF-8 encoding for mounts
While we have `atob` and `btoa` it doesn't support anything other than
Latin1, which causes issues for mountpoint names that exceed what Latin1
supports - such as Chinese.

Tests were updated with a new Chinese name, this caused a reordering of
the modal and subsequently had to be updated in the tests. The Chinese
mount name "数据资料" roughly translates to data and information
according to DeepL.

Fixes: https://github.com/cockpit-project/cockpit/issues/23783
Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
2026-10-09 16:04:40 +02:00
tomasmatus
55b3948dda pkg/lib: set overflow-y on .pf-v6-c-page__main-container
In pixel-test changes on new tasks container (2026-10-03) our hack to
hide scrollbars in pixeltests stopped working.
Setting `overflow-y: clip` both on `main` and on .pf-v6-c-page__main-container
makes this hack work again.
2026-10-07 08:42:35 +02:00
Allison Karlitskaya
18c130647b pkg/lib: fix trivial linter errors 2026-10-06 15:17:50 +02:00
Allison Karlitskaya
eeeda8786e cockpit-po-plugin: properly quote the language
Presuming that .po files are an untrusted input, the "Language" string
in the .po file header could easily be set to something like

  " + console.log("pwned") + "

which would escape the naive application of double quotes to either side
of it by the plugin when inserting it into the header of the .po.js
file.  Use JSON.stringify() to make sure we get the quoting right.
2026-10-06 14:43:43 +02:00
Allison Karlitskaya
9b38d4d213 cockpit-po-plugin: ensure Plural-Forms is valid
This might have been done in a separate file but cockpit-po-plugin is
currently standalone, so let's keep it that way.  This file is imported
into external projects.

Add a test case that runs once on module import: it's cheap (~1-2ms).

CVE-2026-92769
Fixes: https://redhat.atlassian.net/browse/RHEL-219811
2026-10-06 14:43:43 +02:00
Freya Gustavsson
b1c58b672f po: Sort manifest2po files
This prevents updates to source strings in pot file that only changes
the order in which the strings appear when a string is used in multiple
files.

Fixes: https://github.com/cockpit-project/cockpit/issues/23754
Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
2026-09-21 14:03:07 +02:00
Marius Vollmer
eeac2a3459 lib: More robust responsive behavior of the FileChooser
We should not try to control the "display" style of PatternFly
elements. They might have their own CSS rules for it with unknown
specificity.

Specifically, a DropdownItem has "display: flex" from PatternFly with
the same specificity as our "display: none" from the
".file-chooser-hide-on-wide" class.  Which one is in effect seems to
be decided by the roll of a dice.
2026-09-18 14:31:37 +02:00
Freya Gustavsson
556a0ba1e6 lib(dnf5daemon): Reset if pkgs are installed
Resets the transaction and returns if the problems found are only that
the packages are already installed. Since `check_missing_packages` just
checks and doesn't install it shouldn't fail if all packages that are
being checked are installed.

Fixes: https://github.com/cockpit-project/cockpit/issues/23717
Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
2026-09-18 13:23:53 +02:00
Jelle van der Waa
d29ab66bfd lib: Stop using promises for the PO Plugin
The whole plugin uses synchronous IO apis and without the promise
overhead it seems to be slightly faster (3%).
2026-09-15 20:54:10 +02:00
Jelle van der Waa
4527aa12de lib: Pre-compute PO file writing direction
This saves at least doing it twice per PO file, additionally make the
RTL languages a constant.
2026-09-15 20:54:10 +02:00
Jelle van der Waa
fdeaddeb8d lib: Use async I/O APIs in RemoveRHIconsPlugin
This function is async so use asynchronous I/O functions.
2026-09-15 20:54:10 +02:00
Jelle van der Waa
f64ac24714 lib: Read and parse PO files once with gettext-parser
After the introduction of generating JavaScript translation files for
manifest files we now parse our PO files twice. Additionally we also
parse them again for every `config.subdirs` although parsing PO files
does not depend that configuration option. With these two improvements
building is now 2x as fast.
2026-09-15 20:54:10 +02:00
Freya Gustavsson
27d94bab8b lib: Kbps->kbps to match standard
We didn't adhere to the standard fully and missed one spot where we used
capital K instead of lowercase one. Although the style is that all
suffixes use capital letter, kilobit is special in that it would
otherwise showcase Kelvin in it - which is why it is lowercase k.

Fixes: https://github.com/cockpit-project/cockpit/issues/23716
Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
2026-09-15 16:40:49 +02:00
Marius Vollmer
b9b97703f1 lib: Don't focus terminal during prop updates
Some of the manipulations triggered by property updates might
accidentally remove the focus, so we put it back at the end, but only
when we had the focus at the start.
2026-09-11 13:37:36 +02:00
Marius Vollmer
35ae5abfe8 cockpit: Add file chooser component
This is a "standard" desktopy File Chooser dialog.

It can be used directly with Dialogs.show:

    Dialogs.show(
      <FileChooser
         title={"Select a file that starts with \"foo\""}
         actionLabel="Load"
         action={loadFile}
         filters={
             [
                 {
                     label: "TXT files",
                     filter: (name, type) => type === "reg" && !!name.match("\\.txt$")
                 },
             ]
         }
         shortcuts={
           ...
         }
         collections={
           ...
         }
      />
    )

Or as part of a specialized TextInput that can replace the
FileAutoComplete component:

    <DialogFileChooserInput
        label="File"
        field={dlg.field("file")}
        fileChooserProps={
            {
                title: "Select a file",
                superuser: "try",
                filters: [
                   ...
                ],
                shortcuts: [
                   ...
                ],
                collections: [
                   ...
                ]
            }
        }
    />
2026-09-08 12:46:09 +03:00
Léon Avic Simmons
4761a367a7 lib: Fix LongRunningProcess spelling in reset() error message
The error thrown by reset() said "LongRuningProcess" with a single 'n'.
The two sibling errors in run() and terminate(), and the class itself,
all spell it "LongRunningProcess".

codespell does not catch this because pyproject.toml excludes ./pkg from
its scan.
2026-09-07 08:28:15 +02:00
Jelle van der Waa
f8660ccc60 lib: Implement is_available for the dnf5daemon backend
`is_available` is used to check if `coreutils` is available on RHEL
systems to verify if a subscription is required to be configured or not.
2026-08-27 09:15:39 +02:00
Jelle van der Waa
377717d000 lib: Implement get_history for the dnf5daemon backend
dnf5 5.4.3 provides a new org.rpm.dnf.v0.History.list method with which
we can retrieve a list of transactions. The software updates page only
shows updates not newly installed packages or other transactions which
are available.
2026-08-27 09:15:39 +02:00
Jelle van der Waa
5d0515e3f0 lib: Document the History packages record 2026-08-27 09:15:39 +02:00
Jelle van der Waa
3834a50f25 pkg: Fix typos discovered by codespell 2026-08-18 11:58:12 +02:00
Freya Gustavsson
d14360e559 css: Use PF headers and font-weight
Some font-weight rules needed to use `--default` as part of the CSS
variable usage as the font-weight without it no longer exists.

We had instances of `<h1>` and `<h2>` that used the incorrect font and
didn't get any font-weight changes which made it not match the rest of
Cockpit. Updating it to Patternfly's Title component fixes it.

Overview page's "running on" will remain Red Hat Text while getting the
size reduced to `md` even for larger screens. RH text works better with
smaller sizes and RH Display works better with bigger ones. It would
either be keeping the size large or we proper subtitles with RH Text instead.

Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
2026-07-17 23:47:09 +02:00
Freya Gustavsson
295c68a226 patternfly: Revert text overflow PF bug
Patternfly 6.6.0 introduced a migration from `break-word` to
`overflow-wrap` as the former is deprecated. However, Patternfly did not
update the value correctly and assumed it to be the same. This caused
text with long unbroken strings to not break to match the content width
and instead overflowed the page.

Fix for this is to change the `overflow-wrap` value from `break-word` to
`anywhere`.

Related-to: https://github.com/patternfly/patternfly/issues/8484
Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
2026-07-17 23:47:09 +02:00
Freya Gustavsson
69a796aa9f css: Remove Alert icon size override
Has been fixed in PF v6.6

Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
2026-07-17 23:47:09 +02:00
Freya Gustavsson
6b49c16734 lib: Remove zero-slash font override
PF's numeric font used to have a slashed zero that we tried to remove.
But that has been changed at some point and it no longer contains the
slashed zero.

Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
2026-07-17 23:47:09 +02:00
Marius Vollmer
fc8c2a5ef6 dialog: Change debouncing API
Debouncing was controlled in the wrong place in the API, during
validation and when starting asynchronous computations for new field
values.  Instead, it should be specified when handling the event that
causes a dialog field to change.  When the event is the result of
keyboard input, it should be debounced, but when it comes from a
dropdown menu, it should not be.

This matters when a dialog field is changed by different events, for
example when a file can either be typed by the user, or selected from
the FileChooser dialog.  We want to debounce the former but not the
latter.  (It's not a huge problem if the FileChooser selection is also
debounced, but it is still not something we want, we just tolerate
because the API can't do it otherwise.)

A better example is when a single function should run when any of a
number of fields changes.  Some fields should cause debounce the
calling of that function, but other should not.

Thus, the "debounce" arguments of "handle.validate_async",
"handle.set_async", and "handle.get_async" have been removed.
Instead, there is a new "handle.set_debounced" function.  This
function is used by DialogTextInput and DialogPasswordInput and should
in general be used by all events that result from keyboard input.

There are no "handle.add_debounced" or "handle.remove_debounced"
functions although theoretically there should be, since they are
special cases of "handle.set".
2026-07-17 09:11:19 +03:00
Freya Gustavsson
b1433d5e8c doc: Fix links for Antora
Several files, including the deployment guide index page, link to the
old AsciiDoc guide on our website whereas our new docs site is published
under docs subdomain using Antora. While these links will work in the
future thanks to redirects we should update the links where we can to
avoid this unnecessary redirect.

Other changes include changing links from being header anchors within a
single-page to a multi-page navigation with asciidoctor's xref. This
change only applies to links within the same module and doesn't change
any links from guide to manpage for example. That will be tackled in a
future commit as it also has to deal with compiling to manpages.

Signed-off-by: Freya Gustavsson <freya@venefilyn.se>
2026-07-14 15:47:27 +02:00
Marius Vollmer
2eef4aee05 dialog: More features for action buttons
Namely support for secondary actions and an "excuse".

Also allow isDisabled and isAriaDisabled to be passed to
DialogActionButton and DialogCancelButton.
2026-07-01 19:09:19 +03:00
Marius Vollmer
ad404ae3f2
lib: Style select headers like Patternfly group titles (#23423)
Our SimpleSelect, TypeaheadSelect, etc components use regular,
disabled SelectOptions for headers and style them to look like PF
groups headers.

With the update to PF 6.5 we also need to copy the font weight style.
2026-06-30 12:33:18 +02:00
Marius Vollmer
49b8f4cc4e dialog: Use OUIA to identify dialog elements in tests
We don't want to use the "id" attribute with values like
"dialog-field-name" since that is not automatically unique when
multiple dialogs are displayed at the same time.  Instead, we want to
use something like

  #my-dialog [data-id=dialog-field-name]

to find elements for a field called "name".  And if we are using a
data attribute, why not use the one specified by OUIA.  It has
dedicated support from Patternfly.

(Maybe Patternfly makes us fully OUIA compliant, or maybe not. This is
not important to us.)
2026-06-29 17:25:19 +03:00