Skip to content

Commit

Permalink
track3
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed May 20, 2020
1 parent 2678c42 commit 855e14e
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from './cloud-shell-utils';
import CloudShellSetup from './setup/CloudShellSetup';
import './CloudShellTerminal.scss';
import { K8sResourceKind } from '@console/internal/module/k8s';

type StateProps = {
username: string;
Expand All @@ -40,7 +41,6 @@ const CloudShellTerminal: React.FC<CloudShellTerminalProps> = ({ username, onCan
const [initData, setInitData] = React.useState<TerminalInitData>();
const [initDataLoading, setInitDataLoading] = React.useState<boolean>(false);
const [initError, setInitError] = React.useState<string>();
const [workspaceNamespace, setWorkspaceNamespace] = React.useState<string>();

React.useEffect(() => {
let destroy = false;
Expand All @@ -58,7 +58,6 @@ const CloudShellTerminal: React.FC<CloudShellTerminalProps> = ({ username, onCan
if (destroy) return;
setInitData(res);
setInitDataLoading(false);
setWorkspaceNamespace(namespace);
})
.catch(() => {
if (destroy) return;
Expand Down Expand Up @@ -91,11 +90,18 @@ const CloudShellTerminal: React.FC<CloudShellTerminalProps> = ({ username, onCan
);
}

if (initData) {
let workSpace: K8sResourceKind;
if (Array.isArray(data)) {
workSpace = data.find(
(ws) => ws?.metadata?.annotations?.[CLOUD_SHELL_USER_ANNOTATION] === username,
);
}

if (initData && workSpace?.metadata?.namespace) {
return (
<div className="odc-cloudshell-terminal__container">
<CloudshellExec
namespace={workspaceNamespace}
namespace={workSpace.metadata.namespace}
container={initData.container}
podname={initData.pod}
shcommand={initData.cmd || []}
Expand Down

0 comments on commit 855e14e

Please sign in to comment.