Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions pkg/storaged/crypto-keyslots.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ function add_dialog(client, block) {
{
visible: vals => !client.features.clevis || vals.type == "luks-passphrase",
validate: val => !val.length && _("Passphrase cannot be empty"),
new_password: true
}),
PassInput("new_passphrase2", _("Repeat passphrase"),
{
Expand All @@ -523,7 +524,8 @@ function add_dialog(client, block) {
return (vals.new_passphrase.length &&
vals.new_passphrase != val &&
_("Passphrases do not match"));
}
},
new_password: true
}),
TextInput("tang_url", _("Keyserver address"),
{
Expand Down Expand Up @@ -560,9 +562,15 @@ function edit_passphrase_dialog(block, key) {
{ validate: val => !val.length && _("Passphrase cannot be empty") }),
Skip("medskip"),
PassInput("new_passphrase", _("New passphrase"),
{ validate: val => !val.length && _("Passphrase cannot be empty") }),
{
validate: val => !val.length && _("Passphrase cannot be empty"),
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line is not executed by any test. Details

new_password: true
}),
PassInput("new_passphrase2", _("Repeat passphrase"),
{ validate: (val, vals) => vals.new_passphrase.length && vals.new_passphrase != val && _("Passphrases do not match") })
{
validate: (val, vals) => vals.new_passphrase.length && vals.new_passphrase != val && _("Passphrases do not match"),
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line is not executed by any test. Details

new_password: true
})
],
Action: {
Title: _("Save"),
Expand Down
36 changes: 29 additions & 7 deletions pkg/storaged/dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ import { TextInput as TextInputPF4 } from "@patternfly/react-core/dist/esm/compo
import { Popover } from "@patternfly/react-core/dist/esm/components/Popover/index.js";
import { HelperText, HelperTextItem } from "@patternfly/react-core/dist/esm/components/HelperText/index.js";
import { List, ListItem } from "@patternfly/react-core/dist/esm/components/List/index.js";
import { ExclamationTriangleIcon, InfoIcon, HelpIcon } from "@patternfly/react-icons";
import { ExclamationTriangleIcon, InfoIcon, HelpIcon, EyeIcon, EyeSlashIcon } from "@patternfly/react-icons";
import { InputGroup } from "@patternfly/react-core/dist/esm/components/InputGroup/index.js";

import { show_modal_dialog, apply_modal_dialog } from "cockpit-components-dialog.jsx";
import { ListingTable } from "cockpit-components-table.jsx";
Expand Down Expand Up @@ -563,6 +564,27 @@ export const TextInput = (tag, title, options) => {
};
};

const PassInputElement = ({ tag, title, options, val, change, validated }) => {
const [show, setShow] = useState(false);

return (
<InputGroup>
<TextInputPF4 data-field={tag} data-field-type="text-input"
validated={validated}
disabled={options.disabled}
aria-label={title}
autoComplete={options.new_password ? "new-password" : null}
type={show ? "text" : "password"}
value={val}
onChange={(_event, value) => change(value)} />
<Button variant="control"
onClick={() => setShow(!show)}
isDisabled={options.disabled}>
{ show ? <EyeSlashIcon /> : <EyeIcon /> }
</Button>
</InputGroup>);
};

export const PassInput = (tag, title, options) => {
return {
tag,
Expand All @@ -571,12 +593,12 @@ export const PassInput = (tag, title, options) => {
initial_value: options.value || "",

render: (val, change, validated) =>
<TextInputPF4 data-field={tag} data-field-type="text-input"
validated={validated}
disabled={options.disabled}
aria-label={title}
type="password" value={val}
onChange={(_event, value) => change(value)} />
<PassInputElement tag={tag}
title={title}
options={options}
val={val}
change={change}
validated={validated} />
};
};

Expand Down
2 changes: 2 additions & 0 deletions pkg/storaged/format-dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ function format_dialog_internal(client, path, start, size, enable_dos_extended,
return _("Passphrase cannot be empty");
},
visible: vals => is_encrypted(vals) && vals.crypto != " keep",
new_password: true
}),
PassInput("passphrase2", _("Confirm"),
{
Expand All @@ -338,6 +339,7 @@ function format_dialog_internal(client, path, start, size, enable_dos_extended,
return _("Passphrases do not match");
},
visible: vals => is_encrypted(vals) && vals.crypto != " keep",
new_password: true
}),
CheckBoxes("store_passphrase", "",
{
Expand Down
6 changes: 4 additions & 2 deletions pkg/storaged/stratis-panel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,17 @@ export function create_stratis_pool(client) {
if (phrase === "")
return _("Passphrase cannot be empty");
},
visible: vals => vals.encrypt.on
visible: vals => vals.encrypt.on,
new_password: true
}),
PassInput("passphrase2", _("Confirm"),
{
validate: function (phrase2, vals) {
if (phrase2 != vals.passphrase)
return _("Passphrases do not match");
},
visible: vals => vals.encrypt.on
visible: vals => vals.encrypt.on,
new_password: true
})
]
}),
Expand Down