mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2026-11-03 12:49:23 -06:00
On pressing Ctrl+C on a tree object, copy the fully qualified name to clipboard. #5854
This commit is contained in:
1 parent
3f78cfa092
commit
5330121b36
4 files changed
+60
-18
No files matched your search
@@ -17,6 +17,7 @@ import { pgHandleItemError } from '../../../static/js/utils';
|
||||
import { Search } from './quick_search/trigger_search';
|
||||
import { send_heartbeat, stop_heartbeat } from './heartbeat';
|
||||
import getApiInstance from '../../../static/js/api_instance';
|
||||
import { copyToClipboard } from '../../../static/js/clipboard';
|
||||
|
||||
define('pgadmin.browser', [
|
||||
'sources/gettext', 'sources/url_for', 'jquery',
|
||||
@@ -70,10 +71,31 @@ define('pgadmin.browser', [
|
||||
|
||||
let initializeBrowserTree = pgAdmin.Browser.initializeBrowserTree =
|
||||
function(b) {
|
||||
const draggableTypes = [
|
||||
'collation domain domain_constraints fts_configuration fts_dictionary fts_parser fts_template synonym table partition type sequence package view mview foreign_table edbvar',
|
||||
'schema column database cast event_trigger extension language foreign_data_wrapper foreign_server user_mapping compound_trigger index index_constraint primary_key unique_constraint check_constraint exclusion_constraint foreign_key rule',
|
||||
'trigger trigger_function',
|
||||
'edbfunc function edbproc procedure'
|
||||
];
|
||||
InitTree.initBrowserTree(b).then(() => {
|
||||
const getQualifiedName = (data, item)=>{
|
||||
if(draggableTypes[0].includes(data._type)) {
|
||||
return pgadminUtils.fully_qualify(b, data, item);
|
||||
} else if(draggableTypes[1].includes(data._type)) {
|
||||
return pgadminUtils.quote_ident(data._label);
|
||||
} else if(draggableTypes[3].includes(data._type)) {
|
||||
let newData = {...data};
|
||||
let parsedFunc = pgadminUtils.parseFuncParams(newData._label);
|
||||
newData._label = parsedFunc.func_name;
|
||||
return pgadminUtils.fully_qualify(b, newData, item);
|
||||
} else {
|
||||
return data._label;
|
||||
}
|
||||
};
|
||||
|
||||
b.tree.registerDraggableType({
|
||||
'collation domain domain_constraints fts_configuration fts_dictionary fts_parser fts_template synonym table partition type sequence package view mview foreign_table edbvar' : (data, item, treeNodeInfo)=>{
|
||||
let text = pgadminUtils.fully_qualify(b, data, item);
|
||||
[draggableTypes[0]] : (data, item, treeNodeInfo)=>{
|
||||
let text = getQualifiedName(data, item);
|
||||
return {
|
||||
text: text,
|
||||
objUrl: generateNodeUrl.call(pgBrowser.Nodes[data._type], treeNodeInfo, 'properties', data, true),
|
||||
@@ -84,22 +106,17 @@ define('pgadmin.browser', [
|
||||
},
|
||||
};
|
||||
},
|
||||
'schema column database cast event_trigger extension language foreign_data_wrapper foreign_server user_mapping compound_trigger index index_constraint primary_key unique_constraint check_constraint exclusion_constraint foreign_key rule' : (data)=>{
|
||||
return pgadminUtils.quote_ident(data._label);
|
||||
[draggableTypes[1]] : (data)=>{
|
||||
return getQualifiedName(data);
|
||||
},
|
||||
'trigger trigger_function' : (data)=>{
|
||||
return data._label;
|
||||
[draggableTypes[2]] : (data)=>{
|
||||
return getQualifiedName(data);
|
||||
},
|
||||
'edbfunc function edbproc procedure' : (data, item)=>{
|
||||
let newData = {...data},
|
||||
parsedFunc = null,
|
||||
dropVal = '',
|
||||
[draggableTypes[3]] : (data, item)=>{
|
||||
let parsedFunc = pgadminUtils.parseFuncParams(data._label),
|
||||
dropVal = getQualifiedName(data, item),
|
||||
curPos = {from: 0, to: 0};
|
||||
|
||||
parsedFunc = pgadminUtils.parseFuncParams(newData._label);
|
||||
newData._label = parsedFunc.func_name;
|
||||
dropVal = pgadminUtils.fully_qualify(b, newData, item);
|
||||
|
||||
if(parsedFunc.params.length > 0) {
|
||||
dropVal = dropVal + '(';
|
||||
curPos.from = dropVal.length;
|
||||
@@ -122,6 +139,10 @@ define('pgadmin.browser', [
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
b.tree.onNodeCopy((data, item)=>{
|
||||
copyToClipboard(getQualifiedName(data, item));
|
||||
});
|
||||
}, () => {console.warn('Tree Load Error');});
|
||||
};
|
||||
|
||||
|
||||
Reference in new issue
Block a user