mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-11-04 05:06:57 -06:00
2) Added Dark(Beta) UI Theme option. Fixes #3741. 3) Fix an issue where a black arrow-kind image is displaying at the background of browser tree images. Fixes #4171 Changes include: 1) New theme option in preferences - Miscellaneous -> Themes. You can select the theme from the dropdown. It also has a preview of the theme just below the dropdown. Note that, a page refresh is needed to apply changes. On saving, a dialog appears to ask for refresh. 2) You can create your own theme and submit to hackers. README is updated to help you create a theme. Theme will be available only after the bundle. 3) Correction of SASS variables at few places and few other CSS corrections. 4) Added iconfont-webpack-plugin, which will convert all the SVG files(monochrome) used as icons for buttons to font icons. This will allow us to change the color of the icon by using CSS color property. 5) All the .css files will bundle into a separate file now- pgadmin.style.css. This will help reduce the size of theme CSS files as CSS in .css files will not change with the change of SASS variables.
104 lines
3.0 KiB
JavaScript
104 lines
3.0 KiB
JavaScript
/////////////////////////////////////////////////////////////
|
|
//
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
//
|
|
// Copyright (C) 2013 - 2019, The pgAdmin Development Team
|
|
// This software is released under the PostgreSQL Licence
|
|
//
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
import gettext from 'sources/gettext';
|
|
import _ from 'underscore';
|
|
import pgAdmin from 'sources/pgadmin';
|
|
|
|
let _toolbarButtons = {};
|
|
let _browserPanel = null;
|
|
|
|
// Default Tool Bar Buttons.
|
|
let _defaultToolBarButtons = [
|
|
{
|
|
label: gettext('Filtered Rows'),
|
|
btnClass: 'fa fa-filter',
|
|
text: '',
|
|
toggled: false,
|
|
toggleClass: '',
|
|
parentClass: 'pg-toolbar-btn btn-secondary',
|
|
enabled: false,
|
|
},
|
|
{
|
|
label: gettext('View Data'),
|
|
btnClass: 'fa fa-table',
|
|
text: '',
|
|
toggled: false,
|
|
toggleClass: '',
|
|
parentClass: 'pg-toolbar-btn btn-secondary',
|
|
enabled: false,
|
|
},
|
|
{
|
|
label: gettext('Query Tool'),
|
|
btnClass: 'fa fa-bolt',
|
|
text: '',
|
|
toggled: false,
|
|
toggleClass: '',
|
|
parentClass: 'pg-toolbar-btn btn-secondary',
|
|
enabled: false,
|
|
},
|
|
];
|
|
|
|
// Place holder for non default tool bar buttons.
|
|
let _otherToolbarButtons = [];
|
|
|
|
// This function is used to add button into the browser panel.
|
|
function registerToolBarButton(btn) {
|
|
/* Sometimes the panel onCreate is called two times.
|
|
* Add buttons if not present in the panel also.
|
|
*/
|
|
if (!(btn.label in _toolbarButtons)
|
|
|| (_.findIndex(_browserPanel._buttonList,{name:btn.label}) < 0)) {
|
|
_browserPanel.addButton(
|
|
btn.label, btn.btnClass, btn.text, btn.label, btn.toggled,
|
|
btn.toggleClass, btn.parentClass, btn.enabled
|
|
);
|
|
|
|
_toolbarButtons[btn.label] = btn;
|
|
}
|
|
}
|
|
|
|
// This function is used to add tool bar button and
|
|
// listen on the button event.
|
|
export function initializeToolbar(panel, wcDocker) {
|
|
_browserPanel = panel;
|
|
|
|
// Iterate through default tool bar buttons and add them into the
|
|
// browser panel.
|
|
_.each(_defaultToolBarButtons, (btn) => {
|
|
registerToolBarButton(btn);
|
|
});
|
|
|
|
// Iterate through other tool bar buttons and add them into the
|
|
// browser panel.
|
|
_.each(_otherToolbarButtons, (btn) => {
|
|
registerToolBarButton(btn);
|
|
});
|
|
|
|
// Listen on button click event.
|
|
panel.on(wcDocker.EVENT.BUTTON, function(data) {
|
|
if ('name' in data && data.name === gettext('Query Tool'))
|
|
pgAdmin.DataGrid.show_query_tool('', pgAdmin.Browser.tree.selected());
|
|
else if ('name' in data && data.name === gettext('View Data'))
|
|
pgAdmin.DataGrid.show_data_grid({mnuid: 3}, pgAdmin.Browser.tree.selected());
|
|
else if ('name' in data && data.name === gettext('Filtered Rows'))
|
|
pgAdmin.DataGrid.show_filtered_row({mnuid: 4}, pgAdmin.Browser.tree.selected());
|
|
});
|
|
}
|
|
|
|
// This function is used to enable/disable the specific button
|
|
// based on their label.
|
|
export function enable(label, enable) {
|
|
if (label in _toolbarButtons) {
|
|
_browserPanel.buttonEnable(label, enable);
|
|
} else {
|
|
console.warn('Developer warning: No tool button found with label: ' + label);
|
|
}
|
|
}
|