@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.
@@ -2,10 +2,10 @@ import APIDialogAction from "../lib/APIDialogAction/APIDialogAction";
2
2
  import APIParams from "../lib/APIParams/APIParams";
3
3
  import APIPath from "../lib/APIPath/APIPath";
4
4
  import APITree from "../lib/APITree/APITree";
5
+ import APITreeDialog from "../lib/APITreeDialog/APITreeDialog";
5
6
  import APITypes from "../lib/APITypes/APITypes";
6
7
  import CssBaseline from "@mui/material/CssBaseline";
7
8
  import NewAPIBody from "../lib/NewApiBody/NewAPIBody";
8
- import NucDialog from "../lib/NucDialog/NucDialog";
9
9
 
10
10
  import { Box, Divider } from "@mui/material";
11
11
  import React, { useEffect, useRef, useState } from "react";
@@ -80,7 +80,8 @@ export default {
80
80
  description: {
81
81
  component:
82
82
  "APITree displays API endpoints in a tree structure grouped by path segments. " +
83
- "It supports context menus for editing/deleting methods and a resource menu for adding new endpoints.",
83
+ "It is a controlled component: selection and expansion are driven by the " +
84
+ "selected/expanded props and reported via onSelect/onExpand.",
84
85
  },
85
86
  },
86
87
  layout: "centered",
@@ -92,6 +93,8 @@ const ALL_METHODS = ["GET", "POST", "PUT", "DELETE", "PATCH"];
92
93
  const APIWorkspace = () => {
93
94
  const [view, setView] = useState("PARAMS");
94
95
  const [dialogKey, setDialogKey] = useState(0);
96
+ const [expanded, setExpanded] = useState(["/", "/items"]);
97
+ const [selectedItem, setSelectedItem] = useState(null);
95
98
 
96
99
  const methodRef = useRef("GET");
97
100
  const pathRef = useRef("/");
@@ -337,10 +340,17 @@ const APIWorkspace = () => {
337
340
  return (
338
341
  <Box sx={{ display: "flex", height: "100%", gap: 2 }}>
339
342
  <Box sx={{ width: 280, flexShrink: 0, height: "100%" }}>
340
- <APITree />
343
+ <APITree
344
+ api={api}
345
+ theme={theme}
346
+ expanded={expanded}
347
+ selected={selectedItem}
348
+ onExpand={(_event, itemIds) => setExpanded(itemIds)}
349
+ onSelect={(_event, itemId) => setSelectedItem(itemId)}
350
+ />
341
351
  </Box>
342
352
 
343
- <NucDialog
353
+ <APITreeDialog
344
354
  title={dialogTitle}
345
355
  open={dialog.open}
346
356
  handleClose={handleCloseDialog}
@@ -398,7 +408,7 @@ const APIWorkspace = () => {
398
408
  <APITypes tstypes={[]} nuctypes={types} typesRef={typesRef} />
399
409
  )}
400
410
  </Box>
401
- </NucDialog>
411
+ </APITreeDialog>
402
412
  </Box>
403
413
  );
404
414
  };
@@ -420,9 +430,9 @@ export const APITreeWorkspace = {
420
430
  docs: {
421
431
  description: {
422
432
  story:
423
- "Full workspace: right-click a path node or click the + FAB to open the ResourceMenu, " +
424
- "then choose Resource, Method, or Delete. Adding a resource or method opens the API dialog " +
425
- "where you can configure the path, method, params, and body before saving.",
433
+ "Full workspace: click a method node to select it, then use the API dialog " +
434
+ "events (API_DIALOG_OPEN) to add or edit endpoints, configuring the path, " +
435
+ "method, params, and body before saving.",
426
436
  },
427
437
  },
428
438
  },
