Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Prevent crashes when accessing cluster details #911

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class AddClusterDialog extends React.Component<Props, State> {
});
}
};

onClose = () => {
this.props.onClose();
this.resetField();
Expand All @@ -69,13 +69,13 @@ class AddClusterDialog extends React.Component<Props, State> {
}
if (editMode) {
updateCluster({
name: cluster.name,
name: cluster?.name,
alias: values.alias,
icon: cluster.icon,
icon: cluster?.icon,
description: values.description,
dashboardURL: values.dashboardURL,
kubeConfig: values.kubeConfig,
labels: cluster.labels,
labels: cluster?.labels,
}).then((re: any) => {
if (re) {
Message.success(<Translation>cluster update success</Translation>);
Expand Down Expand Up @@ -140,7 +140,7 @@ class AddClusterDialog extends React.Component<Props, State> {
};
const init = this.field.init;
const values: { kubeConfig: string } = this.field.getValues();
const valueInfo = cluster.kubeConfig || values.kubeConfig || '';
const valueInfo = cluster?.kubeConfig || values.kubeConfig || '';
return (
<Dialog
locale={locale().Dialog}
Expand Down Expand Up @@ -170,7 +170,7 @@ class AddClusterDialog extends React.Component<Props, State> {
name="name"
disabled={editMode}
{...init('name', {
initValue: cluster.name,
initValue: cluster?.name || editClusterName,
rules: [
{
required: true,
Expand All @@ -187,7 +187,7 @@ class AddClusterDialog extends React.Component<Props, State> {
<Input
name="alias"
{...init('alias', {
initValue: cluster.alias,
initValue: cluster?.alias,
rules: [
{
minLength: 2,
Expand All @@ -204,10 +204,10 @@ class AddClusterDialog extends React.Component<Props, State> {
<Col span={12} style={{ padding: '0 8px' }}>
<FormItem label={<Translation>Description</Translation>}>
<Input
defaultValue={cluster.description}
defaultValue={cluster?.description}
name="description"
{...init('description', {
initValue: cluster.description,
initValue: cluster?.description,
rules: [
{
maxLength: 256,
Expand All @@ -223,7 +223,7 @@ class AddClusterDialog extends React.Component<Props, State> {
<Input
name="dashboardURL"
{...init('dashboardURL', {
initValue: cluster.dashboardURL,
initValue: cluster?.dashboardURL,
rules: [
{
required: false,
Expand Down Expand Up @@ -252,7 +252,7 @@ class AddClusterDialog extends React.Component<Props, State> {
language={'yaml'}
readOnly={false}
{...init('kubeConfig', {
initValue: cluster.kubeConfig,
initValue: cluster?.kubeConfig,
rules: [
{
required: true,
Expand Down
Loading