-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
shell: Include state.jsx in type checking #21267
Conversation
To reduce the complexity of the Shell slightly. The build_href function is special in that it constructs a string for a Location object without including the configured URL root of this Cockpit instance. The only point of this is to create strings that can be passed to ShellState.jump. They also show up in href attributes, but they never really should. So, let's never pass a string to ShellState.jump and just pass the Location object directly.
Found by TypeScript. The symptom of the bug is that navigating again to the current location would not be a no-op, but would create a history entry. This seems hard to trigger. Still a bug.
@@ -130,8 +130,7 @@ export class CockpitHosts extends React.Component { | |||
|
|||
const connection_string = machine.connection_string; | |||
const parts = split_connection_string(connection_string); | |||
const addr = build_href({ host: parts.address }); | |||
state.jump(addr); | |||
state.jump({ host: parts.address }); |
There was a problem hiding this comment.
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.
@@ -147,8 +146,7 @@ | |||
|
|||
if (current_machine === machine) { | |||
// Removing machine underneath ourself - jump to localhost | |||
const addr = build_href({ host: "localhost" }); | |||
state.jump(addr); | |||
state.jump({ host: "localhost" }); |
There was a problem hiding this comment.
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.
active={m === current_machine} | ||
key={m.key} | ||
name={m.label} | ||
header={(m.user ? m.user : this.state.current_user) + " @"} | ||
status={m.state === "failed" ? { type: "error", title: _("Connection error") } : null} | ||
className={m.state} | ||
jump={() => this.onHostSwitch(m)} | ||
onClick={() => this.onHostSwitch(m)} |
There was a problem hiding this comment.
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.
if (machine == current_machine && parts.address != machine.address) { | ||
shell_state.loader.connect(parts.address); | ||
shell_state.jump(addr); | ||
shell_state.jump({ host: parts.address }); |
There was a problem hiding this comment.
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.
<a className="pf-v5-c-nav__section-title nav-item" | ||
href={encode_location(g.action.target)} | ||
onClick={ ev => { | ||
this.props.jump(g.action.target); | ||
ev.preventDefault(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 5 added lines are not executed by any test.
section, | ||
label: cockpit.gettext(info.label) || prop, | ||
label: info.label ? cockpit.gettext(info.label) : prop, |
There was a problem hiding this comment.
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.
if (comp && comp.parent && comp.parent.component) | ||
component = comp.parent.component as string; |
There was a problem hiding this comment.
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.
}; | ||
const item = this.items.get(component); | ||
if (item) | ||
return item; |
There was a problem hiding this comment.
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.
checksum: string; | ||
} | ||
|
||
function component_checksum(machine: Machine, path: string): string | undefined { |
There was a problem hiding this comment.
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.
const p = parseInt(conn_to.substring(port_spot + 1), 10); | ||
if (!isNaN(p)) { | ||
port = p; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These 3 added lines are not executed by any test.
Nope. |
This is a minimum effort to get test/static-code to find errors in ShellState. It doesn't do anything for users of ShellState.