Skip to content

Commit

Permalink
shell: Remove the "half-off" mode of the host switcher
Browse files Browse the repository at this point in the history
Cockpit should either not connect to remote machines at all, or trust
the user to do it right.  Also, the better place to explain the
security implications of connecting to remote hosts is when actually
connecting.
  • Loading branch information
mvollmer committed Aug 1, 2024
1 parent eaec61d commit c495f90
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 39 deletions.
22 changes: 1 addition & 21 deletions pkg/shell/hosts.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ import {
CaretDownIcon,
CaretUpIcon,
EditIcon,
ExclamationCircleIcon,
ExternalLinkAltIcon,
MinusIcon,
} from '@patternfly/react-icons';
import { Label } from "@patternfly/react-core/dist/esm/components/Label";
import { PageSidebar } from "@patternfly/react-core/dist/esm/components/Page";
import { Popover } from "@patternfly/react-core/dist/esm/components/Popover";
import { Tooltip } from "@patternfly/react-core/dist/esm/components/Tooltip";

import 'polyfills';
Expand Down Expand Up @@ -197,22 +193,7 @@ export class CockpitHosts extends React.Component {
const label = this.props.machine.label || "";
const user = this.props.machine.user || this.state.current_user;

let add_host_action;

if (this.props.enable_add_host) {
add_host_action = <Button variant="secondary" onClick={this.onAddNewHost}>{_("Add new host")}</Button>;
} else {
const footer = <a href="https://cockpit-project.org/blog/cockpit-322.html" target="_blank" rel="noreferrer">
<ExternalLinkAltIcon /> {_("Read more...")}
</a>;
add_host_action = (
<Popover id="disabled-add-host-help"
headerContent={_("Host switching is not supported")}
bodyContent={_("Connecting to remote hosts inside of a web console session is deprecated and will be removed in the future. You can still connect to your existing hosts for now.")}
footerContent={footer}>
<Label className="deprecated-add-host" color="blue" icon={<ExclamationCircleIcon />}>{_("Deprecated")}</Label>
</Popover>);
}
const add_host_action = <Button variant="secondary" onClick={this.onAddNewHost}>{_("Add new host")}</Button>;

return (
<>
Expand Down Expand Up @@ -285,5 +266,4 @@ CockpitHosts.propTypes = {
selector: PropTypes.string.isRequired,
hostAddr: PropTypes.func.isRequired,
jump: PropTypes.func.isRequired,
enable_add_host: PropTypes.bool.isRequired,
};
3 changes: 1 addition & 2 deletions pkg/shell/indexes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -389,15 +389,14 @@ function MachinesIndex(index_options, machines, loader) {
machine = machines.lookup(state.host);

// deprecation transition period: show existing remote hosts, but disable adding new ones
if (host_switcher_enabled || machines.list.length > 1) {
if (host_switcher_enabled) {
hosts_sel_root.render(
React.createElement(CockpitHosts, {
machine: machine || {},
machines,
selector: "nav-hosts",
hostAddr: index.href,
jump: index.jump,
enable_add_host: host_switcher_enabled,
}));
} else {
hosts_sel_root.render(React.createElement(CockpitCurrentHost, { machine: machine || {} }));
Expand Down
16 changes: 0 additions & 16 deletions test/verify/check-shell-host-switching
Original file line number Diff line number Diff line change
Expand Up @@ -139,22 +139,6 @@ class TestHostSwitching(testlib.MachineCase, HostSwitcherHelpers):
b.assert_pixels("#hosts-sel", "no-switching", skip_layouts=["mobile"])
b.logout()

# transition period: Existing remote hosts are still shown
m1.write("/etc/cockpit/machines.d/99-webui.json",
'{"srv": { "address": "my.srv", "visible": true }}')
b.login_and_go(superuser=False)
b.click("#hosts-sel button")
self.wait_host_addresses(b, ["localhost", "my.srv"])
b.wait_in_text(".deprecated-add-host", "Deprecated")
b.assert_pixels(".nav-hosts-actions", "deprecated", skip_layouts=["mobile"])
# clicking on it shows popover with help
b.click(".deprecated-add-host")
b.wait_text("#popover-disabled-add-host-help-header", "Host switching is not supported")
b.click(".pf-v5-c-popover__close button")
b.wait_not_present("#popover-disabled-add-host-help-header")
b.logout()
m1.execute("rm /etc/cockpit/machines.d/99-webui.json")

# enable host switcher for this test
self.enable_multihost(m1)
b.login_and_go(superuser=False)
Expand Down

0 comments on commit c495f90

Please sign in to comment.