@canmingir/link 1.2.63 → 1.2.65
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/package.json +1 -1
- package/src/components/settings/context/settings-provider.jsx +1 -1
- package/src/http/index.js +9 -9
- package/src/http/user.js +5 -5
- package/src/layouts/DashboardLayout/nav-vertical.jsx +9 -14
- package/src/layouts/common/ProjectBar/index.jsx +6 -6
- package/src/lib/{NucDialog/NucDialog.jsx → APITreeDialog/APITreeDialog.jsx} +6 -8
- package/src/lib/APITreeDialog/index.js +1 -0
- package/src/lib/SidebarChat/ChatDrawer.tsx +246 -207
- package/src/lib/SidebarChat/SidebarChat.tsx +22 -14
- package/src/lib/index.js +1 -1
- package/src/pages/Callback.jsx +5 -5
- package/src/pages/LoginPage.jsx +2 -2
- package/src/stories/APITree.stories.jsx +18 -8
- package/src/widgets/Login/CognitoLogin.jsx +3 -3
- package/src/widgets/Login/DemoLogin.jsx +3 -3
- package/src/widgets/Login/Login.jsx +2 -2
- package/src/widgets/SettingsDialog.jsx +9 -8
- package/src/ContextProvider/ContextProvider.jsx +0 -19
- package/src/context/Context.js +0 -98
- package/src/context/reducer.js +0 -632
- package/src/layouts/AppLayout.jsx +0 -113
- package/src/lib/NucDialog/index.js +0 -1
- package/src/templates/ActionTemplate.js +0 -24
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ import { useLocalStorage } from "../../../hooks/use-local-storage";
|
|
|
5
5
|
|
|
6
6
|
import { useCallback, useMemo, useState } from "react";
|
|
7
7
|
|
|
8
|
-
const STORAGE_KEY = "settings";
|
|
8
|
+
const STORAGE_KEY = "link.settings";
|
|
9
9
|
|
|
10
10
|
export function SettingsProvider({ children, defaultSettings }) {
|
|
11
11
|
const { state, update, reset } = useLocalStorage(
|
package/src/http/index.js
CHANGED
|
@@ -14,7 +14,7 @@ const instance = axios.create({
|
|
|
14
14
|
|
|
15
15
|
instance.interceptors.request.use((request) => {
|
|
16
16
|
const { base } = config();
|
|
17
|
-
const accessToken = storage.get("link", "
|
|
17
|
+
const accessToken = storage.get("link", "accesstoken");
|
|
18
18
|
|
|
19
19
|
if (!accessToken) {
|
|
20
20
|
window.location.href = base === "/" ? "/login" : `${base}/login`;
|
|
@@ -40,11 +40,11 @@ function processQueue(error, token = null) {
|
|
|
40
40
|
|
|
41
41
|
async function doRefresh() {
|
|
42
42
|
const { appId } = config();
|
|
43
|
-
const projectId = storage.get("
|
|
44
|
-
const identityProvider = storage.get("link", "
|
|
43
|
+
const projectId = storage.get("link", "projectid");
|
|
44
|
+
const identityProvider = storage.get("link", "identityprovider");
|
|
45
45
|
|
|
46
46
|
const { data } = await oauth.post("/oauth", {
|
|
47
|
-
refreshToken: storage.get("link", "
|
|
47
|
+
refreshToken: storage.get("link", "refreshtoken"),
|
|
48
48
|
appId,
|
|
49
49
|
projectId,
|
|
50
50
|
identityProvider,
|
|
@@ -54,9 +54,9 @@ async function doRefresh() {
|
|
|
54
54
|
}),
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
storage.set("link", "
|
|
57
|
+
storage.set("link", "accesstoken", data.accessToken);
|
|
58
58
|
if (data.refreshToken) {
|
|
59
|
-
storage.set("link", "
|
|
59
|
+
storage.set("link", "refreshtoken", data.refreshToken);
|
|
60
60
|
}
|
|
61
61
|
return data.accessToken;
|
|
62
62
|
}
|
|
@@ -81,7 +81,7 @@ instance.interceptors.response.use(
|
|
|
81
81
|
"Bearer ",
|
|
82
82
|
""
|
|
83
83
|
);
|
|
84
|
-
const storedToken = storage.get("link", "
|
|
84
|
+
const storedToken = storage.get("link", "accesstoken");
|
|
85
85
|
|
|
86
86
|
if (storedToken && storedToken !== usedToken) {
|
|
87
87
|
originalRequest.headers["Authorization"] = `Bearer ${storedToken}`;
|
|
@@ -107,8 +107,8 @@ instance.interceptors.response.use(
|
|
|
107
107
|
} catch (refreshError) {
|
|
108
108
|
processQueue(refreshError, null);
|
|
109
109
|
const { base } = config();
|
|
110
|
-
storage.remove("link", "
|
|
111
|
-
storage.remove("link", "
|
|
110
|
+
storage.remove("link", "accesstoken");
|
|
111
|
+
storage.remove("link", "refreshtoken");
|
|
112
112
|
window.location.href = `${window.location.origin}${base}/login`;
|
|
113
113
|
return Promise.reject(refreshError);
|
|
114
114
|
} finally {
|
package/src/http/user.js
CHANGED
|
@@ -13,7 +13,7 @@ const instance = axios.create({
|
|
|
13
13
|
});
|
|
14
14
|
|
|
15
15
|
instance.interceptors.request.use(async (request) => {
|
|
16
|
-
const refreshToken = await storage.get("link", "
|
|
16
|
+
const refreshToken = await storage.get("link", "refreshtoken");
|
|
17
17
|
if (refreshToken) {
|
|
18
18
|
request.headers["Authorization"] = `Bearer ${refreshToken}`;
|
|
19
19
|
}
|
|
@@ -22,7 +22,7 @@ instance.interceptors.request.use(async (request) => {
|
|
|
22
22
|
|
|
23
23
|
instance.getUserDetails = async () => {
|
|
24
24
|
try {
|
|
25
|
-
const refreshToken = storage.get("link", "
|
|
25
|
+
const refreshToken = storage.get("link", "refreshtoken");
|
|
26
26
|
|
|
27
27
|
if (!refreshToken) {
|
|
28
28
|
return null;
|
|
@@ -47,8 +47,8 @@ instance.getUserDetails = async () => {
|
|
|
47
47
|
|
|
48
48
|
instance.getPermittedUsers = async () => {
|
|
49
49
|
const { appId } = config();
|
|
50
|
-
const projectId = storage.get("
|
|
51
|
-
const identityProvider = storage.get("link", "
|
|
50
|
+
const projectId = storage.get("link", "projectid");
|
|
51
|
+
const identityProvider = storage.get("link", "identityprovider");
|
|
52
52
|
|
|
53
53
|
const response = await http.get("/permissions");
|
|
54
54
|
|
|
@@ -110,7 +110,7 @@ instance.getPermittedUsers = async () => {
|
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
if (identityProvider?.toUpperCase() === "COGNITO") {
|
|
113
|
-
const accessToken = await storage.get("link", "
|
|
113
|
+
const accessToken = await storage.get("link", "accesstoken");
|
|
114
114
|
let currentUserId = null;
|
|
115
115
|
|
|
116
116
|
try {
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import { Button, Typography } from "@mui/material";
|
|
2
|
-
import { useEffect, useState } from "react";
|
|
3
|
-
|
|
4
1
|
import Box from "@mui/material/Box";
|
|
5
2
|
import Drawer from "@mui/material/Drawer";
|
|
6
3
|
import Iconify from "../../components/Iconify";
|
|
@@ -20,6 +17,9 @@ import { usePathname } from "../../routes/hooks/use-pathname";
|
|
|
20
17
|
import { useResponsive } from "../../hooks/use-responsive";
|
|
21
18
|
import { useUser } from "../../hooks/use-user";
|
|
22
19
|
|
|
20
|
+
import { Button, Typography } from "@mui/material";
|
|
21
|
+
import { useEffect, useState } from "react";
|
|
22
|
+
|
|
23
23
|
// ----------------------------------------------------------------------
|
|
24
24
|
|
|
25
25
|
export default function NavVertical({ openNav, onCloseNav }) {
|
|
@@ -31,15 +31,9 @@ export default function NavVertical({ openNav, onCloseNav }) {
|
|
|
31
31
|
const lgUp = useResponsive("up", "lg");
|
|
32
32
|
const { beta, name } = config();
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
if (index !== -1) {
|
|
40
|
-
sideMenu.splice(index, 1);
|
|
41
|
-
}
|
|
42
|
-
}, [hideSubheader]);
|
|
34
|
+
const filteredSideMenu = sideMenu.filter(
|
|
35
|
+
(item) => item.subheader !== hideSubheader.subheader
|
|
36
|
+
);
|
|
43
37
|
|
|
44
38
|
useEffect(() => {
|
|
45
39
|
if (openNav) {
|
|
@@ -105,7 +99,8 @@ export default function NavVertical({ openNav, onCloseNav }) {
|
|
|
105
99
|
mt: 3,
|
|
106
100
|
}}
|
|
107
101
|
>
|
|
108
|
-
<Logo maxSize={name ? 100 : 150} sx={{ ml: name ?
|
|
102
|
+
<Logo maxSize={name ? 100 : 150} sx={{ ml: name ? -8 : -10 }} />
|
|
103
|
+
|
|
109
104
|
<Typography
|
|
110
105
|
sx={{
|
|
111
106
|
ml: 2,
|
|
@@ -116,7 +111,7 @@ export default function NavVertical({ openNav, onCloseNav }) {
|
|
|
116
111
|
</Box>
|
|
117
112
|
)}
|
|
118
113
|
<NavSectionVertical
|
|
119
|
-
data={
|
|
114
|
+
data={filteredSideMenu}
|
|
120
115
|
slotProps={{
|
|
121
116
|
currentRole: user?.role,
|
|
122
117
|
}}
|
|
@@ -45,7 +45,7 @@ function ProjectBar() {
|
|
|
45
45
|
}, [projectCreated]);
|
|
46
46
|
|
|
47
47
|
const id = window.matchMedia("projectId").matches;
|
|
48
|
-
const [selectedProjectId] = useStorage("
|
|
48
|
+
const [selectedProjectId] = useStorage("link", "projectid", id);
|
|
49
49
|
|
|
50
50
|
const [selectedProject, setSelectedProject] = useState();
|
|
51
51
|
|
|
@@ -91,7 +91,7 @@ function ProjectBar() {
|
|
|
91
91
|
const handleSelect = (project) => {
|
|
92
92
|
const { id: projectId } = project;
|
|
93
93
|
|
|
94
|
-
const identityProviderRaw = storage.get("link", "
|
|
94
|
+
const identityProviderRaw = storage.get("link", "identityprovider");
|
|
95
95
|
const identityProvider = identityProviderRaw?.toUpperCase();
|
|
96
96
|
|
|
97
97
|
const payload = {
|
|
@@ -104,7 +104,7 @@ function ProjectBar() {
|
|
|
104
104
|
payload.username = "admin";
|
|
105
105
|
payload.password = "admin";
|
|
106
106
|
} else {
|
|
107
|
-
payload.refreshToken = storage.get("link", "
|
|
107
|
+
payload.refreshToken = storage.get("link", "refreshtoken");
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
const request = oauth.post("/oauth", payload);
|
|
@@ -112,9 +112,9 @@ function ProjectBar() {
|
|
|
112
112
|
request
|
|
113
113
|
.then(({ data }) => {
|
|
114
114
|
const { refreshToken, accessToken } = data;
|
|
115
|
-
storage.set("link", "
|
|
116
|
-
storage.set("link", "
|
|
117
|
-
storage.set("
|
|
115
|
+
storage.set("link", "accesstoken", accessToken);
|
|
116
|
+
storage.set("link", "refreshtoken", refreshToken);
|
|
117
|
+
storage.set("link", "projectid", projectId);
|
|
118
118
|
})
|
|
119
119
|
.finally(() => {
|
|
120
120
|
setSelectedProject(project);
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
|
|
3
1
|
import { Close, Fullscreen, FullscreenExit } from "@mui/icons-material";
|
|
4
2
|
import {
|
|
5
3
|
Dialog,
|
|
@@ -8,9 +6,9 @@ import {
|
|
|
8
6
|
DialogTitle,
|
|
9
7
|
IconButton,
|
|
10
8
|
} from "@mui/material";
|
|
11
|
-
import {
|
|
9
|
+
import React, { useState } from "react";
|
|
12
10
|
|
|
13
|
-
function
|
|
11
|
+
function APITreeDialog({
|
|
14
12
|
title,
|
|
15
13
|
minWidth = 600,
|
|
16
14
|
children,
|
|
@@ -20,7 +18,7 @@ function NucDialog({
|
|
|
20
18
|
maximizedDimensions = { width: "65rem", height: "50rem" },
|
|
21
19
|
minimizedDimensions = { width: "55rem", height: "40rem" },
|
|
22
20
|
}) {
|
|
23
|
-
const [maximized] =
|
|
21
|
+
const [maximized, setMaximized] = useState(false);
|
|
24
22
|
const currentDimensions = maximized
|
|
25
23
|
? maximizedDimensions
|
|
26
24
|
: minimizedDimensions;
|
|
@@ -63,7 +61,7 @@ function NucDialog({
|
|
|
63
61
|
{maximized ? (
|
|
64
62
|
<IconButton
|
|
65
63
|
aria-label="collapse"
|
|
66
|
-
onClick={() =>
|
|
64
|
+
onClick={() => setMaximized(false)}
|
|
67
65
|
sx={{
|
|
68
66
|
position: "absolute",
|
|
69
67
|
right: 48,
|
|
@@ -76,7 +74,7 @@ function NucDialog({
|
|
|
76
74
|
) : (
|
|
77
75
|
<IconButton
|
|
78
76
|
aria-label="expand"
|
|
79
|
-
onClick={() =>
|
|
77
|
+
onClick={() => setMaximized(true)}
|
|
80
78
|
sx={{
|
|
81
79
|
position: "absolute",
|
|
82
80
|
right: 48,
|
|
@@ -105,4 +103,4 @@ function NucDialog({
|
|
|
105
103
|
);
|
|
106
104
|
}
|
|
107
105
|
|
|
108
|
-
export default
|
|
106
|
+
export default APITreeDialog;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from "./APITreeDialog";
|