Skip to content

Commit

Permalink
Fixed issues for Workspaces:
Browse files Browse the repository at this point in the history
1) Unable to add ad-hoc server with External Database.
2) Server list not updating when password is saved on the Welcome page.
3) Icons for Query Tool and PSQL missing on the Welcome page.
4) Error when removing connection parameters.
  • Loading branch information
akshay-joshi committed Jan 29, 2025
1 parent 707d037 commit 1607875
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 28 deletions.
27 changes: 14 additions & 13 deletions web/pgadmin/misc/workspaces/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,24 @@ def adhoc_connect_server():
connection_params = convert_connection_parameter(
data.get('connection_params', []))

if 'hostaddr' in connection_params and \
not is_valid_ipaddress(connection_params['hostaddr']):
return make_json_response(
success=0,
status=400,
errormsg=gettext('Not a valid Host address')
)
if connection_params is not None:
if 'hostaddr' in connection_params and \
not is_valid_ipaddress(connection_params['hostaddr']):
return make_json_response(
success=0,
status=400,
errormsg=gettext('Not a valid Host address')
)

# To check ssl configuration
_, connection_params = check_ssl_fields(connection_params)
# set the connection params again in the data
if 'connection_params' in data:
data['connection_params'] = connection_params
# To check ssl configuration
_, connection_params = check_ssl_fields(connection_params)
# set the connection params again in the data
if 'connection_params' in data:
data['connection_params'] = connection_params

# Fetch all the new data in case of non-existing servers
new_host = data.get('host', None)
new_port = data.get('port', None)
new_port = int(data.get('port', 0))
new_db = data.get('database_name', None)
if new_db is None:
new_db = data.get('did')
Expand Down
36 changes: 23 additions & 13 deletions web/pgadmin/misc/workspaces/static/js/AdHocConnection.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,15 @@ class AdHocConnectionSchema extends BaseUISchema {
optionsReloadBasis: `${self.flatServers.map((s) => s.connected).join('')}${state.connection_refresh}`,
}),
depChange: (state, source)=>{
if(source == 'connection_refresh') return;
/* Once the option is selected get the name */
/* Force sid to null, and set only if connected */
// Check for connection status
let selectedServer = _.find(
self.flatServers, (s) => s.value == state.sid
);
if(source.includes('connection_refresh')) {
return {
connected: selectedServer?.connected
};
}
return {
server_name: null,
did: null,
Expand Down Expand Up @@ -205,7 +208,7 @@ class AdHocConnectionSchema extends BaseUISchema {
disabled: (state) => state.sid,
},{
id: 'did', label: gettext('Database'), deps: ['sid', 'connected'],
noEmpty: true, controlProps: {creatable: true},
controlProps: {creatable: true},
type: (state) => {
if (state?.sid) {
return {
Expand Down Expand Up @@ -303,24 +306,31 @@ class AdHocConnectionSchema extends BaseUISchema {
setError('host', null);
}
}
if(isEmptyString(state.port)) {
errmsg = gettext('Port must be specified.');
setError('port', errmsg);
return true;
} else {
setError('port', null);
}

if(isEmptyString(state.username)) {
errmsg = gettext('Username must be specified.');
setError('username', errmsg);
if(isEmptyString(state.did)) {
errmsg = gettext('Database must be specified.');
setError('did', errmsg);
return true;
} else {
setError('username', null);
setError('did', null);
}

if(isEmptyString(state.port)) {
errmsg = gettext('Port must be specified.');
setError('port', errmsg);
if(isEmptyString(state.user)) {
errmsg = gettext('User must be specified.');
setError('user', errmsg);
return true;
} else {
setError('port', null);
setError('user', null);
}
} else {
_.each(['host', 'db', 'username', 'port'], (item) => {
_.each(['host', 'port', 'did', 'user'], (item) => {
setError(item, null);
});
}
Expand Down
5 changes: 3 additions & 2 deletions web/pgadmin/static/js/SchemaView/SchemaDialogView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import { useSchemaState } from './hooks';
import { getForQueryParams } from './common';
import { QueryToolIcon } from '../components/ExternalIcon';
import TerminalRoundedIcon from '@mui/icons-material/TerminalRounded';
import { WORKSPACES } from '../../../browser/static/js/constants';


/* If its the dialog */
Expand Down Expand Up @@ -167,9 +168,9 @@ export default function SchemaDialogView({
return <PublishIcon />;
} else if(props.customSaveBtnIconType == 'done') {
return <DoneIcon />;
} else if(props.customSaveBtnIconType == 'Query Tool') {
} else if(props.customSaveBtnIconType == WORKSPACES.QUERY_TOOL) {
return <QueryToolIcon />;
} else if(props.customSaveBtnIconType == 'PSQL') {
} else if(props.customSaveBtnIconType == WORKSPACES.PSQL_TOOL) {
return <TerminalRoundedIcon style={{width:'unset'}}/>;
}
return <SaveIcon />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ const StyledPgReactDataGrid = styled(PgReactDataGrid)(({stripedRows, theme})=>({
outlineColor: theme.palette.primary.main,
backgroundColor: theme.palette.primary.light,
color: theme.otherVars.qtDatagridSelectFg,
'&.rdg-cell-copied[aria-selected=false][role="gridcell"]': {
backgroundColor: theme.palette.primary.light + '!important',
}
},
... stripedRows && {'& .rdg-row.rdg-row-even': {
backgroundColor: theme.palette.grey[400],
Expand Down

0 comments on commit 1607875

Please sign in to comment.