@devtron-labs/devtron-fe-common-lib 0.0.7-beta-44 → 0.0.7-beta-46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/Common/index.d.ts
CHANGED
|
@@ -29,4 +29,4 @@ export { default as GenericEmptyState } from './EmptyState/GenericEmptyState';
|
|
|
29
29
|
export { default as Toggle } from './Toggle/Toggle';
|
|
30
30
|
export { default as ScanVulnerabilitiesTable } from './Security/ScanVulnerabilitiesTable';
|
|
31
31
|
export { default as StyledRadioGroup } from './RadioGroup/RadioGroup';
|
|
32
|
-
export
|
|
32
|
+
export { default as DeleteComponent } from './DeleteComponentModal/DeleteComponent';
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,6 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
4
4
|
var React = require('react');
|
|
5
5
|
var ReactDOM = require('react-dom');
|
|
6
6
|
var reactRouterDom = require('react-router-dom');
|
|
7
|
-
require('react-router');
|
|
8
7
|
|
|
9
8
|
function _interopNamespaceDefault(e) {
|
|
10
9
|
var n = Object.create(null);
|
|
@@ -16705,6 +16704,67 @@ function Radio(_a) {
|
|
|
16705
16704
|
}
|
|
16706
16705
|
RadioGroup.Radio = Radio;
|
|
16707
16706
|
|
|
16707
|
+
var info = "data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2220%22%20height%3D%2220%22%20viewBox%3D%220%200%2032%2032%22%3E%20%20%20%20%3Cg%20fill%3D%22none%22%20fill-rule%3D%22evenodd%22%3E%20%20%20%20%20%20%20%20%3Cpath%20d%3D%22M0%200h32v32H0z%22%2F%3E%20%20%20%20%20%20%20%20%3Cpath%20fill%3D%22%2306C%22%20d%3D%22M16%202.667C8.64%202.667%202.667%208.64%202.667%2016S8.64%2029.333%2016%2029.333%2029.333%2023.36%2029.333%2016%2023.36%202.667%2016%202.667z%22%2F%3E%20%20%20%20%20%20%20%20%3Cpath%20fill%3D%22%23FFF%22%20d%3D%22M16%2014.667c.736%200%201.333.597%201.333%201.333v5.333a1.333%201.333%200%201%201-2.666%200V16c0-.736.597-1.333%201.333-1.333zm0-5.334A1.333%201.333%200%201%201%2016%2012a1.333%201.333%200%200%201%200-2.667z%22%2F%3E%20%20%20%20%3C%2Fg%3E%3C%2Fsvg%3E";
|
|
16708
|
+
|
|
16709
|
+
function DeleteComponent(_a) {
|
|
16710
|
+
var setDeleting = _a.setDeleting, toggleConfirmation = _a.toggleConfirmation, deleteComponent = _a.deleteComponent, title = _a.title, component = _a.component, payload = _a.payload, _b = _a.confirmationDialogDescription, confirmationDialogDescription = _b === void 0 ? '' : _b, _c = _a.redirectTo, redirectTo = _c === void 0 ? false : _c, _d = _a.url, url = _d === void 0 ? '' : _d, reload = _a.reload, _e = _a.configuration, configuration = _e === void 0 ? '' : _e, closeCustomComponent = _a.closeCustomComponent;
|
|
16711
|
+
var _f = __read(React.useState(false), 2), showCannotDeleteDialogModal = _f[0], setCannotDeleteDialogModal = _f[1];
|
|
16712
|
+
var push = reactRouterDom.useHistory().push;
|
|
16713
|
+
function handleDelete() {
|
|
16714
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
16715
|
+
var serverError_1;
|
|
16716
|
+
return __generator(this, function (_a) {
|
|
16717
|
+
switch (_a.label) {
|
|
16718
|
+
case 0:
|
|
16719
|
+
setDeleting(true);
|
|
16720
|
+
_a.label = 1;
|
|
16721
|
+
case 1:
|
|
16722
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
16723
|
+
return [4 /*yield*/, deleteComponent(payload)];
|
|
16724
|
+
case 2:
|
|
16725
|
+
_a.sent();
|
|
16726
|
+
toast.success('Successfully deleted');
|
|
16727
|
+
toggleConfirmation(false);
|
|
16728
|
+
if (redirectTo) {
|
|
16729
|
+
push(url);
|
|
16730
|
+
}
|
|
16731
|
+
else {
|
|
16732
|
+
reload();
|
|
16733
|
+
}
|
|
16734
|
+
if (typeof closeCustomComponent === 'function') {
|
|
16735
|
+
closeCustomComponent();
|
|
16736
|
+
}
|
|
16737
|
+
return [3 /*break*/, 5];
|
|
16738
|
+
case 3:
|
|
16739
|
+
serverError_1 = _a.sent();
|
|
16740
|
+
if (serverError_1 instanceof ServerErrors && serverError_1.code === 500) {
|
|
16741
|
+
setCannotDeleteDialogModal(true);
|
|
16742
|
+
}
|
|
16743
|
+
return [3 /*break*/, 5];
|
|
16744
|
+
case 4:
|
|
16745
|
+
setDeleting(false);
|
|
16746
|
+
return [7 /*endfinally*/];
|
|
16747
|
+
case 5: return [2 /*return*/];
|
|
16748
|
+
}
|
|
16749
|
+
});
|
|
16750
|
+
});
|
|
16751
|
+
}
|
|
16752
|
+
var handleConfirmation = function () {
|
|
16753
|
+
setCannotDeleteDialogModal(false);
|
|
16754
|
+
toggleConfirmation(false);
|
|
16755
|
+
if (typeof closeCustomComponent === 'function') {
|
|
16756
|
+
closeCustomComponent();
|
|
16757
|
+
}
|
|
16758
|
+
};
|
|
16759
|
+
var renderCannotDeleteDialogModal = function () {
|
|
16760
|
+
return (jsxRuntime.jsxs(ConfirmationDialog, __assign({ className: "confirmation-dialog__body--w-360" }, { children: [jsxRuntime.jsx(ConfirmationDialog.Icon, { src: info }), jsxRuntime.jsx(ConfirmationDialog.Body, { title: "Cannot delete ".concat(component, " '").concat(title, "'") }), jsxRuntime.jsx("p", __assign({ className: "fs-13 cn-7 " }, { children: confirmationDialogDescription })), jsxRuntime.jsx(ConfirmationDialog.ButtonGroup, { children: jsxRuntime.jsx("button", __assign({ type: "button", className: "cta", onClick: handleConfirmation }, { children: "Okay" })) })] })));
|
|
16761
|
+
};
|
|
16762
|
+
var renderDeleteDialog = function () {
|
|
16763
|
+
return (jsxRuntime.jsx(DeleteDialog, __assign({ title: "Delete ".concat(component, " '").concat(title, "'"), delete: handleDelete, closeDelete: function () { return toggleConfirmation(false); }, dataTestId: "delete-dialog" }, { children: jsxRuntime.jsx(DeleteDialog.Description, { children: jsxRuntime.jsxs("p", { children: ["Are you sure you want to delete this ", configuration ? configuration : component, "? "] }) }) })));
|
|
16764
|
+
};
|
|
16765
|
+
return (jsxRuntime.jsxs("div", { children: [!showCannotDeleteDialogModal && renderDeleteDialog(), showCannotDeleteDialogModal && renderCannotDeleteDialogModal()] }));
|
|
16766
|
+
}
|
|
16767
|
+
|
|
16708
16768
|
exports.BreadCrumb = BreadCrumb;
|
|
16709
16769
|
exports.BreadcrumbStore = Store;
|
|
16710
16770
|
exports.CDModalTab = CDModalTab;
|
|
@@ -16717,6 +16777,7 @@ exports.CustomSelect = CustomSelect;
|
|
|
16717
16777
|
exports.DEFAULT_TAG_DATA = DEFAULT_TAG_DATA;
|
|
16718
16778
|
exports.DOCUMENTATION = DOCUMENTATION;
|
|
16719
16779
|
exports.DOCUMENTATION_HOME_PAGE = DOCUMENTATION_HOME_PAGE;
|
|
16780
|
+
exports.DeleteComponent = DeleteComponent;
|
|
16720
16781
|
exports.DeleteDialog = DeleteDialog;
|
|
16721
16782
|
exports.DetailsProgressing = DetailsProgressing;
|
|
16722
16783
|
exports.DialogForm = DialogForm;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
|
-
import { useHistory } from 'react-router'
|
|
2
|
+
import { useHistory } from 'react-router-dom'
|
|
3
3
|
import { toast } from 'react-toastify'
|
|
4
4
|
import info from '../../Assets/Icon/ic-info-filled.svg'
|
|
5
5
|
import { ConfirmationDialog, DeleteDialog } from '../Dialogs'
|
package/src/Common/index.ts
CHANGED
|
@@ -29,4 +29,4 @@ export { default as GenericEmptyState } from './EmptyState/GenericEmptyState'
|
|
|
29
29
|
export { default as Toggle } from './Toggle/Toggle'
|
|
30
30
|
export { default as ScanVulnerabilitiesTable } from './Security/ScanVulnerabilitiesTable'
|
|
31
31
|
export { default as StyledRadioGroup } from './RadioGroup/RadioGroup'
|
|
32
|
-
export
|
|
32
|
+
export { default as DeleteComponent } from './DeleteComponentModal/DeleteComponent'
|