@nocobase/app-template-default 1.0.0-beta.87 → 1.0.0-beta.88
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/.agents/rules/notification-templates.md +5 -0
- package/.agents/rules/shell.md +2 -2
- package/AGENTS.md +3 -1
- package/README.MD +11 -5
- package/client/components/body-portal.tsx +25 -0
- package/client/components/breadcrumbs.tsx +13 -0
- package/client/components/flow-diagram.tsx +2 -2
- package/client/layouts/app-layout.tsx +8 -4
- package/client/layouts/components/sidebar-footer.tsx +18 -25
- package/client/lib/navigation-transform.ts +156 -22
- package/client/locales/system/en-US.ts +7 -5
- package/client/locales/system/settings-en-US.ts +17 -0
- package/client/locales/system/settings-zh-CN.ts +15 -0
- package/client/locales/system/zh-CN.ts +7 -5
- package/client/pages/auth/register.tsx +39 -22
- package/client/pages/auth/shared.tsx +1 -3
- package/client/pages/settings/hooks.tsx +3 -68
- package/client/pages/settings/notification-routes.ts +109 -0
- package/client/pages/settings/notification-templates.tsx +26 -0
- package/client/pages/settings/permission-management-page.tsx +15 -90
- package/client/pages/settings/routes.ts +96 -98
- package/client/pages/settings/settings-home.tsx +109 -0
- package/client/pages/settings/settings-module-page.tsx +158 -0
- package/client/pages/settings/shell-routes.ts +53 -0
- package/client/routes.ts +17 -1
- package/client/routing/app-router.tsx +1 -14
- package/client/routing/client-route.tsx +16 -9
- package/client/routing/route-context.tsx +30 -3
- package/client/routing/route-leave-boundary.tsx +249 -0
- package/client/routing/route-navigation.ts +72 -8
- package/client/routing/route-tree.tsx +7 -12
- package/client/runtime.ts +2 -2
- package/config.example.yml +1 -1
- package/package.json +12 -12
- package/server/config/auth.ts +1 -1
- package/server/providers/index.ts +2 -0
- package/server/providers/notification-management.ts +27 -0
- package/tests/client/account-permissions.test.tsx +1 -1
- package/tests/client/client-auth.test.tsx +10 -1
- package/tests/client/client-routes.test.ts +137 -4
- package/tests/client/client-shell.test.tsx +23 -8
- package/tests/client/foundation-integration.test.ts +38 -17
- package/tests/client/layout-i18n.test.tsx +9 -4
- package/tests/client/permission-management-tabs.test.tsx +421 -16
- package/tests/client/registration-feedback.test.tsx +143 -0
- package/tests/client/settings-home.test.tsx +110 -0
- package/tests/client/settings-navigation.test.ts +230 -0
- package/tests/server/notification-templates.test.ts +144 -0
- package/tests/client/permission-management-routes.test.ts +0 -64
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { useNavigationGuard } from '@nocobase/app-client';
|
|
2
|
+
import { useTranslation } from '@nocobase/i18n/client';
|
|
3
|
+
import {
|
|
4
|
+
createContext,
|
|
5
|
+
useContext,
|
|
6
|
+
useEffect,
|
|
7
|
+
useLayoutEffect,
|
|
8
|
+
useState,
|
|
9
|
+
type PropsWithChildren,
|
|
10
|
+
type ReactElement,
|
|
11
|
+
} from 'react';
|
|
12
|
+
import { useLocation } from 'react-router';
|
|
13
|
+
import { ConfirmAction } from '../pages/settings/shared.js';
|
|
14
|
+
|
|
15
|
+
/* eslint-disable react-refresh/only-export-components -- the route boundary and its hook share one context */
|
|
16
|
+
|
|
17
|
+
type Decision = boolean | Promise<boolean>;
|
|
18
|
+
interface Prompt {
|
|
19
|
+
readonly owner: LeaveController;
|
|
20
|
+
readonly title: string;
|
|
21
|
+
readonly description: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
class LeaveController {
|
|
25
|
+
dirty = false;
|
|
26
|
+
busy = false;
|
|
27
|
+
active = false;
|
|
28
|
+
private allowed = false;
|
|
29
|
+
private pending?: {
|
|
30
|
+
promise: Promise<boolean>;
|
|
31
|
+
resolve: (value: boolean) => void;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
constructor(
|
|
35
|
+
readonly origin: string,
|
|
36
|
+
private readonly show: (prompt: Prompt | undefined) => void,
|
|
37
|
+
) {}
|
|
38
|
+
|
|
39
|
+
title = '';
|
|
40
|
+
description = '';
|
|
41
|
+
onDiscard?: () => void;
|
|
42
|
+
|
|
43
|
+
update(
|
|
44
|
+
dirty: boolean,
|
|
45
|
+
busy: boolean,
|
|
46
|
+
onDiscard: (() => void) | undefined,
|
|
47
|
+
title: string,
|
|
48
|
+
description: string,
|
|
49
|
+
): void {
|
|
50
|
+
this.dirty = dirty;
|
|
51
|
+
this.busy = busy;
|
|
52
|
+
this.onDiscard = onDiscard;
|
|
53
|
+
this.title = title;
|
|
54
|
+
this.description = description;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
guard = (): Decision => {
|
|
58
|
+
if (this.allowed) return true;
|
|
59
|
+
if (this.busy) return false;
|
|
60
|
+
if (!this.dirty) return true;
|
|
61
|
+
if (!this.pending) {
|
|
62
|
+
let resolve!: (value: boolean) => void;
|
|
63
|
+
const promise = new Promise<boolean>((done) => {
|
|
64
|
+
resolve = done;
|
|
65
|
+
});
|
|
66
|
+
this.pending = { promise, resolve };
|
|
67
|
+
this.show({
|
|
68
|
+
owner: this,
|
|
69
|
+
title: this.title,
|
|
70
|
+
description: this.description,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
return this.pending.promise;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
decide(value: boolean): void {
|
|
77
|
+
if (value) this.onDiscard?.();
|
|
78
|
+
this.allowed = value;
|
|
79
|
+
this.pending?.resolve(value);
|
|
80
|
+
this.pending = undefined;
|
|
81
|
+
this.show(undefined);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
allow = (): void => {
|
|
85
|
+
this.allowed = true;
|
|
86
|
+
};
|
|
87
|
+
reset(): void {
|
|
88
|
+
this.allowed = false;
|
|
89
|
+
}
|
|
90
|
+
cancel(): void {
|
|
91
|
+
if (this.pending) this.decide(false);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
class LeaveScope {
|
|
96
|
+
private readonly entries = new Set<LeaveController>();
|
|
97
|
+
private hidden = false;
|
|
98
|
+
constructor(private readonly dirtyChanged: (dirty: boolean) => void) {}
|
|
99
|
+
|
|
100
|
+
changed = (): void => {
|
|
101
|
+
this.dirtyChanged([...this.entries].some((entry) => entry.dirty));
|
|
102
|
+
};
|
|
103
|
+
attach(entry: LeaveController): void {
|
|
104
|
+
entry.active = true;
|
|
105
|
+
this.entries.add(entry);
|
|
106
|
+
this.changed();
|
|
107
|
+
}
|
|
108
|
+
detach(entry: LeaveController): void {
|
|
109
|
+
entry.active = false;
|
|
110
|
+
// Activity disconnects Effects before the shell commits its new visibility.
|
|
111
|
+
queueMicrotask(() => {
|
|
112
|
+
if (!entry.active && !this.hidden) this.remove(entry);
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
private remove(entry: LeaveController): void {
|
|
116
|
+
this.entries.delete(entry);
|
|
117
|
+
entry.cancel();
|
|
118
|
+
this.changed();
|
|
119
|
+
}
|
|
120
|
+
update(hidden: boolean, pathname: string): void {
|
|
121
|
+
this.hidden = hidden;
|
|
122
|
+
for (const entry of this.entries) {
|
|
123
|
+
if (pathname !== entry.origin && !pathname.startsWith(`${entry.origin}/`))
|
|
124
|
+
this.remove(entry);
|
|
125
|
+
else entry.reset();
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
prune(): void {
|
|
129
|
+
if (!this.hidden)
|
|
130
|
+
for (const entry of this.entries) if (!entry.active) this.remove(entry);
|
|
131
|
+
}
|
|
132
|
+
guard = (): Decision => {
|
|
133
|
+
const remaining = [...this.entries];
|
|
134
|
+
const next = (): Decision => {
|
|
135
|
+
const entry = remaining.shift();
|
|
136
|
+
if (!entry) return true;
|
|
137
|
+
const value = entry.guard();
|
|
138
|
+
return typeof value === 'boolean'
|
|
139
|
+
? value && next()
|
|
140
|
+
: value.then((allowed) => allowed && next());
|
|
141
|
+
};
|
|
142
|
+
return next();
|
|
143
|
+
};
|
|
144
|
+
dispose(): void {
|
|
145
|
+
for (const entry of this.entries) entry.cancel();
|
|
146
|
+
this.entries.clear();
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
interface BoundaryContext {
|
|
151
|
+
readonly scope: LeaveScope;
|
|
152
|
+
readonly show: (prompt: Prompt | undefined) => void;
|
|
153
|
+
}
|
|
154
|
+
const Context = createContext<BoundaryContext | undefined>(undefined);
|
|
155
|
+
|
|
156
|
+
function useBeforeUnload(dirty: boolean): void {
|
|
157
|
+
useEffect(() => {
|
|
158
|
+
if (!dirty) return;
|
|
159
|
+
const handler = (event: BeforeUnloadEvent) => {
|
|
160
|
+
event.preventDefault();
|
|
161
|
+
event.returnValue = '';
|
|
162
|
+
};
|
|
163
|
+
window.addEventListener('beforeunload', handler);
|
|
164
|
+
return () => window.removeEventListener('beforeunload', handler);
|
|
165
|
+
}, [dirty]);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function promptDialog(prompt: Prompt | undefined): ReactElement | null {
|
|
169
|
+
return prompt ? (
|
|
170
|
+
<ConfirmAction
|
|
171
|
+
open
|
|
172
|
+
title={prompt.title}
|
|
173
|
+
description={prompt.description}
|
|
174
|
+
busy={false}
|
|
175
|
+
onCancel={() => prompt.owner.decide(false)}
|
|
176
|
+
onConfirm={() => prompt.owner.decide(true)}
|
|
177
|
+
/>
|
|
178
|
+
) : null;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/** The shell owns leave decisions and their UI, outside every page's Activity and its nested routes. */
|
|
182
|
+
export function RouteLeaveBoundary({
|
|
183
|
+
hidden,
|
|
184
|
+
children,
|
|
185
|
+
}: PropsWithChildren<{ readonly hidden: boolean }>): ReactElement {
|
|
186
|
+
const location = useLocation();
|
|
187
|
+
const [prompt, setPrompt] = useState<Prompt>();
|
|
188
|
+
const [dirty, setDirty] = useState(false);
|
|
189
|
+
const [context] = useState(() => ({
|
|
190
|
+
scope: new LeaveScope(setDirty),
|
|
191
|
+
show: setPrompt,
|
|
192
|
+
}));
|
|
193
|
+
useNavigationGuard(context.scope.guard);
|
|
194
|
+
useBeforeUnload(dirty);
|
|
195
|
+
useLayoutEffect(
|
|
196
|
+
() => context.scope.update(hidden, location.pathname),
|
|
197
|
+
[context, hidden, location.pathname, location.key],
|
|
198
|
+
);
|
|
199
|
+
useEffect(() => {
|
|
200
|
+
context.scope.prune();
|
|
201
|
+
}, [context, hidden]);
|
|
202
|
+
useEffect(() => () => context.scope.dispose(), [context]);
|
|
203
|
+
return (
|
|
204
|
+
<Context.Provider value={context}>
|
|
205
|
+
{children}
|
|
206
|
+
{promptDialog(prompt)}
|
|
207
|
+
</Context.Provider>
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Compatible with standalone form renders; routed forms keep protection in the shell during permission rechecks. */
|
|
212
|
+
export function usePageLeave(
|
|
213
|
+
dirty: boolean,
|
|
214
|
+
busy: boolean,
|
|
215
|
+
onDiscard?: () => void,
|
|
216
|
+
) {
|
|
217
|
+
const boundary = useContext(Context);
|
|
218
|
+
const { t } = useTranslation();
|
|
219
|
+
const location = useLocation();
|
|
220
|
+
const [prompt, setPrompt] = useState<Prompt>();
|
|
221
|
+
const [controller] = useState(
|
|
222
|
+
() => new LeaveController(location.pathname, boundary?.show ?? setPrompt),
|
|
223
|
+
);
|
|
224
|
+
useNavigationGuard(boundary ? () => true : controller.guard);
|
|
225
|
+
useBeforeUnload(!boundary && dirty);
|
|
226
|
+
useLayoutEffect(() => {
|
|
227
|
+
controller.update(
|
|
228
|
+
dirty,
|
|
229
|
+
busy,
|
|
230
|
+
onDiscard,
|
|
231
|
+
t('settings.discardTitle'),
|
|
232
|
+
t('settings.discardHint'),
|
|
233
|
+
);
|
|
234
|
+
boundary?.scope.changed();
|
|
235
|
+
}, [controller, dirty, busy, onDiscard, boundary, t]);
|
|
236
|
+
useLayoutEffect(() => {
|
|
237
|
+
controller.reset();
|
|
238
|
+
}, [controller, location.key]);
|
|
239
|
+
useLayoutEffect(() => {
|
|
240
|
+
if (!boundary) return () => controller.cancel();
|
|
241
|
+
boundary.scope.attach(controller);
|
|
242
|
+
return () => boundary.scope.detach(controller);
|
|
243
|
+
}, [boundary, controller]);
|
|
244
|
+
return {
|
|
245
|
+
guard: controller.guard,
|
|
246
|
+
allow: controller.allow,
|
|
247
|
+
dialog: boundary ? null : promptDialog(prompt),
|
|
248
|
+
};
|
|
249
|
+
}
|
|
@@ -8,7 +8,12 @@ import { useEffect, useMemo, useState } from 'react';
|
|
|
8
8
|
import { matchPath, matchRoutes, type RouteObject } from 'react-router';
|
|
9
9
|
|
|
10
10
|
import { EMPTY_ARRAY } from '#lib/constants';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
organizeNavigation,
|
|
13
|
+
settingsCatalog,
|
|
14
|
+
transformNavigation,
|
|
15
|
+
type SettingsCategory,
|
|
16
|
+
} from '#lib/navigation-transform';
|
|
12
17
|
|
|
13
18
|
export interface RouteNavigationItem {
|
|
14
19
|
/** Route keys represented by a single sidebar entry whose content uses tabs. */
|
|
@@ -22,7 +27,17 @@ export function buildRouteNavigation(
|
|
|
22
27
|
routes: readonly AppClientRegisteredRoute[],
|
|
23
28
|
denied: ReadonlySet<string>,
|
|
24
29
|
): RouteNavigationItem[] {
|
|
25
|
-
return transformNavigation(visibleRouteNavigation(routes, denied));
|
|
30
|
+
return transformNavigation(visibleRouteNavigation(routes, denied), routes);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The settings home's categories and modules the viewer may open (`settingsCatalog`). */
|
|
34
|
+
export function buildSettingsCatalog(
|
|
35
|
+
routes: readonly AppClientRegisteredRoute[],
|
|
36
|
+
denied: ReadonlySet<string>,
|
|
37
|
+
): SettingsCategory[] {
|
|
38
|
+
return settingsCatalog(
|
|
39
|
+
organizeNavigation(visibleRouteNavigation(routes, denied), routes),
|
|
40
|
+
);
|
|
26
41
|
}
|
|
27
42
|
|
|
28
43
|
function visibleRouteNavigation(
|
|
@@ -96,6 +111,8 @@ function navigationPages(
|
|
|
96
111
|
]);
|
|
97
112
|
}
|
|
98
113
|
|
|
114
|
+
const NONE_DENIED: ReadonlySet<string> = new Set();
|
|
115
|
+
|
|
99
116
|
export function useRouteNavigation(
|
|
100
117
|
routes: readonly AppClientRegisteredRoute[],
|
|
101
118
|
) {
|
|
@@ -151,9 +168,8 @@ export function useRouteNavigation(
|
|
|
151
168
|
result.guards !== guards ||
|
|
152
169
|
result.revision !== revision),
|
|
153
170
|
);
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
: new Set<string>();
|
|
171
|
+
// A stable empty set keeps consumers that memoize on `denied` from recomputing on every render.
|
|
172
|
+
const denied = (guards.length && result?.denied) || NONE_DENIED;
|
|
157
173
|
return {
|
|
158
174
|
loading,
|
|
159
175
|
items: loading ? [] : buildRouteNavigation(routes, denied),
|
|
@@ -165,11 +181,17 @@ export function matchRouteTree(
|
|
|
165
181
|
routes: readonly AppClientRegisteredRoute[],
|
|
166
182
|
pathname: string,
|
|
167
183
|
) {
|
|
168
|
-
const toMatch = (
|
|
184
|
+
const toMatch = (
|
|
185
|
+
nodes: readonly AppClientRegisteredRoute[],
|
|
186
|
+
parentPath = '',
|
|
187
|
+
): RouteObject[] =>
|
|
169
188
|
nodes.map((route) => ({
|
|
170
|
-
path: route
|
|
189
|
+
path: relativeRoutePath(route, parentPath),
|
|
171
190
|
handle: route,
|
|
172
|
-
children: toMatch(
|
|
191
|
+
children: toMatch(
|
|
192
|
+
route.children ?? EMPTY_ARRAY,
|
|
193
|
+
childRouteParentPath(route, parentPath),
|
|
194
|
+
),
|
|
173
195
|
}));
|
|
174
196
|
return matchRoutes(toMatch(routes), pathname)?.map((match) => ({
|
|
175
197
|
...match,
|
|
@@ -177,6 +199,48 @@ export function matchRouteTree(
|
|
|
177
199
|
}));
|
|
178
200
|
}
|
|
179
201
|
|
|
202
|
+
/**
|
|
203
|
+
* A registered route's path relative to its parent's, as the router nests it. Registered paths are absolute; a route at
|
|
204
|
+
* its parent's own path (a group's home page, a pathless group) nests with an empty path.
|
|
205
|
+
*/
|
|
206
|
+
export function relativeRoutePath(
|
|
207
|
+
route: AppClientRegisteredRoute,
|
|
208
|
+
parentPath: string,
|
|
209
|
+
): string {
|
|
210
|
+
if (!parentPath) return route.path;
|
|
211
|
+
if (
|
|
212
|
+
route.path === parentPath ||
|
|
213
|
+
parentPath.startsWith(`${route.path.replace(/\/$/, '')}/`)
|
|
214
|
+
)
|
|
215
|
+
return '';
|
|
216
|
+
return route.path.slice(parentPath === '/' ? 1 : parentPath.length + 1);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** The path a route's children are relative to. */
|
|
220
|
+
export function childRouteParentPath(
|
|
221
|
+
route: AppClientRegisteredRoute,
|
|
222
|
+
parentPath: string,
|
|
223
|
+
): string {
|
|
224
|
+
return parentPath.startsWith(`${route.path.replace(/\/$/, '')}/`)
|
|
225
|
+
? parentPath
|
|
226
|
+
: route.path;
|
|
227
|
+
}
|
|
228
|
+
|
|
180
229
|
export function routeKey(route: AppClientRegisteredRoute): string {
|
|
181
230
|
return `${route.packageName}:${route.path}:${route.id}`;
|
|
182
231
|
}
|
|
232
|
+
|
|
233
|
+
/** Pure groups can span shells; a page and its descendants always share their shell. */
|
|
234
|
+
export function filterRouteTree(
|
|
235
|
+
routes: readonly AppClientRegisteredRoute[],
|
|
236
|
+
predicate: (route: AppClientRegisteredRoute) => boolean,
|
|
237
|
+
): AppClientRegisteredRoute[] {
|
|
238
|
+
return routes.flatMap((route) => {
|
|
239
|
+
if (route.componentLoader) return predicate(route) ? [route] : [];
|
|
240
|
+
const children = filterRouteTree(route.children ?? EMPTY_ARRAY, predicate);
|
|
241
|
+
// A group declared empty, such as a settings category waiting for modules, stays so its title is still known.
|
|
242
|
+
return children.length || !route.children?.length
|
|
243
|
+
? [{ ...route, children }]
|
|
244
|
+
: [];
|
|
245
|
+
});
|
|
246
|
+
}
|
|
@@ -4,7 +4,11 @@ import { Outlet, Route } from 'react-router';
|
|
|
4
4
|
|
|
5
5
|
import { EMPTY_ARRAY } from '#lib/constants';
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
childRouteParentPath,
|
|
9
|
+
relativeRoutePath,
|
|
10
|
+
routeKey,
|
|
11
|
+
} from './route-navigation.js';
|
|
8
12
|
import { ClientRoute } from './client-route.js';
|
|
9
13
|
|
|
10
14
|
/** Groups pass children through; pages deliberately own their Outlet placement. */
|
|
@@ -15,14 +19,7 @@ export function renderRouteTree(
|
|
|
15
19
|
return routes.map((route) => (
|
|
16
20
|
<Route
|
|
17
21
|
key={routeKey(route)}
|
|
18
|
-
path={
|
|
19
|
-
parentPath
|
|
20
|
-
? route.path === parentPath ||
|
|
21
|
-
parentPath.startsWith(`${route.path.replace(/\/$/, '')}/`)
|
|
22
|
-
? ''
|
|
23
|
-
: route.path.slice(parentPath === '/' ? 1 : parentPath.length + 1)
|
|
24
|
-
: route.path
|
|
25
|
-
}
|
|
22
|
+
path={relativeRoutePath(route, parentPath)}
|
|
26
23
|
element={
|
|
27
24
|
route.componentLoader ? (
|
|
28
25
|
<ClientRoute key={routeKey(route)} route={route} />
|
|
@@ -33,9 +30,7 @@ export function renderRouteTree(
|
|
|
33
30
|
>
|
|
34
31
|
{renderRouteTree(
|
|
35
32
|
route.children ?? EMPTY_ARRAY,
|
|
36
|
-
|
|
37
|
-
? parentPath
|
|
38
|
-
: route.path,
|
|
33
|
+
childRouteParentPath(route, parentPath),
|
|
39
34
|
)}
|
|
40
35
|
</Route>
|
|
41
36
|
));
|
package/client/runtime.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { defineAppRuntime } from '@nocobase/app-client/runtime';
|
|
|
5
5
|
import locales from './locales/index.js';
|
|
6
6
|
import plugins from './plugins.js';
|
|
7
7
|
import reactProviders from './react-providers.js';
|
|
8
|
-
import
|
|
8
|
+
import { createApplicationRoutes } from './routes.js';
|
|
9
9
|
import serviceProviders from './service-provider.js';
|
|
10
10
|
|
|
11
11
|
const appRuntime = defineAppRuntime({
|
|
@@ -15,7 +15,7 @@ const appRuntime = defineAppRuntime({
|
|
|
15
15
|
serviceProviders,
|
|
16
16
|
locales,
|
|
17
17
|
reactProviders,
|
|
18
|
-
routes,
|
|
18
|
+
routes: () => createApplicationRoutes(),
|
|
19
19
|
plugins,
|
|
20
20
|
});
|
|
21
21
|
|
package/config.example.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/app-template-default",
|
|
3
3
|
"displayName": "Default Template",
|
|
4
|
-
"version": "1.0.0-beta.
|
|
4
|
+
"version": "1.0.0-beta.88",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"prettier": "@nocobase/dev-config/prettier",
|
|
7
7
|
"engines": {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
},
|
|
10
10
|
"nocobase": {
|
|
11
11
|
"templateKind": "app",
|
|
12
|
-
"defaultTemplateVersion": "1.0.0-beta.
|
|
12
|
+
"defaultTemplateVersion": "1.0.0-beta.88"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@ai-sdk/react": "4.0.131",
|
|
@@ -74,9 +74,9 @@
|
|
|
74
74
|
"elkjs": "^0.10.2",
|
|
75
75
|
"@types/jsdom": "^30.0.0",
|
|
76
76
|
"@noble/hashes": "2.3.0",
|
|
77
|
-
"@nocobase/app-client": "^4.0.0-beta.
|
|
77
|
+
"@nocobase/app-client": "^4.0.0-beta.8",
|
|
78
78
|
"@nocobase/app-plugin-template-print": "0.0.2-beta.2",
|
|
79
|
-
"@nocobase/app-skills": "0.1.0-beta.
|
|
79
|
+
"@nocobase/app-skills": "0.1.0-beta.59",
|
|
80
80
|
"@nocobase/app-testing": "0.1.0-beta.8",
|
|
81
81
|
"@nocobase/app-websocket": "^0.1.0-beta.1",
|
|
82
82
|
"@nocobase/dev-config": "0.1.0-beta.25",
|
|
@@ -144,22 +144,22 @@
|
|
|
144
144
|
"hono": "^4.13.2",
|
|
145
145
|
"@nocobase/concurrency": "^0.1.0-beta.1",
|
|
146
146
|
"@nocobase/app-plugin-concurrency": "^0.1.0-beta.2",
|
|
147
|
-
"@nocobase/app-plugin-agents": "^2.0.0-beta.
|
|
147
|
+
"@nocobase/app-plugin-agents": "^2.0.0-beta.4",
|
|
148
148
|
"@nocobase/app-plugin-api-keys": "^1.0.0-beta.21",
|
|
149
|
-
"@nocobase/app-plugin-authentication": "^2.0.0-beta.
|
|
150
|
-
"@nocobase/app-plugin-authorization": "^1.0.0-beta.
|
|
149
|
+
"@nocobase/app-plugin-authentication": "^2.0.0-beta.19",
|
|
150
|
+
"@nocobase/app-plugin-authorization": "^1.0.0-beta.36",
|
|
151
151
|
"@nocobase/app-plugin-database-explorer": "^1.0.0-beta.19",
|
|
152
152
|
"@nocobase/app-plugin-file": "^1.0.0-beta.29",
|
|
153
|
-
"@nocobase/app-plugin-foundation": "^0.1.0-beta.
|
|
154
|
-
"@nocobase/app-plugin-i18n": "^1.0.0-beta.
|
|
153
|
+
"@nocobase/app-plugin-foundation": "^0.1.0-beta.14",
|
|
154
|
+
"@nocobase/app-plugin-i18n": "^1.0.0-beta.21",
|
|
155
155
|
"@nocobase/app-plugin-knowledge": "^0.1.0-beta.17",
|
|
156
156
|
"@nocobase/app-plugin-mail": "^1.0.0-beta.21",
|
|
157
|
-
"@nocobase/app-plugin-notification": "^2.0.0-beta.
|
|
157
|
+
"@nocobase/app-plugin-notification": "^2.0.0-beta.5",
|
|
158
158
|
"@nocobase/app-plugin-notification-in-app": "^2.0.0-beta.2",
|
|
159
159
|
"@nocobase/app-plugin-notification-providers": "^1.0.0-beta.18",
|
|
160
160
|
"@nocobase/app-plugin-scheduler": "^1.0.0-beta.23",
|
|
161
|
-
"@nocobase/app-plugin-users": "^2.0.0-beta.
|
|
162
|
-
"@nocobase/app-server": "^5.0.0-beta.
|
|
161
|
+
"@nocobase/app-plugin-users": "^2.0.0-beta.15",
|
|
162
|
+
"@nocobase/app-server": "^5.0.0-beta.1",
|
|
163
163
|
"@nocobase/config": "^0.1.0-beta.3",
|
|
164
164
|
"@nocobase/db": "^1.0.0-beta.25",
|
|
165
165
|
"@nocobase/db-sqlite": "^0.1.0-beta.6",
|
package/server/config/auth.ts
CHANGED
|
@@ -29,7 +29,7 @@ const auth: AppConfigFactory<AuthConfig> = defineAuthConfig({
|
|
|
29
29
|
}),
|
|
30
30
|
bearer(),
|
|
31
31
|
],
|
|
32
|
-
emailAndPassword: { enabled: true, autoSignIn:
|
|
32
|
+
emailAndPassword: { enabled: true, autoSignIn: true },
|
|
33
33
|
session: { storeSessionInDatabase: true },
|
|
34
34
|
account: { encryptOAuthTokens: true },
|
|
35
35
|
},
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import NotificationManagementProvider from './notification-management.js';
|
|
1
2
|
import SubmissionProvider from './submission.js';
|
|
2
3
|
import type { ApplicationServiceProviderConstructor } from '@nocobase/app-server/application';
|
|
3
4
|
|
|
4
5
|
const serviceProviders: readonly ApplicationServiceProviderConstructor[] = [
|
|
5
6
|
SubmissionProvider,
|
|
7
|
+
NotificationManagementProvider,
|
|
6
8
|
];
|
|
7
9
|
|
|
8
10
|
export default serviceProviders;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ServiceProvider } from '@nocobase/service-provider';
|
|
2
|
+
import type { AppPluginApplication } from '@nocobase/app-server/plugins';
|
|
3
|
+
import type { MailersConfig } from '@nocobase/app-server/mailers/config';
|
|
4
|
+
import {
|
|
5
|
+
describeInvitationEmailChannel,
|
|
6
|
+
type UsersConfig,
|
|
7
|
+
} from '@nocobase/app-plugin-users/server/config';
|
|
8
|
+
|
|
9
|
+
/** Only a derived boolean reaches the existing SPA bootstrap; all transport configuration stays private. */
|
|
10
|
+
export default class NotificationManagementProvider extends ServiceProvider<AppPluginApplication> {
|
|
11
|
+
readonly name = 'app.notification-management';
|
|
12
|
+
override boot(): Promise<void> {
|
|
13
|
+
const channel = describeInvitationEmailChannel({
|
|
14
|
+
invitations: this.app.config.get<UsersConfig>('users')?.invitations,
|
|
15
|
+
mailers: this.app.config.get<MailersConfig>('mailers'),
|
|
16
|
+
channels: this.app.config.get<{
|
|
17
|
+
channels?: Readonly<Record<string, { enabled?: boolean }>>;
|
|
18
|
+
}>('notification')?.channels,
|
|
19
|
+
});
|
|
20
|
+
this.app.config.mergeDefaults({
|
|
21
|
+
client: {
|
|
22
|
+
notificationTemplates: { invitationConfigured: channel.configured },
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
return Promise.resolve();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -115,7 +115,7 @@ describe('account permission changes without a browser reload', () => {
|
|
|
115
115
|
await expectMenu(true);
|
|
116
116
|
await changePermissions(view, false);
|
|
117
117
|
invalidate(view);
|
|
118
|
-
expect(screen.
|
|
118
|
+
expect(screen.getByText('users content')).not.toBeVisible();
|
|
119
119
|
await expectMenu(false);
|
|
120
120
|
await changePermissions(view, true);
|
|
121
121
|
invalidate(view);
|
|
@@ -2,7 +2,13 @@ import {
|
|
|
2
2
|
TestI18nProvider,
|
|
3
3
|
createTestI18nRuntime,
|
|
4
4
|
} from '@nocobase/i18n/testing';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
fireEvent,
|
|
7
|
+
render,
|
|
8
|
+
screen,
|
|
9
|
+
waitFor,
|
|
10
|
+
within,
|
|
11
|
+
} from '@testing-library/react';
|
|
6
12
|
import type { ReactElement } from 'react';
|
|
7
13
|
import { MemoryRouter, Route, Routes } from 'react-router';
|
|
8
14
|
import { describe, expect, it, vi } from 'vitest';
|
|
@@ -98,6 +104,9 @@ describe('application authentication pages', () => {
|
|
|
98
104
|
});
|
|
99
105
|
expect(panel).toHaveClass('hidden', 'xl:block');
|
|
100
106
|
expect(panel).toHaveTextContent('AI-native application platform');
|
|
107
|
+
expect(within(panel).getByRole('heading', { level: 2 })).toHaveTextContent(
|
|
108
|
+
/^AI \+ NocoBase\s*Build reliable business systems$/,
|
|
109
|
+
);
|
|
101
110
|
expect(panel).toHaveTextContent('AI-native frontend');
|
|
102
111
|
expect(panel).toHaveTextContent('NocoBase foundation');
|
|
103
112
|
expect(panel).toHaveTextContent('Freedom above. Confidence below.');
|