Skip to content

Commit 73bbc82

Browse files
author
Demetris Manikas
committed
Allow user to show/hide internal commands in ui
Signed-off-by: Demetris Manikas <dmanikas@admin.grnet.gr>
1 parent a633a2b commit 73bbc82

File tree

5 files changed

+40
-13
lines changed

5 files changed

+40
-13
lines changed

ui/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@
6969
"xterm": "4.1.0"
7070
},
7171
"scripts": {
72-
"start": "NODE_ENV=development nodemon scripts/start.js",
73-
"build": "node scripts/build.js"
72+
"start": "NODE_ENV=development NODE_OPTIONS=--openssl-legacy-provider nodemon scripts/start.js",
73+
"build": "NODE_OPTIONS=--openssl-legacy-provider node scripts/build.js"
7474
},
7575
"devDependencies": {
7676
"@types/jest": "^23.3.10",

ui/src/components/views/Commands/Commands/CommandsList/CommandsList.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,9 @@ class CommandsList extends React.PureComponent<Props, State> {
3939
return <PortletSimple key={key}>
4040
{{
4141
top: {
42-
left: key,
42+
left: cmd.internal === true ? (<div>
43+
{key} <br/> <span style={{fontSize: 'small'}}>(internal)</span>
44+
</div>): key,
4345
right: (
4446
<React.Fragment>
4547
<IconButton

ui/src/contexts/withDevSpaceConfig/withDevSpaceConfig.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ interface RawConfig {
5050

5151
export interface Command {
5252
command: string;
53+
internal?: boolean;
5354
}
5455

5556
interface ImageConfig {

ui/src/pages/commands/commands.tsx

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@ import CommandsLinkTabSelector from 'components/basic/LinkTabSelector/CommandsLi
1010
import CommandsList, { getURLByName } from 'components/views/Commands/Commands/CommandsList/CommandsList';
1111
import InteractiveTerminal, { InteractiveTerminalProps } from 'components/advanced/InteractiveTerminal/InteractiveTerminal';
1212
import AdvancedCodeLine from 'components/basic/CodeSnippet/AdvancedCodeLine/AdvancedCodeLine';
13+
import Button from '../../components/basic/Button/Button';
1314

1415
interface Props extends DevSpaceConfigContext, PopupContext, WarningContext, RouteComponentProps {}
1516

1617
interface State {
1718
podList?: V1PodList;
1819
selected?: string;
1920
terminals: StateTerminalProps[];
21+
showInternal: boolean;
2022
}
2123

2224
interface StateTerminalProps extends InteractiveTerminalProps {
@@ -26,6 +28,7 @@ interface StateTerminalProps extends InteractiveTerminalProps {
2628
class Commands extends React.PureComponent<Props, State> {
2729
state: State = {
2830
terminals: [],
31+
showInternal: false
2932
};
3033

3134
onSelectCommand = (commandName: string) => {
@@ -81,11 +84,18 @@ class Commands extends React.PureComponent<Props, State> {
8184
};
8285

8386
render() {
87+
let commands = this.props.devSpaceConfig.config.commands;
88+
if (this.state.showInternal === false) {
89+
commands = Object.fromEntries(Object.entries(commands).filter(([_key, config]) => {
90+
return config.internal !== true
91+
}))
92+
}
93+
8494
return (
8595
<PageLayout className={styles['commands-component']} heading={<CommandsLinkTabSelector />}>
8696
{!this.props.devSpaceConfig.config ||
87-
!this.props.devSpaceConfig.config.commands ||
88-
Object.entries(this.props.devSpaceConfig.config.commands).length === 0 ? (
97+
!this.props.devSpaceConfig.config.commands ||
98+
Object.entries(this.props.devSpaceConfig.config.commands).length === 0 ? (
8999
<div className={styles['no-config']}>
90100
<div>
91101
No commands available. Take a look at&nbsp;
@@ -98,13 +108,27 @@ class Commands extends React.PureComponent<Props, State> {
98108
) : (
99109
<React.Fragment>
100110
{this.renderTerminals()}
101-
<div className={styles['info-part']}>
102-
<CommandsList
103-
commandsList={this.props.devSpaceConfig.config.commands}
104-
running={this.state.terminals.map((terminal) => terminal.url)}
105-
selected={this.state.selected}
106-
onSelect={this.onSelectCommand}
107-
/>
111+
<div style={{ display: 'flex', flexDirection: 'column', gap: '1rem' }}>
112+
<div style={{ height: '3rem', display: 'flex', justifyContent: 'right', marginRight: '10px', marginBottom: '10px' }}>
113+
<Button
114+
onClick={() => {
115+
this.setState((state) => {
116+
return {
117+
showInternal: !state.showInternal
118+
}
119+
})
120+
}}
121+
>{this.state.showInternal ? 'Hide internal' : 'Show internal'}</Button>
122+
</div>
123+
124+
<div className={styles['info-part']} style={{ overflowY: 'auto' }}>
125+
<CommandsList
126+
commandsList={commands}
127+
running={this.state.terminals.map((terminal) => terminal.url)}
128+
selected={this.state.selected}
129+
onSelect={this.onSelectCommand}
130+
/>
131+
</div>
108132
</div>
109133
</React.Fragment>
110134
)}

ui/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"compilerOptions": {
44
"baseUrl": "src",
55
"typeRoots": ["./node_modules/@types", "./@types"],
6-
"lib": ["dom", "es2015", "es2016", "es2017"], // es6, es7, es8
6+
"lib": ["dom", "es2015", "es2016", "es2017", "es2019"], // es6, es7, es8
77
"target": "es5",
88
"module": "esnext",
99
"jsx": "react", // "preserve" would throw error

0 commit comments

Comments
 (0)