refactor: client build in plugins (#1067)

Reviewed-on: daoyoucloud/tachybase#1067
This commit is contained in:
sealday 2024-05-29 17:04:28 +08:00
parent 33b7525e27
commit 82a70fd5c5
78 changed files with 240 additions and 281 deletions

View File

@ -1,6 +1,8 @@
import React, { useCallback, useEffect } from 'react';
import { observer } from '@tachybase/schema';
import React, { FC, useCallback, useEffect } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
import type { Application } from '../Application';
import { ApplicationContext } from '../context';
@ -8,8 +10,8 @@ export interface AppComponentProps {
app: Application;
}
export const AppComponent: FC<AppComponentProps> = observer(
(props) => {
export const AppComponent = observer(
(props: AppComponentProps) => {
const { app } = props;
const handleErrors = useCallback((error: Error, info: { componentStack: string }) => {
console.error(error);

View File

@ -1,7 +1,8 @@
import React, { FC, ReactNode } from 'react';
import React, { ReactNode } from 'react';
import { UNSAFE_LocationContext, UNSAFE_RouteContext } from 'react-router-dom';
export const RouterContextCleaner: FC<{ children?: ReactNode }> = React.memo((props) => {
export const RouterContextCleaner = React.memo((props: { children?: ReactNode }) => {
return (
<UNSAFE_RouteContext.Provider
value={{

View File

@ -1,15 +1,16 @@
import React, { FC } from 'react';
import { MainComponent } from './MainComponent';
const Loading: FC = () => <div>Loading...</div>;
const AppError: FC<{ error: Error }> = ({ error }) => (
const Loading = () => <div>Loading...</div>;
const AppError = ({ error }: { error: Error }) => (
<div>
<div>Load Plugin Error</div>
{error?.message}
</div>
);
const AppNotFound: FC = () => <div></div>;
const AppNotFound = () => <div></div>;
export const defaultAppComponents = {
AppMain: MainComponent,

View File

@ -1,5 +1,7 @@
import { Spin } from 'antd';
import React from 'react';
import { Spin } from 'antd';
import { useApp } from './useApp';
export const useAppSpin = () => {

View File

@ -8,6 +8,7 @@ import template from 'lodash/template';
import { Link } from 'react-router-dom';
import {
ACLCollectionProvider,
DataBlockProvider,
TableFieldResource,
useCollectionManager,
@ -21,7 +22,6 @@ import {
useRecord,
WithoutTableFieldResource,
} from '../';
import { ACLCollectionProvider } from '../acl/ACLProvider';
import {
CollectionProvider_deprecated,
useCollection_deprecated,

View File

@ -1,5 +1,3 @@
import React from 'react';
import { Plugin } from '../application/Plugin';
import { ActionSchemaToolbar } from '../modules/actions/ActionSchemaToolbar';
import { BlockSchemaToolbar } from '../modules/blocks/BlockSchemaToolbar';
@ -22,7 +20,6 @@ import { CollapseItemSchemaToolbar } from '../modules/blocks/filter-blocks/colla
import { useCollapseBlockDecoratorProps } from '../modules/blocks/filter-blocks/collapse/hooks/useCollapseBlockDecoratorProps';
import { useFilterFormBlockDecoratorProps } from '../modules/blocks/filter-blocks/form/hooks/useFilterFormBlockDecoratorProps';
import { useFilterFormBlockProps } from '../modules/blocks/filter-blocks/form/hooks/useFilterFormBlockProps';
import { SchemaComponentOptions } from '../schema-component';
import { RecordLink, useParamsFromRecord, useSourceIdFromParentRecord, useSourceIdFromRecord } from './BlockProvider';
import { DetailsBlockProvider, useDetailsBlockProps } from './DetailsBlockProvider';
import { FilterFormBlockProvider } from './FilterFormBlockProvider';
@ -33,53 +30,6 @@ import { TableBlockProvider } from './TableBlockProvider';
import { TableFieldProvider, useTableFieldProps } from './TableFieldProvider';
import { TableSelectorProvider, useTableSelectorProps } from './TableSelectorProvider';
// TODO: delete this, replaced by `BlockSchemaComponentPlugin`
export const BlockSchemaComponentProvider = (props) => {
return (
<SchemaComponentOptions
components={{
TableFieldProvider,
TableBlockProvider,
TableSelectorProvider,
FormBlockProvider,
FilterFormBlockProvider,
FormFieldProvider,
DetailsBlockProvider,
RecordLink,
}}
scope={{
...bp,
useSourceIdFromRecord,
useSourceIdFromParentRecord,
useParamsFromRecord,
useFormBlockProps,
useCreateFormBlockProps,
useCreateFormBlockDecoratorProps,
useEditFormBlockDecoratorProps,
useEditFormBlockProps,
useFormFieldProps,
useDetailsBlockProps,
useDetailsProps,
useDetailsWithPaginationProps,
useDetailsDecoratorProps,
useDetailsWithPaginationDecoratorProps,
useTableFieldProps,
useTableBlockProps,
useTableSelectorProps,
useTableBlockDecoratorProps,
useListBlockDecoratorProps,
useTableSelectorDecoratorProps,
useCollapseBlockDecoratorProps,
useFilterFormBlockProps,
useFilterFormBlockDecoratorProps,
useGridCardBlockDecoratorProps,
}}
>
{props.children}
</SchemaComponentOptions>
);
};
export class BlockSchemaComponentPlugin extends Plugin {
async load() {
this.addComponents();

View File

@ -1,17 +1,18 @@
import { Field } from '@tachybase/schema';
import { Schema, useField, useFieldSchema } from '@tachybase/schema';
import React, { createContext, useContext, useEffect } from 'react';
import { Navigate } from 'react-router-dom';
import { Field, Schema, useField, useFieldSchema } from '@tachybase/schema';
import { omit } from 'lodash';
import { useAPIClient, useRequest } from '../api-client';
import { useAppSpin } from '../application/hooks/useAppSpin';
import { useBlockRequestContext } from '../block-provider/BlockProvider';
import { useCollection_deprecated, useCollectionManager_deprecated } from '../collection-manager';
import { useResourceActionContext } from '../collection-manager/ResourceActionProvider';
import { useRecord } from '../record-provider';
import { SchemaComponentOptions, useDesignable } from '../schema-component';
import { useApp } from '../application';
import { useDataSourceKey } from '../data-source/data-source/DataSourceProvider';
import { Navigate } from 'react-router-dom';
import { useAPIClient, useRequest } from '../../api-client';
import { useApp } from '../../application';
import { useAppSpin } from '../../application/hooks/useAppSpin';
import { useBlockRequestContext } from '../../block-provider/BlockProvider';
import { useCollection_deprecated, useCollectionManager_deprecated } from '../../collection-manager';
import { useResourceActionContext } from '../../collection-manager/ResourceActionProvider';
import { useDataSourceKey } from '../../data-source/data-source/DataSourceProvider';
import { useRecord } from '../../record-provider';
import { SchemaComponentOptions, useDesignable } from '../../schema-component';
export const ACLContext = createContext<any>({});
ACLContext.displayName = 'ACLContext';

View File

@ -1,8 +1,9 @@
import { ISchema } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import { Card } from 'antd';
import React from 'react';
import { SchemaComponent } from '../schema-component';
import { ISchema, uid } from '@tachybase/schema';
import { Card } from 'antd';
import { SchemaComponent } from '../../schema-component';
import * as components from './Configuration';
const schema2: ISchema = {

View File

@ -4,11 +4,11 @@ import { Checkbox, message, Table } from 'antd';
import { omit } from 'lodash';
import { useTranslation } from 'react-i18next';
import { useAPIClient, useRequest } from '../../api-client';
import { useApp } from '../../application';
import { useAPIClient, useRequest } from '../../../api-client';
import { useApp } from '../../../application';
import { useRecord } from '../../../record-provider';
import { useCompile } from '../../../schema-component';
import { SettingsCenterContext } from '../../pm';
import { useRecord } from '../../record-provider';
import { useCompile } from '../../schema-component';
import { useStyles } from '../style';
const getParentKeys = (tree, func, path = []) => {

View File

@ -4,8 +4,8 @@ import { Checkbox, message, Table } from 'antd';
import { uniq } from 'lodash';
import { useTranslation } from 'react-i18next';
import { useAPIClient, useRequest } from '../../api-client';
import { useRecord } from '../../record-provider';
import { useAPIClient, useRequest } from '../../../api-client';
import { useRecord } from '../../../record-provider';
import { useStyles } from '../style';
import { useMenuItems } from './MenuItemsProvider';

View File

@ -1,7 +1,9 @@
import { Spin } from 'antd';
import React, { createContext, useContext } from 'react';
import { useRequest } from '../../api-client';
import { useAdminSchemaUid } from '../../hooks';
import { Spin } from 'antd';
import { useRequest } from '../../../api-client';
import { useAdminSchemaUid } from '../../../hooks';
const MenuItemsContext = createContext(null);
MenuItemsContext.displayName = 'MenuItemsContext';

View File

@ -1,9 +1,10 @@
import { message } from 'antd';
import React, { createContext, useContext, useState } from 'react';
import { message } from 'antd';
import { useTranslation } from 'react-i18next';
import { useAPIClient } from '../../api-client';
import { useRecord } from '../../record-provider';
import { useAPIClient } from '../../../api-client';
import { useRecord } from '../../../record-provider';
export const SettingCenterPermissionProvider = (props) => {
const { currentRecord } = useContext(PermissionContext);

View File

@ -1,11 +1,12 @@
import { onFieldChange } from '@tachybase/schema';
import { connect } from '@tachybase/schema';
import React, { useContext } from 'react';
import { connect, onFieldChange } from '@tachybase/schema';
import { Checkbox } from 'antd';
import uniq from 'lodash/uniq';
import React, { useContext } from 'react';
import { useTranslation } from 'react-i18next';
import { useAPIClient, useRequest } from '../../api-client';
import { SchemaComponent } from '../../schema-component';
import { useAPIClient, useRequest } from '../../../api-client';
import { SchemaComponent } from '../../../schema-component';
import { PermissionContext } from './PermisionProvider';
const SnippetCheckboxGroup = connect((props) => {

View File

@ -2,8 +2,8 @@ import React, { createContext, useContext } from 'react';
import { Spin } from 'antd';
import { useRequest } from '../../api-client';
import { SchemaComponent, SchemaComponentContext } from '../../schema-component';
import { useRequest } from '../../../api-client';
import { SchemaComponent, SchemaComponentContext } from '../../../schema-component';
import { MenuItemsProvider } from '../Configuration/MenuItemsProvider';
import { PermissionProvider, SettingCenterPermissionProvider } from '../Configuration/PermisionProvider';
import { roleSchema } from './schemas/roles';

View File

@ -6,7 +6,7 @@ import { Checkbox, Table, Tag } from 'antd';
import { isEmpty } from 'lodash';
import { useTranslation } from 'react-i18next';
import { useCollectionManager_deprecated, useCompile, useRecord } from '../..';
import { useCollectionManager_deprecated, useCompile, useRecord } from '../../..';
import { useStyles } from '../style';
import { useAvailableActions } from './RoleTable';
import { ScopeSelect } from './ScopeSelect';

View File

@ -1,7 +1,7 @@
import React, { createContext, useContext, useMemo, useState } from 'react';
import { createForm } from '@tachybase/schema';
import { FormProvider, SchemaComponent } from '../../schema-component';
import { FormProvider, SchemaComponent } from '../../../schema-component';
import { scopesSchema } from './schemas/scopes';
const RolesResourcesScopesSelectedRowKeysContext = createContext(null);

View File

@ -4,7 +4,7 @@ import { ArrayField, connect, useField } from '@tachybase/schema';
import { Checkbox, Select, Table, Tag } from 'antd';
import { useTranslation } from 'react-i18next';
import { useCompile } from '../..';
import { useCompile } from '../../..';
import { useAvailableActions } from './RoleTable';
const toScopes = (value) => {

View File

@ -1,10 +1,11 @@
import { ISchema } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import pick from 'lodash/pick';
import { useEffect } from 'react';
import { useRequest } from '../../../api-client';
import { useRecord } from '../../../record-provider';
import { useActionContext } from '../../../schema-component';
import { ISchema, uid } from '@tachybase/schema';
import pick from 'lodash/pick';
import { useRequest } from '../../../../api-client';
import { useRecord } from '../../../../record-provider';
import { useActionContext } from '../../../../schema-component';
const collection = {
name: 'roles',

View File

@ -1,8 +1,9 @@
import { ISchema } from '@tachybase/schema';
import { useContext, useEffect } from 'react';
import { useFormBlockContext } from '../../../block-provider';
import { useFilterOptions } from '../../../schema-component';
import { VariableInput } from '../../../schema-settings';
import { ISchema } from '@tachybase/schema';
import { useFormBlockContext } from '../../../../block-provider';
import { useFilterOptions } from '../../../../schema-component';
import { VariableInput } from '../../../../schema-settings';
import { RoleResourceCollectionContext } from '../RolesResourcesActions';
export const rolesResourcesScopesCollection = {

View File

@ -1,5 +1,6 @@
import { useEffect } from 'react';
import { useActionContext, useRecord, useRequest } from '../../../';
import { useActionContext, useRecord, useRequest } from '../../../..';
export const useRoleResourceValues = (options) => {
const record = useRecord();

View File

@ -1,5 +1,6 @@
import { useForm } from '@tachybase/schema';
import { useActionContext, useAPIClient, useRecord, useResourceActionContext } from '../../../';
import { useActionContext, useAPIClient, useRecord, useResourceActionContext } from '../../../..';
export const useSaveRoleResourceAction = () => {
const form = useForm();

View File

@ -1,8 +1,4 @@
export * from './ACLProvider';
export * from './ACLShortcut';
export * from './Configuration';
import { Plugin } from '../application/Plugin';
import { Plugin } from '../../application/Plugin';
import {
ACLActionProvider,
ACLCollectionFieldProvider,
@ -10,6 +6,10 @@ import {
ACLMenuItemProvider,
} from './ACLProvider';
export * from './ACLProvider';
export * from './ACLShortcut';
export * from './Configuration';
export class ACLPlugin extends Plugin {
async load() {
this.app.addComponents({

View File

@ -22,10 +22,10 @@ import {
useDocumentTitle,
useRequest,
useSystemSettings,
} from '../../../';
import { useAppSpin } from '../../../application/hooks/useAppSpin';
import { Plugin } from '../../../application/Plugin';
import { VariablesProvider } from '../../../variables';
} from '../..';
import { useAppSpin } from '../../application/hooks/useAppSpin';
import { Plugin } from '../../application/Plugin';
import { VariablesProvider } from '../../variables';
const useStyles = createStyles(({ css, token }) => {
return {
@ -399,7 +399,6 @@ const SetThemeOfHeaderSubmenu = ({ children }) => {
export const InternalAdminLayout = (props: any) => {
const sideMenuRef = useRef<HTMLDivElement>();
const result = useSystemSettings();
// const { service } = useCollectionManager_deprecated();
const params = useParams<any>();
const { styles } = useStyles();
return (

View File

@ -3,7 +3,7 @@ import React, { createContext, useContext, useEffect, useState } from 'react';
import { Helmet } from 'react-helmet';
import { useTranslation } from 'react-i18next';
import { Plugin } from '../application/Plugin';
import { Plugin } from '../../application/Plugin';
import { useSystemSettings } from '../system-settings';
interface DocumentTitleContextProps {

View File

@ -7,24 +7,24 @@ import { Button, Modal, Result, Spin } from 'antd';
import { createStyles } from 'antd-style';
import { Navigate, useNavigate } from 'react-router-dom';
import { ACLPlugin } from '../acl';
import { useAPIClient } from '../api-client';
import { Application } from '../application';
import { Plugin } from '../application/Plugin';
import { BlockSchemaComponentPlugin } from '../block-provider';
import { CollectionPlugin } from '../collection-manager';
import { RemoteDocumentTitlePlugin } from '../document-title';
import { PinnedListPlugin } from '../plugin-manager';
import { PMPlugin } from '../pm';
import { AdminLayoutPlugin, RouteSchemaComponent } from '../route-switch';
import { AntdSchemaComponentPlugin, SchemaComponentPlugin } from '../schema-component';
import { ErrorFallback } from '../schema-component/antd/error-fallback';
import { AssociationFilterPlugin, SchemaInitializerPlugin } from '../schema-initializer';
import { SchemaSettingsPlugin } from '../schema-settings';
import { BlockTemplateDetails, BlockTemplatePage } from '../schema-templates';
import { SystemSettingsPlugin } from '../system-settings';
import { CurrentUserProvider, CurrentUserSettingsMenuProvider } from '../user';
import { LocalePlugin } from './plugins/LocalePlugin';
import { ACLPlugin } from './acl';
import { RemoteDocumentTitlePlugin } from './document-title';
import { LocalePlugin } from './locale/LocalePlugin';
import { PinnedListPlugin } from './pinned-list';
import { PMPlugin } from './pm';
import { SystemSettingsPlugin } from './system-settings';
interface AppStatusProps {
error: Error;

View File

@ -4,7 +4,7 @@ import { SchemaOptionsContext } from '@tachybase/schema';
import { createStyles } from 'antd-style';
import { get } from 'lodash';
import { useACLRoleContext } from '../acl/ACLProvider';
import { useACLRoleContext } from '../acl';
import { PinnedPluginListContext } from './context';
export const PinnedPluginListProvider = (props: { items: any; children: React.ReactNode }) => {

View File

@ -1,9 +1,9 @@
import { Plugin } from '../../application/Plugin';
import { PinnedPluginListProvider } from './PinnedPluginListProvider';
export * from './context';
export * from './PinnedPluginListProvider';
import { Plugin } from '../application/Plugin';
import { PinnedPluginListProvider } from './PinnedPluginListProvider';
export class PinnedListPlugin extends Plugin {
async load() {
this.app.use(PinnedPluginListProvider, this.options.config);

View File

@ -6,8 +6,8 @@ import classnames from 'classnames';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
import { useAPIClient } from '../api-client';
import { useApp } from '../application';
import { useAPIClient } from '../../api-client';
import { useApp } from '../../application';
import { PluginDetail } from './PluginDetail';
import { NPM_REGISTRY_ADDRESS } from './PluginForm/form/PluginNpmForm';
import { PluginUpgradeModal } from './PluginForm/modal/PluginUpgradeModal';

View File

@ -1,9 +1,11 @@
import React, { FC, useMemo } from 'react';
import { Alert, Col, Modal, Row, Space, Spin, Table, Tabs, TabsProps, Tag, Typography } from 'antd';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import React, { FC, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useRequest } from '../api-client';
import { useRequest } from '../../api-client';
import { PluginDocument } from './PluginDocument';
import { useStyles } from './style';
import { IPluginData } from './types';

View File

@ -1,11 +1,12 @@
import { Spin } from 'antd';
import React, { memo, useCallback, useEffect, useMemo, useState } from 'react';
import { useRequest } from '../api-client';
import { useStyles as useMarkdownStyles } from '../schema-component/antd/markdown/style';
import { useParseMarkdown } from '../schema-component/antd/markdown/util';
import { Spin } from 'antd';
import { useRequest } from '../../api-client';
import { useGlobalTheme } from '../../global-theme';
import { useStyles as useMarkdownStyles } from '../../schema-component/antd/markdown/style';
import { useParseMarkdown } from '../../schema-component/antd/markdown/util';
import { useStyles } from './style';
import { useGlobalTheme } from '../global-theme';
const PLUGIN_STATICS_PATH = '/static/plugins/';

View File

@ -1,13 +1,12 @@
import { ISchema } from '@tachybase/schema';
import { useForm } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import { App } from 'antd';
import React, { FC, useMemo } from 'react';
import { ISchema, uid, useForm } from '@tachybase/schema';
import { App } from 'antd';
import { pick } from 'lodash';
import { useTranslation } from 'react-i18next';
import { pick } from 'lodash';
import { useAPIClient, useRequest } from '../../../api-client';
import { SchemaComponent } from '../../../schema-component';
import { useAPIClient, useRequest } from '../../../../api-client';
import { SchemaComponent } from '../../../../schema-component';
import { IPluginData } from '../../types';
interface IPluginNpmFormProps {

View File

@ -1,13 +1,12 @@
import { ISchema } from '@tachybase/schema';
import { useForm } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import React, { FC, useMemo } from 'react';
import { ISchema, uid, useForm } from '@tachybase/schema';
import { App } from 'antd';
import type { RcFile } from 'antd/es/upload';
import React, { FC, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useAPIClient } from '../../../api-client';
import { SchemaComponent } from '../../../schema-component';
import { useAPIClient } from '../../../../api-client';
import { SchemaComponent } from '../../../../schema-component';
import { IPluginData } from '../../types';
interface IPluginUploadFormProps {

View File

@ -1,12 +1,11 @@
import { ISchema } from '@tachybase/schema';
import { useForm } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import { App } from 'antd';
import React, { FC, useMemo } from 'react';
import { ISchema, uid, useForm } from '@tachybase/schema';
import { App } from 'antd';
import { useTranslation } from 'react-i18next';
import { useAPIClient, useRequest } from '../../../api-client';
import { SchemaComponent } from '../../../schema-component';
import { useAPIClient, useRequest } from '../../../../api-client';
import { SchemaComponent } from '../../../../schema-component';
import { IPluginData } from '../../types';
interface IPluginUrlFormProps {

View File

@ -1,8 +1,9 @@
import { Modal, Radio } from 'antd';
import React, { FC, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useStyles } from '../../style';
import { Modal, Radio } from 'antd';
import { useTranslation } from 'react-i18next';
import { useStyles } from '../../style';
import { PluginNpmForm } from '../form/PluginNpmForm';
import { PluginUploadForm } from '../form/PluginUploadForm';
import { PluginUrlForm } from '../form/PluginUrlForm';

View File

@ -1,5 +1,6 @@
import { Modal, Radio } from 'antd';
import React, { FC, useState } from 'react';
import { Modal, Radio } from 'antd';
import { useTranslation } from 'react-i18next';
import { useStyles } from '../../style';

View File

@ -8,10 +8,10 @@ import _ from 'lodash';
import { useTranslation } from 'react-i18next';
import { useNavigate, useParams } from 'react-router-dom';
import { useACLRoleContext } from '../acl/ACLProvider';
import { useRequest } from '../api-client';
import { i18n } from '../i18n';
import { useToken } from '../style';
import { useRequest } from '../../api-client';
import { useACLRoleContext } from '../../buildin-plugin/acl';
import { i18n } from '../../i18n';
import { useToken } from '../../style';
import { SwitchAction } from './PluginCard';
import { useStyles } from './style';
import { IPluginData } from './types';

View File

@ -5,9 +5,9 @@ import { Button, Dropdown, Tooltip } from 'antd';
import { useTranslation } from 'react-i18next';
import { Link, useNavigate } from 'react-router-dom';
import { useApp } from '../application';
import { useCompile } from '../schema-component';
import { useToken } from '../style';
import { useApp } from '../../application';
import { useCompile } from '../../schema-component';
import { useToken } from '../../style';
export const PluginManagerLink = () => {
const { t } = useTranslation();

View File

@ -5,8 +5,8 @@ import { Layout, Menu, Result } from 'antd';
import _ from 'lodash';
import { Navigate, Outlet, useLocation, useNavigate, useParams } from 'react-router-dom';
import { ADMIN_SETTINGS_PATH, PluginSettingsPageType, useApp } from '../application';
import { useCompile } from '../schema-component';
import { ADMIN_SETTINGS_PATH, PluginSettingsPageType, useApp } from '../../application';
import { useCompile } from '../../schema-component';
import { useStyles } from './style';
export const SettingsCenterContext = createContext<any>({});

View File

@ -1,9 +1,9 @@
import React from 'react';
import { ACLPane } from '../acl/ACLShortcut';
import { ADMIN_SETTINGS_PATH } from '../application';
import { Plugin } from '../application/Plugin';
import { BlockTemplatesPane } from '../schema-templates';
import { SystemSettingsPane } from '../system-settings';
import { ADMIN_SETTINGS_PATH } from '../../application';
import { Plugin } from '../../application/Plugin';
import { SystemSettingsPane } from '../../buildin-plugin/system-settings';
import { BlockTemplatesPane } from '../../schema-templates';
import { PluginManager } from './PluginManager';
import { PluginManagerLink, SettingsCenterDropdown } from './PluginManagerLink';
import { AdminSettingsLayout } from './PluginSetting';
@ -20,12 +20,6 @@ export class PMPlugin extends Plugin {
}
addSettings() {
// this.app.pluginSettingsManager.add('acl', {
// title: '{{t("Access control")}}',
// icon: 'LockOutlined',
// Component: ACLPane,
// aclSnippet: 'pm.acl.roles',
// });
this.app.pluginSettingsManager.add('ui-schema-storage', {
title: '{{t("Block templates")}}',
icon: 'LayoutOutlined',

View File

@ -1,7 +1,9 @@
import { Result } from 'ahooks/es/useRequest/src/types';
import React, { createContext, ReactNode, useContext } from 'react';
import { useRequest } from '../api-client';
import { useAppSpin } from '../application/hooks/useAppSpin';
import { Result } from 'ahooks/es/useRequest/src/types';
import { useRequest } from '../../api-client';
import { useAppSpin } from '../../application/hooks/useAppSpin';
export const SystemSettingsContext = createContext<Result<any, any>>(null);
SystemSettingsContext.displayName = 'SystemSettingsContext';

View File

@ -1,13 +1,14 @@
import { ISchema, useForm } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import { Card, message } from 'antd';
import cloneDeep from 'lodash/cloneDeep';
import React from 'react';
import { ISchema, uid, useForm } from '@tachybase/schema';
import { Card, message } from 'antd';
import { cloneDeep } from 'lodash';
import { useTranslation } from 'react-i18next';
import { useSystemSettings } from '.';
import { i18n, useAPIClient, useRequest } from '..';
import locale from '../locale';
import { SchemaComponent, useActionContext } from '../schema-component';
import { i18n, useAPIClient, useRequest } from '../..';
import locale from '../../locale';
import { SchemaComponent, useActionContext } from '../../schema-component';
const langs = Object.keys(locale).map((lang) => {
return {
@ -119,20 +120,6 @@ const schema: ISchema = {
});
},
},
// allowSignUp: {
// type: 'boolean',
// default: true,
// 'x-content': '{{t("Allow sign up")}}',
// 'x-component': 'Checkbox',
// 'x-decorator': 'FormItem',
// },
// smsAuthEnabled: {
// type: 'boolean',
// default: false,
// 'x-content': '{{t("Enable SMS authentication")}}',
// 'x-component': 'Checkbox',
// 'x-decorator': 'FormItem',
// },
footer1: {
type: 'void',
'x-component': 'ActionBar',
@ -149,13 +136,6 @@ const schema: ISchema = {
useAction: '{{ useSaveSystemSettingsValues }}',
},
},
// cancel: {
// title: 'Cancel',
// 'x-component': 'Action',
// 'x-component-props': {
// useAction: '{{ useCloseAction }}',
// },
// },
},
},
},

View File

@ -1,7 +1,8 @@
import { Plugin } from '../../application/Plugin';
import { SystemSettingsProvider } from './SystemSettingsProvider';
export * from './SystemSettingsProvider';
export * from './SystemSettingsShortcut';
import { Plugin } from '../application/Plugin';
import { SystemSettingsProvider } from './SystemSettingsProvider';
export class SystemSettingsPlugin extends Plugin {
async load() {

View File

@ -1,6 +1,6 @@
import { Plugin } from '../application/Plugin';
import { InheritanceCollectionMixin } from './mixins/InheritanceCollectionMixin';
import { DataSource } from '../data-source/data-source/DataSource';
import { DEFAULT_DATA_SOURCE_KEY, DEFAULT_DATA_SOURCE_TITLE } from '../data-source/data-source/DataSourceManager';
import {
CheckboxFieldInterface,
CheckboxGroupFieldInterface,
@ -21,38 +21,37 @@ import {
M2OFieldInterface,
MarkdownFieldInterface,
MultipleSelectFieldInterface,
NanoidFieldInterface,
NumberFieldInterface,
O2MFieldInterface,
O2OFieldInterface,
OHOFieldInterface,
OBOFieldInterface,
OHOFieldInterface,
PasswordFieldInterface,
PercentFieldInterface,
PhoneFieldInterface,
RadioGroupFieldInterface,
RichTextFieldInterface,
SelectFieldInterface,
SortFieldInterface,
SubTableFieldInterface,
TableoidFieldInterface,
TextareaFieldInterface,
TimeFieldInterface,
UnixTimestampFieldInterface,
UpdatedAtFieldInterface,
UpdatedByFieldInterface,
UrlFieldInterface,
SortFieldInterface,
UUIDFieldInterface,
NanoidFieldInterface,
UnixTimestampFieldInterface,
} from './interfaces';
import { InheritanceCollectionMixin } from './mixins/InheritanceCollectionMixin';
import {
GeneralCollectionTemplate,
ExpressionCollectionTemplate,
GeneralCollectionTemplate,
SqlCollectionTemplate,
TreeCollectionTemplate,
ViewCollectionTemplate,
} from './templates';
import { DEFAULT_DATA_SOURCE_KEY, DEFAULT_DATA_SOURCE_TITLE } from '../data-source/data-source/DataSourceManager';
import { DataSource } from '../data-source/data-source/DataSource';
class MainDataSource extends DataSource {
async getDataSource() {

View File

@ -1,8 +1,8 @@
import React, { createContext, ReactNode, useContext, useMemo } from 'react';
import { ACLCollectionProvider } from '../../acl/ACLProvider';
import { UseRequestOptions, UseRequestService } from '../../api-client';
import { withDynamicSchemaProps } from '../../application/hoc';
import { ACLCollectionProvider } from '../../buildin-plugin/acl';
import { Designable, useDesignable } from '../../schema-component';
import { AssociationProvider, CollectionManagerProvider, CollectionOptions, CollectionProvider } from '../collection';
import { CollectionRecord } from '../collection-record';

View File

@ -3,7 +3,7 @@ import 'antd/dist/reset.css';
import './global.less';
export * from '@emotion/css';
export * from './acl';
export * from './buildin-plugin/acl';
export * from './antd-config-provider';
export * from './api-client';
export * from './appInfo';
@ -15,7 +15,7 @@ export * from './collection-manager';
export * from './common';
export * from './css-variable';
export * from './data-source';
export * from './document-title';
export * from './buildin-plugin/document-title';
export * from './filter-provider';
export * from './flag-provider';
export * from './global-theme';
@ -24,9 +24,9 @@ export * from './i18n';
export * from './icon';
export { default as locale } from './locale';
export * from './buildin-plugin';
export * from './plugin-manager';
export * from './pm';
export * from './powered-by-v2';
export * from './buildin-plugin/pinned-list';
export * from './buildin-plugin/pm';
export * from './powered-by';
export * from './record-provider';
export * from './route-switch';
export * from './schema-component';
@ -36,7 +36,7 @@ export * from './schema-settings';
export * from './schema-templates';
export * from './style';
export type { CustomToken } from './global-theme';
export * from './system-settings';
export * from './buildin-plugin/system-settings';
export * from './testUtils';
export * from './user';
export * from './variables';

View File

@ -17,7 +17,7 @@ const useStyles = createStyles(({ css, token }) => {
};
});
export const PoweredByV2 = () => {
export const PoweredBy = () => {
const { styles } = useStyles();
const date = new Date();
const year = date.getFullYear();

View File

@ -1,2 +1,2 @@
export * from './admin-layout';
export * from '../../buildin-plugin/admin-layout';
export * from './route-schema-component';

View File

@ -1,5 +1,7 @@
import React from 'react';
import { useParams } from 'react-router-dom';
import { RemoteSchemaComponent } from '../../../';
export function RouteSchemaComponent(props: any) {

View File

@ -9,8 +9,8 @@ import { useTranslation } from 'react-i18next';
import { StablePopover, useActionContext } from '../..';
import { useDesignable } from '../../';
import { useACLActionParamsContext } from '../../../acl';
import { withDynamicSchemaProps } from '../../../application/hoc/withDynamicSchemaProps';
import { useACLActionParamsContext } from '../../../buildin-plugin/acl';
import { Icon } from '../../../icon';
import { RecordProvider, useRecord } from '../../../record-provider';
import { useLocalVariables, useVariables } from '../../../variables';

View File

@ -5,7 +5,7 @@ import { observer, RecursionField, useField, useFieldSchema } from '@tachybase/s
import { createStyles } from 'antd-style';
import cx from 'classnames';
import { ACLCollectionProvider, useACLActionParamsContext } from '../../../acl';
import { ACLCollectionProvider, useACLActionParamsContext } from '../../../buildin-plugin/acl';
import { CollectionProvider_deprecated } from '../../../collection-manager';
import { useAssociationFieldContext, useInsertSchema } from './hooks';
import schema from './schema';

View File

@ -4,7 +4,7 @@ import { observer, RecursionField, SchemaOptionsContext, useField, useFieldSchem
import { createStyles } from 'antd-style';
import { ACLCollectionProvider, useACLActionParamsContext } from '../../../acl';
import { ACLCollectionProvider, useACLActionParamsContext } from '../../../buildin-plugin/acl';
import { CollectionProvider_deprecated } from '../../../collection-manager';
import { FormItem, useSchemaOptionsContext } from '../../../schema-component';
import Select from '../select/Select';

View File

@ -5,9 +5,9 @@ import { Field, observer, useField, useFieldSchema } from '@tachybase/schema';
import { createStyles } from 'antd-style';
import cx from 'classnames';
import { ACLCollectionFieldProvider } from '../../../acl/ACLProvider';
import { useApp } from '../../../application';
import { useFormActiveFields } from '../../../block-provider/hooks/useFormActiveFields';
import { ACLCollectionFieldProvider } from '../../../buildin-plugin/acl';
import { Collection_deprecated } from '../../../collection-manager';
import { CollectionFieldProvider, useContextConfigSetting } from '../../../data-source';
import { GeneralSchemaDesigner } from '../../../schema-settings';

View File

@ -1,17 +1,20 @@
import { PlusOutlined } from '@ant-design/icons';
import { PageHeader as AntdPageHeader } from '@ant-design/pro-layout';
import React, { useContext, useEffect, useMemo, useState } from 'react';
import { FormLayout } from '@tachybase/components';
import { Schema, SchemaOptionsContext, useFieldSchema } from '@tachybase/schema';
import { PlusOutlined } from '@ant-design/icons';
import { PageHeader as AntdPageHeader } from '@ant-design/pro-layout';
import { Button, Tabs } from 'antd';
import classNames from 'classnames';
import React, { useContext, useEffect, useMemo, useState } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
import { useTranslation } from 'react-i18next';
import { useSearchParams } from 'react-router-dom';
import { FormDialog } from '..';
import { useStyles as useAClStyles } from '../../../acl/style';
import { useToken } from '../__builtins__';
import { useAppSpin } from '../../../application/hooks/useAppSpin';
import { useDocumentTitle } from '../../../document-title';
import { useStyles as useAClStyles } from '../../../buildin-plugin/acl/style';
import { useDocumentTitle } from '../../../buildin-plugin/document-title';
import { FilterBlockProvider } from '../../../filter-provider/FilterProvider';
import { useGlobalTheme } from '../../../global-theme';
import { Icon } from '../../../icon';
@ -20,7 +23,6 @@ import { DndContext } from '../../common';
import { SortableItem } from '../../common/sortable-item';
import { SchemaComponent, SchemaComponentOptions } from '../../core';
import { useCompile, useDesignable } from '../../hooks';
import { useToken } from '../__builtins__';
import { ErrorFallback } from '../error-fallback';
import FixedBlock from './FixedBlock';
import { PageDesigner, PageTabDesigner } from './PageTabDesigner';

View File

@ -25,6 +25,7 @@ import { DndContext, useDesignable, useTableSize } from '../..';
import {
RecordIndexProvider,
RecordProvider,
useACLFieldWhitelist,
useCollection,
useCollection_deprecated,
useCollectionParentRecordData,
@ -32,7 +33,6 @@ import {
useTableBlockContext,
useTableSelectorContext,
} from '../../../';
import { useACLFieldWhitelist } from '../../../acl/ACLProvider';
import { withDynamicSchemaProps } from '../../../application/hoc/withDynamicSchemaProps';
import { isNewRecord, markRecordAsNew } from '../../../data-source/collection-record/isNewRecord';
import { SubFormProvider } from '../association-field/hooks';

View File

@ -1,8 +1,10 @@
import React from 'react';
import { HighlightOutlined } from '@ant-design/icons';
import { Button, Tooltip } from 'antd';
import React from 'react';
import { useHotkeys } from 'react-hotkeys-hook';
import { useTranslation } from 'react-i18next';
import { useDesignable } from '..';
import { useToken } from '../../style';
@ -22,10 +24,8 @@ export const DesignableSwitch = () => {
<Tooltip title={t('UI Editor')}>
<Button
data-testid={'ui-editor-button'}
// selected={designable}
icon={<HighlightOutlined style={{ color: token.colorTextHeaderMenu }} />}
title={t('UI Editor')}
// subtitle={'Ctrl+Shift+U'}
style={style}
onClick={() => {
setDesignable(!designable);

View File

@ -1,13 +1,14 @@
import { createForm } from '@tachybase/schema';
import React, { useContext, useMemo } from 'react';
import {
createForm,
FormProvider as FormilyFormProvider,
SchemaExpressionScopeContext,
SchemaOptionsContext,
} from '@tachybase/schema';
import React, { useContext, useMemo } from 'react';
import { SchemaComponentOptions } from './SchemaComponentOptions';
const WithForm = (props) => {
const WithForm = (props: any) => {
const { children, form, ...others } = props;
const options = useContext(SchemaOptionsContext);
const expressionScope = useContext(SchemaExpressionScopeContext);
@ -22,7 +23,7 @@ const WithForm = (props) => {
);
};
const WithoutForm = (props) => {
const WithoutForm = (props: any) => {
const { children, ...others } = props;
const options = useContext(SchemaOptionsContext);
const expressionScope = useContext(SchemaExpressionScopeContext);
@ -38,6 +39,6 @@ const WithoutForm = (props) => {
);
};
export const FormProvider: React.FC<any> = (props) => {
export const FormProvider = (props: any) => {
return props.form ? <WithForm {...props} /> : <WithoutForm {...props} />;
};

View File

@ -1,4 +1,3 @@
// import { Spin } from 'antd';
import React, { PropsWithChildren, useMemo } from 'react';
import { createForm, Schema } from '@tachybase/schema';

View File

@ -1,5 +1,6 @@
import { IRecursionFieldProps, ISchemaFieldProps, RecursionField, Schema } from '@tachybase/schema';
import React, { useContext, useMemo } from 'react';
import { IRecursionFieldProps, ISchemaFieldProps, RecursionField, Schema } from '@tachybase/schema';
import { SchemaComponentContext } from '../context';
import { SchemaComponentOptions } from './SchemaComponentOptions';

View File

@ -1,5 +1,6 @@
import React, { memo, PropsWithChildren, useContext, useMemo } from 'react';
import { ExpressionScope, SchemaComponentsContext, SchemaOptionsContext } from '@tachybase/schema';
import React, { PropsWithChildren, memo, useContext, useMemo } from 'react';
import { ISchemaComponentOptionsProps } from '../types';
export const useSchemaOptionsContext = () => {

View File

@ -1,8 +1,8 @@
import { createForm } from '@tachybase/schema';
import { FormProvider, Schema } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import React, { useMemo, useState, PropsWithChildren } from 'react';
import React, { PropsWithChildren, useMemo, useState } from 'react';
import { createForm, FormProvider, Schema, uid } from '@tachybase/schema';
import { useTranslation } from 'react-i18next';
import { SchemaComponentContext } from '../context';
import { ISchemaComponentProvider } from '../types';
import { SchemaComponentOptions } from './SchemaComponentOptions';

View File

@ -1,11 +1,12 @@
import { Plugin } from '../../application/Plugin';
import { DesignableSwitch } from './DesignableSwitch';
export * from './DesignableSwitch';
export * from './FormProvider';
export * from './RemoteSchemaComponent';
export * from './SchemaComponent';
export * from './SchemaComponentOptions';
export * from './SchemaComponentProvider';
import { Plugin } from '../../application/Plugin';
import { DesignableSwitch } from './DesignableSwitch';
export class SchemaComponentPlugin extends Plugin {
async load() {

View File

@ -6,8 +6,7 @@ import { Button, Dropdown, MenuProps } from 'antd';
import { createStyles } from 'antd-style';
import { composeRef } from 'rc-util/lib/ref';
import { useDesignable } from '../../';
import { useACLRolesCheck, useRecordPkValue } from '../../acl/ACLProvider';
import { useACLRolesCheck, useDesignable, useRecordPkValue } from '../../';
import {
CollectionProvider_deprecated,
useCollection_deprecated,

View File

@ -38,18 +38,18 @@ import {
readPrettyFormItemInitializers_deprecated,
} from '../modules/blocks/data-blocks/details-single/ReadPrettyFormItemInitializers';
import { RecordReadPrettyFormBlockInitializer } from '../modules/blocks/data-blocks/details-single/RecordReadPrettyFormBlockInitializer';
import { CreateFormBlockInitializer } from '../modules/blocks/data-blocks/form/CreateFormBlockInitializer';
import { FormBlockInitializer } from '../modules/blocks/data-blocks/form/FormBlockInitializer';
import { RecordFormBlockInitializer } from '../modules/blocks/data-blocks/form/RecordFormBlockInitializer';
import {
createFormActionInitializers,
createFormActionInitializers_deprecated,
} from '../modules/blocks/data-blocks/form/createFormActionInitializers';
import { CreateFormBlockInitializer } from '../modules/blocks/data-blocks/form/CreateFormBlockInitializer';
import { formActionInitializers } from '../modules/blocks/data-blocks/form/formActionInitializers';
import { FormBlockInitializer } from '../modules/blocks/data-blocks/form/FormBlockInitializer';
import {
formItemInitializers,
formItemInitializers_deprecated,
} from '../modules/blocks/data-blocks/form/formItemInitializers';
import { RecordFormBlockInitializer } from '../modules/blocks/data-blocks/form/RecordFormBlockInitializer';
import {
updateFormActionInitializers,
updateFormActionInitializers_deprecated,
@ -113,12 +113,13 @@ import {
recordBlockInitializers_deprecated,
subTableActionInitializers,
subTableActionInitializers_deprecated,
tabPaneInitializers_deprecated,
tabPaneInitializersForBulkEditFormBlock,
tabPaneInitializersForRecordBlock,
tabPaneInitializers_deprecated,
} from './buttons';
import * as initializerComponents from './components';
import * as items from './items';
export * from './buttons';
export * from './items';
export {

View File

@ -1,8 +1,9 @@
import { ISchema, useForm } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import { MenuProps } from 'antd';
import React, { useContext, useMemo, useState } from 'react';
import { ISchema, uid, useForm } from '@tachybase/schema';
import { MenuProps } from 'antd';
import { useTranslation } from 'react-i18next';
import { ActionContextProvider, DropdownVisibleContext, SchemaComponent, useActionContext } from '../';
import { useAPIClient } from '../api-client';

View File

@ -1,8 +1,10 @@
import React, { createContext, useContext, useMemo } from 'react';
import { Navigate, useLocation } from 'react-router-dom';
import { useACLRoleContext } from '../acl';
import { ReturnTypeOfUseRequest, useRequest } from '../api-client';
import { useAppSpin } from '../application/hooks/useAppSpin';
import { useACLRoleContext } from '../buildin-plugin/acl';
import { useCompile } from '../schema-component';
export const CurrentUserContext = createContext<ReturnTypeOfUseRequest>(null);

View File

@ -1,6 +1,7 @@
import { error } from '@tachybase/utils/client';
import { ItemType } from 'antd/es/menu/hooks/useItems';
import React, { createContext, useCallback, useContext, useRef } from 'react';
import { error } from '@tachybase/utils/client';
import { ItemType } from 'antd/es/menu/hooks/useItems';
type menuItemsKey =
| 'version'

View File

@ -1,8 +1,9 @@
import { ISchema, useForm } from '@tachybase/schema';
import { uid } from '@tachybase/schema';
import { MenuProps } from 'antd';
import React, { useContext, useMemo, useState } from 'react';
import { ISchema, uid, useForm } from '@tachybase/schema';
import { MenuProps } from 'antd';
import { useTranslation } from 'react-i18next';
import {
ActionContextProvider,
DropdownVisibleContext,

View File

@ -1,6 +1,8 @@
import { MenuProps } from 'antd';
import React, { useMemo } from 'react';
import { MenuProps } from 'antd';
import { useTranslation } from 'react-i18next';
import { SelectWithTitle, useAPIClient, useSystemSettings } from '..';
import locale from '../locale';

View File

@ -1,6 +1,8 @@
import { MenuProps } from 'antd';
import React, { useMemo } from 'react';
import { MenuProps } from 'antd';
import { useTranslation } from 'react-i18next';
import { useAPIClient } from '../api-client';
import { SelectWithTitle } from '../common';
import { useCurrentRoles } from './CurrentUserProvider';

View File

@ -1,6 +1,6 @@
import React from 'react';
import { Input } from '@tachybase/client';
import evaluators from '@tachybase/evaluators/client';
import { evaluators } from '@tachybase/evaluators/client';
import { useField, useFieldSchema, useForm } from '@tachybase/schema';
import { FormulaProps } from './Formula.interface';

View File

@ -1,5 +1,5 @@
import React from 'react';
import { css, PoweredByV2 as PoweredBy, useAPIClient, useRequest, useSystemSettings } from '@tachybase/client';
import { css, PoweredBy, useAPIClient, useRequest, useSystemSettings } from '@tachybase/client';
import { Outlet } from 'react-router-dom';