Ver Fonte

add check for different name

Anukul Sangwan há 4 anos atrás
pai
commit
6da91e7561

+ 2 - 1
dashboard/src/main/home/cluster-dashboard/env-groups/ExpandedEnvGroup.tsx

@@ -205,6 +205,7 @@ class ExpandedEnvGroup extends Component<PropsType, StateType> {
     let name = envGroup.metadata.name;
     let name = envGroup.metadata.name;
     const isEnvGroupNameValid =
     const isEnvGroupNameValid =
       isAlphanumeric(this.state.envGroupName) && this.state.envGroupName !== "";
       isAlphanumeric(this.state.envGroupName) && this.state.envGroupName !== "";
+    const isEnvGroupNameDifferent = this.state.envGroupName !== name;
 
 
     switch (currentTab) {
     switch (currentTab) {
       case "environment":
       case "environment":
@@ -263,7 +264,7 @@ class ExpandedEnvGroup extends Component<PropsType, StateType> {
                 />
                 />
                 <Button
                 <Button
                   color="#616FEEcc"
                   color="#616FEEcc"
-                  disabled={!isEnvGroupNameValid}
+                  disabled={!(isEnvGroupNameDifferent && isEnvGroupNameValid)}
                   onClick={this.handleRename}
                   onClick={this.handleRename}
                 >
                 >
                   Rename {name}
                   Rename {name}

+ 5 - 0
server/api/k8s_handler.go

@@ -632,6 +632,11 @@ func (app *App) HandleRenameConfigMap(w http.ResponseWriter, r *http.Request) {
 		SecretEnvVariables: decodedSecretData,
 		SecretEnvVariables: decodedSecretData,
 	}
 	}
 
 
+	if newConfigMap.Name == configMap.Name {
+		w.WriteHeader(http.StatusBadRequest)
+		return
+	}
+
 	if err := createConfigMap(agent, newConfigMap); err != nil {
 	if err := createConfigMap(agent, newConfigMap); err != nil {
 		app.handleErrorInternal(err, w)
 		app.handleErrorInternal(err, w)
 		return
 		return