Skip to content
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

Closed
wants to merge 4 commits into from

Conversation

mvollmer
Copy link
Member

@mvollmer mvollmer commented Nov 14, 2024

This is a minimum effort to get test/static-code to find errors in ShellState. It doesn't do anything for users of ShellState.

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 });
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.

@@ -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" });
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.

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)}
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.

if (machine == current_machine && parts.address != machine.address) {
shell_state.loader.connect(parts.address);
shell_state.jump(addr);
shell_state.jump({ host: parts.address });
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.

Comment on lines +148 to +152
<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();
Copy link
Contributor

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,
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.

Comment on lines +207 to +208
if (comp && comp.parent && comp.parent.component)
component = comp.parent.component as string;
Copy link
Contributor

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;
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.

checksum: string;
}

function component_checksum(machine: Machine, path: string): string | undefined {
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.

Comment on lines +329 to +331
const p = parseInt(conn_to.substring(port_spot + 1), 10);
if (!isNaN(p)) {
port = p;
Copy link
Contributor

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.

@mvollmer
Copy link
Member Author

Nope.

@mvollmer mvollmer closed this Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants