-
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
[WIP] terminal: Open path in terminal #21162
base: main
Are you sure you want to change the base?
Conversation
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
{/* 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> |
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.
payload: "stream", | ||
spawn: [user.shell || "/bin/bash"], | ||
environ: [ | ||
"TERM=xterm-256color", | ||
], | ||
directory: user.home || "/", | ||
directory: dir || user.home || "/", |
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.
componentWillUnmount() { | ||
cockpit.removeEventListener("locationchanged", this.onNavigate); |
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.
onModal(){ | ||
this.setState({ changePathBusy: false }); | ||
this.setState(prevState => ({ channel: this.createChannel(prevState.user, cockpit.location.options.path)})); |
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.
async onNavigate(){ | ||
if (cockpit.location.options.path) { |
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.
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 }) |
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 6 added lines are not executed by any test.
.catch((err) => { | ||
console.log("pid not exists") | ||
this.setState(prevState => ({ channel: this.createChannel(prevState.user, cockpit.location.options.path) })); |
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.
position="top" | ||
variant="small" | ||
isOpen={this.state.changePathBusy} | ||
onClose={() => this.setState({ changePathBusy: false })} |
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.
<Button key="confirm" variant="primary" onClick={this.onModal}> | ||
{_("Continue")} | ||
</Button>, | ||
<Button key="cancel" variant="secondary" onClick={() => this.setState({ changePathBusy: false })}> |
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.
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 😌