@variamosple/variamos-components 0.1.0 → 0.1.2
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.
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsxs as S, Fragment as
|
|
2
|
-
import { useState as h, useEffect as
|
|
1
|
+
import { jsxs as S, Fragment as F, jsx as p } from "react/jsx-runtime";
|
|
2
|
+
import { useState as h, useEffect as T, useMemo as j } from "react";
|
|
3
3
|
import { NavDropdown as g } from "react-bootstrap";
|
|
4
4
|
import "../../Context/AnalyticsContext.js";
|
|
5
|
-
import { useMenu as
|
|
6
|
-
import { useRouter as
|
|
7
|
-
import { useSession as
|
|
8
|
-
import { mapToWebTarget as
|
|
5
|
+
import { useMenu as C } from "../../Context/MenuContext.js";
|
|
6
|
+
import { useRouter as b } from "../../Context/RouterContext.js";
|
|
7
|
+
import { useSession as x } from "../../Context/SessionContext.js";
|
|
8
|
+
import { mapToWebTarget as L } from "../../Model/Router.js";
|
|
9
9
|
import { Events as y } from "../../Common/Events.js";
|
|
10
|
-
import { BugFormModal as
|
|
11
|
-
const u = {},
|
|
12
|
-
const { user: o, isAuthenticated: m, logout:
|
|
10
|
+
import { BugFormModal as U } from "./BugFormModal.js";
|
|
11
|
+
const u = {}, O = ({ adminApiUrl: B }) => {
|
|
12
|
+
const { user: o, isAuthenticated: m, logout: P } = x(), { options: l } = C(), { navigate: A } = b(), [R, c] = h(!1), [k] = h([
|
|
13
13
|
"Editor",
|
|
14
14
|
"Model",
|
|
15
15
|
"Language",
|
|
@@ -17,8 +17,8 @@ const u = {}, K = () => {
|
|
|
17
17
|
"Simulation",
|
|
18
18
|
"Account/Security",
|
|
19
19
|
"Other"
|
|
20
|
-
]), [
|
|
21
|
-
|
|
20
|
+
]), [v, f] = h(!1), D = B || (u == null ? void 0 : u.VITE_ADMIN_API_URL) || "/v1";
|
|
21
|
+
T(() => {
|
|
22
22
|
const t = () => {
|
|
23
23
|
c(!0);
|
|
24
24
|
};
|
|
@@ -26,14 +26,16 @@ const u = {}, K = () => {
|
|
|
26
26
|
y.unsubscribe("openReportBugModal", t);
|
|
27
27
|
};
|
|
28
28
|
}, []);
|
|
29
|
-
const
|
|
29
|
+
const E = async (t, d) => {
|
|
30
30
|
f(!0);
|
|
31
31
|
try {
|
|
32
32
|
const e = new FormData();
|
|
33
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
|
-
|
|
34
|
+
let r = D.replace(/\/v1$/, "");
|
|
35
|
+
r.endsWith("/") && (r = r.slice(0, -1));
|
|
36
|
+
const s = {}, n = localStorage.getItem("authToken");
|
|
35
37
|
n && (s.Authorization = `Bearer ${n}`);
|
|
36
|
-
const a = await fetch(`${
|
|
38
|
+
const a = await fetch(`${r}/bugs`, {
|
|
37
39
|
method: "POST",
|
|
38
40
|
headers: s,
|
|
39
41
|
body: e,
|
|
@@ -43,21 +45,21 @@ const u = {}, K = () => {
|
|
|
43
45
|
} catch (e) {
|
|
44
46
|
f(!1), alert("Failed to submit bug. Please try again."), console.error(e);
|
|
45
47
|
}
|
|
46
|
-
},
|
|
48
|
+
}, i = j(() => {
|
|
47
49
|
const t = (o == null ? void 0 : o.permissions) || [], d = (o == null ? void 0 : o.roles) || [];
|
|
48
50
|
return l != null && l.length ? l.filter((e) => {
|
|
49
51
|
var s, n;
|
|
50
52
|
if (!((s = e == null ? void 0 : e.allowedPermissions) != null && s.length) && !((n = e == null ? void 0 : e.allowedRoles) != null && n.length))
|
|
51
53
|
return !0;
|
|
52
|
-
let
|
|
53
|
-
return e.allowedRoles && (
|
|
54
|
+
let r = !0;
|
|
55
|
+
return e.allowedRoles && (r = r && e.allowedRoles.some((a) => d.includes(a))), e.allowedPermissions && (r = r && e.allowedPermissions.some(
|
|
54
56
|
(a) => t.includes(a)
|
|
55
|
-
)),
|
|
57
|
+
)), r;
|
|
56
58
|
}) : [];
|
|
57
59
|
}, [l, o]);
|
|
58
|
-
return !(
|
|
60
|
+
return !(i != null && i.length) && !m ? null : /* @__PURE__ */ S(F, { children: [
|
|
59
61
|
/* @__PURE__ */ S(g, { title: (o == null ? void 0 : o.name) || "Options", id: "nav-dropdown", children: [
|
|
60
|
-
|
|
62
|
+
i == null ? void 0 : i.map((t) => /* @__PURE__ */ p(
|
|
61
63
|
g.Item,
|
|
62
64
|
{
|
|
63
65
|
onClick: () => {
|
|
@@ -65,29 +67,29 @@ const u = {}, K = () => {
|
|
|
65
67
|
c(!0);
|
|
66
68
|
return;
|
|
67
69
|
}
|
|
68
|
-
|
|
69
|
-
target:
|
|
70
|
+
A(t.location, {
|
|
71
|
+
target: L(t.target)
|
|
70
72
|
});
|
|
71
73
|
},
|
|
72
74
|
children: t.title
|
|
73
75
|
},
|
|
74
76
|
t.title
|
|
75
77
|
)),
|
|
76
|
-
m && !!(
|
|
77
|
-
m && /* @__PURE__ */ p(g.Item, { onClick:
|
|
78
|
+
m && !!(i != null && i.length) && /* @__PURE__ */ p(g.Divider, {}),
|
|
79
|
+
m && /* @__PURE__ */ p(g.Item, { onClick: P, children: "Logout" })
|
|
78
80
|
] }),
|
|
79
81
|
/* @__PURE__ */ p(
|
|
80
|
-
|
|
82
|
+
U,
|
|
81
83
|
{
|
|
82
84
|
show: R,
|
|
83
85
|
onHide: () => c(!1),
|
|
84
|
-
onSubmit:
|
|
85
|
-
categories:
|
|
86
|
-
isSubmitting:
|
|
86
|
+
onSubmit: E,
|
|
87
|
+
categories: k,
|
|
88
|
+
isSubmitting: v
|
|
87
89
|
}
|
|
88
90
|
)
|
|
89
91
|
] });
|
|
90
92
|
};
|
|
91
93
|
export {
|
|
92
|
-
|
|
94
|
+
O as HeaderOptions
|
|
93
95
|
};
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { jsxs as o, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { Navbar as t, Container as
|
|
2
|
+
import { Navbar as t, Container as h, Nav as i } from "react-bootstrap";
|
|
3
3
|
import "../../Context/AnalyticsContext.js";
|
|
4
|
-
import { useMenu as
|
|
5
|
-
import { useRouter as
|
|
6
|
-
import { useSession as
|
|
7
|
-
import { HeaderOptions as
|
|
4
|
+
import { useMenu as f } from "../../Context/MenuContext.js";
|
|
5
|
+
import { useRouter as g } from "../../Context/RouterContext.js";
|
|
6
|
+
import { useSession as N } from "../../Context/SessionContext.js";
|
|
7
|
+
import { HeaderOptions as k } from "./HeaderOptions.js";
|
|
8
8
|
import { MenuItemComponent as n } from "./MenuItem.js";
|
|
9
|
-
import { SubHeader as
|
|
10
|
-
const
|
|
9
|
+
import { SubHeader as b } from "./SubHeader.js";
|
|
10
|
+
const M = ({
|
|
11
11
|
logoUrl: a,
|
|
12
12
|
logoAlt: m = "App logo",
|
|
13
|
-
signInUrl: s
|
|
13
|
+
signInUrl: s,
|
|
14
|
+
adminApiUrl: c
|
|
14
15
|
}) => {
|
|
15
|
-
const { items:
|
|
16
|
+
const { items: l } = f(), { navigate: p } = g(), { isAuthenticated: d, isLoading: u } = N();
|
|
16
17
|
return /* @__PURE__ */ o("header", { className: "sticky-top", children: [
|
|
17
|
-
/* @__PURE__ */ e(t, { bg: "dark", variant: "dark", children: /* @__PURE__ */ o(
|
|
18
|
-
/* @__PURE__ */ e(t.Brand, { onClick: () =>
|
|
18
|
+
/* @__PURE__ */ e(t, { bg: "dark", variant: "dark", children: /* @__PURE__ */ o(h, { fluid: !0, children: [
|
|
19
|
+
/* @__PURE__ */ e(t.Brand, { onClick: () => p("/"), children: /* @__PURE__ */ e(
|
|
19
20
|
"img",
|
|
20
21
|
{
|
|
21
22
|
src: a,
|
|
@@ -24,10 +25,10 @@ const I = ({
|
|
|
24
25
|
alt: m
|
|
25
26
|
}
|
|
26
27
|
) }),
|
|
27
|
-
/* @__PURE__ */ e(i, { className: "me-auto", children:
|
|
28
|
+
/* @__PURE__ */ e(i, { className: "me-auto", children: l.map((r) => /* @__PURE__ */ e(n, { ...r }, r.title)) }),
|
|
28
29
|
/* @__PURE__ */ o(i, { className: "me-5 pe-5", children: [
|
|
29
|
-
/* @__PURE__ */ e(
|
|
30
|
-
!
|
|
30
|
+
/* @__PURE__ */ e(k, { adminApiUrl: c }),
|
|
31
|
+
!u && !d && /* @__PURE__ */ e(
|
|
31
32
|
n,
|
|
32
33
|
{
|
|
33
34
|
title: "Sign In",
|
|
@@ -37,9 +38,9 @@ const I = ({
|
|
|
37
38
|
)
|
|
38
39
|
] })
|
|
39
40
|
] }) }),
|
|
40
|
-
/* @__PURE__ */ e(
|
|
41
|
+
/* @__PURE__ */ e(b, {})
|
|
41
42
|
] });
|
|
42
43
|
};
|
|
43
44
|
export {
|
|
44
|
-
|
|
45
|
+
M as Header
|
|
45
46
|
};
|