Skip to content

Commit

Permalink
dialogs: unify the dialog titles
Browse files Browse the repository at this point in the history
Unify them to all use the form `$action <b>$name</b>` so all dialog
titles use the same style.
  • Loading branch information
jelly committed Oct 9, 2024
1 parent b073227 commit 8dc2256
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 13 deletions.
19 changes: 11 additions & 8 deletions src/dialogs/delete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { Modal, ModalVariant } from '@patternfly/react-core/dist/esm/components/
import cockpit from 'cockpit';
import { InlineNotification } from 'cockpit-components-inline-notification';
import type { Dialogs, DialogResult } from 'dialogs';
import { fmt_to_fragments } from 'utils';

import type { FolderFileInfo } from '../app';

Expand All @@ -40,23 +41,25 @@ const ConfirmDeletionDialog = ({ dialogResult, path, selected, setSelected } : {

let modalTitle;
if (selected.length > 1) {
modalTitle = cockpit.format(forceDelete ? _("Force delete $0 items") : _("Delete $0 items?"), selected.length);
const selectedJSX = <b>{selected.length}</b>;
modalTitle = fmt_to_fragments(forceDelete ? _("Force delete $0 items") : _("Delete $0 items?"), selectedJSX);
} else {
const selectedItem = selected[0];
const selectedJSX = <b>{selectedItem.name}</b>;
if (selectedItem.type === "reg") {
modalTitle = cockpit.format(
forceDelete ? _("Force delete file $0?") : _("Delete file $0?"), selectedItem.name
modalTitle = fmt_to_fragments(
forceDelete ? _("Force delete file $0?") : _("Delete file $0?"), selectedJSX
);
} else if (selectedItem.type === "lnk") {
modalTitle = cockpit.format(
forceDelete ? _("Force delete link $0?") : _("Delete link $0?"), selectedItem.name
modalTitle = fmt_to_fragments(
forceDelete ? _("Force delete link $0?") : _("Delete link $0?"), selectedJSX
);
} else if (selectedItem.type === "dir") {
modalTitle = cockpit.format(
forceDelete ? _("Force delete directory $0?") : _("Delete directory $0?"), selectedItem.name
modalTitle = fmt_to_fragments(
forceDelete ? _("Force delete directory $0?") : _("Delete directory $0?"), selectedJSX
);
} else {
modalTitle = cockpit.format(forceDelete ? _("Force delete $0") : _("Delete $0?"), selectedItem.name);
modalTitle = fmt_to_fragments(forceDelete ? _("Force delete $0") : _("Delete $0?"), selectedJSX);
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/dialogs/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { debounce } from "throttle-debounce";
import cockpit from 'cockpit';
import { EventEmitter } from 'cockpit/event.ts';
import type { Dialogs, DialogResult } from 'dialogs';
import { fmt_to_fragments } from 'utils';

import "./editor.scss";

Expand Down Expand Up @@ -165,7 +166,7 @@ export const EditFileModal = ({ dialogResult, path } : {
};

/* Translators: This is the title of a modal dialog. $0 represents a filename. */
let title = <>{cockpit.format(state?.writable ? _("Edit “$0”") : _("View “$0”"), path)}</>;
let title = <>{fmt_to_fragments(state?.writable ? _("Edit $0") : _("View $0"), <b>{path}</b>)}</>;
if (!state.writable) {
// TODO: dark mode and lack of spacing
title = (<>{title}<Label className="file-editor-title-label" variant="filled">{_("Read-only")}</Label></>);
Expand Down
3 changes: 2 additions & 1 deletion src/dialogs/permissions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { basename } from "cockpit-path";
import { useInit } from 'hooks';
import { etc_group_syntax, etc_passwd_syntax } from 'pam_user_parser';
import { superuser } from 'superuser';
import { fmt_to_fragments } from 'utils.tsx';

import { useFilesContext } from '../app.tsx';
import { map_permissions, inode_types } from '../common.ts';
Expand Down Expand Up @@ -119,7 +120,7 @@ const EditPermissionsModal = ({ dialogResult, selected, path }) => {
position="top"
variant={ModalVariant.small}
/* Translators: $0 represents a filename */
title={cockpit.format(_("“$0” permissions"), selected.name)}
title={fmt_to_fragments(_("$0 permissions"), <b>{selected.name}</b>)}
description={inode_types[selected.type] || "Unknown type"}
isOpen
onClose={dialogResult.resolve}
Expand Down
4 changes: 2 additions & 2 deletions test/check-application
Original file line number Diff line number Diff line change
Expand Up @@ -2292,7 +2292,7 @@ class TestFiles(testlib.MachineCase):

# Opening an test file, editing and closing (discard)
open_editor("test.txt")
b.wait_text(".pf-v5-c-modal-box__title", "Edit /home/admin/test.txt")
b.wait_text(".pf-v5-c-modal-box__title", "Edit /home/admin/test.txt")
b.wait_text(".file-editor-modal textarea", "test\n")

# Save button is disabled when not editing yet
Expand Down Expand Up @@ -2401,7 +2401,7 @@ class TestFiles(testlib.MachineCase):
b.go("/files#/?path=/etc")
self.assert_last_breadcrumb("etc")
open_editor("cockpit-files-test.cfg")
b.wait_text(".pf-v5-c-modal-box__title", "View /etc/cockpit-files-test.cfg”Read-only")
b.wait_text(".pf-v5-c-modal-box__title", "View /etc/cockpit-files-test.cfgRead-only")
b.assert_pixels(".file-editor-modal", "editor-modal-read-only")

b.click(".pf-v5-c-modal-box__footer button.pf-m-secondary")
Expand Down
2 changes: 1 addition & 1 deletion test/reference
Submodule reference updated 25 files
+ TestFiles-testDelete-delete-modal-dark-pixels.png
+ TestFiles-testDelete-delete-modal-error-dark-pixels.png
+ TestFiles-testDelete-delete-modal-error-medium-pixels.png
+ TestFiles-testDelete-delete-modal-error-mobile-pixels.png
+ TestFiles-testDelete-delete-modal-error-pixels.png
+ TestFiles-testDelete-delete-modal-error-rtl-pixels.png
+ TestFiles-testDelete-delete-modal-medium-pixels.png
+ TestFiles-testDelete-delete-modal-mobile-pixels.png
+ TestFiles-testDelete-delete-modal-pixels.png
+ TestFiles-testDelete-delete-modal-rtl-pixels.png
+ TestFiles-testEditor-editor-modal-changed-dark-pixels.png
+ TestFiles-testEditor-editor-modal-changed-medium-pixels.png
+ TestFiles-testEditor-editor-modal-changed-mobile-pixels.png
+ TestFiles-testEditor-editor-modal-changed-pixels.png
+ TestFiles-testEditor-editor-modal-changed-rtl-pixels.png
+ TestFiles-testEditor-editor-modal-read-only-dark-pixels.png
+ TestFiles-testEditor-editor-modal-read-only-medium-pixels.png
+ TestFiles-testEditor-editor-modal-read-only-mobile-pixels.png
+ TestFiles-testEditor-editor-modal-read-only-pixels.png
+ TestFiles-testEditor-editor-modal-read-only-rtl-pixels.png
+ TestFiles-testPermissions-permissions-modal-dark-pixels.png
+ TestFiles-testPermissions-permissions-modal-medium-pixels.png
+ TestFiles-testPermissions-permissions-modal-mobile-pixels.png
+ TestFiles-testPermissions-permissions-modal-pixels.png
+ TestFiles-testPermissions-permissions-modal-rtl-pixels.png

1 comment on commit 8dc2256

@packit-as-a-service
Copy link

Choose a reason for hiding this comment

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

Based on your Packit configuration the settings of the @cockpit/cockpit-preview Copr project would need to be updated as follows:

field old value new value
bootstrap off default

Packit was unable to update the settings above as it is missing admin permissions on the @cockpit/cockpit-preview Copr project.

To fix this you can do one of the following:

  • Grant Packit admin permissions on the @cockpit/cockpit-preview Copr project on the permissions page.
  • Change the above Copr project settings manually on the settings page to match the Packit configuration.
  • Update the Packit configuration to match the Copr project settings.

Please retrigger the build, once the issue above is fixed.

Please sign in to comment.