Skip to content

Commit

Permalink
Fix/initializer improve (#4533)
Browse files Browse the repository at this point in the history
* fix: imporve code

* fix: test bug
  • Loading branch information
dream2023 committed May 30, 2024
1 parent 950495c commit d83c102
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 2 deletions.
19 changes: 19 additions & 0 deletions packages/core/client/docs/en-US/core/application/application.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
19 changes: 19 additions & 0 deletions packages/core/client/docs/zh-CN/core/application/application.md
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import { ComponentType } from 'react';
import {
SchemaSettingsActionModalItemProps,
SchemaSettingsCascaderItemProps,
SchemaSettingsItemProps,
SchemaSettingsModalItemProps,
Expand Down Expand Up @@ -77,7 +78,7 @@ export type SchemaSettingItemModalType = SchemaSettingsItemCommon<SchemaSettings
type: 'modal';
};

export type SchemaSettingItemActionModalType = SchemaSettingsItemCommon<SchemaSettingsSelectItemProps> & {
export type SchemaSettingItemActionModalType = SchemaSettingsItemCommon<SchemaSettingsActionModalItemProps> & {
type: 'actionModal';
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface ActionContextProps {
modalProps?: ModalProps;
submitted?: boolean;
setSubmitted?: (v: boolean) => void;
children?: React.ReactNode;
}

export type UseActionType = (callback?: () => void) => {
Expand Down
1 change: 1 addition & 0 deletions packages/core/client/src/schema-component/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ export interface ISchemaComponentOptionsProps {
scope?: any;
components?: SchemaReactComponents;
inherit?: boolean;
children?: React.ReactNode;
}
15 changes: 14 additions & 1 deletion packages/core/test/src/client/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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
Expand Down

0 comments on commit d83c102

Please sign in to comment.