@nocobase/client-v2 3.0.0-alpha.8 → 3.0.0-alpha.9
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/es/flow/models/blocks/form/FormBlockModel.d.ts +1 -0
- package/es/index.mjs +98 -98
- package/lib/index.js +98 -98
- package/package.json +7 -7
- package/src/__tests__/settings-center.test.tsx +222 -21
- package/src/flow/models/blocks/form/FormBlockModel.tsx +43 -0
- package/src/flow/models/blocks/form/__tests__/runJsFormSubmit.test.ts +131 -0
- package/src/flow/models/fields/DisplayNumberFieldModel.tsx +1 -1
- package/src/flow/models/fields/NumberFieldModel.tsx +1 -1
- package/src/flow/models/fields/__tests__/DisplayNumberFieldModel.test.ts +33 -0
- package/src/flow/models/fields/__tests__/NumberFieldModel.test.tsx +47 -0
- package/src/settings-center/AdminSettingsLayout.tsx +38 -3
|
@@ -13,9 +13,11 @@ import { FlowModelRenderer, useFlowEngine } from '@nocobase/flow-engine';
|
|
|
13
13
|
import { Layout, Result, Tabs, theme } from 'antd';
|
|
14
14
|
import React, { useEffect, useMemo, useRef } from 'react';
|
|
15
15
|
import { useTranslation } from 'react-i18next';
|
|
16
|
-
import { Navigate, Outlet, useLocation, useNavigate } from 'react-router-dom';
|
|
16
|
+
import { generatePath, Navigate, Outlet, useLocation, useNavigate, useParams } from 'react-router-dom';
|
|
17
|
+
import { getModernClientPrefix } from '../authRedirect';
|
|
17
18
|
import type { PluginSettingsPageType } from '../PluginSettingsManager';
|
|
18
19
|
import { useApp } from '../hooks/useApp';
|
|
20
|
+
import { resolveSettingsAppScopeWithinPublicPath } from '../settings-app/settingsDocumentPath';
|
|
19
21
|
import { AdminSettingsLayoutModel } from './AdminSettingsLayoutModel';
|
|
20
22
|
import { useSettingsGroups } from './useSettingsGroups';
|
|
21
23
|
import {
|
|
@@ -34,6 +36,19 @@ import {
|
|
|
34
36
|
*/
|
|
35
37
|
const SETTINGS_CONTENT_MAX_WIDTH = 1280;
|
|
36
38
|
|
|
39
|
+
function AdminDocumentRedirect() {
|
|
40
|
+
const app = useApp();
|
|
41
|
+
const rootPublicPath = app.getPublicPath().replace(/\/+$/, '');
|
|
42
|
+
const appScope = resolveSettingsAppScopeWithinPublicPath(app.getPublicPath(), app.router.getBasename?.());
|
|
43
|
+
const targetPath = `${rootPublicPath}/${getModernClientPrefix()}${appScope}/admin`;
|
|
44
|
+
|
|
45
|
+
useEffect(() => {
|
|
46
|
+
window.location.replace(targetPath);
|
|
47
|
+
}, [targetPath]);
|
|
48
|
+
|
|
49
|
+
return app.renderComponent('AppSpin');
|
|
50
|
+
}
|
|
51
|
+
|
|
37
52
|
function SettingsEmpty(props: { type: 'forbidden' | 'home' | 'not-found' }) {
|
|
38
53
|
const { type } = props;
|
|
39
54
|
const { t } = useTranslation();
|
|
@@ -83,6 +98,10 @@ export const InternalAdminSettingsLayout = () => {
|
|
|
83
98
|
const app = useApp();
|
|
84
99
|
const navigate = useNavigate();
|
|
85
100
|
const location = useLocation();
|
|
101
|
+
const params = useParams();
|
|
102
|
+
const routeParams = Object.fromEntries(
|
|
103
|
+
Object.entries(params).filter((entry): entry is [string, string] => typeof entry[1] === 'string'),
|
|
104
|
+
);
|
|
86
105
|
const { token } = theme.useToken();
|
|
87
106
|
const {
|
|
88
107
|
allSettings,
|
|
@@ -173,8 +192,24 @@ export const InternalAdminSettingsLayout = () => {
|
|
|
173
192
|
}
|
|
174
193
|
|
|
175
194
|
if (currentSetting.isAllow === false) {
|
|
176
|
-
|
|
177
|
-
|
|
195
|
+
const firstVisibleTabPath = (currentVisibleTopLevelSetting?.children || [])
|
|
196
|
+
.map((tab) => getDefaultSettingsPath([tab]))
|
|
197
|
+
.filter((path): path is string => typeof path === 'string')
|
|
198
|
+
.map((path) => {
|
|
199
|
+
try {
|
|
200
|
+
return generatePath(path, routeParams);
|
|
201
|
+
} catch {
|
|
202
|
+
return null;
|
|
203
|
+
}
|
|
204
|
+
})
|
|
205
|
+
.find((path): path is string => typeof path === 'string');
|
|
206
|
+
|
|
207
|
+
if (firstVisibleTabPath) {
|
|
208
|
+
return <Navigate replace to={firstVisibleTabPath} />;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (!defaultSettingsPath) {
|
|
212
|
+
return <AdminDocumentRedirect />;
|
|
178
213
|
}
|
|
179
214
|
|
|
180
215
|
return <SettingsEmpty type="forbidden" />;
|