diff --git a/packages/core/client/src/built-in/admin-layout/index.tsx b/packages/core/client/src/built-in/admin-layout/index.tsx index 53041be9a..7d2d43400 100644 --- a/packages/core/client/src/built-in/admin-layout/index.tsx +++ b/packages/core/client/src/built-in/admin-layout/index.tsx @@ -26,6 +26,8 @@ import { } from '../..'; import { Plugin } from '../../application/Plugin'; import { VariablesProvider } from '../../variables'; +import { PageTab } from '../page-style/PageTab'; +import { usePageStyle } from '../page-style/usePageStyle'; import { NoticeArea } from './NoticeArea'; const useStyles = createStyles(({ css, token }) => { @@ -407,6 +409,7 @@ export const InternalAdminLayout = (props: any) => { const app = useApp(); const params = useParams(); const { styles } = useStyles(); + const pageStyle = usePageStyle(); return ( @@ -447,7 +450,7 @@ export const InternalAdminLayout = (props: any) => { {params.name && }
- + {params.name && pageStyle === 'tab' ? : }
); diff --git a/packages/core/client/src/built-in/index.tsx b/packages/core/client/src/built-in/index.tsx index aff04fd14..0211f492f 100644 --- a/packages/core/client/src/built-in/index.tsx +++ b/packages/core/client/src/built-in/index.tsx @@ -9,7 +9,7 @@ import { useTranslation } from 'react-i18next'; import { Navigate, useNavigate } from 'react-router-dom'; import { useAPIClient } from '../api-client'; -import { Application, AttachmentPreviewManager, NoticeLevel, useApp } from '../application'; +import { Application, NoticeLevel, useApp } from '../application'; import { Plugin } from '../application/Plugin'; import { BlockSchemaComponentPlugin } from '../block-provider'; import { CollectionPlugin } from '../collection-manager'; @@ -24,15 +24,14 @@ import { ACLPlugin } from './acl'; import { AdminLayoutPlugin } from './admin-layout'; import { PluginAssistant } from './assistant'; import { AttachmentPreviewPlugin } from './attachment-preview'; -import { PluginBuiltInCollections } from './built-in-collections'; import { PluginContextMenu } from './context-menu'; import { RemoteDocumentTitlePlugin } from './document-title'; import { LocalePlugin } from './locale/LocalePlugin'; +import { PluginPageStyle } from './page-style'; import { PinnedListPlugin } from './pinned-list'; import { PMPlugin } from './pm'; import { SystemSettingsPlugin } from './system-settings'; import { UserSettingsPlugin } from './user-settings'; -import { PluginWebNotification } from './web-notification/PluginWebNotification'; export { AdminProvider, NoticeArea } from './admin-layout'; export * from './context-menu'; @@ -358,5 +357,6 @@ export class BuiltInPlugin extends Plugin { await this.app.pm.add(PluginAssistant, { name: 'drag-assistant' }); await this.app.pm.add(UserSettingsPlugin, { name: 'user-settings' }); await this.app.pm.add(AttachmentPreviewPlugin, { name: 'attachment-preview' }); + await this.app.pm.add(PluginPageStyle, { name: 'page-style' }); } } diff --git a/packages/plugins/@hera/plugin-core/src/client/features/page-style/PageStyle.provider.tsx b/packages/core/client/src/built-in/page-style/PageStyle.provider.tsx similarity index 97% rename from packages/plugins/@hera/plugin-core/src/client/features/page-style/PageStyle.provider.tsx rename to packages/core/client/src/built-in/page-style/PageStyle.provider.tsx index 3e2f173f3..84b421b74 100644 --- a/packages/plugins/@hera/plugin-core/src/client/features/page-style/PageStyle.provider.tsx +++ b/packages/core/client/src/built-in/page-style/PageStyle.provider.tsx @@ -1,8 +1,8 @@ import React, { createContext, useEffect, useState } from 'react'; -import { useCurrentUserContext, useCurrentUserSettingsMenu } from '@tachybase/client'; import { TabsProps } from 'antd'; +import { useCurrentUserContext, useCurrentUserSettingsMenu } from '../../user'; import { useTabSettings } from './useTabSettings'; export interface PageStyleContextValue { diff --git a/packages/plugins/@hera/plugin-core/src/client/features/page-style/PageTab.tsx b/packages/core/client/src/built-in/page-style/PageTab.tsx similarity index 91% rename from packages/plugins/@hera/plugin-core/src/client/features/page-style/PageTab.tsx rename to packages/core/client/src/built-in/page-style/PageTab.tsx index e81775147..1077570d2 100644 --- a/packages/plugins/@hera/plugin-core/src/client/features/page-style/PageTab.tsx +++ b/packages/core/client/src/built-in/page-style/PageTab.tsx @@ -1,9 +1,11 @@ import React, { useContext, useEffect } from 'react'; -import { css, RemoteSchemaComponent, useDocumentTitle } from '@tachybase/client'; +import { css } from '@emotion/css'; import { Tabs } from 'antd'; import { useNavigate, useParams } from 'react-router-dom'; +import { RemoteSchemaComponent } from '../../schema-component'; +import { useDocumentTitle } from '../document-title'; import { PageStyleContext } from './PageStyle.provider'; export const PageTab = () => { diff --git a/packages/plugins/@hera/plugin-core/src/client/features/page-style/index.ts b/packages/core/client/src/built-in/page-style/index.ts similarity index 76% rename from packages/plugins/@hera/plugin-core/src/client/features/page-style/index.ts rename to packages/core/client/src/built-in/page-style/index.ts index 099997425..183fdc8a7 100644 --- a/packages/plugins/@hera/plugin-core/src/client/features/page-style/index.ts +++ b/packages/core/client/src/built-in/page-style/index.ts @@ -1,5 +1,4 @@ -import { Plugin } from '@tachybase/client'; - +import { Plugin } from '../../application/Plugin'; import { PageStyleProvider } from './PageStyle.provider'; export class PluginPageStyle extends Plugin { diff --git a/packages/plugins/@hera/plugin-core/src/client/features/page-style/usePageStyle.tsx b/packages/core/client/src/built-in/page-style/usePageStyle.tsx similarity index 100% rename from packages/plugins/@hera/plugin-core/src/client/features/page-style/usePageStyle.tsx rename to packages/core/client/src/built-in/page-style/usePageStyle.tsx diff --git a/packages/plugins/@hera/plugin-core/src/client/features/page-style/useTabSettings.tsx b/packages/core/client/src/built-in/page-style/useTabSettings.tsx similarity index 89% rename from packages/plugins/@hera/plugin-core/src/client/features/page-style/useTabSettings.tsx rename to packages/core/client/src/built-in/page-style/useTabSettings.tsx index 99ccf3cfa..8f1c7a483 100644 --- a/packages/plugins/@hera/plugin-core/src/client/features/page-style/useTabSettings.tsx +++ b/packages/core/client/src/built-in/page-style/useTabSettings.tsx @@ -1,8 +1,11 @@ import React, { useCallback } from 'react'; -import { SelectWithTitle, useAPIClient, useCurrentUserContext } from '@tachybase/client'; import { error } from '@tachybase/utils/client'; -import { useTranslation } from '../../locale'; +import { useTranslation } from 'react-i18next'; + +import { useAPIClient } from '../../api-client'; +import { SelectWithTitle } from '../../common'; +import { useCurrentUserContext } from '../../user'; export const useTabSettings = () => { return { diff --git a/packages/core/client/src/built-in/pinned-list/PinnedPluginListProvider.tsx b/packages/core/client/src/built-in/pinned-list/PinnedPluginListProvider.tsx index b114cfe89..e9b85b122 100644 --- a/packages/core/client/src/built-in/pinned-list/PinnedPluginListProvider.tsx +++ b/packages/core/client/src/built-in/pinned-list/PinnedPluginListProvider.tsx @@ -38,8 +38,8 @@ const useStyles = createStyles(({ css }) => { export const PinnedPluginList = () => { const { allowAll, snippets } = useACLRoleContext(); - const getSnippetsAllow = (aclKey) => { - return allowAll || snippets?.includes(aclKey); + const getSnippetsAllow = (aclKey, isPublic = false) => { + return allowAll || isPublic || snippets?.includes(aclKey); }; const { styles } = useStyles(); const ctx = useContext(PinnedPluginListContext); @@ -48,7 +48,7 @@ export const PinnedPluginList = () => {
{Object.keys(ctx.items) .sort((a, b) => ctx.items[a].order - ctx.items[b].order) - .filter((key) => getSnippetsAllow(ctx.items[key].snippet)) + .filter((key) => getSnippetsAllow(ctx.items[key].snippet, ctx.items[key].isPublic)) .map((key) => { const Action = get(components, ctx.items[key].component); return Action ? : null; diff --git a/packages/core/client/src/locale/en_US.json b/packages/core/client/src/locale/en_US.json index 9911ea0ad..9a8e6ee93 100644 --- a/packages/core/client/src/locale/en_US.json +++ b/packages/core/client/src/locale/en_US.json @@ -845,5 +845,8 @@ "Full Screen":"Full Screen", "Designer Mode":"Designer Mode", "Embedded page": "Embedded page", + "Page style": "Page Style", + "classical": "classical", + "tabs": "tabs", "There are no full screen blocks available at the current location":"There are no full screen blocks available at the current location" } diff --git a/packages/core/client/src/locale/zh-CN.json b/packages/core/client/src/locale/zh-CN.json index 0545ef5c4..ab8f1d79d 100644 --- a/packages/core/client/src/locale/zh-CN.json +++ b/packages/core/client/src/locale/zh-CN.json @@ -961,5 +961,8 @@ "User settings":"个人设置", "Import collection": "导入数据表", "Embedded page": "嵌入页面", + "Page style": "页面样式", + "classical": "经典", + "tabs": "标签", "Demonstration text": "演示文本" } diff --git a/packages/plugins/@hera/plugin-core/src/client/components/index.ts b/packages/plugins/@hera/plugin-core/src/client/components/index.ts index 1e64b446d..fae14942b 100644 --- a/packages/plugins/@hera/plugin-core/src/client/components/index.ts +++ b/packages/plugins/@hera/plugin-core/src/client/components/index.ts @@ -8,7 +8,5 @@ export * from './custom-components/CustomField'; export * from './fields/AssociatedField'; export * from './fields/CalcResult'; export * from './fields/Expression'; -export * from './system/MobileLink'; -export * from './system/Notifications'; export * from './system/OnlineUserProvider'; export * from './excel-table/ExcelFile'; diff --git a/packages/plugins/@hera/plugin-core/src/client/components/system/MobileLink.tsx b/packages/plugins/@hera/plugin-core/src/client/components/system/MobileLink.tsx deleted file mode 100644 index adc261f2d..000000000 --- a/packages/plugins/@hera/plugin-core/src/client/components/system/MobileLink.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import React from 'react'; -import { css } from '@tachybase/client'; - -import { MobileOutlined } from '@ant-design/icons'; -import { Button, Tooltip } from 'antd'; - -import { useTranslation } from '../../locale'; - -export const MobileLink = () => { - const { t } = useTranslation(); - return ( -
- - - -
- ); -}; diff --git a/packages/plugins/@hera/plugin-core/src/client/components/system/Notifications.tsx b/packages/plugins/@hera/plugin-core/src/client/components/system/Notifications.tsx deleted file mode 100644 index 2d805ee45..000000000 --- a/packages/plugins/@hera/plugin-core/src/client/components/system/Notifications.tsx +++ /dev/null @@ -1,104 +0,0 @@ -import React from 'react'; -import { css, useRequest } from '@tachybase/client'; -import { dayjs } from '@tachybase/utils/client'; - -import { BellOutlined } from '@ant-design/icons'; -import { Badge, Button, List, Popover } from 'antd'; -import { useNavigate } from 'react-router-dom'; - -import { useInitializationLinkKey, useLinkKey } from '../../hooks/useNotifications'; - -export const Notifications = () => { - // 注册链接关联,链接管理使用tachybase代码方式注册数据表 - useInitializationLinkKey(); - const linkDetail = useLinkKey(); - - const navigate = useNavigate(); - const { data, run } = useRequest<{ data: any }>({ - url: `/system_notifications:get`, - }); - const getNotificationList = data?.data || []; - const { run: updateRead } = useRequest<{ data: any }>( - { - url: `/system_notifications:update`, - params: { - ids: getNotificationList.map((item) => item.id), - }, - }, - { - onSuccess() { - run(); - }, - }, - ); - const content = ( - - - - - } - renderItem={(item: any) => ( - - - {item.content} - - )} - /> - ); - return ( -
- - - - - -
- ); -}; diff --git a/packages/plugins/@hera/plugin-core/src/client/features/hera-version/HeraVersion.provider.tsx b/packages/plugins/@hera/plugin-core/src/client/features/hera-version/HeraVersion.provider.tsx index b134f9371..facc56730 100644 --- a/packages/plugins/@hera/plugin-core/src/client/features/hera-version/HeraVersion.provider.tsx +++ b/packages/plugins/@hera/plugin-core/src/client/features/hera-version/HeraVersion.provider.tsx @@ -2,7 +2,6 @@ import React, { useEffect } from 'react'; import { useCurrentUserSettingsMenu } from '@tachybase/client'; import { usePluginVersion } from '../../hooks/usePluginVersion'; -import { useTabSettings } from '../page-style/useTabSettings'; const useHeraVersion = () => { const version = usePluginVersion(); @@ -16,10 +15,9 @@ const useHeraVersion = () => { export const HeraVersionProvider = ({ children }) => { const { addMenuItem } = useCurrentUserSettingsMenu(); const heraVersion = useHeraVersion(); - const tabItem = useTabSettings(); useEffect(() => { addMenuItem(heraVersion, { before: 'divider_1' }); - }, [addMenuItem, tabItem, heraVersion]); + }, [addMenuItem, heraVersion]); return <>{children}; }; diff --git a/packages/plugins/@hera/plugin-core/src/client/index.tsx b/packages/plugins/@hera/plugin-core/src/client/index.tsx index 6a76945a8..98ce3b4c2 100644 --- a/packages/plugins/@hera/plugin-core/src/client/index.tsx +++ b/packages/plugins/@hera/plugin-core/src/client/index.tsx @@ -21,7 +21,6 @@ import { EmbedPlugin } from './features/embed'; import { PluginFieldAppends } from './features/field-appends'; import { PluginHeraVersion } from './features/hera-version'; import { PluginOutbound } from './features/outbound'; -import { PluginPageStyle } from './features/page-style'; import { PluginPDF } from './features/pdf'; import { PluginSheet } from './features/sheet'; import { useGetCustomAssociatedComponents } from './hooks/useGetCustomAssociatedComponents'; @@ -36,7 +35,7 @@ import { } from './interfaces'; import { TstzrangeFieldInterface } from './interfaces/TstzrangeFieldInterface'; import { Locale, tval } from './locale'; -import { AdminLayout, DetailsPage, PageLayout } from './pages'; +import { DetailsPage, PageLayout } from './pages'; import { CreateSubmitActionInitializer, SettingBlockInitializer } from './schema-initializer'; import { useCreateActionProps } from './schema-initializer/actions/hooks/useCreateActionProps'; import { EditTitle, IsTablePageSize, PageModeSetting, usePaginationVisible } from './schema-settings'; @@ -59,7 +58,6 @@ export class PluginCoreClient extends Plugin { await this.app.pm.add(PluginGroupBlock); await this.app.pm.add(EmbedPlugin); await this.app.pm.add(DepartmentsPlugin); - await this.app.pm.add(PluginPageStyle); await this.app.pm.add(PluginHeraVersion); await this.app.pm.add(PluginPDF); await this.app.pm.add(PluginOutbound); @@ -115,7 +113,6 @@ export class PluginCoreClient extends Plugin { }); this.app.addComponents({ - AdminLayout, AssociatedField, CalcResult, CodeMirror, diff --git a/packages/plugins/@hera/plugin-core/src/client/pages/AdminLayout.tsx b/packages/plugins/@hera/plugin-core/src/client/pages/AdminLayout.tsx deleted file mode 100644 index 4b7374d45..000000000 --- a/packages/plugins/@hera/plugin-core/src/client/pages/AdminLayout.tsx +++ /dev/null @@ -1,384 +0,0 @@ -import React, { createContext, useContext, useEffect, useMemo, useRef, useState } from 'react'; -import { - AdminProvider, - css, - CurrentUser, - findByUid, - findMenuItem, - NoticeArea, - PinnedPluginList, - SchemaComponent, - useACLRoleContext, - useAdminSchemaUid, - useApp, - useDocumentTitle, - useRequest, - useSystemSettings, - useToken, -} from '@tachybase/client'; - -import { useSessionStorageState } from 'ahooks'; -import { App, Layout } from 'antd'; -import { Link, Outlet, useMatch, useNavigate, useParams } from 'react-router-dom'; - -import { MobileLink } from '../components/system/MobileLink'; -import { Notifications } from '../components/system/Notifications'; -import { OnlineUserDropdown } from '../components/system/OnlineUserProvider'; -import { PageTab } from '../features/page-style/PageTab'; -import { usePageStyle } from '../features/page-style/usePageStyle'; - -const filterByACL = (schema, options) => { - const { allowAll, allowMenuItemIds = [] } = options; - if (allowAll) { - return schema; - } - const filterSchema = (s) => { - if (!s) { - return; - } - for (const key in s.properties) { - if (Object.prototype.hasOwnProperty.call(s.properties, key)) { - const element = s.properties[key]; - if (element['x-uid'] && !allowMenuItemIds.includes(element['x-uid'])) { - delete s.properties[key]; - } - if (element['x-uid']) { - filterSchema(element); - } - } - } - }; - filterSchema(schema); - return schema; -}; - -const SchemaIdContext = createContext(null); -const useMenuProps = () => { - const defaultSelectedUid = useContext(SchemaIdContext); - return { - selectedUid: defaultSelectedUid, - defaultSelectedUid, - }; -}; - -const MenuEditor = (props) => { - const { notification } = App.useApp(); - const [hasNotice, setHasNotice] = useSessionStorageState('plugin-notice', { defaultValue: false }); - const { setTitle } = useDocumentTitle(); - const navigate = useNavigate(); - const params = useParams(); - const isMatchAdmin = useMatch('/admin'); - const isMatchAdminName = useMatch('/admin/:name'); - const defaultSelectedUid = params.name; - const { sideMenuRef } = props; - const ctx = useACLRoleContext(); - const [current, setCurrent] = useState(null); - const onSelect = ({ item }) => { - const schema = item.props.schema; - setTitle(schema.title); - setCurrent(schema); - navigate(`/admin/${schema['x-uid']}`); - }; - const adminSchemaUid = useAdminSchemaUid(); - const { data, loading } = useRequest<{ - data: any; - }>( - { - url: `/uiSchemas:getJsonSchema/${adminSchemaUid}`, - }, - { - refreshDeps: [adminSchemaUid], - onSuccess(data) { - const schema = filterByACL(data?.data, ctx); - // url 为 `/admin` 的情况 - if (isMatchAdmin) { - const s = findMenuItem(schema); - if (s) { - navigate(`/admin/${s['x-uid']}`); - setTitle(s.title); - } else { - navigate(`/admin/`); - } - return; - } - - // url 不为 `/admin/xxx` 的情况,不做处理 - if (!isMatchAdminName) return; - - // url 为 `admin/xxx` 的情况 - const s = findByUid(schema, defaultSelectedUid); - if (s) { - setTitle(s.title); - } else { - const s = findMenuItem(schema); - if (s) { - navigate(`/admin/${s['x-uid']}`); - setTitle(s.title); - } else { - navigate(`/admin/`); - } - } - }, - }, - ); - - useEffect(() => { - const properties = Object.values(current?.root?.properties || {}).shift()?.['properties'] || data?.data?.properties; - if (properties && sideMenuRef.current) { - const pageType = Object.values(properties).find( - (item) => item['x-uid'] === params.name && item['x-component'] === 'Menu.Item', - ); - if (pageType) { - sideMenuRef.current.style.display = 'none'; - } else { - sideMenuRef.current.style.display = 'block'; - } - } - }, [data?.data, params.name, sideMenuRef]); - - const schema = useMemo(() => { - const s = filterByACL(data?.data, ctx); - if (s?.['x-component-props']) { - s['x-component-props']['useProps'] = useMenuProps; - } - return s; - }, [data?.data]); - - useRequest( - { - url: 'applicationPlugins:list', - params: { - sort: 'id', - paginate: false, - }, - }, - { - onSuccess: ({ data }) => { - setHasNotice(true); - const errorPlugins = data.filter((item) => !item.isCompatible); - if (errorPlugins.length) { - notification.error({ - message: 'Plugin dependencies check failed', - description: ( -
-
- These plugins failed dependency checks. Please go to the{' '} - plugin management page for more details.{' '} -
-
    - {errorPlugins.map((item) => ( -
  • - {item.displayName} - {item.packageName} -
  • - ))} -
-
- ), - }); - } - }, - manual: true, - // ready: !hasNotice, - }, - ); - - if (loading) { - return void 0; - } - return ( - - - - ); -}; - -export const InternalAdminLayout = () => { - const sideMenuRef = useRef(); - const result = useSystemSettings(); - const params = useParams<{ name?: string }>(); - const app = useApp(); - const { token } = useToken(); - const pageStyle = usePageStyle(); - - return ( - - .ant-menu-item:hover { - background-color: ${token.colorBgHeaderMenuHover}; - color: ${token.colorTextHeaderMenuHover}; - } - - position: fixed; - left: 0; - right: 0; - height: var(--tb-header-height); - line-height: var(--tb-header-height); - padding: 0; - z-index: 100; - background-color: ${token.colorBgHeader}; - - .ant-menu { - background-color: transparent; - } - - .ant-menu-item { - color: ${token.colorTextHeaderMenu}; - } - `} - > -
-
-
{ - location.href = app.adminUrl; - }} - > - -

- {result?.data?.data?.title} -

-
-
- - -
-
-
- - - - - -
-
-
- {params.name && ( - -
-
- )} - div { - position: relative; - } - .ant-layout-footer { - position: absolute; - bottom: 0; - text-align: center; - width: 100%; - z-index: 0; - padding: 0px 50px; - } - `} - > -
- <>{params.name && pageStyle === 'tab' ? : } -
-
- ); -}; - -export const AdminLayout = (props) => { - const AdminComponent = ( - - - - ); - return AdminComponent; -}; diff --git a/packages/plugins/@hera/plugin-core/src/client/pages/index.ts b/packages/plugins/@hera/plugin-core/src/client/pages/index.ts index 78f33ce89..d23b4a1f5 100644 --- a/packages/plugins/@hera/plugin-core/src/client/pages/index.ts +++ b/packages/plugins/@hera/plugin-core/src/client/pages/index.ts @@ -1,4 +1,3 @@ -export * from './AdminLayout'; export * from './DetailsPage'; export * from '../features/outbound/OutboundPage'; export * from './PageLayout'; diff --git a/packages/plugins/@tachybase/plugin-messages/package.json b/packages/plugins/@tachybase/plugin-messages/package.json index bcff5679c..931e8a949 100644 --- a/packages/plugins/@tachybase/plugin-messages/package.json +++ b/packages/plugins/@tachybase/plugin-messages/package.json @@ -3,11 +3,16 @@ "version": "0.22.4", "main": "dist/server/index.js", "dependencies": { - "antd": "5.19.4" + "@ant-design/icons": "~5.3.7", + "antd": "5.19.4", + "react-i18next": "^14.1.2", + "react-router-dom": "~6.25.1" }, "peerDependencies": { "@tachybase/client": "workspace:*", "@tachybase/database": "workspace:*", + "@tachybase/plugin-workflow": "workspace:*", + "@tachybase/schema": "workspace:*", "@tachybase/server": "workspace:*", "@tachybase/test": "workspace:*" } diff --git a/packages/plugins/@tachybase/plugin-messages/src/client/MessageBlockInitializer.tsx b/packages/plugins/@tachybase/plugin-messages/src/client/MessageBlockInitializer.tsx new file mode 100644 index 000000000..63430bd82 --- /dev/null +++ b/packages/plugins/@tachybase/plugin-messages/src/client/MessageBlockInitializer.tsx @@ -0,0 +1,39 @@ +import React from 'react'; +import { + createTableBlockSchema, + SchemaInitializerItem, + useSchemaInitializer, + useSchemaInitializerItem, +} from '@tachybase/client'; +import { ISchema } from '@tachybase/schema'; + +import { BellOutlined } from '@ant-design/icons'; + +import { useTranslation } from './locale'; + +export const MessageBlockInitializer = () => { + const { insert } = useSchemaInitializer(); + const { t } = useTranslation(); + const itemConfig = useSchemaInitializerItem(); + + const schema = createTableBlockSchema({ + collection: 'messages', + rowKey: 'id', + tableActionInitializers: 'MessageTable:configureActions', + tableColumnInitializers: 'MessageTable:configureColumns', + tableActionColumnInitializers: 'MessageTable:configureItemActions', + tableBlockProvider: 'MessageBlockProvider', + disableTemplate: true, + }); + + return ( + } + onClick={() => { + insert(schema as ISchema); + }} + title={t('Messages')} + {...itemConfig} + /> + ); +}; diff --git a/packages/plugins/@tachybase/plugin-messages/src/client/MessageBlockProvider.tsx b/packages/plugins/@tachybase/plugin-messages/src/client/MessageBlockProvider.tsx new file mode 100644 index 000000000..b6fb27210 --- /dev/null +++ b/packages/plugins/@tachybase/plugin-messages/src/client/MessageBlockProvider.tsx @@ -0,0 +1,18 @@ +import React from 'react'; +import { ExtendCollectionsProvider, TableBlockProvider } from '@tachybase/client'; + +import { useAuditChangesCollection, useCollectionsCollection, useMessageCollection } from './collections'; + +export const MessageBlockProvider = ({ children, ...restProps }) => { + const auditChangesCollection = useAuditChangesCollection(); + const MessageCollection = useMessageCollection(); + const collectionsCollection = useCollectionsCollection(); + + return ( + + + {children} + + + ); +}; diff --git a/packages/plugins/@tachybase/plugin-messages/src/client/MessageNotificationProvider.tsx b/packages/plugins/@tachybase/plugin-messages/src/client/MessageNotificationProvider.tsx new file mode 100644 index 000000000..0f13d7fa5 --- /dev/null +++ b/packages/plugins/@tachybase/plugin-messages/src/client/MessageNotificationProvider.tsx @@ -0,0 +1,37 @@ +import React from 'react'; +import { PinnedPluginListProvider, SchemaComponentOptions, useToken } from '@tachybase/client'; + +import { BellOutlined } from '@ant-design/icons'; +import { Button, Tooltip } from 'antd'; +import { useNavigate } from 'react-router-dom'; + +import { useTranslation } from './locale'; + +const NotificationLink = () => { + const navigate = useNavigate(); + const { token } = useToken(); + const { t } = useTranslation(); + return ( + +