mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Add error message for no contexts in add cluster page (#3868)
This commit is contained in:
parent
49e8b9cc0a
commit
3fc5b83461
@ -62,7 +62,7 @@ export class AddCluster extends React.Component {
|
|||||||
@observable kubeContexts = observable.map<string, Option>();
|
@observable kubeContexts = observable.map<string, Option>();
|
||||||
@observable customConfig = "";
|
@observable customConfig = "";
|
||||||
@observable isWaiting = false;
|
@observable isWaiting = false;
|
||||||
@observable errorText: string;
|
@observable errors: string[] = [];
|
||||||
|
|
||||||
constructor(props: {}) {
|
constructor(props: {}) {
|
||||||
super(props);
|
super(props);
|
||||||
@ -75,7 +75,7 @@ export class AddCluster extends React.Component {
|
|||||||
|
|
||||||
@computed get allErrors(): string[] {
|
@computed get allErrors(): string[] {
|
||||||
return [
|
return [
|
||||||
this.errorText,
|
...this.errors,
|
||||||
...iter.map(this.kubeContexts.values(), ({ error }) => error)
|
...iter.map(this.kubeContexts.values(), ({ error }) => error)
|
||||||
].filter(Boolean);
|
].filter(Boolean);
|
||||||
}
|
}
|
||||||
@ -85,7 +85,14 @@ export class AddCluster extends React.Component {
|
|||||||
const { config, error } = loadConfigFromString(this.customConfig.trim() || "{}");
|
const { config, error } = loadConfigFromString(this.customConfig.trim() || "{}");
|
||||||
|
|
||||||
this.kubeContexts.replace(getContexts(config));
|
this.kubeContexts.replace(getContexts(config));
|
||||||
this.errorText = error?.toString();
|
|
||||||
|
if (error) {
|
||||||
|
this.errors.push(error.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.contexts.length === 0) {
|
||||||
|
this.errors.push('No contexts defined, either missing the "contexts" field, or it is empty.');
|
||||||
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
|
|
||||||
@action
|
@action
|
||||||
@ -124,7 +131,7 @@ export class AddCluster extends React.Component {
|
|||||||
value={this.customConfig}
|
value={this.customConfig}
|
||||||
onChange={value => {
|
onChange={value => {
|
||||||
this.customConfig = value;
|
this.customConfig = value;
|
||||||
this.errorText = "";
|
this.errors.length = 0;
|
||||||
this.refreshContexts();
|
this.refreshContexts();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user