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

[WIP] terminal: Open path in terminal #21162

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ashley-cui
Copy link
Contributor

Allow opening of a path from a URL option, path=path. If the terminal is busy, then warn the user and prompt them to continue.

WIP: changing to a path that does not exist should result in an alert, but there's some css magic that's preventing the alert from showing, and I can't figure out what it is. Also needs tests, but thought I would draft it for feedback so far 😌

Allow opening of a path from a URL option, path=path.
If the terminal is busy, then warn the user and prompt them to
continue.

Signed-off-by: Ashley Cui <[email protected]>
@@ -7,6 +7,11 @@
import { FormSelect, FormSelectOption } from "@patternfly/react-core/dist/esm/components/FormSelect/index.js";
import { NumberInput } from "@patternfly/react-core/dist/esm/components/NumberInput/index.js";
import { Toolbar, ToolbarContent, ToolbarGroup, ToolbarItem } from "@patternfly/react-core/dist/esm/components/Toolbar/index.js";
import { Modal } from "@patternfly/react-core/dist/esm/components/Modal/index.js";
import { Button } from '@patternfly/react-core/dist/esm/components/Button';
import { Alert, AlertActionCloseButton } from "@patternfly/react-core/dist/esm/components/Alert/index.js";

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused imports Alert, AlertActionCloseButton.
@martinpitt martinpitt added the no-test For doc/workflow changes, or experiments which don't need a full CI run, label Oct 25, 2024
{/* DEV ARTIFACT: FOR TESTING */}
<button ref={this.asdf}
className="pf-v5-c-button pf-m-secondary asdf"
onClick={() => cockpit.jump("/system/terminal#/?path=/home%2Fadmin%2Fa%2Fb")}>{_("asdf")}</button>
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.

payload: "stream",
spawn: [user.shell || "/bin/bash"],
environ: [
"TERM=xterm-256color",
],
directory: user.home || "/",
directory: dir || user.home || "/",
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 +103 to +104
componentWillUnmount() {
cockpit.removeEventListener("locationchanged", this.onNavigate);
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.

Comment on lines +117 to +119
onModal(){
this.setState({ changePathBusy: false });
this.setState(prevState => ({ channel: this.createChannel(prevState.user, cockpit.location.options.path)}));
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.

Comment on lines +122 to +123
async onNavigate(){
if (cockpit.location.options.path) {
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.

Comment on lines +129 to +134
if (this.state.pid !== null){
const cmmd = "grep -qr '^PPid:[[:space:]]*" + this.state.pid + "$' /proc/*/status";
cockpit.script(cmmd, [], {err: "message"})
.then(() => {
console.log("pid exists")
this.setState({ changePathBusy: true })
Copy link
Contributor

Choose a reason for hiding this comment

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

These 6 added lines are not executed by any test.

Comment on lines +136 to +138
.catch((err) => {
console.log("pid not exists")
this.setState(prevState => ({ channel: this.createChannel(prevState.user, cockpit.location.options.path) }));
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.

position="top"
variant="small"
isOpen={this.state.changePathBusy}
onClose={() => this.setState({ changePathBusy: false })}
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.

<Button key="confirm" variant="primary" onClick={this.onModal}>
{_("Continue")}
</Button>,
<Button key="cancel" variant="secondary" onClick={() => this.setState({ changePathBusy: false })}>
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-test For doc/workflow changes, or experiments which don't need a full CI run,
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants