fix: add displayName (#3628)

* fix: context add displayName

* fix: observer add displayName

* fix: memo component add displayName

* fix: forwordRef component add displayName
This commit is contained in:
jack zhang 2024-03-06 18:22:31 +08:00 committed by GitHub
parent bccde967cc
commit 454d1d34ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
135 changed files with 1089 additions and 868 deletions

View File

@ -14,6 +14,7 @@ import { useApp } from '../application';
import { useDataSourceKey } from '../data-source/data-source/DataSourceProvider'; import { useDataSourceKey } from '../data-source/data-source/DataSourceProvider';
export const ACLContext = createContext<any>({}); export const ACLContext = createContext<any>({});
ACLContext.displayName = 'ACLContext';
// TODO: delete thisreplace by `ACLPlugin` // TODO: delete thisreplace by `ACLPlugin`
export const ACLProvider = (props) => { export const ACLProvider = (props) => {
@ -90,6 +91,7 @@ export const useACLContext = () => {
}; };
export const ACLActionParamsContext = createContext<any>({}); export const ACLActionParamsContext = createContext<any>({});
ACLActionParamsContext.displayName = 'ACLActionParamsContext';
export const useACLRolesCheck = () => { export const useACLRolesCheck = () => {
const ctx = useContext(ACLContext); const ctx = useContext(ACLContext);

View File

@ -31,6 +31,7 @@ const getChildrenKeys = (data = [], arr = []) => {
}; };
const SettingMenuContext = createContext(null); const SettingMenuContext = createContext(null);
SettingMenuContext.displayName = 'SettingMenuContext';
export const SettingCenterProvider = (props) => { export const SettingCenterProvider = (props) => {
const configureItems = useContext(SettingsCenterContext); const configureItems = useContext(SettingsCenterContext);

View File

@ -4,6 +4,7 @@ import { useRequest } from '../../api-client';
import { useAdminSchemaUid } from '../../hooks'; import { useAdminSchemaUid } from '../../hooks';
const MenuItemsContext = createContext(null); const MenuItemsContext = createContext(null);
MenuItemsContext.displayName = 'MenuItemsContext';
export const toItems = (properties = {}) => { export const toItems = (properties = {}) => {
const items = []; const items = [];

View File

@ -14,6 +14,7 @@ export const SettingCenterPermissionProvider = (props) => {
}; };
export const PermissionContext = createContext<any>(null); export const PermissionContext = createContext<any>(null);
PermissionContext.displayName = 'PermissionContext';
export const PermissionProvider = (props) => { export const PermissionProvider = (props) => {
const api = useAPIClient(); const api = useAPIClient();

View File

@ -7,6 +7,7 @@ import { PermissionProvider, SettingCenterPermissionProvider } from '../Configur
import { roleSchema } from './schemas/roles'; import { roleSchema } from './schemas/roles';
const AvailableActionsContext = createContext([]); const AvailableActionsContext = createContext([]);
AvailableActionsContext.displayName = 'AvailableActionsContext';
const AvailableActionsProver: React.FC = (props) => { const AvailableActionsProver: React.FC = (props) => {
const { data, loading } = useRequest<{ const { data, loading } = useRequest<{

View File

@ -22,6 +22,7 @@ const toActionMap = (arr: any[]) => {
}; };
export const RoleResourceCollectionContext = createContext<any>({}); export const RoleResourceCollectionContext = createContext<any>({});
RoleResourceCollectionContext.displayName = 'RoleResourceCollectionContext';
export const RolesResourcesActions = connect((props) => { export const RolesResourcesActions = connect((props) => {
const { styles } = useStyles(); const { styles } = useStyles();

View File

@ -4,6 +4,7 @@ import { FormProvider, SchemaComponent } from '../../schema-component';
import { scopesSchema } from './schemas/scopes'; import { scopesSchema } from './schemas/scopes';
const RolesResourcesScopesSelectedRowKeysContext = createContext(null); const RolesResourcesScopesSelectedRowKeysContext = createContext(null);
RolesResourcesScopesSelectedRowKeysContext.displayName = 'RolesResourcesScopesSelectedRowKeysContext';
const RolesResourcesScopesSelectedRowKeysProvider: React.FC = (props) => { const RolesResourcesScopesSelectedRowKeysProvider: React.FC = (props) => {
const [keys, setKeys] = useState([]); const [keys, setKeys] = useState([]);

View File

@ -7,6 +7,7 @@ import { Plugin } from '../application/Plugin';
import { loadConstrueLocale } from './loadConstrueLocale'; import { loadConstrueLocale } from './loadConstrueLocale';
export const AppLangContext = createContext<any>({}); export const AppLangContext = createContext<any>({});
AppLangContext.displayName = 'AppLangContext';
export const useAppLangContext = () => { export const useAppLangContext = () => {
return useContext(AppLangContext); return useContext(AppLangContext);

View File

@ -2,3 +2,4 @@ import { createContext } from 'react';
import { APIClient } from './APIClient'; import { APIClient } from './APIClient';
export const APIClientContext = createContext<APIClient>(new APIClient()); export const APIClientContext = createContext<APIClient>(new APIClient());
APIClientContext.displayName = 'APIClientContext';

View File

@ -3,6 +3,7 @@ import { useRequest } from '../api-client';
import { useAppSpin } from '../application/hooks/useAppSpin'; import { useAppSpin } from '../application/hooks/useAppSpin';
export const CurrentAppInfoContext = createContext(null); export const CurrentAppInfoContext = createContext(null);
CurrentAppInfoContext.displayName = 'CurrentAppInfoContext';
export const useCurrentAppInfo = () => { export const useCurrentAppInfo = () => {
return useContext<{ return useContext<{

View File

@ -45,6 +45,7 @@ export class PluginSettingsManager {
protected settings: Record<string, PluginSettingOptions> = {}; protected settings: Record<string, PluginSettingOptions> = {};
protected aclSnippets: string[] = []; protected aclSnippets: string[] = [];
public app: Application; public app: Application;
private cachedList = {};
constructor(_pluginSettings: Record<string, PluginSettingOptions>, app: Application) { constructor(_pluginSettings: Record<string, PluginSettingOptions>, app: Application) {
this.app = app; this.app = app;
@ -141,11 +142,16 @@ export class PluginSettingsManager {
} }
getList(filterAuth = true): PluginSettingsPageType[] { getList(filterAuth = true): PluginSettingsPageType[] {
return Array.from(new Set(Object.values(this.settings).map((item) => item.topLevelName))) const cacheKey = JSON.stringify(filterAuth);
if (this.cachedList[cacheKey]) return this.cachedList[cacheKey];
return (this.cachedList[cacheKey] = Array.from(
new Set(Object.values(this.settings).map((item) => item.topLevelName)),
)
.sort((a, b) => a.localeCompare(b)) // sort by name .sort((a, b) => a.localeCompare(b)) // sort by name
.map((name) => this.get(name, filterAuth)) .map((name) => this.get(name, filterAuth))
.filter(Boolean) .filter(Boolean)
.sort((a, b) => (a.sort || 0) - (b.sort || 0)); .sort((a, b) => (a.sort || 0) - (b.sort || 0)));
} }
getAclSnippets() { getAclSnippets() {

View File

@ -8,7 +8,8 @@ export interface AppComponentProps {
app: Application; app: Application;
} }
export const AppComponent: FC<AppComponentProps> = observer((props) => { export const AppComponent: FC<AppComponentProps> = observer(
(props) => {
const { app } = props; const { app } = props;
const handleErrors = useCallback((error: Error, info: { componentStack: string }) => { const handleErrors = useCallback((error: Error, info: { componentStack: string }) => {
console.error(error); console.error(error);
@ -36,4 +37,6 @@ export const AppComponent: FC<AppComponentProps> = observer((props) => {
</ApplicationContext.Provider> </ApplicationContext.Provider>
</ErrorBoundary> </ErrorBoundary>
); );
}); },
{ displayName: 'AppComponent' },
);

View File

@ -2,3 +2,4 @@ import { createContext } from 'react';
import { Application } from './Application'; import { Application } from './Application';
export const ApplicationContext = createContext<Application>(null); export const ApplicationContext = createContext<Application>(null);
ApplicationContext.displayName = 'ApplicationContext';

View File

@ -13,7 +13,8 @@ import { SchemaInitializerOptions } from '../types';
const defaultWrap = (s: ISchema) => s; const defaultWrap = (s: ISchema) => s;
export function withInitializer<T>(C: ComponentType<T>) { export function withInitializer<T>(C: ComponentType<T>) {
const WithInitializer = observer((props: SchemaInitializerOptions<T>) => { const WithInitializer = observer(
(props: SchemaInitializerOptions<T>) => {
const { designable, insertAdjacent } = useDesignable(); const { designable, insertAdjacent } = useDesignable();
const { isInSubTable } = useFlag() || {}; const { isInSubTable } = useFlag() || {};
const { const {
@ -118,8 +119,8 @@ export function withInitializer<T>(C: ComponentType<T>) {
)} )}
</SchemaInitializerContext.Provider> </SchemaInitializerContext.Provider>
); );
}); },
{ displayName: `WithInitializer(${C.displayName || C.name})` },
WithInitializer.displayName = `WithInitializer(${C.displayName || C.name})`; );
return WithInitializer; return WithInitializer;
} }

View File

@ -11,7 +11,7 @@ export * from './useAriaAttributeOfMenuItem';
export function useSchemaInitializerMenuItems(items: any[], name?: string, onClick?: (args: any) => void) { export function useSchemaInitializerMenuItems(items: any[], name?: string, onClick?: (args: any) => void) {
const getMenuItems = useGetSchemaInitializerMenuItems(onClick); const getMenuItems = useGetSchemaInitializerMenuItems(onClick);
return getMenuItems(items, name); return useMemo(() => getMenuItems(items, name), [getMenuItems, items, name]);
} }
export function useGetSchemaInitializerMenuItems(onClick?: (args: any) => void) { export function useGetSchemaInitializerMenuItems(onClick?: (args: any) => void) {

View File

@ -13,3 +13,4 @@ export const SchemaSettingsIcon: FC<SchemaSettingOptions> = React.memo((props) =
const style = useMemo(() => ({ cursor: 'pointer', fontSize: 12 }), []); const style = useMemo(() => ({ cursor: 'pointer', fontSize: 12 }), []);
return <MenuOutlined role="button" style={style} aria-label={getAriaLabel('schema-settings', name)} />; return <MenuOutlined role="button" style={style} aria-label={getAriaLabel('schema-settings', name)} />;
}); });
SchemaSettingsIcon.displayName = 'SchemaSettingsIcon';

View File

@ -3,6 +3,7 @@ import React, { createContext, useContext } from 'react';
import { useRequest } from '../api-client'; import { useRequest } from '../api-client';
export const AsyncDataContext = createContext<Result<any, any> & { state?: any; setState?: any }>(null); export const AsyncDataContext = createContext<Result<any, any> & { state?: any; setState?: any }>(null);
AsyncDataContext.displayName = 'AsyncDataContext';
export interface AsyncDataProviderProps { export interface AsyncDataProviderProps {
value?: any; value?: any;

View File

@ -35,7 +35,9 @@ import { useDataBlockSourceId } from './hooks/useDataBlockSourceId';
* @deprecated * @deprecated
*/ */
export const BlockResourceContext = createContext(null); export const BlockResourceContext = createContext(null);
BlockResourceContext.displayName = 'BlockResourceContext';
export const BlockAssociationContext = createContext(null); export const BlockAssociationContext = createContext(null);
BlockAssociationContext.displayName = 'BlockAssociationContext';
/** /**
* @deprecated * @deprecated
@ -50,6 +52,7 @@ export const BlockRequestContext_deprecated = createContext<{
__parent?: any; __parent?: any;
updateAssociationValues?: any[]; updateAssociationValues?: any[];
}>({}); }>({});
BlockRequestContext_deprecated.displayName = 'BlockRequestContext_deprecated';
export const useBlockResource = () => { export const useBlockResource = () => {
const resource = useDataBlockResource(); const resource = useDataBlockResource();
@ -209,6 +212,7 @@ const BlockContext = createContext<{
/** 用以区分区块的标识 */ /** 用以区分区块的标识 */
name: string; name: string;
}>(null); }>(null);
BlockContext.displayName = 'BlockContext';
export const useBlockContext = () => { export const useBlockContext = () => {
return useContext(BlockContext); return useContext(BlockContext);

View File

@ -9,6 +9,7 @@ import { BlockProvider, useBlockRequestContext } from './BlockProvider';
import { useParsedFilter } from './hooks'; import { useParsedFilter } from './hooks';
export const DetailsBlockContext = createContext<any>({}); export const DetailsBlockContext = createContext<any>({});
DetailsBlockContext.displayName = 'DetailsBlockContext';
const InternalDetailsBlockProvider = (props) => { const InternalDetailsBlockProvider = (props) => {
const { action, readPretty } = props; const { action, readPretty } = props;

View File

@ -12,6 +12,7 @@ import { TemplateBlockProvider } from './TemplateBlockProvider';
import { FormActiveFieldsProvider } from './hooks/useFormActiveFields'; import { FormActiveFieldsProvider } from './hooks/useFormActiveFields';
export const FormBlockContext = createContext<any>({}); export const FormBlockContext = createContext<any>({});
FormBlockContext.displayName = 'FormBlockContext';
const InternalFormBlockProvider = (props) => { const InternalFormBlockProvider = (props) => {
const ctx = useFormBlockContext(); const ctx = useFormBlockContext();

View File

@ -10,6 +10,7 @@ import { BlockProvider, useBlockRequestContext } from './BlockProvider';
import { useFormBlockContext } from './FormBlockProvider'; import { useFormBlockContext } from './FormBlockProvider';
export const FormFieldContext = createContext<any>({}); export const FormFieldContext = createContext<any>({});
FormFieldContext.displayName = 'FormFieldContext';
const InternalFormFieldProvider = (props) => { const InternalFormFieldProvider = (props) => {
const { action, readPretty, fieldName } = props; const { action, readPretty, fieldName } = props;
@ -75,6 +76,7 @@ const InternalFormFieldProvider = (props) => {
}; };
export const WithoutFormFieldResource = createContext(null); export const WithoutFormFieldResource = createContext(null);
WithoutFormFieldResource.displayName = 'WithoutFormFieldResource';
export const FormFieldProvider = (props) => { export const FormFieldProvider = (props) => {
return ( return (

View File

@ -9,6 +9,8 @@ import { BlockProvider, RenderChildrenWithAssociationFilter, useBlockRequestCont
import { findFilterTargets, useParsedFilter } from './hooks'; import { findFilterTargets, useParsedFilter } from './hooks';
export const TableBlockContext = createContext<any>({}); export const TableBlockContext = createContext<any>({});
TableBlockContext.displayName = 'TableBlockContext';
export function getIdsWithChildren(nodes) { export function getIdsWithChildren(nodes) {
const ids = []; const ids = [];
if (nodes) { if (nodes) {

View File

@ -7,6 +7,7 @@ import { useFormBlockContext } from './FormBlockProvider';
import { useFormFieldContext } from './FormFieldProvider'; import { useFormFieldContext } from './FormFieldProvider';
export const TableFieldContext = createContext<any>({}); export const TableFieldContext = createContext<any>({});
TableFieldContext.displayName = 'TableFieldContext';
const InternalTableFieldProvider = (props) => { const InternalTableFieldProvider = (props) => {
const { params = {}, showIndex, dragSort, fieldName } = props; const { params = {}, showIndex, dragSort, fieldName } = props;
@ -122,6 +123,7 @@ export class TableFieldResource {
} }
export const WithoutTableFieldResource = createContext(null); export const WithoutTableFieldResource = createContext(null);
WithoutTableFieldResource.displayName = 'WithoutTableFieldResource';
export const TableFieldProvider = (props) => { export const TableFieldProvider = (props) => {
return ( return (

View File

@ -20,7 +20,9 @@ type Params = {
}; };
export const TableSelectorContext = createContext<any>({}); export const TableSelectorContext = createContext<any>({});
TableSelectorContext.displayName = 'TableSelectorContext';
const TableSelectorParamsContext = createContext<Params>({}); // 用于传递参数 const TableSelectorParamsContext = createContext<Params>({}); // 用于传递参数
TableSelectorParamsContext.displayName = 'TableSelectorParamsContext';
type TableSelectorProviderProps = { type TableSelectorProviderProps = {
params: Record<string, any>; params: Record<string, any>;

View File

@ -5,6 +5,7 @@ const TemplateBlockContext = createContext<{
templateFinshed?: boolean; templateFinshed?: boolean;
onTemplateSuccess?: Function; onTemplateSuccess?: Function;
}>({}); }>({});
TemplateBlockContext.displayName = 'TemplateBlockContext';
export const useTemplateBlockContext = () => { export const useTemplateBlockContext = () => {
return useContext(TemplateBlockContext); return useContext(TemplateBlockContext);

View File

@ -12,6 +12,7 @@ const CollectionHistoryContext = createContext<CollectionHistoryContextValue>({
historyCollections: [], historyCollections: [],
refreshCH: () => undefined, refreshCH: () => undefined,
}); });
CollectionHistoryContext.displayName = 'CollectionHistoryContext';
export const CollectionHistoryProvider: React.FC = (props) => { export const CollectionHistoryProvider: React.FC = (props) => {
const api = useAPIClient(); const api = useAPIClient();

View File

@ -51,6 +51,4 @@ const Summary = observer(
{ displayName: 'Summary' }, { displayName: 'Summary' },
); );
Summary.displayName = 'Summary';
export default Summary; export default Summary;

View File

@ -8,6 +8,7 @@ import { useAPIClient, useRequest } from '../api-client';
export const ResourceActionContext = createContext< export const ResourceActionContext = createContext<
Result<any, any> & { state?: any; setState?: any; dragSort?: boolean; defaultRequest?: any } Result<any, any> & { state?: any; setState?: any; dragSort?: boolean; defaultRequest?: any }
>(null); >(null);
ResourceActionContext.displayName = 'ResourceActionContext';
interface ResourceActionProviderProps { interface ResourceActionProviderProps {
type?: 'association' | 'collection'; type?: 'association' | 'collection';
@ -18,6 +19,7 @@ interface ResourceActionProviderProps {
} }
const ResourceContext = createContext<any>(null); const ResourceContext = createContext<any>(null);
ResourceContext.displayName = 'ResourceContext';
const CollectionResourceActionProvider = (props) => { const CollectionResourceActionProvider = (props) => {
const { collection, request, uid, dragSort } = props; const { collection, request, uid, dragSort } = props;

View File

@ -1,3 +1,4 @@
import { createContext } from 'react'; import { createContext } from 'react';
export const CollectionCategroriesContext = createContext({ data: [], refresh: () => {} }); export const CollectionCategroriesContext = createContext({ data: [], refresh: () => {} });
CollectionCategroriesContext.displayName = 'CollectionCategroriesContext';

View File

@ -69,6 +69,7 @@ const collection: CollectionOptions = {
}; };
export const DataSourceContext_deprecated = createContext(null); export const DataSourceContext_deprecated = createContext(null);
DataSourceContext_deprecated.displayName = 'DataSourceContext_deprecated';
const useSelectedRowKeys = () => { const useSelectedRowKeys = () => {
const ctx = useContext(DataSourceContext_deprecated); const ctx = useContext(DataSourceContext_deprecated);

View File

@ -100,7 +100,8 @@ const getDefaultCollectionFields = (presetFields, values) => {
// 其他 // 其他
return defaults; return defaults;
}; };
export const PresetFields = observer((props: any) => { export const PresetFields = observer(
(props: any) => {
const { getInterface } = useCollectionManager_deprecated(); const { getInterface } = useCollectionManager_deprecated();
const form = useForm(); const form = useForm();
const compile = useCompile(); const compile = useCompile();
@ -211,4 +212,6 @@ export const PresetFields = observer((props: any) => {
}} }}
/> />
); );
}); },
{ displayName: 'PresetFields' },
);

View File

@ -73,7 +73,8 @@ const useSourceFieldsOptions = () => {
return data; return data;
}; };
export const FieldsConfigure = observer(() => { export const FieldsConfigure = observer(
() => {
const { t } = useTranslation(); const { t } = useTranslation();
const [dataSource, setDataSource] = useState([]); const [dataSource, setDataSource] = useState([]);
const { data: res, error, loading } = useAsyncData(); const { data: res, error, loading } = useAsyncData();
@ -291,4 +292,6 @@ export const FieldsConfigure = observer(() => {
rowKey="name" rowKey="name"
/> />
); );
}); },
{ displayName: 'FieldsConfigure' },
);

View File

@ -4,7 +4,8 @@ import { Table } from 'antd';
import { Schema, observer, useForm } from '@formily/react'; import { Schema, observer, useForm } from '@formily/react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
export const PreviewTable = observer(() => { export const PreviewTable = observer(
() => {
const { data: res, loading, error } = useAsyncData(); const { data: res, loading, error } = useAsyncData();
const { data } = res || {}; const { data } = res || {};
const { t } = useTranslation(); const { t } = useTranslation();
@ -55,4 +56,6 @@ export const PreviewTable = observer(() => {
rowKey="key" rowKey="key"
/> />
); );
}); },
{ displayName: 'PreviewTable' },
);

View File

@ -12,6 +12,7 @@ export interface AssociationProviderProps {
} }
const ParentCollectionContext = createContext<Collection>(null); const ParentCollectionContext = createContext<Collection>(null);
ParentCollectionContext.displayName = 'ParentCollectionContext';
const ParentCollectionProvider = (props) => { const ParentCollectionProvider = (props) => {
const collection = useCollection(); const collection = useCollection();

View File

@ -13,6 +13,7 @@ export const DocumentTitleContext = createContext<DocumentTitleContextProps>({
title: null, title: null,
setTitle() {}, setTitle() {},
}); });
DocumentTitleContext.displayName = 'DocumentTitleContext';
export const DocumentTitleProvider: React.FC<{ addonBefore?: string; addonAfter?: string }> = (props) => { export const DocumentTitleProvider: React.FC<{ addonBefore?: string; addonAfter?: string }> = (props) => {
const { addonBefore, addonAfter } = props; const { addonBefore, addonAfter } = props;

View File

@ -58,6 +58,7 @@ interface FilterContextValue {
} }
const FilterContext = createContext<FilterContextValue>(null); const FilterContext = createContext<FilterContextValue>(null);
FilterContext.displayName = 'FilterContext';
/** /**
* 使 * 使

View File

@ -15,6 +15,7 @@ const AppInner = memo(({ children }: { children: React.ReactNode }) => {
return <>{children}</>; return <>{children}</>;
}); });
AppInner.displayName = 'AppInner';
const AntdAppProvider = ({ children }: { children: React.ReactNode }) => { const AntdAppProvider = ({ children }: { children: React.ReactNode }) => {
return ( return (

View File

@ -25,6 +25,7 @@ interface GlobalThemeContextProps {
} }
const GlobalThemeContext = createContext<GlobalThemeContextProps>(null); const GlobalThemeContext = createContext<GlobalThemeContextProps>(null);
GlobalThemeContext.displayName = 'GlobalThemeContext';
export const useGlobalTheme = () => { export const useGlobalTheme = () => {
return React.useContext(GlobalThemeContext) || ({ theme: {}, isDarkTheme: false } as GlobalThemeContextProps); return React.useContext(GlobalThemeContext) || ({ theme: {}, isDarkTheme: false } as GlobalThemeContextProps);

View File

@ -10,7 +10,9 @@ type Item = MenuProps['items'][0] & {
}; };
export const GetMenuItemContext = createContext<{ collectMenuItem?(item: Item): void; onChange?: () => void }>(null); export const GetMenuItemContext = createContext<{ collectMenuItem?(item: Item): void; onChange?: () => void }>(null);
GetMenuItemContext.displayName = 'GetMenuItemContext';
export const GetMenuItemsContext = createContext<{ pushMenuItem?(item: Item): void }>(null); export const GetMenuItemsContext = createContext<{ pushMenuItem?(item: Item): void }>(null);
GetMenuItemsContext.displayName = 'GetMenuItemsContext';
/** /**
* SchemaInitializer.Item * SchemaInitializer.Item

View File

@ -65,7 +65,8 @@ const useErrorProps = (app: Application, error: any) => {
} }
}; };
const AppError: FC<{ error: Error; app: Application }> = observer(({ app, error }) => { const AppError: FC<{ error: Error; app: Application }> = observer(
({ app, error }) => {
const props = useErrorProps(app, error); const props = useErrorProps(app, error);
return ( return (
<div> <div>
@ -88,7 +89,9 @@ const AppError: FC<{ error: Error; app: Application }> = observer(({ app, error
/> />
</div> </div>
); );
}); },
{ displayName: 'AppError' },
);
const getProps = (app: Application) => { const getProps = (app: Application) => {
if (app.ws.serverDown) { if (app.ws.serverDown) {
@ -195,7 +198,8 @@ const getProps = (app: Application) => {
return {}; return {};
}; };
const AppMaintaining: FC<{ app: Application; error: Error }> = observer(({ app }) => { const AppMaintaining: FC<{ app: Application; error: Error }> = observer(
({ app }) => {
const { icon, status, title, subTitle } = getProps(app); const { icon, status, title, subTitle } = getProps(app);
return ( return (
<div> <div>
@ -218,16 +222,21 @@ const AppMaintaining: FC<{ app: Application; error: Error }> = observer(({ app }
/> />
</div> </div>
); );
}); },
{ displayName: 'AppMaintaining' },
);
const AppMaintainingDialog: FC<{ app: Application; error: Error }> = observer(({ app }) => { const AppMaintainingDialog: FC<{ app: Application; error: Error }> = observer(
({ app }) => {
const { icon, status, title, subTitle } = getProps(app); const { icon, status, title, subTitle } = getProps(app);
return ( return (
<Modal open={true} footer={null} closable={false}> <Modal open={true} footer={null} closable={false}>
<Result icon={icon} status={status} title={app.i18n.t(title)} subTitle={app.i18n.t(subTitle)} /> <Result icon={icon} status={status} title={app.i18n.t(title)} subTitle={app.i18n.t(subTitle)} />
</Modal> </Modal>
); );
}); },
{ displayName: 'AppMaintainingDialog' },
);
const AppNotFound = () => { const AppNotFound = () => {
const navigate = useNavigate(); const navigate = useNavigate();

View File

@ -1,3 +1,4 @@
import { createContext } from 'react'; import { createContext } from 'react';
export const PinnedPluginListContext = createContext({ items: {} }); export const PinnedPluginListContext = createContext({ items: {} });
PinnedPluginListContext.displayName = 'PinnedPluginListContext';

View File

@ -73,3 +73,4 @@ export const PluginDocument: React.FC<PluginDocumentProps> = memo((props) => {
</div> </div>
); );
}); });
PluginDocument.displayName = 'PluginDocument';

View File

@ -9,6 +9,7 @@ import { ADMIN_SETTINGS_PATH, PluginSettingsPageType, useApp } from '../applicat
import { useCompile } from '../schema-component'; import { useCompile } from '../schema-component';
export const SettingsCenterContext = createContext<any>({}); export const SettingsCenterContext = createContext<any>({});
SettingsCenterContext.displayName = 'SettingsCenterContext';
function getMenuItems(list: PluginSettingsPageType[]) { function getMenuItems(list: PluginSettingsPageType[]) {
return list.map((item) => { return list.map((item) => {

View File

@ -4,7 +4,9 @@ import { CollectionRecordProvider } from '../data-source';
import { useCurrentUserContext } from '../user'; import { useCurrentUserContext } from '../user';
export const RecordContext_deprecated = createContext({}); export const RecordContext_deprecated = createContext({});
RecordContext_deprecated.displayName = 'RecordContext_deprecated';
export const RecordIndexContext = createContext(null); export const RecordIndexContext = createContext(null);
RecordIndexContext.displayName = 'RecordIndexContext';
/** /**
* @deprecated use `CollectionRecordProvider` instead * @deprecated use `CollectionRecordProvider` instead

View File

@ -54,6 +54,7 @@ const filterByACL = (schema, options) => {
}; };
const SchemaIdContext = createContext(null); const SchemaIdContext = createContext(null);
SchemaIdContext.displayName = 'SchemaIdContext';
const useMenuProps = () => { const useMenuProps = () => {
const defaultSelectedUid = useContext(SchemaIdContext); const defaultSelectedUid = useContext(SchemaIdContext);
return { return {

View File

@ -4,6 +4,7 @@ import React, { createContext } from 'react';
import { useActionContext } from './hooks'; import { useActionContext } from './hooks';
export const ActionContext = createContext<ActionContextProps>({}); export const ActionContext = createContext<ActionContextProps>({});
ActionContext.displayName = 'ActionContext';
export const ActionContextProvider: React.FC<ActionContextProps & { value?: ActionContextProps }> = (props) => { export const ActionContextProvider: React.FC<ActionContextProps & { value?: ActionContextProps }> = (props) => {
const contextProps = useActionContext(); const contextProps = useActionContext();

View File

@ -40,7 +40,8 @@ export const filterAnalyses = (filters): any[] => {
return results; return results;
}; };
const InternalAssociationSelect = observer((props: AssociationSelectProps) => { const InternalAssociationSelect = observer(
(props: AssociationSelectProps) => {
const { objectValue = true } = props; const { objectValue = true } = props;
const field: any = useField(); const field: any = useField();
const fieldSchema = useFieldSchema(); const fieldSchema = useFieldSchema();
@ -149,7 +150,9 @@ const InternalAssociationSelect = observer((props: AssociationSelectProps) => {
</Space.Compact> </Space.Compact>
</div> </div>
); );
}); },
{ displayName: 'AssociationSelect' },
);
interface AssociationSelectInterface { interface AssociationSelectInterface {
(props: any): React.ReactElement; (props: any): React.ReactElement;

View File

@ -10,3 +10,4 @@ export interface AssociationFieldContextProps {
} }
export const AssociationFieldContext = createContext<AssociationFieldContextProps>({}); export const AssociationFieldContext = createContext<AssociationFieldContextProps>({});
AssociationFieldContext.displayName = 'AssociationFieldContext';

View File

@ -179,6 +179,7 @@ export const useFieldNames = (props) => {
}; };
const SubFormContext = createContext<Record<string, any>>(null); const SubFormContext = createContext<Record<string, any>>(null);
SubFormContext.displayName = 'SubFormContext';
export const SubFormProvider = SubFormContext.Provider; export const SubFormProvider = SubFormContext.Provider;
/** /**

View File

@ -12,6 +12,7 @@ import { Action } from '../action';
import { StablePopover } from '../popover'; import { StablePopover } from '../popover';
export const FilterActionContext = createContext<any>(null); export const FilterActionContext = createContext<any>(null);
FilterActionContext.displayName = 'FilterActionContext';
export const FilterAction = observer( export const FilterAction = observer(
(props: any) => { (props: any) => {

View File

@ -12,5 +12,8 @@ export interface FilterContextProps {
} }
export const RemoveConditionContext = createContext(null); export const RemoveConditionContext = createContext(null);
RemoveConditionContext.displayName = 'RemoveConditionContext';
export const FilterContext = createContext<FilterContextProps>(null); export const FilterContext = createContext<FilterContextProps>(null);
FilterContext.displayName = 'FilterContext';
export const FilterLogicContext = createContext(null); export const FilterLogicContext = createContext(null);
FilterLogicContext.displayName = 'FilterLogicContext';

View File

@ -1,5 +1,6 @@
import { useFieldSchema } from '@formily/react'; import { useFieldSchema } from '@formily/react';
import { useCollection_deprecated, useCollectionManager_deprecated } from '../../../collection-manager'; import { useCollection_deprecated, useCollectionManager_deprecated } from '../../../collection-manager';
import { useMemo } from 'react';
/** /**
* *
@ -7,15 +8,17 @@ import { useCollection_deprecated, useCollectionManager_deprecated } from '../..
*/ */
export const useOperatorList = (): any[] => { export const useOperatorList = (): any[] => {
const schema = useFieldSchema(); const schema = useFieldSchema();
const fieldInterface = schema['x-designer-props']?.interface;
const { name } = useCollection_deprecated(); const { name } = useCollection_deprecated();
const { getCollectionFields, getInterface } = useCollectionManager_deprecated(); const { getCollectionFields, getInterface } = useCollectionManager_deprecated();
const collectionFields = getCollectionFields(name);
const res = useMemo(() => {
const fieldInterface = schema['x-designer-props']?.interface;
const collectionFields = getCollectionFields(name);
if (fieldInterface) { if (fieldInterface) {
return getInterface(fieldInterface)?.filterable?.operators || []; return getInterface(fieldInterface)?.filterable?.operators || [];
} }
const field = collectionFields.find((item) => item.name === schema.name); const field = collectionFields.find((item) => item.name === schema.name);
return getInterface(field?.interface)?.filterable?.operators || []; return getInterface(field?.interface)?.filterable?.operators || [];
}, [schema.name]);
return res;
}; };

View File

@ -78,9 +78,12 @@ export function FormDialog(title: any, id: any, renderer?: any, theme?: any): IF
root.unmount(); root.unmount();
}, },
}; };
const DialogContent = observer(() => { const DialogContent = observer(
() => {
return <Fragment>{isFn(renderer) ? renderer(env.form) : renderer}</Fragment>; return <Fragment>{isFn(renderer) ? renderer(env.form) : renderer}</Fragment>;
}); },
{ displayName: 'DialogContent' },
);
const renderDialog = (open = true, resolve?: () => any, reject?: () => any) => { const renderDialog = (open = true, resolve?: () => any, reject?: () => any) => {
const { form } = env; const { form } = env;
if (!form) return null; if (!form) return null;

View File

@ -87,6 +87,7 @@ const useDefaultValues = (opts: any = {}, props: FormProps = {}) => {
}; };
const FormBlockContext = createContext<any>(null); const FormBlockContext = createContext<any>(null);
FormBlockContext.displayName = 'FormBlockContext';
export const Form: React.FC<FormProps> & { Designer?: any } = observer( export const Form: React.FC<FormProps> & { Designer?: any } = observer(
(props) => { (props) => {

View File

@ -126,6 +126,7 @@ export const G2PlotRenderer = forwardRef(function <O = any>(props: ReactG2PlotPr
return <div className={cls(['g2plot', className])} ref={containerRef} />; return <div className={cls(['g2plot', className])} ref={containerRef} />;
}); });
G2PlotRenderer.displayName = 'G2PlotRenderer';
export const G2Plot: any = observer( export const G2Plot: any = observer(
(props: any) => { (props: any) => {
@ -140,12 +141,14 @@ export const G2Plot: any = observer(
if (typeof fn === 'function') { if (typeof fn === 'function') {
const result = fn.bind({ api })(); const result = fn.bind({ api })();
if (result?.then) { if (result?.then) {
result.then((data) => { result
.then((data) => {
if (Array.isArray(data)) { if (Array.isArray(data)) {
field.componentProps.config.data = data; field.componentProps.config.data = data;
} }
field.data.loading = false; field.data.loading = false;
}); })
.catch(console.error);
} else { } else {
field.data.loading = false; field.data.loading = false;
} }

View File

@ -5,6 +5,7 @@ import React, { createContext, useContext, useEffect, useMemo } from 'react';
import { BlockProvider, useBlockRequestContext, useParsedFilter } from '../../../block-provider'; import { BlockProvider, useBlockRequestContext, useParsedFilter } from '../../../block-provider';
import useStyles from './GridCard.Decorator.style'; import useStyles from './GridCard.Decorator.style';
export const GridCardBlockContext = createContext<any>({}); export const GridCardBlockContext = createContext<any>({});
GridCardBlockContext.displayName = 'GridCardBlockContext';
const InternalGridCardBlockProvider = (props) => { const InternalGridCardBlockProvider = (props) => {
const { resource, service } = useBlockRequestContext(); const { resource, service } = useBlockRequestContext();

View File

@ -11,8 +11,11 @@ import { useToken } from '../__builtins__';
import useStyles from './Grid.style'; import useStyles from './Grid.style';
const GridRowContext = createContext<any>({}); const GridRowContext = createContext<any>({});
GridRowContext.displayName = 'GridRowContext';
const GridColContext = createContext<any>({}); const GridColContext = createContext<any>({});
GridColContext.displayName = 'GridColContext';
const GridContext = createContext<any>({}); const GridContext = createContext<any>({});
GridContext.displayName = 'GridContext';
const breakRemoveOnGrid = (s: Schema) => s['x-component'] === 'Grid'; const breakRemoveOnGrid = (s: Schema) => s['x-component'] === 'Grid';
const breakRemoveOnRow = (s: Schema) => s['x-component'] === 'Grid.Row'; const breakRemoveOnRow = (s: Schema) => s['x-component'] === 'Grid.Row';

View File

@ -77,3 +77,4 @@ export const EllipsisWithTooltip = forwardRef((props: Partial<IEllipsisWithToolt
</Popover> </Popover>
); );
}); });
EllipsisWithTooltip.displayName = 'EllipsisWithTooltip';

View File

@ -67,3 +67,4 @@ export const Json = React.forwardRef<typeof Input.TextArea, JSONTextAreaProps>(
); );
}, },
); );
Json.displayName = 'Json';

View File

@ -7,6 +7,7 @@ import React, { createContext, useContext, useEffect, useMemo } from 'react';
import { BlockProvider, useBlockRequestContext, useParsedFilter } from '../../../block-provider'; import { BlockProvider, useBlockRequestContext, useParsedFilter } from '../../../block-provider';
export const ListBlockContext = createContext<any>({}); export const ListBlockContext = createContext<any>({});
ListBlockContext.displayName = 'ListBlockContext';
const InternalListBlockProvider = (props) => { const InternalListBlockProvider = (props) => {
const { resource, service } = useBlockRequestContext(); const { resource, service } = useBlockRequestContext();

View File

@ -350,7 +350,6 @@ const SideMenu = ({
}; };
const MenuModeContext = createContext(null); const MenuModeContext = createContext(null);
MenuModeContext.displayName = 'MenuModeContext'; MenuModeContext.displayName = 'MenuModeContext';
const useSideMenuRef = () => { const useSideMenuRef = () => {

View File

@ -6,7 +6,8 @@ import React, { useMemo, useRef } from 'react';
import { useCollectionManager_deprecated } from '../../../collection-manager'; import { useCollectionManager_deprecated } from '../../../collection-manager';
import { StablePopover } from '../popover'; import { StablePopover } from '../popover';
export const Editable = observer((props) => { export const Editable = observer(
(props) => {
const field: any = useField(); const field: any = useField();
const containerRef = useRef(null); const containerRef = useRef(null);
const fieldSchema = useFieldSchema(); const fieldSchema = useFieldSchema();
@ -65,9 +66,12 @@ export const Editable = observer((props) => {
</StablePopover> </StablePopover>
</FormItem> </FormItem>
); );
}); },
{ displayName: 'Editable' },
);
export const QuickEdit = observer((props) => { export const QuickEdit = observer(
(props) => {
const field = useField<Field>(); const field = useField<Field>();
const { getCollectionJoinField } = useCollectionManager_deprecated(); const { getCollectionJoinField } = useCollectionManager_deprecated();
const fieldSchema = useFieldSchema(); const fieldSchema = useFieldSchema();
@ -76,4 +80,6 @@ export const QuickEdit = observer((props) => {
return null; return null;
} }
return field.editable ? <Editable {...props} /> : <FormItem {...props} style={{ padding: '0 8px' }} />; return field.editable ? <Editable {...props} /> : <FormItem {...props} style={{ padding: '0 8px' }} />;
}); },
{ displayName: 'QuickEdit' },
);

View File

@ -16,6 +16,7 @@ import { useFieldNames } from './useFieldNames';
import { getLabelFormatValue, useLabelUiSchema } from './util'; import { getLabelFormatValue, useLabelUiSchema } from './util';
export const RecordPickerContext = createContext(null); export const RecordPickerContext = createContext(null);
RecordPickerContext.displayName = 'RecordPickerContext';
function flatData(data) { function flatData(data) {
const newArr = []; const newArr = [];

View File

@ -13,6 +13,7 @@ import {
import React, { createContext, useContext, useState } from 'react'; import React, { createContext, useContext, useState } from 'react';
const DataSourceContext = createContext(null); const DataSourceContext = createContext(null);
DataSourceContext.displayName = 'DataSourceContext';
const useSelectedRowKeys = () => { const useSelectedRowKeys = () => {
const ctx = useContext(DataSourceContext); const ctx = useContext(DataSourceContext);

View File

@ -7,6 +7,7 @@ import { RawTextArea } from './RawTextArea';
import { TextArea } from './TextArea'; import { TextArea } from './TextArea';
const VariableScopeContext = createContext([]); const VariableScopeContext = createContext([]);
VariableScopeContext.displayName = 'VariableScopeContext';
export function VariableScopeProvider({ scope = [], children }) { export function VariableScopeProvider({ scope = [], children }) {
return <VariableScopeContext.Provider value={scope}>{children}</VariableScopeContext.Provider>; return <VariableScopeContext.Provider value={scope}>{children}</VariableScopeContext.Provider>;

View File

@ -15,3 +15,4 @@ export const XButton = forwardRef((props: ButtonProps, ref: any) => {
</Button> </Button>
); );
}); });
XButton.displayName = 'XButton';

View File

@ -2,11 +2,13 @@ import { TinyColor } from '@ctrl/tinycolor';
import { useDraggable, useDroppable } from '@dnd-kit/core'; import { useDraggable, useDroppable } from '@dnd-kit/core';
import { cx } from '@emotion/css'; import { cx } from '@emotion/css';
import { Schema, observer, useField, useFieldSchema } from '@formily/react'; import { Schema, observer, useField, useFieldSchema } from '@formily/react';
import React, { HTMLAttributes, createContext, useContext } from 'react'; import React, { HTMLAttributes, createContext, useContext, useMemo } from 'react';
import { useToken } from '../../antd/__builtins__'; import { useToken } from '../../antd/__builtins__';
export const DraggableContext = createContext(null); export const DraggableContext = createContext(null);
DraggableContext.displayName = 'DraggableContext';
export const SortableContext = createContext(null); export const SortableContext = createContext(null);
SortableContext.displayName = 'SortableContext';
export const SortableProvider = (props) => { export const SortableProvider = (props) => {
const { id, data, children } = props; const { id, data, children } = props;
@ -74,15 +76,17 @@ interface SortableItemProps extends HTMLAttributes<HTMLDivElement> {
export const SortableItem: React.FC<SortableItemProps> = observer( export const SortableItem: React.FC<SortableItemProps> = observer(
(props) => { (props) => {
const { schema, id, eid, removeParentsIfNoChildren, ...others } = useSortableItemProps(props); const { schema, id, eid, removeParentsIfNoChildren, ...others } = useSortableItemProps(props);
return (
<SortableProvider const data = useMemo(() => {
id={id} return {
data={{
insertAdjacent: 'afterEnd', insertAdjacent: 'afterEnd',
schema: schema, schema: schema,
removeParentsIfNoChildren: removeParentsIfNoChildren ?? true, removeParentsIfNoChildren: removeParentsIfNoChildren ?? true,
}} };
> }, [schema, removeParentsIfNoChildren]);
return (
<SortableProvider id={id} data={data}>
<Sortable id={eid} {...others}> <Sortable id={eid} {...others}>
{props.children} {props.children}
</Sortable> </Sortable>

View File

@ -2,3 +2,4 @@ import { createContext } from 'react';
import { ISchemaComponentContext } from './types'; import { ISchemaComponentContext } from './types';
export const SchemaComponentContext = createContext<ISchemaComponentContext>({}); export const SchemaComponentContext = createContext<ISchemaComponentContext>({});
SchemaComponentContext.displayName = 'SchemaComponentContext.Provider';

View File

@ -1,5 +1,5 @@
import { ExpressionScope, SchemaComponentsContext, SchemaOptionsContext } from '@formily/react'; import { ExpressionScope, SchemaComponentsContext, SchemaOptionsContext } from '@formily/react';
import React, { useContext } from 'react'; import React, { memo, useContext, useMemo } from 'react';
import { ISchemaComponentOptionsProps } from '../types'; import { ISchemaComponentOptionsProps } from '../types';
export const useSchemaOptionsContext = () => { export const useSchemaOptionsContext = () => {
@ -7,16 +7,28 @@ export const useSchemaOptionsContext = () => {
return options || {}; return options || {};
}; };
export const SchemaComponentOptions: React.FC<ISchemaComponentOptionsProps> = (props) => { export const SchemaComponentOptions: React.FC<ISchemaComponentOptionsProps> = memo((props) => {
const { children } = props; const { children } = props;
const options = useSchemaOptionsContext(); const options = useSchemaOptionsContext();
const components = { ...options.components, ...props.components }; const components = useMemo(() => {
const scope = { ...options.scope, ...props.scope }; return { ...options.components, ...props.components };
}, [options.components, props.components]);
const scope = useMemo(() => {
return { ...options.scope, ...props.scope };
}, [options.scope, props.scope]);
const schemaOptionsContextValue = useMemo(() => {
return { scope, components };
}, [scope, components]);
return ( return (
<SchemaOptionsContext.Provider value={{ scope, components }}> <SchemaOptionsContext.Provider value={schemaOptionsContextValue}>
<SchemaComponentsContext.Provider value={components}> <SchemaComponentsContext.Provider value={components}>
<ExpressionScope value={scope}>{children}</ExpressionScope> <ExpressionScope value={scope}>{children}</ExpressionScope>
</SchemaComponentsContext.Provider> </SchemaComponentsContext.Provider>
</SchemaOptionsContext.Provider> </SchemaOptionsContext.Provider>
); );
}; });
SchemaComponentOptions.displayName = 'SchemaComponentOptions';

View File

@ -44,19 +44,23 @@ Schema.registerCompiler(Registry.compile);
export const SchemaComponentProvider: React.FC<ISchemaComponentProvider> = (props) => { export const SchemaComponentProvider: React.FC<ISchemaComponentProvider> = (props) => {
const { designable, onDesignableChange, components, children } = props; const { designable, onDesignableChange, components, children } = props;
const [, setUid] = useState(uid()); const [uidValue, setUid] = useState(uid());
const [formId, setFormId] = useState(uid()); const [formId, setFormId] = useState(uid());
const form = useMemo(() => props.form || createForm(), [formId]); const form = useMemo(() => props.form || createForm(), [formId]);
const { t } = useTranslation(); const { t } = useTranslation();
const scope = { ...props.scope, t, randomString }; const scope = useMemo(() => {
return { ...props.scope, t, randomString };
}, [props.scope, t]);
const [active, setActive] = useState(designable); const [active, setActive] = useState(designable);
return (
<SchemaComponentContext.Provider const schemaComponentContextValue = useMemo(
value={{ () => ({
scope, scope,
components, components,
reset: () => setFormId(uid()), reset: () => setFormId(uid()),
refresh: () => setUid(uid()), refresh: () => {
setUid(uid());
},
designable: typeof designable === 'boolean' ? designable : active, designable: typeof designable === 'boolean' ? designable : active,
setDesignable: (value) => { setDesignable: (value) => {
if (typeof designable !== 'boolean') { if (typeof designable !== 'boolean') {
@ -64,8 +68,12 @@ export const SchemaComponentProvider: React.FC<ISchemaComponentProvider> = (prop
} }
onDesignableChange?.(value); onDesignableChange?.(value);
}, },
}} }),
> [uidValue, scope, components, designable, active],
);
return (
<SchemaComponentContext.Provider value={schemaComponentContextValue}>
<FormProvider form={form}> <FormProvider form={form}>
<SchemaComponentOptions inherit scope={scope} components={components}> <SchemaComponentOptions inherit scope={scope} components={components}>
{children} {children}

View File

@ -36,3 +36,4 @@ export const AsDefaultTemplate = React.forwardRef((props: any, ref) => {
/> />
); );
}); });
AsDefaultTemplate.displayName = 'AsDefaultTemplate';

View File

@ -276,3 +276,4 @@ ArrayCollapse.Copy = React.forwardRef((props: any, ref) => {
/> />
); );
}); });
(ArrayCollapse as any).Copy.displayName = 'ArrayCollapse.Copy';

View File

@ -32,3 +32,4 @@ export const EnableLinkage = React.forwardRef((props: any, ref) => {
/> />
); );
}); });
EnableLinkage.displayName = 'EnableLinkage';

View File

@ -266,3 +266,4 @@ ArrayCollapse.Copy = React.forwardRef((props: any, ref) => {
/> />
); );
}); });
(ArrayCollapse as any).Copy.displayName = 'ArrayCollapse.Copy';

View File

@ -11,5 +11,8 @@ export interface FilterContextProps {
} }
export const RemoveActionContext = createContext(null); export const RemoveActionContext = createContext(null);
RemoveActionContext.displayName = 'RemoveActionContext';
export const FilterContext = createContext<FilterContextProps>(null); export const FilterContext = createContext<FilterContextProps>(null);
FilterContext.displayName = 'FilterContext';
export const LinkageLogicContext = createContext(null); export const LinkageLogicContext = createContext(null);
LinkageLogicContext.displayName = 'LinkageLogicContext';

View File

@ -124,6 +124,7 @@ interface SchemaSettingsContextProps<T = any> {
} }
const SchemaSettingsContext = createContext<SchemaSettingsContextProps>(null); const SchemaSettingsContext = createContext<SchemaSettingsContextProps>(null);
SchemaSettingsContext.displayName = 'SchemaSettingsContext';
export function useSchemaSettings<T = any>() { export function useSchemaSettings<T = any>() {
return useContext(SchemaSettingsContext) as SchemaSettingsContextProps<T>; return useContext(SchemaSettingsContext) as SchemaSettingsContextProps<T>;

View File

@ -5,6 +5,7 @@ import { useSchemaTemplateManager } from './SchemaTemplateManagerProvider';
import { useTemplateBlockContext } from '../block-provider/TemplateBlockProvider'; import { useTemplateBlockContext } from '../block-provider/TemplateBlockProvider';
const BlockTemplateContext = createContext<any>({}); const BlockTemplateContext = createContext<any>({});
BlockTemplateContext.displayName = 'BlockTemplateContext';
export const useBlockTemplateContext = () => { export const useBlockTemplateContext = () => {
return useContext(BlockTemplateContext); return useContext(BlockTemplateContext);

View File

@ -11,6 +11,7 @@ import { BlockTemplate } from './BlockTemplate';
import { DEFAULT_DATA_SOURCE_KEY } from '../data-source'; import { DEFAULT_DATA_SOURCE_KEY } from '../data-source';
export const SchemaTemplateManagerContext = createContext<any>({}); export const SchemaTemplateManagerContext = createContext<any>({});
SchemaTemplateManagerContext.displayName = 'SchemaTemplateManagerContext';
export const SchemaTemplateManagerProvider: React.FC<any> = (props) => { export const SchemaTemplateManagerProvider: React.FC<any> = (props) => {
const { templates, refresh } = props; const { templates, refresh } = props;

View File

@ -4,6 +4,7 @@ import { useRequest } from '../api-client';
import { useAppSpin } from '../application/hooks/useAppSpin'; import { useAppSpin } from '../application/hooks/useAppSpin';
export const SystemSettingsContext = createContext<Result<any, any>>(null); export const SystemSettingsContext = createContext<Result<any, any>>(null);
SystemSettingsContext.displayName = 'SystemSettingsContext';
export const useSystemSettings = () => { export const useSystemSettings = () => {
return useContext(SystemSettingsContext); return useContext(SystemSettingsContext);

View File

@ -162,6 +162,8 @@ export const SettingsMenu: React.FC<{
}; };
export const DropdownVisibleContext = createContext(null); export const DropdownVisibleContext = createContext(null);
DropdownVisibleContext.displayName = 'DropdownVisibleContext';
export const CurrentUser = () => { export const CurrentUser = () => {
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const { token } = useToken(); const { token } = useToken();

View File

@ -6,6 +6,7 @@ import { useAppSpin } from '../application/hooks/useAppSpin';
import { useCompile } from '../schema-component'; import { useCompile } from '../schema-component';
export const CurrentUserContext = createContext<ReturnTypeOfUseRequest>(null); export const CurrentUserContext = createContext<ReturnTypeOfUseRequest>(null);
CurrentUserContext.displayName = 'CurrentUserContext';
export const useCurrentUserContext = () => { export const useCurrentUserContext = () => {
return useContext(CurrentUserContext); return useContext(CurrentUserContext);

View File

@ -24,6 +24,7 @@ interface OptionsOfAddMenuItem {
type Item = ItemType & { _options?: OptionsOfAddMenuItem }; type Item = ItemType & { _options?: OptionsOfAddMenuItem };
const CurrentUserSettingsMenuContext = createContext<{ menuItems: React.MutableRefObject<Item[]> }>(null); const CurrentUserSettingsMenuContext = createContext<{ menuItems: React.MutableRefObject<Item[]> }>(null);
CurrentUserSettingsMenuContext.displayName = 'CurrentUserSettingsMenuContext';
export const useCurrentUserSettingsMenu = () => { export const useCurrentUserSettingsMenu = () => {
const { menuItems } = useContext(CurrentUserSettingsMenuContext) || {}; const { menuItems } = useContext(CurrentUserSettingsMenuContext) || {};

View File

@ -16,6 +16,7 @@ import { isVariable } from './utils/isVariable';
import { uniq } from './utils/uniq'; import { uniq } from './utils/uniq';
export const VariablesContext = createContext<VariablesContextType>(null); export const VariablesContext = createContext<VariablesContextType>(null);
VariablesContext.displayName = 'VariablesContext';
const variableToCollectionName = {}; const variableToCollectionName = {};

View File

@ -6,3 +6,4 @@ export const RolesManagerContext = createContext<{
}>({ }>({
role: null, role: null,
} as any); } as any);
RolesManagerContext.displayName = 'RolesManagerContext';

View File

@ -3,6 +3,7 @@ import { Spin } from 'antd';
import React, { createContext, useContext } from 'react'; import React, { createContext, useContext } from 'react';
const AvailableActionsContext = createContext([]); const AvailableActionsContext = createContext([]);
AvailableActionsContext.displayName = 'AvailableActionsContext';
export const AvailableActionsProvider: React.FC = (props) => { export const AvailableActionsProvider: React.FC = (props) => {
const { data, loading } = useRequest<{ const { data, loading } = useRequest<{

View File

@ -3,6 +3,7 @@ import { Spin } from 'antd';
import React, { createContext, useContext } from 'react'; import React, { createContext, useContext } from 'react';
const MenuItemsContext = createContext(null); const MenuItemsContext = createContext(null);
MenuItemsContext.displayName = 'MenuItemsContext';
export const toItems = (properties = {}) => { export const toItems = (properties = {}) => {
const items = []; const items = [];

View File

@ -28,6 +28,7 @@ const toActionMap = (arr: any[]) => {
}; };
export const RoleResourceCollectionContext = createContext<any>({}); export const RoleResourceCollectionContext = createContext<any>({});
RoleResourceCollectionContext.displayName = 'RoleResourceCollectionContext';
export const RolesResourcesActions = connect((props) => { export const RolesResourcesActions = connect((props) => {
const { styles } = useStyles(); const { styles } = useStyles();

View File

@ -4,6 +4,7 @@ import { FormProvider, SchemaComponent } from '@nocobase/client';
import { scopesSchema } from '../schemas/scopes'; import { scopesSchema } from '../schemas/scopes';
const RolesResourcesScopesSelectedRowKeysContext = createContext(null); const RolesResourcesScopesSelectedRowKeysContext = createContext(null);
RolesResourcesScopesSelectedRowKeysContext.displayName = 'RolesResourcesScopesSelectedRowKeysContext';
const RolesResourcesScopesSelectedRowKeysProvider: React.FC = (props) => { const RolesResourcesScopesSelectedRowKeysProvider: React.FC = (props) => {
const [keys, setKeys] = useState([]); const [keys, setKeys] = useState([]);

View File

@ -103,6 +103,7 @@ const Value = observer(
); );
const IsAssociationBlock = createContext(null); const IsAssociationBlock = createContext(null);
IsAssociationBlock.displayName = 'IsAssociationBlock';
export const AuditLogs: any = () => { export const AuditLogs: any = () => {
const isAssoc = useContext(IsAssociationBlock); const isAssoc = useContext(IsAssociationBlock);

View File

@ -12,6 +12,7 @@ export type Authenticator = {
}; };
export const AuthenticatorsContext = createContext<Authenticator[]>([]); export const AuthenticatorsContext = createContext<Authenticator[]>([]);
AuthenticatorsContext.displayName = 'AuthenticatorsContext';
export const useAuthenticator = (name: string) => { export const useAuthenticator = (name: string) => {
const authenticators = useContext(AuthenticatorsContext); const authenticators = useContext(AuthenticatorsContext);

View File

@ -11,6 +11,7 @@ export const SignupPageContext = createContext<{
}>; }>;
}; };
}>({}); }>({});
SignupPageContext.displayName = 'SignupPageContext';
export const SignupPageProvider: React.FC<{ export const SignupPageProvider: React.FC<{
authType: string; authType: string;

View File

@ -34,9 +34,12 @@ export const useAdminSettingsForm = (authType: string) => {
return auth?.components?.AdminSettingsForm; return auth?.components?.AdminSettingsForm;
}; };
export const Options = observer(() => { export const Options = observer(
() => {
const form = useForm(); const form = useForm();
const record = useRecord(); const record = useRecord();
const Component = useAdminSettingsForm(form.values.authType || record.authType); const Component = useAdminSettingsForm(form.values.authType || record.authType);
return Component ? <Component /> : null; return Component ? <Component /> : null;
}); },
{ displayName: 'Options' },
);

View File

@ -3,6 +3,7 @@ import { createContext, useContext } from 'react';
export const AuthTypeContext = createContext<{ export const AuthTypeContext = createContext<{
type: string; type: string;
}>({ type: '' }); }>({ type: '' });
AuthTypeContext.displayName = 'AuthTypeContext';
export const AuthTypesContext = createContext<{ export const AuthTypesContext = createContext<{
types: { types: {
@ -11,6 +12,7 @@ export const AuthTypesContext = createContext<{
value: string; value: string;
}[]; }[];
}>({ types: [] }); }>({ types: [] });
AuthTypesContext.displayName = 'AuthTypesContext';
export const useAuthTypes = () => { export const useAuthTypes = () => {
const { types } = useContext(AuthTypesContext); const { types } = useContext(AuthTypesContext);

View File

@ -2,8 +2,11 @@ import { createContext, useContext } from 'react';
import type { ToolbarProps } from './types'; import type { ToolbarProps } from './types';
export const CalendarToolbarContext = createContext<ToolbarProps>(null); export const CalendarToolbarContext = createContext<ToolbarProps>(null);
CalendarToolbarContext.displayName = 'CalendarToolbarContext';
export const CalendarContext = createContext(null); export const CalendarContext = createContext(null);
CalendarContext.displayName = 'CalendarContext';
export const DeleteEventContext = createContext(null); export const DeleteEventContext = createContext(null);
DeleteEventContext.displayName = 'DeleteEventContext';
export const useDeleteEvent = () => { export const useDeleteEvent = () => {
return useContext(DeleteEventContext); return useContext(DeleteEventContext);

View File

@ -5,6 +5,7 @@ import _ from 'lodash';
import React, { createContext, useContext, useEffect, useMemo } from 'react'; import React, { createContext, useContext, useEffect, useMemo } from 'react';
export const CalendarBlockContext = createContext<any>({}); export const CalendarBlockContext = createContext<any>({});
CalendarBlockContext.displayName = 'CalendarBlockContext';
const InternalCalendarBlockProvider = (props) => { const InternalCalendarBlockProvider = (props) => {
const { fieldNames, showLunar } = props; const { fieldNames, showLunar } = props;

View File

@ -7,6 +7,7 @@ export const ChartQueryMetadataContext = createContext({
refresh: () => {}, refresh: () => {},
data: [] as any[], data: [] as any[],
}); });
ChartQueryMetadataContext.displayName = 'ChartQueryMetadataContext';
export const ChartQueryMetadataProvider: React.FC = (props) => { export const ChartQueryMetadataProvider: React.FC = (props) => {
const api = useAPIClient(); const api = useAPIClient();

View File

@ -3,6 +3,7 @@ import React, { FC, useState, createContext } from 'react';
import * as hooks from './hooks'; import * as hooks from './hooks';
export const DataSourceContext = createContext(null); export const DataSourceContext = createContext(null);
DataSourceContext.displayName = 'DataSourceContext';
export const DatabaseConnectionProvider: FC = (props) => { export const DatabaseConnectionProvider: FC = (props) => {
const [dataSource, setDataSource] = useState(null); const [dataSource, setDataSource] = useState(null);

View File

@ -33,6 +33,7 @@ const RemoteCollectionContext = createContext<{
refreshRM: Function; refreshRM: Function;
titleField: string; titleField: string;
}>({ refreshRM: () => {}, titleField: null, targetCollection: null }); }>({ refreshRM: () => {}, titleField: null, targetCollection: null });
RemoteCollectionContext.displayName = 'RemoteCollectionContext';
export const useRemoteCollectionContext = () => { export const useRemoteCollectionContext = () => {
return useContext(RemoteCollectionContext); return useContext(RemoteCollectionContext);
}; };

View File

@ -4,7 +4,8 @@ import { debounce } from 'lodash';
import React, { useState, useMemo, useEffect } from 'react'; import React, { useState, useMemo, useEffect } from 'react';
import { useRecord } from '@nocobase/client'; import { useRecord } from '@nocobase/client';
export const FieldTitleInput = observer((props: any) => { export const FieldTitleInput = observer(
(props: any) => {
const { value, handleFieldChange } = props; const { value, handleFieldChange } = props;
const record = useRecord(); const record = useRecord();
const [titleValue, setTitleValue] = useState(value); const [titleValue, setTitleValue] = useState(value);
@ -38,4 +39,6 @@ export const FieldTitleInput = observer((props: any) => {
setTitleValue(value); setTitleValue(value);
}, [value]); }, [value]);
return <Input value={titleValue} onChange={handleChange} />; return <Input value={titleValue} onChange={handleChange} />;
}); },
{ displayName: 'FieldTitleInput' },
);

View File

@ -11,6 +11,7 @@ import { dataSourceSchema } from './schemas/dataSourceTable';
import { PermissionProvider } from './PermisionProvider'; import { PermissionProvider } from './PermisionProvider';
const AvailableActionsContext = createContext([]); const AvailableActionsContext = createContext([]);
AvailableActionsContext.displayName = 'AvailableActionsContext';
const AvailableActionsProver: React.FC = (props) => { const AvailableActionsProver: React.FC = (props) => {
const { data, loading } = useRequest<{ const { data, loading } = useRequest<{

Some files were not shown because too many files have changed in this diff Show More