updates for new webremote, fix bug in cwd computation

This commit is contained in:
sawka 2023-03-29 12:42:53 -07:00
parent 99cf937ffd
commit 394a2a9ab3
4 changed files with 13 additions and 24 deletions

View File

@ -62,15 +62,12 @@ function replaceHomePath(path : string, homeDir : string) : string {
}
function getCwdStr(remote : RemoteType, state : FeStateType) : string {
if ((state == null || state.cwd == null) && remote != null) {
if (state == null || isBlank(state.cwd)) {
return "~";
}
let cwd = "?";
if (state && state.cwd) {
cwd = state.cwd;
}
let cwd = state.cwd;
if (remote && remote.remotevars.home) {
cwd = replaceHomePath(cwd, remote.remotevars.cwd)
cwd = replaceHomePath(cwd, remote.remotevars.home)
}
return cwd;
}

View File

@ -966,7 +966,6 @@ class InfoRemoteEdit extends React.Component<{}, {}> {
kwargs["autoinstall"] = (this.autoInstallBool.get() ? "1" : "0");
kwargs["visual"] = "1";
kwargs["submit"] = "1";
console.log("submit remote", (isEditing ? redit.remoteid : cname), kwargs);
mobx.action(() => {
if (isEditing) {
GlobalCommandRunner.editRemote(redit.remoteid, kwargs);

View File

@ -506,9 +506,12 @@ type WebLine = {
};
type WebRemote = {
remoteid : string,
alias : string,
canonicalname : string,
name : string,
homedir : string,
isroot : boolean,
};
type WebCmd = {

View File

@ -43,18 +43,13 @@ function replaceHomePath(path : string, homeDir : string) : string {
return path;
}
function getCwdStr(state : T.FeStateType) : string {
let remote = null;
if ((state == null || state.cwd == null) && remote != null) {
function getCwdStr(remote : T.WebRemote, state : T.FeStateType) : string {
if (state == null || isBlank(state.cwd)) {
return "~";
}
let cwd = "?";
if (state && state.cwd) {
cwd = state.cwd;
}
// TODO fix
if (remote && remote.remotevars.home) {
cwd = replaceHomePath(cwd, remote.remotevars.cwd)
let cwd = state.cwd;
if (remote && remote.homedir) {
cwd = replaceHomePath(cwd, remote.homedir)
}
return cwd;
}
@ -73,13 +68,8 @@ class Prompt extends React.Component<{remote : T.WebRemote, festate : T.FeStateT
render() {
let {remote, festate} = this.props;
let remoteStr = getRemoteStr(remote);
let cwd = getCwdStr(festate);
let isRoot = false;
// if (remote && remote.remotevars) {
// if (remote.remotevars["sudo"] || remote.remotevars["bestuser"] == "root") {
// isRoot = true;
// }
// }
let cwd = getCwdStr(remote, festate);
let isRoot = !!remote.isroot;
let remoteColorClass = (isRoot ? "color-red" : "color-green");
// if (remote && remote.remoteopts && remote.remoteopts.color) {
// remoteColorClass = "color-" + remote.remoteopts.color;