|
1 | | -import { create as f } from "react-modal-promise"; |
2 | | -import { isEmpty as c, isNumber as g, differenceWith as w, isEqual as E, omit as a, get as s } from "lodash"; |
| 1 | +import { create as g } from "react-modal-promise"; |
| 2 | +import { isEmpty as u, isNumber as E, differenceWith as w, isEqual as T, omit as a, get as s } from "lodash"; |
3 | 3 | import d from "../components/ConfirmDialog/ConfirmDialog.mjs"; |
4 | | -import { PRIMARY_BUTTON as b, TERTIARY_BUTTON as u, DANGER_BUTTON as T, VIEW_SEARCH_PARAMETER as y } from "../constants.mjs"; |
5 | | -import { setFiltersWasHandled as h, showWarning as v } from "../reducers/commonDetailsReducer.mjs"; |
6 | | -import { setNotification as C } from "../reducers/notificationReducer.mjs"; |
| 4 | +import { PRIMARY_BUTTON as b, TERTIARY_BUTTON as m, DANGER_BUTTON as h, FORBIDDEN_ERROR_STATUS_CODE as v, VIEW_SEARCH_PARAMETER as y } from "../constants.mjs"; |
| 5 | +import { setFiltersWasHandled as C, showWarning as R } from "../reducers/commonDetailsReducer.mjs"; |
| 6 | +import { setNotification as N } from "../reducers/notificationReducer.mjs"; |
7 | 7 | import { showErrorNotification as l } from "./notification.util.mjs"; |
8 | | -const m = (t, e) => f(t)(e), M = (t, e) => m(d, { |
| 8 | +const p = (e, t) => g(e)(t), S = (e, t) => p(d, { |
9 | 9 | cancelButton: { |
10 | 10 | label: "Cancel", |
11 | | - variant: u |
| 11 | + variant: m |
12 | 12 | }, |
13 | 13 | confirmButton: { |
14 | 14 | label: "OK", |
15 | 15 | variant: b, |
16 | | - handler: e |
| 16 | + handler: t |
17 | 17 | }, |
18 | 18 | header: "Are you sure?", |
19 | | - message: t |
20 | | -}), O = (t, e, r) => m(d, { |
| 19 | + message: e |
| 20 | +}), _ = (e, t, n) => p(d, { |
21 | 21 | cancelButton: { |
22 | 22 | label: "Cancel", |
23 | | - variant: u |
| 23 | + variant: m |
24 | 24 | }, |
25 | 25 | confirmButton: { |
26 | 26 | label: "Delete", |
27 | | - variant: T, |
28 | | - handler: r |
| 27 | + variant: h, |
| 28 | + handler: n |
29 | 29 | }, |
30 | | - header: t, |
31 | | - message: e |
32 | | -}), F = (t) => Object.values(t).every( |
33 | | - (e) => !e || (e == null ? void 0 : e.length) === 0 || !g(e) && c(e) |
34 | | -), S = (t, e, r = []) => t.length !== e.length ? !1 : c( |
35 | | - w(t, e, (n, i) => E(a(n, r), a(i, r))) |
36 | | -), N = (t) => { |
37 | | - const e = s(t, "response.data.detail", null); |
38 | | - return typeof e == "string" ? e : s(e, "reason", ""); |
39 | | -}, V = (t, e) => { |
40 | | - const n = N(t) || t.message; |
41 | | - return (!n || n === "Not Found" || n.startsWith("Request failed with status code")) && e ? e : n || ""; |
42 | | -}, W = () => { |
43 | | - const t = { |
| 30 | + header: e, |
| 31 | + message: t |
| 32 | +}), F = (e) => Object.values(e).every( |
| 33 | + (t) => !t || (t == null ? void 0 : t.length) === 0 || !E(t) && u(t) |
| 34 | +), V = (e, t, n = []) => e.length !== t.length ? !1 : u( |
| 35 | + w(e, t, (r, i) => T(a(r, n), a(i, n))) |
| 36 | +), c = { |
| 37 | + [v]: "You do not have a permission to view this data" |
| 38 | +}, D = (e) => { |
| 39 | + const t = s(e, "response.data.detail", null); |
| 40 | + return typeof t == "string" ? t : s(t, "reason", ""); |
| 41 | +}, W = (e, t) => { |
| 42 | + const r = D(e) || e.message; |
| 43 | + return (!r || r === "Not Found" || r.startsWith("Request failed with status code")) && t ? t : c[e.status] ? c[e.status] : r || ""; |
| 44 | +}, x = () => { |
| 45 | + const e = { |
44 | 46 | transition: "transitionend", |
45 | 47 | OTransition: "oTransitionEnd", |
46 | 48 | MozTransition: "transitionend", |
47 | 49 | WebkitTransition: "webkitTransitionEnd" |
48 | 50 | }; |
49 | | - let e = document.body.style; |
50 | | - for (let r in t) |
51 | | - if (e[r] !== void 0) |
52 | | - return t[r]; |
53 | | -}, _ = (t) => getComputedStyle(document.documentElement).getPropertyValue(t).trim(), x = (t) => { |
54 | | - var e; |
55 | | - return (e = new URLSearchParams(t).get(y)) == null ? void 0 : e.toLowerCase(); |
56 | | -}, q = async (t, e, r = !1) => { |
57 | | - let n = Promise.resolve(!0); |
58 | | - return t.counter > 0 && (n = await new Promise((i) => { |
59 | | - const o = (p) => { |
60 | | - window.removeEventListener("discardChanges", o), window.removeEventListener("cancelLeave", o), i(p); |
| 51 | + let t = document.body.style; |
| 52 | + for (let n in e) |
| 53 | + if (t[n] !== void 0) |
| 54 | + return e[n]; |
| 55 | +}, I = (e) => getComputedStyle(document.documentElement).getPropertyValue(e).trim(), q = (e) => { |
| 56 | + var t; |
| 57 | + return (t = new URLSearchParams(e).get(y)) == null ? void 0 : t.toLowerCase(); |
| 58 | +}, H = async (e, t, n = !1) => { |
| 59 | + let r = Promise.resolve(!0); |
| 60 | + return e.counter > 0 && (r = await new Promise((i) => { |
| 61 | + const o = (f) => { |
| 62 | + window.removeEventListener("discardChanges", o), window.removeEventListener("cancelLeave", o), i(f); |
61 | 63 | }; |
62 | | - window.addEventListener("discardChanges", () => o(!0)), window.addEventListener("cancelLeave", () => o(!1)), e(h(r)), e(v(!0)); |
63 | | - })), n; |
64 | | -}, H = (t, e) => { |
65 | | - var r; |
66 | | - if (!((r = navigator.clipboard) != null && r.writeText)) |
| 64 | + window.addEventListener("discardChanges", () => o(!0)), window.addEventListener("cancelLeave", () => o(!1)), t(C(n)), t(R(!0)); |
| 65 | + })), r; |
| 66 | +}, Y = (e, t) => { |
| 67 | + var n; |
| 68 | + if (!((n = navigator.clipboard) != null && n.writeText)) |
67 | 69 | return l( |
68 | | - e, |
| 70 | + t, |
69 | 71 | null, |
70 | 72 | "", |
71 | 73 | "Copy to clipboard failed due to unsecured connection" |
72 | 74 | ); |
73 | | - navigator.clipboard.writeText(t).then(() => { |
74 | | - e( |
75 | | - C({ |
| 75 | + navigator.clipboard.writeText(e).then(() => { |
| 76 | + t( |
| 77 | + N({ |
76 | 78 | status: 200, |
77 | 79 | id: Math.random(), |
78 | 80 | message: "Copied to clipboard successfully" |
79 | 81 | }) |
80 | 82 | ); |
81 | | - }).catch((n) => { |
82 | | - l(e, n, "", "Copy to clipboard failed"); |
| 83 | + }).catch((r) => { |
| 84 | + l(t, r, "", "Copy to clipboard failed"); |
83 | 85 | }); |
84 | | -}, I = (t, e) => { |
85 | | - if ((typeof t == "string" && t.trim() !== "" || typeof t == "number") && !isNaN(t)) { |
86 | | - const r = parseFloat(t); |
87 | | - return r % 1 === 0 ? r : +r.toFixed(e ?? 2); |
| 86 | +}, j = (e, t) => { |
| 87 | + if ((typeof e == "string" && e.trim() !== "" || typeof e == "number") && !isNaN(e)) { |
| 88 | + const n = parseFloat(e); |
| 89 | + return n % 1 === 0 ? n : +n.toFixed(t ?? 2); |
88 | 90 | } |
89 | | - return t; |
90 | | -}, j = (t) => new URL(t, window.location.origin).toString(); |
| 91 | + return e; |
| 92 | +}, k = (e) => new URL(e, window.location.origin).toString(); |
91 | 93 | export { |
92 | | - S as areArraysEqual, |
93 | | - H as copyToClipboard, |
94 | | - j as generateUrlFromRouterPath, |
95 | | - N as getErrorDetail, |
96 | | - V as getErrorMsg, |
97 | | - _ as getScssVariableValue, |
98 | | - W as getTransitionEndEventName, |
99 | | - x as getViewMode, |
| 94 | + V as areArraysEqual, |
| 95 | + Y as copyToClipboard, |
| 96 | + k as generateUrlFromRouterPath, |
| 97 | + D as getErrorDetail, |
| 98 | + W as getErrorMsg, |
| 99 | + I as getScssVariableValue, |
| 100 | + x as getTransitionEndEventName, |
| 101 | + q as getViewMode, |
100 | 102 | F as isEveryObjectValueEmpty, |
101 | | - M as openConfirmPopUp, |
102 | | - O as openDeleteConfirmPopUp, |
103 | | - m as openPopUp, |
104 | | - q as performDetailsActionHelper, |
105 | | - I as roundFloats |
| 103 | + S as openConfirmPopUp, |
| 104 | + _ as openDeleteConfirmPopUp, |
| 105 | + p as openPopUp, |
| 106 | + H as performDetailsActionHelper, |
| 107 | + j as roundFloats |
106 | 108 | }; |
107 | 109 | //# sourceMappingURL=common.util.mjs.map |
0 commit comments