@authhero/react-admin 0.10.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/.eslintrc.js +21 -0
- package/.vercelignore +4 -0
- package/CHANGELOG.md +56 -0
- package/LICENSE +21 -0
- package/README.md +50 -0
- package/index.html +125 -0
- package/package.json +61 -0
- package/prettier.config.js +1 -0
- package/public/favicon.ico +0 -0
- package/public/manifest.json +15 -0
- package/src/App.spec.tsx +42 -0
- package/src/App.tsx +232 -0
- package/src/AuthCallback.tsx +138 -0
- package/src/Layout.tsx +12 -0
- package/src/TenantsApp.tsx +115 -0
- package/src/auth0DataProvider.ts +1242 -0
- package/src/authProvider.ts +521 -0
- package/src/components/CertificateErrorDialog.tsx +116 -0
- package/src/components/DomainSelector.tsx +401 -0
- package/src/components/TenantAppBar.tsx +83 -0
- package/src/components/TenantLayout.tsx +25 -0
- package/src/components/TenantsAppBar.tsx +21 -0
- package/src/components/TenantsLayout.tsx +28 -0
- package/src/components/activity/ActivityDashboard.tsx +381 -0
- package/src/components/activity/index.ts +1 -0
- package/src/components/branding/BrandingList.tsx +0 -0
- package/src/components/branding/BrandingShow.tsx +0 -0
- package/src/components/branding/ThemesTab.tsx +286 -0
- package/src/components/branding/edit.tsx +149 -0
- package/src/components/branding/hooks/useThemesData.ts +123 -0
- package/src/components/branding/index.ts +2 -0
- package/src/components/branding/list.tsx +12 -0
- package/src/components/clients/create.tsx +12 -0
- package/src/components/clients/edit.tsx +1285 -0
- package/src/components/clients/index.ts +3 -0
- package/src/components/clients/list.tsx +37 -0
- package/src/components/common/DateAgo.tsx +6 -0
- package/src/components/common/JsonOutput.tsx +26 -0
- package/src/components/common/index.ts +1 -0
- package/src/components/connections/create.tsx +35 -0
- package/src/components/connections/edit.tsx +212 -0
- package/src/components/connections/index.ts +3 -0
- package/src/components/connections/list.tsx +15 -0
- package/src/components/custom-domains/create.tsx +26 -0
- package/src/components/custom-domains/edit.tsx +101 -0
- package/src/components/custom-domains/index.ts +3 -0
- package/src/components/custom-domains/list.tsx +16 -0
- package/src/components/flows/create.tsx +30 -0
- package/src/components/flows/edit.tsx +238 -0
- package/src/components/flows/index.ts +3 -0
- package/src/components/flows/list.tsx +15 -0
- package/src/components/forms/FlowEditor.tsx +1363 -0
- package/src/components/forms/NodeEditor.tsx +1119 -0
- package/src/components/forms/RichTextEditor.tsx +145 -0
- package/src/components/forms/create.tsx +30 -0
- package/src/components/forms/edit.tsx +256 -0
- package/src/components/forms/index.ts +3 -0
- package/src/components/forms/list.tsx +16 -0
- package/src/components/hooks/create.tsx +96 -0
- package/src/components/hooks/edit.tsx +114 -0
- package/src/components/hooks/index.ts +3 -0
- package/src/components/hooks/list.tsx +17 -0
- package/src/components/listActions/PostListActions.tsx +10 -0
- package/src/components/logs/LogIcon.tsx +32 -0
- package/src/components/logs/LogShow.tsx +82 -0
- package/src/components/logs/LogType.tsx +38 -0
- package/src/components/logs/index.ts +4 -0
- package/src/components/logs/list.tsx +41 -0
- package/src/components/organizations/create.tsx +13 -0
- package/src/components/organizations/edit.tsx +682 -0
- package/src/components/organizations/index.ts +3 -0
- package/src/components/organizations/list.tsx +21 -0
- package/src/components/resource-servers/create.tsx +87 -0
- package/src/components/resource-servers/edit.tsx +121 -0
- package/src/components/resource-servers/index.ts +3 -0
- package/src/components/resource-servers/list.tsx +47 -0
- package/src/components/roles/create.tsx +12 -0
- package/src/components/roles/edit.tsx +426 -0
- package/src/components/roles/index.ts +3 -0
- package/src/components/roles/list.tsx +24 -0
- package/src/components/sessions/edit.tsx +101 -0
- package/src/components/sessions/index.ts +3 -0
- package/src/components/sessions/list.tsx +20 -0
- package/src/components/sessions/show.tsx +113 -0
- package/src/components/settings/edit.tsx +236 -0
- package/src/components/settings/index.ts +2 -0
- package/src/components/settings/list.tsx +14 -0
- package/src/components/tenants/create.tsx +20 -0
- package/src/components/tenants/edit.tsx +54 -0
- package/src/components/tenants/index.ts +2 -0
- package/src/components/tenants/list.tsx +67 -0
- package/src/components/themes/edit.tsx +200 -0
- package/src/components/themes/index.ts +2 -0
- package/src/components/themes/list.tsx +12 -0
- package/src/components/users/create.tsx +144 -0
- package/src/components/users/edit.tsx +1711 -0
- package/src/components/users/index.ts +3 -0
- package/src/components/users/list.tsx +35 -0
- package/src/data.json +121 -0
- package/src/dataProvider.ts +97 -0
- package/src/index.tsx +106 -0
- package/src/lib/logs.ts +21 -0
- package/src/types/reactflow.d.ts +86 -0
- package/src/utils/domainUtils.ts +169 -0
- package/src/utils/tokenUtils.ts +75 -0
- package/src/vite-env.d.ts +1 -0
- package/tsconfig.json +37 -0
- package/tsconfig.node.json +10 -0
- package/vercel.json +17 -0
- package/vite.config.ts +30 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
"extends": [
|
|
3
|
+
"eslint:recommended",
|
|
4
|
+
"plugin:react/recommended",
|
|
5
|
+
"plugin:react/jsx-runtime",
|
|
6
|
+
"plugin:react-hooks/recommended",
|
|
7
|
+
"prettier"
|
|
8
|
+
],
|
|
9
|
+
"parser": "@typescript-eslint/parser",
|
|
10
|
+
"plugins": ["@typescript-eslint"],
|
|
11
|
+
"env": {
|
|
12
|
+
"browser": true,
|
|
13
|
+
"es2021": true,
|
|
14
|
+
"node": true
|
|
15
|
+
},
|
|
16
|
+
"settings": {
|
|
17
|
+
"react": {
|
|
18
|
+
"version": "detect"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
package/.vercelignore
ADDED
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# @authhero/react-admin
|
|
2
|
+
|
|
3
|
+
## 0.10.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 283daf2: Refactor multi-tenancy package
|
|
8
|
+
- ae8553a: Add is_system to all adapters
|
|
9
|
+
|
|
10
|
+
## 0.9.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 100b1bd: Patch the redirect action for flows
|
|
15
|
+
|
|
16
|
+
## 0.8.0
|
|
17
|
+
|
|
18
|
+
### Minor Changes
|
|
19
|
+
|
|
20
|
+
- 9e34783: Sync resource servers for multi tenancy setup
|
|
21
|
+
|
|
22
|
+
## 0.7.0
|
|
23
|
+
|
|
24
|
+
### Minor Changes
|
|
25
|
+
|
|
26
|
+
- 906337d: Add flows support
|
|
27
|
+
|
|
28
|
+
## 0.6.0
|
|
29
|
+
|
|
30
|
+
### Minor Changes
|
|
31
|
+
|
|
32
|
+
- a108525: Add flows
|
|
33
|
+
|
|
34
|
+
## 0.5.0
|
|
35
|
+
|
|
36
|
+
### Minor Changes
|
|
37
|
+
|
|
38
|
+
- 1bec131: Add stats endpoints and activity view
|
|
39
|
+
|
|
40
|
+
## 0.4.0
|
|
41
|
+
|
|
42
|
+
### Minor Changes
|
|
43
|
+
|
|
44
|
+
- ee4584d: Small update for getting local mode working smoothly
|
|
45
|
+
|
|
46
|
+
## 0.3.0
|
|
47
|
+
|
|
48
|
+
### Minor Changes
|
|
49
|
+
|
|
50
|
+
- 6929f98: Improve the create authhero for local
|
|
51
|
+
|
|
52
|
+
## 0.2.0
|
|
53
|
+
|
|
54
|
+
### Minor Changes
|
|
55
|
+
|
|
56
|
+
- 23e56b0: Update the logs list view
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 authhero
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# react-admin
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
Install the application dependencies by running:
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install
|
|
9
|
+
# or
|
|
10
|
+
yarn install
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Development
|
|
14
|
+
|
|
15
|
+
Start the application in development mode by running:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
npm run dev
|
|
19
|
+
# or
|
|
20
|
+
yarn dev
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Production
|
|
24
|
+
|
|
25
|
+
Build the application in production mode by running:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npm run build
|
|
29
|
+
# or
|
|
30
|
+
yarn build
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## DataProvider
|
|
34
|
+
|
|
35
|
+
The included data provider use [FakeREST](https://github.com/marmelab/fakerest) to simulate a backend.
|
|
36
|
+
You'll find a `data.json` file in the `src` directory that includes some fake data for testing purposes.
|
|
37
|
+
|
|
38
|
+
It includes two resources, posts and comments.
|
|
39
|
+
Posts have the following properties: `id`, `title` and `content`.
|
|
40
|
+
Comments have the following properties: `id`, `post_id` and `content`.
|
|
41
|
+
|
|
42
|
+
## Tests
|
|
43
|
+
|
|
44
|
+
You can run the included tests with the following command:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
npm run test
|
|
48
|
+
# or
|
|
49
|
+
yarn run test
|
|
50
|
+
```
|
package/index.html
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<meta
|
|
6
|
+
name="viewport"
|
|
7
|
+
content="minimum-scale=1, initial-scale=1, width=device-width, shrink-to-fit=no"
|
|
8
|
+
/>
|
|
9
|
+
<meta name="theme-color" content="#000000" />
|
|
10
|
+
<link rel="manifest" href="./manifest.json" />
|
|
11
|
+
<link rel="shortcut icon" href="./favicon.ico" />
|
|
12
|
+
<title>Auth</title>
|
|
13
|
+
<style>
|
|
14
|
+
body {
|
|
15
|
+
margin: 0;
|
|
16
|
+
padding: 0;
|
|
17
|
+
font-family: sans-serif;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.loader-container {
|
|
21
|
+
display: flex;
|
|
22
|
+
align-items: center;
|
|
23
|
+
justify-content: center;
|
|
24
|
+
flex-direction: column;
|
|
25
|
+
position: absolute;
|
|
26
|
+
top: 0;
|
|
27
|
+
bottom: 0;
|
|
28
|
+
left: 0;
|
|
29
|
+
right: 0;
|
|
30
|
+
background-color: #fafafa;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/* CSS Spinner from https://projects.lukehaas.me/css-loaders/ */
|
|
34
|
+
|
|
35
|
+
.loader,
|
|
36
|
+
.loader:before,
|
|
37
|
+
.loader:after {
|
|
38
|
+
border-radius: 50%;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
.loader {
|
|
42
|
+
color: #283593;
|
|
43
|
+
font-size: 11px;
|
|
44
|
+
text-indent: -99999em;
|
|
45
|
+
margin: 55px auto;
|
|
46
|
+
position: relative;
|
|
47
|
+
width: 10em;
|
|
48
|
+
height: 10em;
|
|
49
|
+
box-shadow: inset 0 0 0 1em;
|
|
50
|
+
-webkit-transform: translateZ(0);
|
|
51
|
+
-ms-transform: translateZ(0);
|
|
52
|
+
transform: translateZ(0);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.loader:before,
|
|
56
|
+
.loader:after {
|
|
57
|
+
position: absolute;
|
|
58
|
+
content: '';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.loader:before {
|
|
62
|
+
width: 5.2em;
|
|
63
|
+
height: 10.2em;
|
|
64
|
+
background: #fafafa;
|
|
65
|
+
border-radius: 10.2em 0 0 10.2em;
|
|
66
|
+
top: -0.1em;
|
|
67
|
+
left: -0.1em;
|
|
68
|
+
-webkit-transform-origin: 5.2em 5.1em;
|
|
69
|
+
transform-origin: 5.2em 5.1em;
|
|
70
|
+
-webkit-animation: load2 2s infinite ease 1.5s;
|
|
71
|
+
animation: load2 2s infinite ease 1.5s;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.loader:after {
|
|
75
|
+
width: 5.2em;
|
|
76
|
+
height: 10.2em;
|
|
77
|
+
background: #fafafa;
|
|
78
|
+
border-radius: 0 10.2em 10.2em 0;
|
|
79
|
+
top: -0.1em;
|
|
80
|
+
left: 5.1em;
|
|
81
|
+
-webkit-transform-origin: 0px 5.1em;
|
|
82
|
+
transform-origin: 0px 5.1em;
|
|
83
|
+
-webkit-animation: load2 2s infinite ease;
|
|
84
|
+
animation: load2 2s infinite ease;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
@-webkit-keyframes load2 {
|
|
88
|
+
0% {
|
|
89
|
+
-webkit-transform: rotate(0deg);
|
|
90
|
+
transform: rotate(0deg);
|
|
91
|
+
}
|
|
92
|
+
100% {
|
|
93
|
+
-webkit-transform: rotate(360deg);
|
|
94
|
+
transform: rotate(360deg);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@keyframes load2 {
|
|
99
|
+
0% {
|
|
100
|
+
-webkit-transform: rotate(0deg);
|
|
101
|
+
transform: rotate(0deg);
|
|
102
|
+
}
|
|
103
|
+
100% {
|
|
104
|
+
-webkit-transform: rotate(360deg);
|
|
105
|
+
transform: rotate(360deg);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
</style>
|
|
109
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" />
|
|
110
|
+
<link
|
|
111
|
+
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap"
|
|
112
|
+
rel="stylesheet"
|
|
113
|
+
/>
|
|
114
|
+
</head>
|
|
115
|
+
|
|
116
|
+
<body>
|
|
117
|
+
<noscript> You need to enable JavaScript to run this app. </noscript>
|
|
118
|
+
<div id="root">
|
|
119
|
+
<div class="loader-container">
|
|
120
|
+
<div class="loader">Loading...</div>
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
</body>
|
|
124
|
+
<script type="module" src="/src/index.tsx"></script>
|
|
125
|
+
</html>
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@authhero/react-admin",
|
|
3
|
+
"version": "0.10.0",
|
|
4
|
+
"private": false,
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/markusahlstrand/authhero"
|
|
8
|
+
},
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@auth0/auth0-spa-js": "^2.1.3",
|
|
11
|
+
"@mui/icons-material": "^7.1.0",
|
|
12
|
+
"@mui/material": "^7.1.0",
|
|
13
|
+
"@tiptap/extension-link": "^3.13.0",
|
|
14
|
+
"@tiptap/extension-underline": "^3.13.0",
|
|
15
|
+
"@tiptap/react": "^3.13.0",
|
|
16
|
+
"@tiptap/starter-kit": "^3.13.0",
|
|
17
|
+
"@xyflow/react": "^12.6.4",
|
|
18
|
+
"auth0": "^5.0.0",
|
|
19
|
+
"date-fns": "^4.1.0",
|
|
20
|
+
"query-string": "^9.1.2",
|
|
21
|
+
"ra-auth-auth0": "^2.0.1",
|
|
22
|
+
"ra-core": "^5.8.0",
|
|
23
|
+
"ra-data-fakerest": "^5.8.0",
|
|
24
|
+
"ra-input-rich-text": "^5.13.3",
|
|
25
|
+
"react": "^19.1.0",
|
|
26
|
+
"react-admin": "^5.8.0",
|
|
27
|
+
"react-admin-color-picker": "^1.0.3",
|
|
28
|
+
"react-dom": "^19.1.0",
|
|
29
|
+
"react-router-dom": "^7.6.0",
|
|
30
|
+
"recharts": "^2.15.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@testing-library/react": "^16.3.0",
|
|
34
|
+
"@types/node": "^22.15.17",
|
|
35
|
+
"@types/react": "^19.1.3",
|
|
36
|
+
"@types/react-dom": "^19.1.3",
|
|
37
|
+
"@typescript-eslint/eslint-plugin": "^8.32.0",
|
|
38
|
+
"@typescript-eslint/parser": "^8.32.0",
|
|
39
|
+
"@vitejs/plugin-react": "^4.4.1",
|
|
40
|
+
"eslint": "^9.26.0",
|
|
41
|
+
"eslint-config-prettier": "^10.1.5",
|
|
42
|
+
"eslint-plugin-react": "^7.37.5",
|
|
43
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
44
|
+
"jsdom": "^26.1.0",
|
|
45
|
+
"pnpm": "^8.15.3",
|
|
46
|
+
"prettier": "^3.5.3",
|
|
47
|
+
"typescript": "^5.8.3",
|
|
48
|
+
"vite": "^6.3.5",
|
|
49
|
+
"vitest": "^3.1.3"
|
|
50
|
+
},
|
|
51
|
+
"packageManager": "pnpm@8.15.3",
|
|
52
|
+
"scripts": {
|
|
53
|
+
"dev": "vite",
|
|
54
|
+
"build": "pnpm install --no-frozen-lockfile && vite build",
|
|
55
|
+
"serve": "vite preview",
|
|
56
|
+
"type-check": "tsc --noEmit",
|
|
57
|
+
"lint": "eslint --fix --ext .js,.jsx,.ts,.tsx ./src",
|
|
58
|
+
"format": "prettier --write ./src",
|
|
59
|
+
"test": "vitest"
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = {}
|
|
Binary file
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"short_name": "react-admin",
|
|
3
|
+
"name": "{{name}}",
|
|
4
|
+
"icons": [
|
|
5
|
+
{
|
|
6
|
+
"src": "favicon.ico",
|
|
7
|
+
"sizes": "64x64 32x32 24x24 16x16",
|
|
8
|
+
"type": "image/x-icon"
|
|
9
|
+
}
|
|
10
|
+
],
|
|
11
|
+
"start_url": "./index.html",
|
|
12
|
+
"display": "standalone",
|
|
13
|
+
"theme_color": "#000000",
|
|
14
|
+
"background_color": "#ffffff"
|
|
15
|
+
}
|
package/src/App.spec.tsx
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { render, screen } from "@testing-library/react";
|
|
2
|
+
import { test, vi, expect } from "vitest";
|
|
3
|
+
import { App } from "./App";
|
|
4
|
+
|
|
5
|
+
// Mock all the react-admin components and dependencies
|
|
6
|
+
vi.mock('react-admin', async (importOriginal) => {
|
|
7
|
+
const actual = await importOriginal() as any;
|
|
8
|
+
return {
|
|
9
|
+
...actual,
|
|
10
|
+
Admin: ({ children }: any) => <div data-testid="admin">{children}</div>,
|
|
11
|
+
Resource: () => <div data-testid="resource" />,
|
|
12
|
+
ShowGuesser: () => <div data-testid="show-guesser" />,
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
vi.mock('./dataProvider', () => ({
|
|
17
|
+
getDataproviderForTenant: () => Promise.resolve(() => Promise.resolve({ data: [] })),
|
|
18
|
+
getDataprovider: () => Promise.resolve(() => Promise.resolve({ data: [] })),
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
vi.mock('./authProvider', () => ({
|
|
22
|
+
getAuthProvider: () => ({}),
|
|
23
|
+
}));
|
|
24
|
+
|
|
25
|
+
vi.mock('./utils/domainUtils', () => ({
|
|
26
|
+
getSelectedDomainFromStorage: () => ({ url: 'test.com', clientId: 'test' }),
|
|
27
|
+
getDomainFromStorage: () => [],
|
|
28
|
+
buildUrlWithProtocol: (url: string) => `https://${url}`,
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
vi.mock('react-router-dom', () => ({
|
|
32
|
+
useNavigate: () => vi.fn(),
|
|
33
|
+
useLocation: () => ({ pathname: '/' }),
|
|
34
|
+
}));
|
|
35
|
+
|
|
36
|
+
test.skip("should pass", async () => {
|
|
37
|
+
vi.spyOn(window, "scrollTo").mockImplementation(() => {});
|
|
38
|
+
render(<App tenantId="test" />);
|
|
39
|
+
|
|
40
|
+
// Just check that something renders
|
|
41
|
+
expect(screen.getByTestId('admin')).toBeTruthy();
|
|
42
|
+
}, 10000);
|
package/src/App.tsx
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import { Admin, Resource, ShowGuesser, CustomRoutes } from "react-admin";
|
|
2
|
+
import { Route } from "react-router-dom";
|
|
3
|
+
import Group from "@mui/icons-material/Group";
|
|
4
|
+
import CloudQueue from "@mui/icons-material/CloudQueue";
|
|
5
|
+
import Layers from "@mui/icons-material/Layers";
|
|
6
|
+
import HistoryIcon from "@mui/icons-material/History";
|
|
7
|
+
import FormatAlignLeftIcon from "@mui/icons-material/FormatAlignLeft";
|
|
8
|
+
import BusinessIcon from "@mui/icons-material/Business";
|
|
9
|
+
import SettingsIcon from "@mui/icons-material/Settings";
|
|
10
|
+
import { getDataproviderForTenant } from "./dataProvider";
|
|
11
|
+
import { getAuthProvider } from "./authProvider";
|
|
12
|
+
import { ClientCreate, ClientEdit, ClientList } from "./components/clients";
|
|
13
|
+
import {
|
|
14
|
+
ConnectionsList,
|
|
15
|
+
ConnectionCreate,
|
|
16
|
+
ConnectionEdit,
|
|
17
|
+
} from "./components/connections";
|
|
18
|
+
import { tenantLayout } from "./components/TenantLayout";
|
|
19
|
+
import { UserCreate, UserEdit, UsersList } from "./components/users";
|
|
20
|
+
import { FormCreate, FormEdit, FormsList } from "./components/forms";
|
|
21
|
+
import { FlowCreate, FlowEdit, FlowsList } from "./components/flows";
|
|
22
|
+
import {
|
|
23
|
+
DomainCreate,
|
|
24
|
+
DomainEdit,
|
|
25
|
+
DomainList,
|
|
26
|
+
} from "./components/custom-domains";
|
|
27
|
+
import { BrandingList, BrandingEdit } from "./components/branding";
|
|
28
|
+
import { LogsList, LogShow } from "./components/logs";
|
|
29
|
+
import { HookEdit, HookList, HooksCreate } from "./components/hooks";
|
|
30
|
+
import { SessionEdit } from "./components/sessions";
|
|
31
|
+
import {
|
|
32
|
+
ResourceServerCreate,
|
|
33
|
+
ResourceServerEdit,
|
|
34
|
+
ResourceServerList,
|
|
35
|
+
} from "./components/resource-servers";
|
|
36
|
+
import {
|
|
37
|
+
OrganizationCreate,
|
|
38
|
+
OrganizationEdit,
|
|
39
|
+
OrganizationList,
|
|
40
|
+
} from "./components/organizations";
|
|
41
|
+
import WebhookIcon from "@mui/icons-material/Webhook";
|
|
42
|
+
import DnsIcon from "@mui/icons-material/Dns";
|
|
43
|
+
import PaletteIcon from "@mui/icons-material/Palette";
|
|
44
|
+
import StorageIcon from "@mui/icons-material/Storage";
|
|
45
|
+
import AccountTreeIcon from "@mui/icons-material/AccountTree";
|
|
46
|
+
import { useMemo, useState } from "react";
|
|
47
|
+
import { RoleCreate, RoleEdit, RoleList } from "./components/roles";
|
|
48
|
+
import SecurityIcon from "@mui/icons-material/Security";
|
|
49
|
+
import { SettingsList, SettingsEdit } from "./components/settings";
|
|
50
|
+
import { CertificateErrorDialog } from "./components/CertificateErrorDialog";
|
|
51
|
+
import { ActivityDashboard } from "./components/activity";
|
|
52
|
+
|
|
53
|
+
interface AppProps {
|
|
54
|
+
tenantId: string;
|
|
55
|
+
initialDomain?: string;
|
|
56
|
+
onAuthComplete?: () => void;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function App(props: AppProps) {
|
|
60
|
+
const [certErrorUrl, setCertErrorUrl] = useState<string | null>(null);
|
|
61
|
+
|
|
62
|
+
// Use a default domain for now - in the working project, domain selection might be handled differently
|
|
63
|
+
const selectedDomain =
|
|
64
|
+
props.initialDomain || import.meta.env.VITE_AUTH0_DOMAIN || "";
|
|
65
|
+
|
|
66
|
+
// Use memoization for creating the auth provider to prevent re-authentication
|
|
67
|
+
const authProvider = useMemo(() => {
|
|
68
|
+
if (!selectedDomain) return null;
|
|
69
|
+
return getAuthProvider(selectedDomain, props.onAuthComplete);
|
|
70
|
+
}, [selectedDomain, props.onAuthComplete]);
|
|
71
|
+
|
|
72
|
+
// Memoize the data provider to prevent unnecessary re-creations
|
|
73
|
+
// Wrap it to catch certificate errors
|
|
74
|
+
const dataProvider = useMemo(() => {
|
|
75
|
+
const baseProvider = getDataproviderForTenant(
|
|
76
|
+
props.tenantId,
|
|
77
|
+
selectedDomain || import.meta.env.VITE_AUTH0_DOMAIN || "",
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
// Wrap all methods to catch certificate errors
|
|
81
|
+
const wrappedProvider: typeof baseProvider = {} as typeof baseProvider;
|
|
82
|
+
for (const method of Object.keys(baseProvider) as Array<
|
|
83
|
+
keyof typeof baseProvider
|
|
84
|
+
>) {
|
|
85
|
+
const original = baseProvider[method];
|
|
86
|
+
if (typeof original === "function") {
|
|
87
|
+
(wrappedProvider as any)[method] = async (...args: any[]) => {
|
|
88
|
+
try {
|
|
89
|
+
return await (original as Function).apply(baseProvider, args);
|
|
90
|
+
} catch (error: any) {
|
|
91
|
+
if (error?.isCertificateError && error?.serverUrl) {
|
|
92
|
+
setCertErrorUrl(error.serverUrl);
|
|
93
|
+
}
|
|
94
|
+
throw error;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return wrappedProvider;
|
|
100
|
+
}, [props.tenantId, selectedDomain]);
|
|
101
|
+
|
|
102
|
+
const handleCloseCertError = () => {
|
|
103
|
+
setCertErrorUrl(null);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
// If no domain is selected, show a loading state
|
|
107
|
+
if (!authProvider || !selectedDomain) {
|
|
108
|
+
return <div>Loading...</div>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return (
|
|
112
|
+
<>
|
|
113
|
+
<CertificateErrorDialog
|
|
114
|
+
open={!!certErrorUrl}
|
|
115
|
+
serverUrl={certErrorUrl || ""}
|
|
116
|
+
onClose={handleCloseCertError}
|
|
117
|
+
/>
|
|
118
|
+
<Admin
|
|
119
|
+
dataProvider={dataProvider}
|
|
120
|
+
authProvider={authProvider}
|
|
121
|
+
requireAuth={!!selectedDomain} // Only require auth when domain is selected
|
|
122
|
+
layout={tenantLayout}
|
|
123
|
+
dashboard={ActivityDashboard}
|
|
124
|
+
>
|
|
125
|
+
<CustomRoutes>
|
|
126
|
+
<Route path="/activity" element={<ActivityDashboard />} />
|
|
127
|
+
</CustomRoutes>
|
|
128
|
+
<Resource
|
|
129
|
+
icon={DnsIcon}
|
|
130
|
+
name="clients"
|
|
131
|
+
list={ClientList}
|
|
132
|
+
edit={ClientEdit}
|
|
133
|
+
create={ClientCreate}
|
|
134
|
+
show={ShowGuesser}
|
|
135
|
+
/>
|
|
136
|
+
<Resource
|
|
137
|
+
icon={CloudQueue}
|
|
138
|
+
name="connections"
|
|
139
|
+
list={ConnectionsList}
|
|
140
|
+
create={ConnectionCreate}
|
|
141
|
+
edit={ConnectionEdit}
|
|
142
|
+
show={ShowGuesser}
|
|
143
|
+
/>
|
|
144
|
+
<Resource
|
|
145
|
+
icon={Group}
|
|
146
|
+
name="users"
|
|
147
|
+
list={UsersList}
|
|
148
|
+
edit={UserEdit}
|
|
149
|
+
create={UserCreate}
|
|
150
|
+
show={ShowGuesser}
|
|
151
|
+
/>
|
|
152
|
+
<Resource
|
|
153
|
+
icon={Layers}
|
|
154
|
+
name="custom-domains"
|
|
155
|
+
create={DomainCreate}
|
|
156
|
+
list={DomainList}
|
|
157
|
+
edit={DomainEdit}
|
|
158
|
+
/>
|
|
159
|
+
<Resource
|
|
160
|
+
icon={WebhookIcon}
|
|
161
|
+
name="hooks"
|
|
162
|
+
create={HooksCreate}
|
|
163
|
+
list={HookList}
|
|
164
|
+
edit={HookEdit}
|
|
165
|
+
/>
|
|
166
|
+
<Resource
|
|
167
|
+
icon={HistoryIcon}
|
|
168
|
+
name="logs"
|
|
169
|
+
list={LogsList}
|
|
170
|
+
show={LogShow}
|
|
171
|
+
/>
|
|
172
|
+
<Resource name="sessions" edit={SessionEdit} show={ShowGuesser} />
|
|
173
|
+
<Resource
|
|
174
|
+
icon={FormatAlignLeftIcon}
|
|
175
|
+
name="forms"
|
|
176
|
+
list={FormsList}
|
|
177
|
+
create={FormCreate}
|
|
178
|
+
edit={FormEdit}
|
|
179
|
+
show={ShowGuesser}
|
|
180
|
+
/>
|
|
181
|
+
<Resource
|
|
182
|
+
icon={AccountTreeIcon}
|
|
183
|
+
name="flows"
|
|
184
|
+
list={FlowsList}
|
|
185
|
+
create={FlowCreate}
|
|
186
|
+
edit={FlowEdit}
|
|
187
|
+
show={ShowGuesser}
|
|
188
|
+
/>
|
|
189
|
+
<Resource
|
|
190
|
+
icon={PaletteIcon}
|
|
191
|
+
name="branding"
|
|
192
|
+
options={{ hasSingle: true }}
|
|
193
|
+
list={BrandingList}
|
|
194
|
+
edit={BrandingEdit}
|
|
195
|
+
show={ShowGuesser}
|
|
196
|
+
/>
|
|
197
|
+
<Resource
|
|
198
|
+
icon={StorageIcon}
|
|
199
|
+
name="resource-servers"
|
|
200
|
+
list={ResourceServerList}
|
|
201
|
+
create={ResourceServerCreate}
|
|
202
|
+
edit={ResourceServerEdit}
|
|
203
|
+
show={ShowGuesser}
|
|
204
|
+
/>
|
|
205
|
+
<Resource name="permissions" />
|
|
206
|
+
<Resource
|
|
207
|
+
icon={SecurityIcon}
|
|
208
|
+
name="roles"
|
|
209
|
+
list={RoleList}
|
|
210
|
+
create={RoleCreate}
|
|
211
|
+
edit={RoleEdit}
|
|
212
|
+
show={ShowGuesser}
|
|
213
|
+
/>
|
|
214
|
+
<Resource
|
|
215
|
+
icon={BusinessIcon}
|
|
216
|
+
name="organizations"
|
|
217
|
+
list={OrganizationList}
|
|
218
|
+
create={OrganizationCreate}
|
|
219
|
+
edit={OrganizationEdit}
|
|
220
|
+
show={ShowGuesser}
|
|
221
|
+
/>
|
|
222
|
+
<Resource
|
|
223
|
+
icon={SettingsIcon}
|
|
224
|
+
name="settings"
|
|
225
|
+
list={SettingsList}
|
|
226
|
+
edit={SettingsEdit}
|
|
227
|
+
options={{ hasSingle: true }}
|
|
228
|
+
/>
|
|
229
|
+
</Admin>
|
|
230
|
+
</>
|
|
231
|
+
);
|
|
232
|
+
}
|