@@ -69,9 +69,9 @@ export default function CognitoLogin() {
69
69
 
70
70
  const data = await res.json();
71
71
 
72
- storage.set("link", "accessToken", data.accessToken);
73
- storage.set("link", "refreshToken", data.refreshToken);
74
- storage.set("link", "identityProvider", "COGNITO");
72
+ storage.set("link", "accesstoken", data.accessToken);
73
+ storage.set("link", "refreshtoken", data.refreshToken);
74
+ storage.set("link", "identityprovider", "COGNITO");
75
75
 
76
76
  navigate("/");
77
77
  } catch (e) {
@@ -43,9 +43,9 @@ export default function DemoLogin() {
43
43
 
44
44
  const data = await res.json();
45
45
 
46
- storage.set("link", "accessToken", data.accessToken);
47
- storage.set("link", "refreshToken", data.refreshToken);
48
- storage.set("link", "identityProvider", "DEMO");
46
+ storage.set("link", "accesstoken", data.accessToken);
47
+ storage.set("link", "refreshtoken", data.refreshToken);
48
+ storage.set("link", "identityprovider", "DEMO");
49
49
 
50
50
  navigate("/");
51
51
  }
@@ -18,8 +18,8 @@ export default function Auth0LoginView() {
18
18
 
19
19
  function token() {
20
20
  if (
21
- storage.get("link", "refreshToken") &&
22
- storage.get("link", "accessToken")
21
+ storage.get("link", "refreshtoken") &&
22
+ storage.get("link", "accesstoken")
23
23
  ) {
24
24
  return true;
25
25
  } else {
@@ -1,3 +1,11 @@
1
+ import Iconify from "../components/Iconify";
2
+ import config from "../config/config";
3
+ import { useEvent } from "@nucleoidai/react-event";
4
+ import useSettings from "../hooks/useSettings";
5
+ import { useSettingsContext } from "../components/settings/context";
6
+ import { useStorage } from "@nucleoidjs/webstorage";
7
+ import { useUser } from "../hooks/use-user";
8
+
1
9
  import {
2
10
  Avatar,
3
11
  Box,
@@ -23,13 +31,6 @@ import {
23
31
  import { Button, Dialog, DialogActions, DialogContent } from "@mui/material";
24
32
  import React, { useEffect, useState } from "react";
25
33
 
26
- import Iconify from "../components/Iconify";
27
- import config from "../config/config";
28
- import { useEvent } from "@nucleoidai/react-event";
29
- import useSettings from "../hooks/useSettings";
30
- import { useSettingsContext } from "../components/settings/context";
31
- import { useUser } from "../hooks/use-user";
32
-
33
34
  let pkg = {
34
35
  name: "",
35
36
  version: "",
@@ -296,7 +297,7 @@ const Permission = () => {
296
297
  };
297
298
 
298
299
  const Settings = () => {
299
- const projectId = localStorage.getItem("projectId");
300
+ const [projectId] = useStorage("link", "projectid");
300
301
  const { settings, updateSettings } = useSettings(projectId);
301
302
  const { beta, onUpdate } = useSettingsContext();
302
303
 
@@ -1,19 +0,0 @@
1
- import React from "react";
2
-
3
- const ContextStore = React.createContext();
4
- ContextStore.displayName = "ContextStore";
5
-
6
- const useContext = () => React.useContext(ContextStore);
7
-
8
- const ContextProvider = ({ children, state, reducer }) => {
9
- const [contextState, contextDispatch] = React.useReducer(reducer, state);
10
-
11
- return (
12
- <ContextStore.Provider value={[contextState, contextDispatch]}>
13
- {children}
14
- </ContextStore.Provider>
15
- );
16
- };
17
-
18
- export { useContext };
19
- export default ContextProvider;
@@ -1,98 +0,0 @@
1
- class Context {
2
- constructor(data = {}) {
3
- this.login = data.login !== undefined ? data.login : false;
4
- this.itemId = data.itemId || null;
5
-
6
- this.specification = {
7
- api: [],
8
- functions: [],
9
- types: [],
10
- declarations: [],
11
- ...(data.specification || {}),
12
- };
13
-
14
- this.pages = {
15
- api: {
16
- selected: { path: "/", method: "get" },
17
- dialog: {
18
- type: null,
19
- action: null,
20
- open: false,
21
- view: null,
22
- map: {},
23
- params: {},
24
- },
25
- resourceMenu: {
26
- open: false,
27
- anchor: null,
28
- path: null,
29
- },
30
- ...(data.pages?.api || {}),
31
- },
32
- functions: {
33
- selected: null,
34
- dialog: {
35
- type: null,
36
- open: false,
37
- },
38
- AIDialog: {
39
- open: false,
40
- },
41
- ...(data.pages?.functions || {}),
42
- },
43
- logic: {
44
- selected: null,
45
- AIDialog: {
46
- open: false,
47
- },
48
- ...(data.pages?.logic || {}),
49
- },
50
- query: {
51
- results: null,
52
- ...(data.pages?.query || {}),
53
- },
54
- ...(data.pages || {}),
55
- };
56
- }
57
-
58
- static copy(context) {
59
- const copied = new Context();
60
-
61
- copied.login = context.login;
62
- copied.itemId = context.itemId;
63
-
64
- copied.specification = {
65
- api: context.specification?.api ? [...context.specification.api] : [],
66
- functions: context.specification?.functions
67
- ? [...context.specification.functions]
68
- : [],
69
- types: context.specification?.types
70
- ? [...context.specification.types]
71
- : [],
72
- declarations: context.specification?.declarations
73
- ? [...context.specification.declarations]
74
- : [],
75
- };
76
-
77
- copied.pages = JSON.parse(JSON.stringify(context.pages || {}));
78
-
79
- return copied;
80
- }
81
-
82
- get(path) {
83
- const keys = path.split(".");
84
- let result = this;
85
-
86
- for (const key of keys) {
87
- if (result && typeof result === "object" && key in result) {
88
- result = result[key];
89
- } else {
90
- return undefined;
91
- }
92
- }
93
-
94
- return result;
95
- }
96
- }
97
-
98
- export default Context;