@devtron-labs/devtron-fe-common-lib 0.0.7-beta-42 → 0.0.7-beta-45
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,3 +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 { default as DeleteComponent } from './DeleteComponentModal/DeleteComponent';
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ 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
|
+
var reactRouter = require('react-router');
|
|
7
8
|
|
|
8
9
|
function _interopNamespaceDefault(e) {
|
|
9
10
|
var n = Object.create(null);
|
|
@@ -16704,6 +16705,67 @@ function Radio(_a) {
|
|
|
16704
16705
|
}
|
|
16705
16706
|
RadioGroup.Radio = Radio;
|
|
16706
16707
|
|
|
16708
|
+
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";
|
|
16709
|
+
|
|
16710
|
+
function DeleteComponent(_a) {
|
|
16711
|
+
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;
|
|
16712
|
+
var _f = __read(React.useState(false), 2), showCannotDeleteDialogModal = _f[0], setCannotDeleteDialogModal = _f[1];
|
|
16713
|
+
var push = reactRouter.useHistory().push;
|
|
16714
|
+
function handleDelete() {
|
|
16715
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
16716
|
+
var serverError_1;
|
|
16717
|
+
return __generator(this, function (_a) {
|
|
16718
|
+
switch (_a.label) {
|
|
16719
|
+
case 0:
|
|
16720
|
+
setDeleting(true);
|
|
16721
|
+
_a.label = 1;
|
|
16722
|
+
case 1:
|
|
16723
|
+
_a.trys.push([1, 3, 4, 5]);
|
|
16724
|
+
return [4 /*yield*/, deleteComponent(payload)];
|
|
16725
|
+
case 2:
|
|
16726
|
+
_a.sent();
|
|
16727
|
+
toast.success('Successfully deleted');
|
|
16728
|
+
toggleConfirmation(false);
|
|
16729
|
+
if (redirectTo) {
|
|
16730
|
+
push(url);
|
|
16731
|
+
}
|
|
16732
|
+
else {
|
|
16733
|
+
reload();
|
|
16734
|
+
}
|
|
16735
|
+
if (typeof closeCustomComponent === 'function') {
|
|
16736
|
+
closeCustomComponent();
|
|
16737
|
+
}
|
|
16738
|
+
return [3 /*break*/, 5];
|
|
16739
|
+
case 3:
|
|
16740
|
+
serverError_1 = _a.sent();
|
|
16741
|
+
if (serverError_1 instanceof ServerErrors && serverError_1.code === 500) {
|
|
16742
|
+
setCannotDeleteDialogModal(true);
|
|
16743
|
+
}
|
|
16744
|
+
return [3 /*break*/, 5];
|
|
16745
|
+
case 4:
|
|
16746
|
+
setDeleting(false);
|
|
16747
|
+
return [7 /*endfinally*/];
|
|
16748
|
+
case 5: return [2 /*return*/];
|
|
16749
|
+
}
|
|
16750
|
+
});
|
|
16751
|
+
});
|
|
16752
|
+
}
|
|
16753
|
+
var handleConfirmation = function () {
|
|
16754
|
+
setCannotDeleteDialogModal(false);
|
|
16755
|
+
toggleConfirmation(false);
|
|
16756
|
+
if (typeof closeCustomComponent === 'function') {
|
|
16757
|
+
closeCustomComponent();
|
|
16758
|
+
}
|
|
16759
|
+
};
|
|
16760
|
+
var renderCannotDeleteDialogModal = function () {
|
|
16761
|
+
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" })) })] })));
|
|
16762
|
+
};
|
|
16763
|
+
var renderDeleteDialog = function () {
|
|
16764
|
+
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, "? "] }) }) })));
|
|
16765
|
+
};
|
|
16766
|
+
return (jsxRuntime.jsxs("div", { children: [!showCannotDeleteDialogModal && renderDeleteDialog(), showCannotDeleteDialogModal && renderCannotDeleteDialogModal()] }));
|
|
16767
|
+
}
|
|
16768
|
+
|
|
16707
16769
|
exports.BreadCrumb = BreadCrumb;
|
|
16708
16770
|
exports.BreadcrumbStore = Store;
|
|
16709
16771
|
exports.CDModalTab = CDModalTab;
|
|
@@ -16716,6 +16778,7 @@ exports.CustomSelect = CustomSelect;
|
|
|
16716
16778
|
exports.DEFAULT_TAG_DATA = DEFAULT_TAG_DATA;
|
|
16717
16779
|
exports.DOCUMENTATION = DOCUMENTATION;
|
|
16718
16780
|
exports.DOCUMENTATION_HOME_PAGE = DOCUMENTATION_HOME_PAGE;
|
|
16781
|
+
exports.DeleteComponent = DeleteComponent;
|
|
16719
16782
|
exports.DeleteDialog = DeleteDialog;
|
|
16720
16783
|
exports.DetailsProgressing = DetailsProgressing;
|
|
16721
16784
|
exports.DialogForm = DialogForm;
|
package/package.json
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 32 32">
|
|
2
|
+
<g fill="none" fill-rule="evenodd">
|
|
3
|
+
<path d="M0 0h32v32H0z"/>
|
|
4
|
+
<path fill="#06C" d="M16 2.667C8.64 2.667 2.667 8.64 2.667 16S8.64 29.333 16 29.333 29.333 23.36 29.333 16 23.36 2.667 16 2.667z"/>
|
|
5
|
+
<path fill="#FFF" d="M16 14.667c.736 0 1.333.597 1.333 1.333v5.333a1.333 1.333 0 1 1-2.666 0V16c0-.736.597-1.333 1.333-1.333zm0-5.334A1.333 1.333 0 1 1 16 12a1.333 1.333 0 0 1 0-2.667z"/>
|
|
6
|
+
</g>
|
|
7
|
+
</svg>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { useState } from 'react'
|
|
2
|
-
import { toast } from 'react-toastify'
|
|
3
2
|
import { useHistory } from 'react-router'
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import { DeleteDialog } from '../Dialogs'
|
|
3
|
+
import { toast } from 'react-toastify'
|
|
4
|
+
import info from '../../Assets/Icon/ic-info-filled.svg'
|
|
5
|
+
import { ConfirmationDialog, DeleteDialog } from '../Dialogs'
|
|
7
6
|
import { ServerErrors } from '../ServerError'
|
|
8
7
|
import { DeleteComponentProps } from './types'
|
|
9
8
|
|
|
9
|
+
|
|
10
10
|
function DeleteComponent({
|
|
11
11
|
setDeleting,
|
|
12
12
|
toggleConfirmation,
|
package/src/Common/index.ts
CHANGED
|
@@ -29,3 +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 { default as DeleteComponent } from './DeleteComponentModal/DeleteComponent'
|