Repository: hasura/graphql-engine
File: console/src/components/Services/Data/TableModify/ColumnEditorList.js (JavaScript)

Code before:
    };

    const onSubmit = toggleEditor => {
      dispatch(saveColumnChangesSql(colName, col, toggleEditor));
    };

    const onDelete = () => {
      let confirmMessage = `This will permanently delete the column "${colName}" from this table`;
      if (columnProperties.pkConstraint) {
        confirmMessage = DELETE_PK_WARNING;
      }

      const isOk = getConfirmation(confirmMessage, true, colName);
      if (isOk) {
        const pk = [];
        let flag = true;
        tableSchema.primary_key.columns.forEach(pkCol => {
          const currentPKCol = pkCol;
          tableSchema.columns.forEach((nonPKCol, colIndex) => {
            if (!nonPKCol.column_name.localeCompare(colName)) {
              flag = false;
            } else {
              if (flag && !currentPKCol.localeCompare(nonPKCol.column_name)) {
                pk.push(colIndex);
              } else if (!currentPKCol.localeCompare(nonPKCol.column_name)) {
                pk.push(colIndex - 1);
              }
            }
          });
          flag = true;
        });

        const pks = [...pk.sort(), ''];
        dispatch(setPrimaryKeys(pks));
        dispatch(deleteColumnSql(col, tableSchema));
      }
    };
    const gqlCompatibilityWarning = () => {
      return (
        <GqlCompatibilityWarning
          identifier={colName}
          className={styles.add_mar_left_small}
        />
      );
    };

    const keyProperties = () => {
      const propertiesDisplay = [];

      const propertiesList = [];
      propertiesList.push(columnProperties.display_type_name);

Review comment (suggestion):
can be simplified like so:
```suggestion
if (currentPKCol === nonPKCol.column_name) {
    if (flag) {
        pk.push(colIndex);
    } else {
       pk.push(colIndex - 1);
    }
}
```

Code after:

    const onSubmit = toggleEditor => {
      dispatch(saveColumnChangesSql(colName, col, toggleEditor));
    };

    const onDelete = () => {
      let confirmMessage = `This will permanently delete the column "${colName}" from this table`;
      if (columnProperties.pkConstraint) {
        confirmMessage = DELETE_PK_WARNING;
      }

      const isOk = getConfirmation(confirmMessage, true, colName);
      if (isOk) {
        dispatch(deleteColumnSql(col, tableSchema));
      }
    };
    const gqlCompatibilityWarning = () => {
      return (
        <GqlCompatibilityWarning
          identifier={colName}
          className={styles.add_mar_left_small}
        />
      );
    };

    const keyProperties = () => {
      const propertiesDisplay = [];

      const propertiesList = [];
      propertiesList.push(columnProperties.display_type_name);

      if (columnProperties.pkConstraint) {
        propertiesList.push('primary key');
      }

      if (columnProperties.isUnique || columnProperties.isOnlyPrimaryKey) {
        propertiesList.push('unique');
      }

      if (columnProperties.isIdentity) {
        propertiesList.push('identity');
      }

      if (columnProperties.isNullable) {
        propertiesList.push('nullable');
      }

      if (columnProperties.default) {
        propertiesList.push(`default: ${columnProperties.default}`);
      }