mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Port preferences dialog to React. Fixes #7149
This commit is contained in:
committed by
Akshay Joshi
parent
3299b0c1b0
commit
74e794b416
@@ -0,0 +1,71 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
//
|
||||
// pgAdmin 4 - PostgreSQL Tools
|
||||
//
|
||||
// Copyright (C) 2013 - 2022, The pgAdmin Development Team
|
||||
// This software is released under the PostgreSQL Licence
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
import gettext from 'sources/gettext';
|
||||
import _ from 'lodash';
|
||||
import url_for from 'sources/url_for';
|
||||
import BaseUISchema from 'sources/SchemaView/base_schema.ui';
|
||||
import getApiInstance from '../../../../../static/js/api_instance';
|
||||
import Notify from '../../../../../static/js/helpers/Notifier';
|
||||
|
||||
export function getBinaryPathSchema() {
|
||||
|
||||
return new BinaryPathSchema();
|
||||
}
|
||||
|
||||
export default class BinaryPathSchema extends BaseUISchema {
|
||||
constructor() {
|
||||
super({
|
||||
isDefault: false,
|
||||
serverType: undefined,
|
||||
binaryPath: null,
|
||||
});
|
||||
}
|
||||
|
||||
get baseFields() {
|
||||
return [
|
||||
{
|
||||
id: 'isDefault', label: gettext('Set as default'), type: 'radio',
|
||||
width: 32,
|
||||
radioType: true,
|
||||
disabled: function (state) {
|
||||
return state?.binaryPath && state?.binaryPath.length > 0 ? false : true;
|
||||
},
|
||||
cell: 'radio',
|
||||
deps: ['binaryPath'],
|
||||
},
|
||||
{
|
||||
id: 'serverType',
|
||||
label: gettext('Database Server'),
|
||||
type: 'text', cell: '',
|
||||
width: 40,
|
||||
},
|
||||
{
|
||||
id: 'binaryPath', label: gettext('Binary Path'), cell: 'file', type: 'file',
|
||||
isvalidate: true, controlProps: { dialogType: 'select_folder', supportedTypes: ['*', 'sql', 'backup'], dialogTitle: 'Select folder' },
|
||||
validate: (data) => {
|
||||
const api = getApiInstance();
|
||||
if (_.isNull(data) || data.trim() === '') {
|
||||
Notify.alert(gettext('Validate Path'), gettext('Path should not be empty.'));
|
||||
} else {
|
||||
api.post(url_for('misc.validate_binary_path'),
|
||||
JSON.stringify({ 'utility_path': data }))
|
||||
.then(function (res) {
|
||||
Notify.alert(gettext('Validate binary path'), gettext(res.data.data));
|
||||
})
|
||||
.catch(function (error) {
|
||||
Notify.pgNotifier(error, gettext('Failed to validate binary path.'));
|
||||
});
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user