Skip to content

Commit 33869b3

Browse files
author
Demetris Manikas
committed
Handle lack of commands properly
1 parent 73bbc82 commit 33869b3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

ui/src/pages/commands/commands.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import styles from './commands.module.scss';
44
import PageLayout from 'components/basic/PageLayout/PageLayout';
55
import withPopup, { PopupContext } from 'contexts/withPopup/withPopup';
66
import { V1PodList } from '@kubernetes/client-node';
7-
import withDevSpaceConfig, { DevSpaceConfigContext } from 'contexts/withDevSpaceConfig/withDevSpaceConfig';
7+
import withDevSpaceConfig, { Command, DevSpaceConfigContext } from 'contexts/withDevSpaceConfig/withDevSpaceConfig';
88
import withWarning, { WarningContext } from 'contexts/withWarning/withWarning';
99
import CommandsLinkTabSelector from 'components/basic/LinkTabSelector/CommandsLinkTabSelector/CommandsLinkTabSelector';
1010
import CommandsList, { getURLByName } from 'components/views/Commands/Commands/CommandsList/CommandsList';
@@ -83,14 +83,16 @@ class Commands extends React.PureComponent<Props, State> {
8383
));
8484
};
8585

86-
render() {
87-
let commands = this.props.devSpaceConfig.config.commands;
86+
getVisibleCommands(commands: { [key: string]: Command }) {
8887
if (this.state.showInternal === false) {
89-
commands = Object.fromEntries(Object.entries(commands).filter(([_key, config]) => {
88+
return Object.fromEntries(Object.entries(commands).filter(([_key, config]) => {
9089
return config.internal !== true
9190
}))
9291
}
92+
return commands;
93+
}
9394

95+
render() {
9496
return (
9597
<PageLayout className={styles['commands-component']} heading={<CommandsLinkTabSelector />}>
9698
{!this.props.devSpaceConfig.config ||
@@ -123,7 +125,7 @@ class Commands extends React.PureComponent<Props, State> {
123125

124126
<div className={styles['info-part']} style={{ overflowY: 'auto' }}>
125127
<CommandsList
126-
commandsList={commands}
128+
commandsList={this.getVisibleCommands(this.props.devSpaceConfig.config.commands)}
127129
running={this.state.terminals.map((terminal) => terminal.url)}
128130
selected={this.state.selected}
129131
onSelect={this.onSelectCommand}

0 commit comments

Comments
 (0)