(type)
| 131 | ]); |
| 132 | |
| 133 | const onDrop = (type) => { |
| 134 | let selRows = [], |
| 135 | selItem = pgAdmin.Browser.tree.selected(), |
| 136 | selectedItemData = selItem ? pgAdmin.Browser.tree.itemData(selItem) : null, |
| 137 | selNode = selectedItemData && pgAdmin.Browser.Nodes[selectedItemData._type], |
| 138 | url, msg, title; |
| 139 | |
| 140 | selRows = Object.keys(selectedObject).map((i)=>(selNode?.type == 'coll-constraints' ? { |
| 141 | id: data[i].oid, |
| 142 | _type: data[i]._type, |
| 143 | } : data[i][schemaRef.current.idAttribute])); |
| 144 | |
| 145 | if (selRows.length === 0) { |
| 146 | pgAdmin.Browser.notifier.alert( |
| 147 | gettext('Drop Multiple'), |
| 148 | gettext('Please select at least one object to drop.') |
| 149 | ); |
| 150 | return; |
| 151 | } |
| 152 | |
| 153 | if (!selNode) return; |
| 154 | |
| 155 | if (type === 'dropCascade') { |
| 156 | url = selNode.generate_url(selItem, 'delete'); |
| 157 | msg = gettext( |
| 158 | 'Are you sure you want to drop all the selected objects and all the objects that depend on them?' |
| 159 | ); |
| 160 | title = gettext('Drop CASCADE multiple objects?'); |
| 161 | } else if (type === 'dropForce') { |
| 162 | url = selNode.generate_url(selItem, 'delete'); |
| 163 | msg = gettext( |
| 164 | 'Drop databases with the force option will attempt to terminate all the existing connections to the selected databases. Are you sure you want to proceed?' |
| 165 | ); |
| 166 | title = gettext('Drop FORCE multiple objects?'); |
| 167 | } else { |
| 168 | url = selNode.generate_url(selItem, 'drop'); |
| 169 | msg = gettext('Are you sure you want to drop all the selected objects?'); |
| 170 | title = gettext('Drop multiple objects?'); |
| 171 | } |
| 172 | |
| 173 | const api = getApiInstance(); |
| 174 | let dropNodeProperties = function () { |
| 175 | setLoaderText(gettext('Deleting Objects...')); |
| 176 | api |
| 177 | .delete(url, { |
| 178 | data: JSON.stringify({ ids: selRows }), |
| 179 | contentType: 'application/json; charset=utf-8', |
| 180 | }) |
| 181 | .then(function (res) { |
| 182 | if (res.success == 0) { |
| 183 | pgAdmin.Browser.notifier.alertText(res.errormsg, res.info); |
| 184 | } |
| 185 | pgAdmin.Browser.tree.refresh(selItem); |
| 186 | setIsStale(true); |
| 187 | setSelectedObject({}); |
| 188 | }) |
| 189 | .catch(function (error) { |
| 190 | pgAdmin.Browser.notifier.alertText( |
no test coverage detected