Zeke Zhang a429b7a4b3
feat: adapt desktop blocks to mobile (#4945)
* feat: register workflow blocks to mobile page

* fix: should hide Divider in subpage

* refactor: rename 'Data blocks' to 'Desktop data blocks'

* feat: adapt blocks within subpages for mobile

* feat: adapt Filter action

* feat: isolate block templates between desktop and mobile

* refactor: export storePopupContext

* feat: support popup URL for 'Workflow todos'

* chore: update e2e tests

* chore: make e2e tests pass

* chore: add comment

* fix: make popup style of duplicate and bulk edit right

* fix(GridCard): ensure single column display in mobile

* fix: fix goBack

* refactor: make more stable

* refactor: change name for add blocks menu

* fix: fix block template for mobile

* feat: adapt Apply action of approval block to mobile

* fix(Map): use window.open to redirect to configuration page

* Revert "fix(Map): use window.open to redirect to configuration page"

This reverts commit 248ae8b68cfd78415184dfab2442081363872fb0.

* fix: redirect to the main app page when URL is starts with 'admin'

* fix(Link): make path right

* fix: refactor Popup to fix draging bug

* fix: should auto refresh when submiting in Manual popup

* fix(Action.Container): should return null when visible is false (T-4949)

* fix: increase z-index of subpage to cover Amap elements

* fix: fix tab switching not work (T-4985)

* fix(Link): should be change Link's URL of all table rows after editing URL (T-4981)

* fix: fix URL not changed after closing popup (T-4987)

* fix: make unit tests pass

* fix: make unit tests pass

* chore: get e2e tests to pass

* fix: use Popup to display data picker (T-4965)

* fix: use mobile Popup in some bloks

* refactor: use local isMobile

* fix: increase Popup's z-index to cover subpage

* fix: optimize Popup for mobile

* style: createRecordAction style improve

* refactor(AssociationField): get Component from AssociationFieldModeProvider

* refactor(InternalPopoverNester): support custom Container component

* feat: adapt PopoverNester to mobile

* chore: update unit tests

* fix: get e2e tests to pass

* chore: make e2e more stable

* refactor: move mobile-action-page in adaptor-of-desktop folder

* fix: get the z-index of popups and subpages correct

* feat: unify the styles of popups

* chore: make e2e more stable

---------

Co-authored-by: chenos <chenlinxh@gmail.com>
Co-authored-by: katherinehhh <katherine_15995@163.com>
2024-08-07 14:25:40 +08:00

41 lines
1.6 KiB
TypeScript

/**
* This file is part of the NocoBase (R) project.
* Copyright (c) 2020-2024 NocoBase Co., Ltd.
* Authors: NocoBase Team.
*
* This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
* For more information, please refer to: https://www.nocobase.com/agreement.
*/
import { observer, useField, useFieldSchema } from '@formily/react';
import React, { useMemo } from 'react';
import { BlockTemplateProvider, CollectionDeletedPlaceholder, RemoteSchemaComponent, useDesignable } from '..';
import { useTemplateBlockContext } from '../block-provider/TemplateBlockProvider';
import { useSchemaTemplateManager } from './SchemaTemplateManagerProvider';
export const BlockTemplate = observer(
(props: any) => {
const { templateId } = props;
const { getTemplateById } = useSchemaTemplateManager();
const field = useField();
const fieldSchema = useFieldSchema();
const { dn } = useDesignable();
const template = useMemo(() => getTemplateById(templateId), [templateId]);
const { onTemplateSuccess } = useTemplateBlockContext();
const onSuccess = (data) => {
fieldSchema['x-linkage-rules'] = data?.data?.['x-linkage-rules'] || [];
fieldSchema.setProperties(data?.data?.properties);
onTemplateSuccess?.();
};
return template ? (
<BlockTemplateProvider {...{ dn, field, fieldSchema, template }}>
<RemoteSchemaComponent noForm uid={template?.uid} onSuccess={onSuccess} />
</BlockTemplateProvider>
) : (
<CollectionDeletedPlaceholder type="Block template" name={templateId} />
);
},
{ displayName: 'BlockTemplate' },
);