()
| 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)=>{ |
nothing calls this directly
no test coverage detected