Skip to content

Commit 707fe4d

Browse files
fix review comments
1 parent 1a079b8 commit 707fe4d

6 files changed

Lines changed: 46 additions & 16 deletions

File tree

web/pgadmin/static/js/Theme/index.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,12 @@ basicSettings = createTheme(basicSettings, {
206206
height: '100%',
207207
boxSizing: 'border-box',
208208
},
209+
adornedStart: {
210+
paddingLeft: basicSettings.spacing(0.75),
211+
},
212+
inputAdornedStart: {
213+
paddingLeft: '2px',
214+
},
209215
adornedEnd: {
210216
paddingRight: basicSettings.spacing(0.75),
211217
},
@@ -523,7 +529,7 @@ function getFinalTheme(baseTheme) {
523529
},
524530
inputSizeSmall: {
525531
height: '16px', // + 12px of padding = 28px;
526-
}
532+
},
527533
}
528534
},
529535
MuiSelect: {

web/pgadmin/static/js/components/PgTable.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import gettext from 'sources/gettext';
3737
import EmptyPanelMessage from './EmptyPanelMessage';
3838
import { InputText } from './FormComponents';
3939
import { PgReactTable, PgReactTableBody, PgReactTableCell, PgReactTableHeader, PgReactTableRow, PgReactTableRowContent, PgReactTableRowExpandContent, getCheckboxCell, getCheckboxHeaderCell } from './PgReactTableStyled';
40+
import SearchRoundedIcon from '@mui/icons-material/SearchRounded';
4041

4142

4243
const ROW_HEIGHT = 30;
@@ -334,6 +335,7 @@ export default function PgTable({ caveTable = true, tableNoBorder = true, tableN
334335
onChange={(val) => {
335336
setSearchVal(val);
336337
}}
338+
startAdornment={<SearchRoundedIcon />}
337339
/>
338340
</Box>
339341
</Box>}

web/pgadmin/tools/user_management/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,8 @@ def create_user(data):
558558

559559
try:
560560
new_data = validate_user(data)
561+
new_data['password'] = new_data['password']\
562+
if 'password' in new_data else None
561563

562564
if 'roles' in new_data:
563565
new_data['roles'] = [Role.query.get(new_data['roles'])]

web/pgadmin/tools/user_management/static/js/Component.jsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
/////////////////////////////////////////////////////////////
2+
//
3+
// pgAdmin 4 - PostgreSQL Tools
4+
//
5+
// Copyright (C) 2013 - 2025, The pgAdmin Development Team
6+
// This software is released under the PostgreSQL Licence
7+
//
8+
//////////////////////////////////////////////////////////////
9+
110
import React from 'react';
211
import { Box, styled, Tab, Tabs } from '@mui/material';
312
import TabPanel from '../../../../static/js/components/TabPanel';

web/pgadmin/tools/user_management/static/js/UserDialog.jsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// This software is released under the PostgreSQL Licence
77
//
88
//////////////////////////////////////////////////////////////
9+
910
import React, { useMemo } from 'react';
1011
import SchemaView from '../../../../static/js/SchemaView';
1112
import BaseUISchema from '../../../../static/js/SchemaView/base_schema.ui';
@@ -46,7 +47,7 @@ class UserSchema extends BaseUISchema {
4647
}
4748

4849
isUserNameEnabled(state) {
49-
return !(this.authOnlyInternal || state.auth_source == AUTH_METHODS['INTERNAL']);
50+
return this.isNew(state) && state.auth_source != AUTH_METHODS['INTERNAL'];
5051
}
5152

5253
isNotCurrentUser(state) {
@@ -81,7 +82,7 @@ class UserSchema extends BaseUISchema {
8182
id: 'username', label: gettext('Username'), type: 'text',
8283
deps: ['auth_source'],
8384
depChange: (state) => {
84-
if (obj.isUserNameEnabled(state) && obj.isNew(state) && !isEmptyString(obj.username)) {
85+
if (!obj.isUserNameEnabled(state)) {
8586
return { username: undefined };
8687
}
8788
},
@@ -95,7 +96,7 @@ class UserSchema extends BaseUISchema {
9596
if (obj.isNew(state)) {
9697
return false;
9798
} else {
98-
return obj.isNotCurrentUser(state) && state.auth_source == AUTH_METHODS['INTERNAL'];
99+
return !obj.isNotCurrentUser(state) || state.auth_source == AUTH_METHODS['INTERNAL'];
99100
}
100101
}
101102
}, {
@@ -124,13 +125,13 @@ class UserSchema extends BaseUISchema {
124125
deps: ['auth_source'], controlProps: {
125126
autoComplete: 'new-password',
126127
},
127-
visible: obj.isNotCurrentUser,
128+
visible: (state)=>obj.isNotCurrentUser(state) && state.auth_source == AUTH_METHODS['INTERNAL'],
128129
}, {
129130
id: 'confirmPassword', label: gettext('Confirm password'), type: 'password',
130131
deps: ['auth_source'], controlProps: {
131132
autoComplete: 'new-password',
132133
},
133-
visible: obj.isNotCurrentUser,
134+
visible: (state)=>obj.isNotCurrentUser(state) && state.auth_source == AUTH_METHODS['INTERNAL'],
134135
}, {
135136
id: 'locked', label: gettext('Locked'), type: 'switch',
136137
readonly: (state) => {
@@ -210,15 +211,15 @@ export default function UserDialog({user, options, onClose}) {
210211
try {
211212
api.post(url_for('user_management.save'), changeData)
212213
.then(()=>{
213-
pgAdmin.Browser.notifier.success('Users Saved Successfully');
214+
pgAdmin.Browser.notifier.success(gettext('Users Saved Successfully'));
214215
resolve();
215216
onClose(null, true);
216217
})
217218
.catch((err)=>{
218219
reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
219220
});
220221
} catch (error) {
221-
reject(parseApiError(error));
222+
reject(Error(parseApiError(error)));
222223
}
223224
});
224225
};

web/pgadmin/tools/user_management/static/js/Users.jsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
1+
/////////////////////////////////////////////////////////////
2+
//
3+
// pgAdmin 4 - PostgreSQL Tools
4+
//
5+
// Copyright (C) 2013 - 2025, The pgAdmin Development Team
6+
// This software is released under the PostgreSQL Licence
7+
//
8+
//////////////////////////////////////////////////////////////
9+
110
import React, { useEffect, useMemo, useRef } from 'react';
2-
import { getDeleteCell, getEditCell } from '../../../../static/js/components/PgReactTableStyled';
11+
import { getDeleteCell, getEditCell, getSwitchCell } from '../../../../static/js/components/PgReactTableStyled';
312
import gettext from 'sources/gettext';
413
import pgAdmin from 'sources/pgadmin';
514
import getApiInstance, { parseApiError } from '../../../../static/js/api_instance';
@@ -80,7 +89,7 @@ export default function Users() {
8089

8190
const onDeleteClick = (row) => {
8291
const deleteRow = async () => {
83-
setLoading('Deleting user...');
92+
setLoading(gettext('Deleting user...'));
8493
try {
8594
await api.delete(url_for('user_management.save_id', { id: row.original.id }));
8695
pgAdmin.Browser.notifier.success(gettext('User deleted successfully.'));
@@ -93,15 +102,16 @@ export default function Users() {
93102

94103
pgAdmin.Browser.notifier.confirm(gettext('Delete User'), gettext('Are you sure you want to delete the user %s?', row.original.username),
95104
async () => {
96-
setLoading('Deleting user...');
105+
setLoading(gettext('Deleting user...'));
97106
try {
98107
const resp = await api.get(url_for('user_management.shared_servers', {'uid': row['id']}));
99-
if (resp.data?.data?.shared_servers > 0) {
108+
const noOfSharedServers = resp.data?.data?.shared_servers ?? 0;
109+
if (noOfSharedServers > 0) {
100110
const resp = await api.get(url_for('user_management.admin_users', {'uid': row['id']}));
101111
showChangeOwnership(
102112
gettext('Change ownership'),
103-
resp?.data?.data?.result?.data,
104-
resp?.data?.data?.shared_servers,
113+
resp.data?.data?.result?.data,
114+
noOfSharedServers,
105115
{'id': row.original['id'], 'name': !isEmptyString(row.original['email']) ? row.original['email'] : row.original['username']},
106116
()=> {
107117
pgAdmin.Browser.notifier.confirm(
@@ -221,7 +231,7 @@ export default function Users() {
221231
size: 50,
222232
minSize: 50,
223233
enableFilters: true,
224-
cell: ({ getValue }) => (getValue() ? gettext('Yes') : gettext('No')),
234+
cell: getSwitchCell(),
225235
},
226236
{
227237
header: gettext('Locked'),
@@ -231,7 +241,7 @@ export default function Users() {
231241
size: 50,
232242
minSize: 50,
233243
enableFilters: true,
234-
cell: ({ getValue }) => (getValue() ? gettext('Yes') : gettext('No')),
244+
cell: getSwitchCell(),
235245
}];
236246
}, []);
237247

0 commit comments

Comments
 (0)