Fix/initializer improve (#4533)

* fix: imporve code

* fix: test bug
This commit is contained in:
jack zhang 2024-05-30 17:20:09 +08:00 committed by GitHub
parent 950495c292
commit d83c102492
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 56 additions and 2 deletions

View File

@ -325,6 +325,25 @@ const anyVar = '';
app.addScopes({ useSomeThing, anyVar })
```
### app.getCollectionManager()
Get the [collection manager](/core/data-source/collection-manager) instance of the specified data source.
- Type
```tsx | pure
class Application {
getCollectionManager(dataSource?: string): CollectionManager;
}
```
- Example
```tsx | pure
app.getCollectionManager() // Get the default data source collection manager
app.getCollectionManager('test') // Get the specified data source collection manager
```
## Hooks
### useApp()

View File

@ -324,6 +324,25 @@ const anyVar = '';
app.addScopes({ useSomeThing, anyVar })
```
### app.getCollectionManager()
获取指定数据源的 [collection manager](/core/data-source/collection-manager) 实例。
- 类型
```tsx | pure
class Application {
getCollectionManager(dataSource?: string): CollectionManager;
}
```
- 示例
```tsx | pure
app.getCollectionManager() // 获取默认数据源的 collection manager
app.getCollectionManager('test') // 获取指定数据源的 collection manager
```
## Hooks
### useApp()

View File

@ -9,6 +9,7 @@
import { ComponentType } from 'react';
import {
SchemaSettingsActionModalItemProps,
SchemaSettingsCascaderItemProps,
SchemaSettingsItemProps,
SchemaSettingsModalItemProps,
@ -77,7 +78,7 @@ export type SchemaSettingItemModalType = SchemaSettingsItemCommon<SchemaSettings
type: 'modal';
};
export type SchemaSettingItemActionModalType = SchemaSettingsItemCommon<SchemaSettingsSelectItemProps> & {
export type SchemaSettingItemActionModalType = SchemaSettingsItemCommon<SchemaSettingsActionModalItemProps> & {
type: 'actionModal';
};

View File

@ -30,6 +30,7 @@ export interface ActionContextProps {
modalProps?: ModalProps;
submitted?: boolean;
setSubmitted?: (v: boolean) => void;
children?: React.ReactNode;
}
export type UseActionType = (callback?: () => void) => {

View File

@ -40,4 +40,5 @@ export interface ISchemaComponentOptionsProps {
scope?: any;
components?: SchemaReactComponents;
inherit?: boolean;
children?: React.ReactNode;
}

View File

@ -8,7 +8,7 @@
*/
import React from 'react';
import { render } from '@testing-library/react';
import { render, waitFor, screen } from '@testing-library/react';
import { sleep } from '../web';
export * from './utils';
@ -22,6 +22,19 @@ function customRender(ui: React.ReactElement, options = {}) {
});
}
export async function waitForApp() {
return waitFor(() => {
// @ts-ignore
expect(screen.queryByText('Loading...')).not.toBeInTheDocument();
});
}
export async function renderApp(element: React.JSX.Element) {
const res = render(element);
await waitForApp();
return res;
}
export * from '@testing-library/react';
export { default as userEvent } from '@testing-library/user-event';
// override render export