@variamosple/variamos-components 0.0.23 → 0.1.0
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/Components/AuthWrapper/index.js +18 -38
- package/dist/Components/ConfirmationModal/index.d.ts +1 -1
- package/dist/Components/ConfirmationModal/index.js +19 -280
- package/dist/Components/Footer/index.js +6 -6
- package/dist/Components/Header/BugFormModal.d.ts +14 -0
- package/dist/Components/Header/BugFormModal.js +100 -0
- package/dist/Components/Header/HeaderOptions.js +85 -31
- package/dist/Components/Header/MenuItem.js +19 -20
- package/dist/Components/Header/SubHeader.js +35 -9
- package/dist/Components/Header/index.js +24 -25
- package/dist/Components/NotAuthorized/index.js +10 -11
- package/dist/Components/Paginator/index.js +56 -128
- package/dist/Components/ProtectedRoute/index.js +10 -10
- package/dist/Context/AnalyticsContext.js +7 -7
- package/dist/Context/MenuContext.js +16 -16
- package/dist/Context/SessionContext.js +35 -35
- package/dist/HOC/WithPageVisit.d.ts +1 -1
- package/dist/HOC/WithPageVisit.js +6 -6
- package/dist/assets/index.css +1 -1
- package/package.json +10 -7
- package/dist/AbstractModalHeader-UzCRSxIO.js +0 -1690
- package/dist/Anchor-DJG5WYYF.js +0 -40
- package/dist/Button-DWo2Fl71.js +0 -78
- package/dist/Button-GQJKgb76.js +0 -33
- package/dist/Container-BLjzOisH.js +0 -22
- package/dist/Nav-CdxSljzW.js +0 -144
- package/dist/NavDropdown-AuV3RgfC.js +0 -1764
- package/dist/NavLink-ebvp1HCw.js +0 -173
- package/dist/SubHeader-gTVD9DIX.js +0 -481
- package/dist/ThemeProvider-Q3gZ4GF2.js +0 -72
- package/dist/jsx-runtime-Drh4NO5G.js +0 -633
- package/dist/useEventCallback-Bfo0-hwZ.js +0 -16
- package/dist/useMergedRefs-BpAaCckn.js +0 -16
- package/dist/useWindow-rGE2GXIv.js +0 -118
|
@@ -1,55 +1,35 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { jsx as o, Fragment as u } from "react/jsx-runtime";
|
|
2
|
+
import d, { useEffect as c } from "react";
|
|
3
|
+
import { Spinner as f } from "react-bootstrap";
|
|
4
4
|
import "../../Context/AnalyticsContext.js";
|
|
5
5
|
import "../../Context/MenuContext.js";
|
|
6
|
-
import { useRouter as
|
|
6
|
+
import { useRouter as p } from "../../Context/RouterContext.js";
|
|
7
7
|
import { useSession as l } from "../../Context/SessionContext.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
variant: n,
|
|
12
|
-
animation: i = "border",
|
|
13
|
-
size: c,
|
|
14
|
-
// Need to define the default "as" during prop destructuring to be compatible with styled-components github.com/react-bootstrap/react-bootstrap/issues/3595
|
|
15
|
-
as: r = "div",
|
|
16
|
-
className: s,
|
|
17
|
-
...m
|
|
18
|
-
}, e) => {
|
|
19
|
-
t = g(t, "spinner");
|
|
20
|
-
const o = `${t}-${i}`;
|
|
21
|
-
return /* @__PURE__ */ a.jsx(r, {
|
|
22
|
-
ref: e,
|
|
23
|
-
...m,
|
|
24
|
-
className: w(s, o, c && `${o}-${c}`, n && `text-${n}`)
|
|
25
|
-
});
|
|
26
|
-
});
|
|
27
|
-
d.displayName = "Spinner";
|
|
28
|
-
const k = ({
|
|
29
|
-
redirectPath: t,
|
|
30
|
-
children: n
|
|
8
|
+
const P = ({
|
|
9
|
+
redirectPath: i,
|
|
10
|
+
children: m
|
|
31
11
|
}) => {
|
|
32
|
-
const [
|
|
33
|
-
return
|
|
34
|
-
if (!
|
|
35
|
-
const e = window.location.href,
|
|
36
|
-
|
|
37
|
-
() =>
|
|
12
|
+
const [a, h] = d.useState(!1), { isAuthenticated: t, isLoading: r } = l(), { navigate: n } = p();
|
|
13
|
+
return c(() => {
|
|
14
|
+
if (!r && !t && !a) {
|
|
15
|
+
const e = window.location.href, s = new URLSearchParams();
|
|
16
|
+
s.set("redirectTo", encodeURIComponent(e)), h(!0), setTimeout(
|
|
17
|
+
() => n(`${i}?${s.toString()}`),
|
|
38
18
|
300
|
|
39
19
|
);
|
|
40
20
|
}
|
|
41
|
-
}, [
|
|
21
|
+
}, [t, r, i, n, a]), c(() => {
|
|
42
22
|
const e = new URL(window.location.href);
|
|
43
23
|
e.searchParams.has("authToken") && (localStorage.setItem("authToken", e.searchParams.get("authToken")), e.searchParams.delete("authToken"), window.history.replaceState({}, "", e));
|
|
44
|
-
}, []),
|
|
45
|
-
|
|
24
|
+
}, []), r || !t ? /* @__PURE__ */ o("div", { className: "d-flex justify-content-center align-items-center w-100 h-100", children: /* @__PURE__ */ o(
|
|
25
|
+
f,
|
|
46
26
|
{
|
|
47
27
|
animation: "border",
|
|
48
28
|
variant: "primary",
|
|
49
29
|
style: { width: "3rem", height: "3rem", borderWidth: "0.5rem" }
|
|
50
30
|
}
|
|
51
|
-
) }) : /* @__PURE__ */
|
|
31
|
+
) }) : /* @__PURE__ */ o(u, { children: m });
|
|
52
32
|
};
|
|
53
33
|
export {
|
|
54
|
-
|
|
34
|
+
P as AuthWrapper
|
|
55
35
|
};
|
|
@@ -9,4 +9,4 @@ export interface ConfirmationModalProps {
|
|
|
9
9
|
cancelButtonVariant?: string;
|
|
10
10
|
}
|
|
11
11
|
export declare const confirmationModalDefaultProps: ConfirmationModalProps;
|
|
12
|
-
export default function ConfirmationModal({ show, onCancel, onConfirm, message, confirmLabel, confirmButtonVariant, cancelButtonVariant, cancelLabel, }: ConfirmationModalProps): import("react
|
|
12
|
+
export default function ConfirmationModal({ show, onCancel, onConfirm, message, confirmLabel, confirmButtonVariant, cancelButtonVariant, cancelLabel, }: ConfirmationModalProps): import("react").JSX.Element;
|
|
@@ -1,267 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import * as u from "react";
|
|
5
|
-
import { useRef as N, useEffect as Oe, useState as E, useMemo as be, useCallback as Ie } from "react";
|
|
6
|
-
import { A as Ue, d as He, M as ze, B as Le, F as X, g as We, t as _e } from "../../AbstractModalHeader-UzCRSxIO.js";
|
|
7
|
-
import { B as J } from "../../Button-GQJKgb76.js";
|
|
8
|
-
function Ke(e) {
|
|
9
|
-
const t = N(e);
|
|
10
|
-
return t.current = e, t;
|
|
11
|
-
}
|
|
12
|
-
function qe(e) {
|
|
13
|
-
const t = Ke(e);
|
|
14
|
-
Oe(() => () => t.current(), []);
|
|
15
|
-
}
|
|
16
|
-
var R;
|
|
17
|
-
function Q(e) {
|
|
18
|
-
if ((!R && R !== 0 || e) && V) {
|
|
19
|
-
var t = document.createElement("div");
|
|
20
|
-
t.style.position = "absolute", t.style.top = "-9999px", t.style.width = "50px", t.style.height = "50px", t.style.overflow = "scroll", document.body.appendChild(t), R = t.offsetWidth - t.clientWidth, document.body.removeChild(t);
|
|
21
|
-
}
|
|
22
|
-
return R;
|
|
23
|
-
}
|
|
24
|
-
function Ge() {
|
|
25
|
-
return E(null);
|
|
26
|
-
}
|
|
27
|
-
const Y = /* @__PURE__ */ u.forwardRef(({
|
|
28
|
-
className: e,
|
|
29
|
-
bsPrefix: t,
|
|
30
|
-
as: r = "div",
|
|
31
|
-
...s
|
|
32
|
-
}, o) => (t = c(t, "modal-body"), /* @__PURE__ */ n.jsx(r, {
|
|
33
|
-
ref: o,
|
|
34
|
-
className: d(e, t),
|
|
35
|
-
...s
|
|
36
|
-
})));
|
|
37
|
-
Y.displayName = "ModalBody";
|
|
38
|
-
const A = /* @__PURE__ */ u.forwardRef(({
|
|
39
|
-
bsPrefix: e,
|
|
40
|
-
className: t,
|
|
41
|
-
contentClassName: r,
|
|
42
|
-
centered: s,
|
|
43
|
-
size: o,
|
|
44
|
-
fullscreen: l,
|
|
45
|
-
children: f,
|
|
46
|
-
scrollable: m,
|
|
47
|
-
...j
|
|
48
|
-
}, C) => {
|
|
49
|
-
e = c(e, "modal");
|
|
50
|
-
const g = `${e}-dialog`, S = typeof l == "string" ? `${e}-fullscreen-${l}` : `${e}-fullscreen`;
|
|
51
|
-
return /* @__PURE__ */ n.jsx("div", {
|
|
52
|
-
...j,
|
|
53
|
-
ref: C,
|
|
54
|
-
className: d(g, t, o && `${e}-${o}`, s && `${g}-centered`, m && `${g}-scrollable`, l && S),
|
|
55
|
-
children: /* @__PURE__ */ n.jsx("div", {
|
|
56
|
-
className: d(`${e}-content`, r),
|
|
57
|
-
children: f
|
|
58
|
-
})
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
A.displayName = "ModalDialog";
|
|
62
|
-
const Z = /* @__PURE__ */ u.forwardRef(({
|
|
63
|
-
className: e,
|
|
64
|
-
bsPrefix: t,
|
|
65
|
-
as: r = "div",
|
|
66
|
-
...s
|
|
67
|
-
}, o) => (t = c(t, "modal-footer"), /* @__PURE__ */ n.jsx(r, {
|
|
68
|
-
ref: o,
|
|
69
|
-
className: d(e, t),
|
|
70
|
-
...s
|
|
71
|
-
})));
|
|
72
|
-
Z.displayName = "ModalFooter";
|
|
73
|
-
const P = /* @__PURE__ */ u.forwardRef(({
|
|
74
|
-
bsPrefix: e,
|
|
75
|
-
className: t,
|
|
76
|
-
closeLabel: r = "Close",
|
|
77
|
-
closeButton: s = !1,
|
|
78
|
-
...o
|
|
79
|
-
}, l) => (e = c(e, "modal-header"), /* @__PURE__ */ n.jsx(Ue, {
|
|
80
|
-
ref: l,
|
|
81
|
-
...o,
|
|
82
|
-
className: d(t, e),
|
|
83
|
-
closeLabel: r,
|
|
84
|
-
closeButton: s
|
|
85
|
-
})));
|
|
86
|
-
P.displayName = "ModalHeader";
|
|
87
|
-
const Je = He("h4"), ee = /* @__PURE__ */ u.forwardRef(({
|
|
88
|
-
className: e,
|
|
89
|
-
bsPrefix: t,
|
|
90
|
-
as: r = Je,
|
|
91
|
-
...s
|
|
92
|
-
}, o) => (t = c(t, "modal-title"), /* @__PURE__ */ n.jsx(r, {
|
|
93
|
-
ref: o,
|
|
94
|
-
className: d(e, t),
|
|
95
|
-
...s
|
|
96
|
-
})));
|
|
97
|
-
ee.displayName = "ModalTitle";
|
|
98
|
-
function Qe(e) {
|
|
99
|
-
return /* @__PURE__ */ n.jsx(X, {
|
|
100
|
-
...e,
|
|
101
|
-
timeout: null
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
function Ve(e) {
|
|
105
|
-
return /* @__PURE__ */ n.jsx(X, {
|
|
106
|
-
...e,
|
|
107
|
-
timeout: null
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
const te = /* @__PURE__ */ u.forwardRef(({
|
|
111
|
-
bsPrefix: e,
|
|
112
|
-
className: t,
|
|
113
|
-
style: r,
|
|
114
|
-
dialogClassName: s,
|
|
115
|
-
contentClassName: o,
|
|
116
|
-
children: l,
|
|
117
|
-
dialogAs: f = A,
|
|
118
|
-
"data-bs-theme": m,
|
|
119
|
-
"aria-labelledby": j,
|
|
120
|
-
"aria-describedby": C,
|
|
121
|
-
"aria-label": g,
|
|
122
|
-
/* BaseModal props */
|
|
123
|
-
show: S = !1,
|
|
124
|
-
animation: h = !0,
|
|
125
|
-
backdrop: M = !0,
|
|
126
|
-
keyboard: ae = !0,
|
|
127
|
-
onEscapeKeyDown: $,
|
|
128
|
-
onShow: ne,
|
|
129
|
-
onHide: w,
|
|
130
|
-
container: oe,
|
|
131
|
-
autoFocus: re = !0,
|
|
132
|
-
enforceFocus: se = !0,
|
|
133
|
-
restoreFocus: le = !0,
|
|
134
|
-
restoreFocusOptions: de,
|
|
135
|
-
onEntered: ie,
|
|
136
|
-
onExit: x,
|
|
137
|
-
onExiting: ce,
|
|
138
|
-
onEnter: D,
|
|
139
|
-
onEntering: F,
|
|
140
|
-
onExited: O,
|
|
141
|
-
backdropClassName: b,
|
|
142
|
-
manager: I,
|
|
143
|
-
...ue
|
|
144
|
-
}, fe) => {
|
|
145
|
-
const [me, ge] = E({}), [he, U] = E(!1), v = N(!1), B = N(!1), p = N(null), [y, pe] = Ge(), ye = xe(fe, pe), H = q(w), Me = $e();
|
|
146
|
-
e = c(e, "modal");
|
|
147
|
-
const we = be(() => ({
|
|
148
|
-
onHide: H
|
|
149
|
-
}), [H]);
|
|
150
|
-
function z() {
|
|
151
|
-
return I || We({
|
|
152
|
-
isRTL: Me
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
function L(a) {
|
|
156
|
-
if (!V) return;
|
|
157
|
-
const i = z().getScrollbarWidth() > 0, K = a.scrollHeight > Fe(a).documentElement.clientHeight;
|
|
158
|
-
ge({
|
|
159
|
-
paddingRight: i && !K ? Q() : void 0,
|
|
160
|
-
paddingLeft: !i && K ? Q() : void 0
|
|
161
|
-
});
|
|
162
|
-
}
|
|
163
|
-
const T = q(() => {
|
|
164
|
-
y && L(y.dialog);
|
|
165
|
-
});
|
|
166
|
-
qe(() => {
|
|
167
|
-
G(window, "resize", T), p.current == null || p.current();
|
|
168
|
-
});
|
|
169
|
-
const Re = () => {
|
|
170
|
-
v.current = !0;
|
|
171
|
-
}, Ne = (a) => {
|
|
172
|
-
v.current && y && a.target === y.dialog && (B.current = !0), v.current = !1;
|
|
173
|
-
}, W = () => {
|
|
174
|
-
U(!0), p.current = _e(y.dialog, () => {
|
|
175
|
-
U(!1);
|
|
176
|
-
});
|
|
177
|
-
}, je = (a) => {
|
|
178
|
-
a.target === a.currentTarget && W();
|
|
179
|
-
}, Ce = (a) => {
|
|
180
|
-
if (M === "static") {
|
|
181
|
-
je(a);
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
-
if (B.current || a.target !== a.currentTarget) {
|
|
185
|
-
B.current = !1;
|
|
186
|
-
return;
|
|
187
|
-
}
|
|
188
|
-
w == null || w();
|
|
189
|
-
}, Se = (a) => {
|
|
190
|
-
ae ? $ == null || $(a) : (a.preventDefault(), M === "static" && W());
|
|
191
|
-
}, ve = (a, i) => {
|
|
192
|
-
a && L(a), D == null || D(a, i);
|
|
193
|
-
}, Be = (a) => {
|
|
194
|
-
p.current == null || p.current(), x == null || x(a);
|
|
195
|
-
}, Te = (a, i) => {
|
|
196
|
-
F == null || F(a, i), De(window, "resize", T);
|
|
197
|
-
}, ke = (a) => {
|
|
198
|
-
a && (a.style.display = ""), O == null || O(a), G(window, "resize", T);
|
|
199
|
-
}, Ee = Ie((a) => /* @__PURE__ */ n.jsx("div", {
|
|
200
|
-
...a,
|
|
201
|
-
className: d(`${e}-backdrop`, b, !h && "show")
|
|
202
|
-
}), [h, b, e]), _ = {
|
|
203
|
-
...r,
|
|
204
|
-
...me
|
|
205
|
-
};
|
|
206
|
-
_.display = "block";
|
|
207
|
-
const Ae = (a) => /* @__PURE__ */ n.jsx("div", {
|
|
208
|
-
role: "dialog",
|
|
209
|
-
...a,
|
|
210
|
-
style: _,
|
|
211
|
-
className: d(t, e, he && `${e}-static`, !h && "show"),
|
|
212
|
-
onClick: M ? Ce : void 0,
|
|
213
|
-
onMouseUp: Ne,
|
|
214
|
-
"data-bs-theme": m,
|
|
215
|
-
"aria-label": g,
|
|
216
|
-
"aria-labelledby": j,
|
|
217
|
-
"aria-describedby": C,
|
|
218
|
-
children: /* @__PURE__ */ n.jsx(f, {
|
|
219
|
-
...ue,
|
|
220
|
-
onMouseDown: Re,
|
|
221
|
-
className: s,
|
|
222
|
-
contentClassName: o,
|
|
223
|
-
children: l
|
|
224
|
-
})
|
|
225
|
-
});
|
|
226
|
-
return /* @__PURE__ */ n.jsx(ze.Provider, {
|
|
227
|
-
value: we,
|
|
228
|
-
children: /* @__PURE__ */ n.jsx(Le, {
|
|
229
|
-
show: S,
|
|
230
|
-
ref: ye,
|
|
231
|
-
backdrop: M,
|
|
232
|
-
container: oe,
|
|
233
|
-
keyboard: !0,
|
|
234
|
-
autoFocus: re,
|
|
235
|
-
enforceFocus: se,
|
|
236
|
-
restoreFocus: le,
|
|
237
|
-
restoreFocusOptions: de,
|
|
238
|
-
onEscapeKeyDown: Se,
|
|
239
|
-
onShow: ne,
|
|
240
|
-
onHide: w,
|
|
241
|
-
onEnter: ve,
|
|
242
|
-
onEntering: Te,
|
|
243
|
-
onEntered: ie,
|
|
244
|
-
onExit: Be,
|
|
245
|
-
onExiting: ce,
|
|
246
|
-
onExited: ke,
|
|
247
|
-
manager: z(),
|
|
248
|
-
transition: h ? Qe : void 0,
|
|
249
|
-
backdropTransition: h ? Ve : void 0,
|
|
250
|
-
renderBackdrop: Ee,
|
|
251
|
-
renderDialog: Ae
|
|
252
|
-
})
|
|
253
|
-
});
|
|
254
|
-
});
|
|
255
|
-
te.displayName = "Modal";
|
|
256
|
-
const k = Object.assign(te, {
|
|
257
|
-
Body: Y,
|
|
258
|
-
Header: P,
|
|
259
|
-
Title: ee,
|
|
260
|
-
Footer: Z,
|
|
261
|
-
Dialog: A,
|
|
262
|
-
TRANSITION_DURATION: 300,
|
|
263
|
-
BACKDROP_TRANSITION_DURATION: 150
|
|
264
|
-
}), at = Object.freeze({
|
|
1
|
+
import { jsxs as e, jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { Modal as n, Button as i } from "react-bootstrap";
|
|
3
|
+
const p = Object.freeze({
|
|
265
4
|
message: "",
|
|
266
5
|
show: !1,
|
|
267
6
|
onCancel: () => {
|
|
@@ -269,25 +8,25 @@ const k = Object.assign(te, {
|
|
|
269
8
|
onConfirm: () => {
|
|
270
9
|
}
|
|
271
10
|
});
|
|
272
|
-
function
|
|
273
|
-
show:
|
|
274
|
-
onCancel:
|
|
275
|
-
onConfirm:
|
|
276
|
-
message:
|
|
277
|
-
confirmLabel:
|
|
278
|
-
confirmButtonVariant:
|
|
279
|
-
cancelButtonVariant:
|
|
280
|
-
cancelLabel:
|
|
11
|
+
function u({
|
|
12
|
+
show: a,
|
|
13
|
+
onCancel: r,
|
|
14
|
+
onConfirm: t,
|
|
15
|
+
message: c,
|
|
16
|
+
confirmLabel: l = "Accept",
|
|
17
|
+
confirmButtonVariant: d = "primary",
|
|
18
|
+
cancelButtonVariant: s = "secondary",
|
|
19
|
+
cancelLabel: f = "Cancel"
|
|
281
20
|
}) {
|
|
282
|
-
return /* @__PURE__ */ n
|
|
283
|
-
/* @__PURE__ */ n.
|
|
284
|
-
/* @__PURE__ */ n.
|
|
285
|
-
/* @__PURE__ */
|
|
286
|
-
/* @__PURE__ */
|
|
21
|
+
return /* @__PURE__ */ e(n, { show: a, onHide: r, children: [
|
|
22
|
+
/* @__PURE__ */ o(n.Body, { children: c }),
|
|
23
|
+
/* @__PURE__ */ e(n.Footer, { children: [
|
|
24
|
+
/* @__PURE__ */ o(i, { variant: s, onClick: r, children: f }),
|
|
25
|
+
/* @__PURE__ */ o(i, { variant: d, onClick: t, children: l })
|
|
287
26
|
] })
|
|
288
27
|
] });
|
|
289
28
|
}
|
|
290
29
|
export {
|
|
291
|
-
|
|
292
|
-
|
|
30
|
+
p as confirmationModalDefaultProps,
|
|
31
|
+
u as default
|
|
293
32
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import '../../assets/index.css';const
|
|
3
|
-
footer:
|
|
4
|
-
},
|
|
1
|
+
import { jsx as r, jsxs as t } from "react/jsx-runtime";
|
|
2
|
+
import '../../assets/index.css';const e = "_footer_cvhpi_1", s = {
|
|
3
|
+
footer: e
|
|
4
|
+
}, i = ({ version: o = "" }) => /* @__PURE__ */ r("footer", { className: `container-fluid ${s.footer}`, children: /* @__PURE__ */ r("div", { className: "row copyright", children: /* @__PURE__ */ t("p", { className: "mb-0", children: [
|
|
5
5
|
"©",
|
|
6
6
|
" Copyright 2023 VariaMos.",
|
|
7
|
-
|
|
7
|
+
o && ` ${o}`
|
|
8
8
|
] }) }) });
|
|
9
9
|
export {
|
|
10
|
-
|
|
10
|
+
i as Footer
|
|
11
11
|
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
interface BugFormModalProps {
|
|
3
|
+
show: boolean;
|
|
4
|
+
onHide: () => void;
|
|
5
|
+
onSubmit: (data: {
|
|
6
|
+
title: string;
|
|
7
|
+
description: string;
|
|
8
|
+
category: string;
|
|
9
|
+
}, file?: File) => void;
|
|
10
|
+
categories: string[];
|
|
11
|
+
isSubmitting: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare const BugFormModal: FC<BugFormModalProps>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { jsxs as l, jsx as r } from "react/jsx-runtime";
|
|
2
|
+
import { useState as a, useEffect as B } from "react";
|
|
3
|
+
import { Modal as o, Form as t, Button as y } from "react-bootstrap";
|
|
4
|
+
const q = ({
|
|
5
|
+
show: i,
|
|
6
|
+
onHide: d,
|
|
7
|
+
onSubmit: C,
|
|
8
|
+
categories: n,
|
|
9
|
+
isSubmitting: c
|
|
10
|
+
}) => {
|
|
11
|
+
const [s, u] = a(""), [h, p] = a(""), [m, g] = a(""), [v, b] = a(null), [F, f] = a(!1);
|
|
12
|
+
B(() => {
|
|
13
|
+
i && (u(""), p(""), g(n[0] || "Other"), b(null), f(!1));
|
|
14
|
+
}, [i, n]);
|
|
15
|
+
const x = (e) => {
|
|
16
|
+
if (e.preventDefault(), e.currentTarget.checkValidity() === !1) {
|
|
17
|
+
e.stopPropagation(), f(!0);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
C({ title: s, description: h, category: m }, v || void 0);
|
|
21
|
+
};
|
|
22
|
+
return /* @__PURE__ */ l(
|
|
23
|
+
o,
|
|
24
|
+
{
|
|
25
|
+
show: i,
|
|
26
|
+
onHide: d,
|
|
27
|
+
backdrop: "static",
|
|
28
|
+
keyboard: !1,
|
|
29
|
+
centered: !0,
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ r(o.Header, { closeButton: !0, children: /* @__PURE__ */ r(o.Title, { children: "Report a New Bug" }) }),
|
|
32
|
+
/* @__PURE__ */ l(t, { noValidate: !0, validated: F, onSubmit: x, children: [
|
|
33
|
+
/* @__PURE__ */ l(o.Body, { children: [
|
|
34
|
+
/* @__PURE__ */ l(t.Group, { className: "mb-3", controlId: "bugTitle", children: [
|
|
35
|
+
/* @__PURE__ */ r(t.Label, { children: "Title *" }),
|
|
36
|
+
/* @__PURE__ */ r(
|
|
37
|
+
t.Control,
|
|
38
|
+
{
|
|
39
|
+
required: !0,
|
|
40
|
+
type: "text",
|
|
41
|
+
placeholder: "e.g. Build error on auth routes",
|
|
42
|
+
value: s,
|
|
43
|
+
onChange: (e) => u(e.target.value),
|
|
44
|
+
maxLength: 100
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
/* @__PURE__ */ r(t.Control.Feedback, { type: "invalid", children: "Title is required (max 100 characters)" })
|
|
48
|
+
] }),
|
|
49
|
+
/* @__PURE__ */ l(t.Group, { className: "mb-3", controlId: "bugDescription", children: [
|
|
50
|
+
/* @__PURE__ */ r(t.Label, { children: "Description *" }),
|
|
51
|
+
/* @__PURE__ */ r(
|
|
52
|
+
t.Control,
|
|
53
|
+
{
|
|
54
|
+
required: !0,
|
|
55
|
+
as: "textarea",
|
|
56
|
+
rows: 4,
|
|
57
|
+
placeholder: "Describe step-by-step how to reproduce the bug...",
|
|
58
|
+
value: h,
|
|
59
|
+
onChange: (e) => p(e.target.value)
|
|
60
|
+
}
|
|
61
|
+
),
|
|
62
|
+
/* @__PURE__ */ r(t.Control.Feedback, { type: "invalid", children: "Description is required" })
|
|
63
|
+
] }),
|
|
64
|
+
/* @__PURE__ */ r("div", { className: "row", children: /* @__PURE__ */ r("div", { className: "col-md-12", children: /* @__PURE__ */ l(t.Group, { className: "mb-3", controlId: "bugCategory", children: [
|
|
65
|
+
/* @__PURE__ */ r(t.Label, { children: "Category *" }),
|
|
66
|
+
/* @__PURE__ */ r(
|
|
67
|
+
t.Select,
|
|
68
|
+
{
|
|
69
|
+
required: !0,
|
|
70
|
+
value: m,
|
|
71
|
+
onChange: (e) => g(e.target.value),
|
|
72
|
+
children: n.map((e) => /* @__PURE__ */ r("option", { value: e, children: e }, e))
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
] }) }) }),
|
|
76
|
+
/* @__PURE__ */ l(t.Group, { className: "mb-3", controlId: "bugFile", children: [
|
|
77
|
+
/* @__PURE__ */ r(t.Label, { children: "Attachment (Optional)" }),
|
|
78
|
+
/* @__PURE__ */ r(
|
|
79
|
+
t.Control,
|
|
80
|
+
{
|
|
81
|
+
type: "file",
|
|
82
|
+
onChange: (e) => {
|
|
83
|
+
e.target.files && e.target.files.length > 0 && b(e.target.files[0]);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
] })
|
|
88
|
+
] }),
|
|
89
|
+
/* @__PURE__ */ l(o.Footer, { children: [
|
|
90
|
+
/* @__PURE__ */ r(y, { variant: "secondary", onClick: d, disabled: c, children: "Cancel" }),
|
|
91
|
+
/* @__PURE__ */ r(y, { variant: "primary", type: "submit", disabled: c, children: c ? "Creating..." : "Report Bug" })
|
|
92
|
+
] })
|
|
93
|
+
] })
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
};
|
|
98
|
+
export {
|
|
99
|
+
q as BugFormModal
|
|
100
|
+
};
|
|
@@ -1,39 +1,93 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useMemo as
|
|
1
|
+
import { jsxs as S, Fragment as E, jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import { useState as h, useEffect as F, useMemo as T } from "react";
|
|
3
|
+
import { NavDropdown as g } from "react-bootstrap";
|
|
3
4
|
import "../../Context/AnalyticsContext.js";
|
|
4
|
-
import { useMenu as
|
|
5
|
-
import { useRouter as
|
|
6
|
-
import { useSession as
|
|
7
|
-
import { mapToWebTarget as
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
5
|
+
import { useMenu as j } from "../../Context/MenuContext.js";
|
|
6
|
+
import { useRouter as C } from "../../Context/RouterContext.js";
|
|
7
|
+
import { useSession as b } from "../../Context/SessionContext.js";
|
|
8
|
+
import { mapToWebTarget as x } from "../../Model/Router.js";
|
|
9
|
+
import { Events as y } from "../../Common/Events.js";
|
|
10
|
+
import { BugFormModal as L } from "./BugFormModal.js";
|
|
11
|
+
const u = {}, K = () => {
|
|
12
|
+
const { user: o, isAuthenticated: m, logout: B } = b(), { options: l } = j(), { navigate: P } = C(), [R, c] = h(!1), [A] = h([
|
|
13
|
+
"Editor",
|
|
14
|
+
"Model",
|
|
15
|
+
"Language",
|
|
16
|
+
"Project",
|
|
17
|
+
"Simulation",
|
|
18
|
+
"Account/Security",
|
|
19
|
+
"Other"
|
|
20
|
+
]), [k, f] = h(!1), v = (u == null ? void 0 : u.VITE_ADMIN_API_URL) || "http://localhost:4000/v1";
|
|
21
|
+
F(() => {
|
|
22
|
+
const t = () => {
|
|
23
|
+
c(!0);
|
|
24
|
+
};
|
|
25
|
+
return y.subscribe("openReportBugModal", t), () => {
|
|
26
|
+
y.unsubscribe("openReportBugModal", t);
|
|
27
|
+
};
|
|
28
|
+
}, []);
|
|
29
|
+
const D = async (t, d) => {
|
|
30
|
+
f(!0);
|
|
31
|
+
try {
|
|
32
|
+
const e = new FormData();
|
|
33
|
+
e.append("title", t.title), e.append("description", t.description), e.append("priority", "medium"), e.append("category", t.category), o != null && o.email && e.append("reporterEmail", o.email), d && e.append("file", d);
|
|
34
|
+
const i = v.replace(/\/v1$/, ""), s = {}, n = localStorage.getItem("authToken");
|
|
35
|
+
n && (s.Authorization = `Bearer ${n}`);
|
|
36
|
+
const a = await fetch(`${i}/bugs`, {
|
|
37
|
+
method: "POST",
|
|
38
|
+
headers: s,
|
|
39
|
+
body: e,
|
|
40
|
+
credentials: "include"
|
|
41
|
+
}), w = await a.json();
|
|
42
|
+
f(!1), a.ok && !w.errorCode ? c(!1) : alert(w.message || "Failed to submit bug. Please try again.");
|
|
43
|
+
} catch (e) {
|
|
44
|
+
f(!1), alert("Failed to submit bug. Please try again."), console.error(e);
|
|
45
|
+
}
|
|
46
|
+
}, r = T(() => {
|
|
47
|
+
const t = (o == null ? void 0 : o.permissions) || [], d = (o == null ? void 0 : o.roles) || [];
|
|
48
|
+
return l != null && l.length ? l.filter((e) => {
|
|
49
|
+
var s, n;
|
|
50
|
+
if (!((s = e == null ? void 0 : e.allowedPermissions) != null && s.length) && !((n = e == null ? void 0 : e.allowedRoles) != null && n.length))
|
|
15
51
|
return !0;
|
|
16
|
-
let
|
|
17
|
-
return
|
|
18
|
-
(
|
|
19
|
-
)),
|
|
52
|
+
let i = !0;
|
|
53
|
+
return e.allowedRoles && (i = i && e.allowedRoles.some((a) => d.includes(a))), e.allowedPermissions && (i = i && e.allowedPermissions.some(
|
|
54
|
+
(a) => t.includes(a)
|
|
55
|
+
)), i;
|
|
20
56
|
}) : [];
|
|
21
|
-
}, [
|
|
22
|
-
return !(
|
|
23
|
-
|
|
24
|
-
|
|
57
|
+
}, [l, o]);
|
|
58
|
+
return !(r != null && r.length) && !m ? null : /* @__PURE__ */ S(E, { children: [
|
|
59
|
+
/* @__PURE__ */ S(g, { title: (o == null ? void 0 : o.name) || "Options", id: "nav-dropdown", children: [
|
|
60
|
+
r == null ? void 0 : r.map((t) => /* @__PURE__ */ p(
|
|
61
|
+
g.Item,
|
|
62
|
+
{
|
|
63
|
+
onClick: () => {
|
|
64
|
+
if (t.location.endsWith("#report-bug")) {
|
|
65
|
+
c(!0);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
P(t.location, {
|
|
69
|
+
target: x(t.target)
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
children: t.title
|
|
73
|
+
},
|
|
74
|
+
t.title
|
|
75
|
+
)),
|
|
76
|
+
m && !!(r != null && r.length) && /* @__PURE__ */ p(g.Divider, {}),
|
|
77
|
+
m && /* @__PURE__ */ p(g.Item, { onClick: B, children: "Logout" })
|
|
78
|
+
] }),
|
|
79
|
+
/* @__PURE__ */ p(
|
|
80
|
+
L,
|
|
25
81
|
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
)
|
|
33
|
-
d && !!(l != null && l.length) && /* @__PURE__ */ s.jsx(a.Divider, {}),
|
|
34
|
-
d && /* @__PURE__ */ s.jsx(a.Item, { onClick: g, children: "Logout" })
|
|
82
|
+
show: R,
|
|
83
|
+
onHide: () => c(!1),
|
|
84
|
+
onSubmit: D,
|
|
85
|
+
categories: A,
|
|
86
|
+
isSubmitting: k
|
|
87
|
+
}
|
|
88
|
+
)
|
|
35
89
|
] });
|
|
36
90
|
};
|
|
37
91
|
export {
|
|
38
|
-
|
|
92
|
+
K as HeaderOptions
|
|
39
93
|
};
|