-
Notifications
You must be signed in to change notification settings - Fork 697
Expand file tree
/
Copy pathCloudShell.tsx
More file actions
33 lines (28 loc) · 1.01 KB
/
CloudShell.tsx
File metadata and controls
33 lines (28 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import type { FC } from 'react';
import { useFlag } from '@console/shared/src/hooks/useFlag';
import { FLAG_DEVWORKSPACE } from '../../const';
import { useToggleCloudShellExpanded } from '../../redux/actions/cloud-shell-dispatchers';
import {
useIsCloudShellExpanded,
useDetachedSessions,
} from '../../redux/reducers/cloud-shell-selectors';
import { CloudShellDrawer } from './CloudShellDrawer';
interface CloudShellProps {
children: React.ReactNode;
}
const CloudShell: FC<CloudShellProps> = ({ children }) => {
const onClose = useToggleCloudShellExpanded();
const open = useIsCloudShellExpanded();
const devWorkspaceAvailable = useFlag(FLAG_DEVWORKSPACE);
const detachedSessions = useDetachedSessions();
const hasDetachedSessions = detachedSessions.length > 0;
if (!devWorkspaceAvailable && !hasDetachedSessions) {
return <>{children}</>;
}
return (
<CloudShellDrawer onClose={onClose} open={open || hasDetachedSessions}>
{children}
</CloudShellDrawer>
);
};
export default CloudShell;