MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / initData

Function initData

web/pgadmin/misc/properties/ObjectNodeProperties.jsx:78–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

76
77 /* Called when dialog is opened in edit mode, promise required */
78 let initData = ()=>new Promise((resolve, reject)=>{
79 if(actionType === 'create' && !isActionTypeCopy) {
80 resolve({});
81 } else {
82 // Do not call the API if tab is not active.
83 if(!isActive && actionType == 'properties') {
84 return;
85 }
86 api.get(url(false))
87 .then((res)=>{
88 let data = res.data;
89 if (isActionTypeCopy) {
90 // Delete the idAttribute while copying the node.
91 delete data[schema.idAttribute];
92 data = node.copy(data);
93 }
94 resolve(data);
95 })
96 .catch((err)=>{
97 pgAdmin.Browser.notifier.pgNotifier('error', err, gettext('Failed to fetch data'), function(msg) {
98 if (msg == 'CRYPTKEY_SET') {
99 return Promise.resolve(initData());
100 } else if (msg == 'CRYPTKEY_NOT_SET') {
101 reject(new Error(gettext('The master password is not set.')));
102 }
103 reject(err instanceof Error ? err : Error(gettext('Something went wrong')));
104 });
105
106 })
107 .then(()=>{
108 // applies only for properties tab
109 setIsStale?.(false);
110 });
111 }
112 });
113
114 /* on save button callback, promise required */
115 const onSaveClick = (isNew, data)=>new Promise((resolve, reject)=>{

Callers

nothing calls this directly

Calls 4

gettextFunction · 0.85
pgNotifierMethod · 0.80
urlFunction · 0.70
getMethod · 0.45

Tested by

no test coverage detected