Ensure that name can't be empty in edit mode for Primary Key and Index. #6204

This commit is contained in:
Akshay Joshi 2023-05-18 15:46:56 +05:30
parent 6949b41fb9
commit 4baae7512b
3 changed files with 16 additions and 0 deletions

View File

@ -35,6 +35,7 @@ Bug fixes
| `Issue #6026 <https://github.com/pgadmin-org/pgadmin4/issues/6026>`_ - Tools menu should be toggled for "pause replay of wal" and "resume replay of wal".
| `Issue #6080 <https://github.com/pgadmin-org/pgadmin4/issues/6080>`_ - pgAdmin icon not showing on taskbar on Windows 10.
| `Issue #6147 <https://github.com/pgadmin-org/pgadmin4/issues/6147>`_ - Heartbeat is getting logged, though no server is connected in pgAdmin.
| `Issue #6204 <https://github.com/pgadmin-org/pgadmin4/issues/6204>`_ - Ensure that name can't be empty in edit mode for Primary Key and Index.
| `Issue #6221 <https://github.com/pgadmin-org/pgadmin4/issues/6221>`_ - Fix circular reference error for the multirange data types in the query tool.
| `Issue #6253 <https://github.com/pgadmin-org/pgadmin4/issues/6253>`_ - Fix an issue in the register server when setting the role, an arbitrary SQL query can be fired.
| `Issue #6267 <https://github.com/pgadmin-org/pgadmin4/issues/6267>`_ - Ensure the user is able to log in if the specified OAUTH2_USERNAME_CLAIM is present in the OAuth2 profile.

View File

@ -256,6 +256,13 @@ export default class PrimaryKeySchema extends BaseUISchema {
}
validate(state, setError) {
if (!this.isNew(state) && isEmptyString(state.name)) {
setError('name', gettext('Name cannot be empty in edit mode.'));
return true;
} else {
setError('name', null);
}
if(isEmptyString(state.index)
&& (_.isUndefined(state.columns) || _.isNull(state.columns) || state.columns.length < 1)) {
setError('columns', gettext('Please specify columns for %s.', gettext('Primary key')));

View File

@ -452,6 +452,14 @@ export default class IndexSchema extends BaseUISchema {
validate(state, setError) {
let msg;
if (!this.isNew(state) && isEmptyString(state.name)) {
msg = gettext('Name cannot be empty in edit mode.');
setError('name', msg);
return true;
} else {
setError('name', null);
}
// Checks if columns is empty
let cols = state.columns;
if(_.isArray(cols) && cols.length == 0){