1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Do not show context switcher if no contexts left

Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
Alex Andreev 2021-09-06 10:18:29 +03:00
parent 3c8c45cbaa
commit fe1921bfbe

View File

@ -197,6 +197,8 @@ export class DeleteClusterDialog extends React.Component {
if (!cluster || !config) return null; if (!cluster || !config) return null;
const contexts = config.contexts.filter(context => context.name !== cluster.contextName);
return ( return (
<Dialog <Dialog
className={styles.dialog} className={styles.dialog}
@ -210,21 +212,25 @@ export class DeleteClusterDialog extends React.Component {
</div> </div>
{this.renderWarning()} {this.renderWarning()}
<hr className={styles.hr}/> <hr className={styles.hr}/>
<div className="mt-4"> {contexts.length > 0 && (
<Checkbox <>
data-testid="context-switch" <div className="mt-4">
theme="light" <Checkbox
label={( data-testid="context-switch"
<> theme="light"
<span className="font-semibold">Select current-context</span>{" "} label={(
{!this.isCurrentContext() && "(optional)"} <>
</> <span className="font-semibold">Select current-context</span>{" "}
)} {!this.isCurrentContext() && "(optional)"}
value={this.showContextSwitch} </>
onChange={value => this.showContextSwitch = value} )}
/> value={this.showContextSwitch}
</div> onChange={value => this.showContextSwitch = value}
{this.renderCurrentContextSwitch()} />
</div>
{this.renderCurrentContextSwitch()}
</>
)}
</div> </div>
<div className={styles.dialogButtons}> <div className={styles.dialogButtons}>
<Button <Button