Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

feat(view): view support group menu

lawvsaa320a174ba5
diff --git a/libs/components/editor-blocks/src/blocks/group/GroupMenu.tsx b/libs/components/editor-blocks/src/blocks/group/GroupMenu.tsx
index 967b9b3afc..1d79daba9f 100644
--- a/libs/components/editor-blocks/src/blocks/group/GroupMenu.tsx
+++ b/libs/components/editor-blocks/src/blocks/group/GroupMenu.tsx
@@ -1,35 +1,61 @@
-import { useState } from 'react';
-import type { ReactNode } from 'react';
+import { CommingSoon } from '@toeverything/components/common';
import {
mergeToPreviousGroup,
RecastScene,
+ RecastView,
useRecastBlockScene,
useRecastKanbanGroupBy,
+ useRecastView,
} from '@toeverything/components/editor-core';
-import { Popover, useTheme, Tooltip } from '@toeverything/components/ui';
-import type { AsyncBlock, BlockEditor } from '@toeverything/framework/virgo';
-import { Filter } from './components/filter';
-import { Sorter } from './components/sorter';
-import { GroupPanel } from './components/group-panel/GroupPanel';
-import { IconButton } from './components/IconButton';
-import { Line } from './components/Line';
import {
- TodoListIcon,
- KanBanIcon,
- TableIcon,
+ AddViewIcon,
FilterIcon,
- SortIcon,
FullScreenIcon,
- GroupIcon,
GroupByIcon,
+ GroupIcon,
+ KanBanIcon,
+ SortIcon,
+ TableIcon,
+ TodoListIcon,
} from '@toeverything/components/icons';
-import { PANEL_CONFIG, SCENE_CONFIG } from './config';
-
-import type { ActivePanel } from './types';
+import { Popover, useTheme } from '@toeverything/components/ui';
import { useFlag } from '@toeverything/datasource/feature-flags';
+import type { AsyncBlock, BlockEditor } from '@toeverything/framework/virgo';
+import type { ReactElement, ReactNode } from 'react';
+import { useState } from 'react';
+import { Filter } from './components/filter';
import { GroupBy } from './components/group-by/GroupBy';
+import { GroupPanel } from './components/group-panel/GroupPanel';
+import { IconButton } from './components/IconButton';
+import { Line } from './components/Line';
+import { Sorter } from './components/sorter';
+import { PANEL_CONFIG, SCENE_CONFIG } from './config';
+import type { ActivePanel } from './types';
+
+const VIEW_ICON_MAP: Record<RecastView['type'], ReactElement> = {
+ page: <TodoListIcon fontSize="small" />,
+ kanban: <KanBanIcon fontSize="small" />,
+ table: <TableIcon fontSize="small" />,
+};
+
+const ViewsMenu = () => {
+ const { currentView, recastViews, changeView } = useRecastView();
+ return (
+ <>
+ {recastViews.map(view => (
+ <IconButton
+ key={view.id}
+ active={view.id === currentView.id}
+ onClick={() => changeView(view)}
+ >
+ {VIEW_ICON_MAP[view.type]}
+ {view.name}
+ </IconButton>
+ ))}
+ </>
+ );
+};
-import { CommingSoon } from '@toeverything/components/common';
const GroupMenuWrapper = ({
block,
editor,
@@ -59,7 +85,6 @@ const GroupMenuWrapper = ({
if (!groupBy?.id) {
setActivePanel(null);
}
-
setOpenPanel(null);
};
@@ -97,6 +122,18 @@ const GroupMenuWrapper = ({
<KanBanIcon fontSize="small" />
Kanban
</IconButton>
+
+ <ViewsMenu />
+ <IconButton
+ active={activePanel === PANEL_CONFIG.ADD_VIEW}
+ onClick={() =>
+ setActivePanel(PANEL_CONFIG.ADD_VIEW as ActivePanel)
+ }
+ >
+ <AddViewIcon fontSize="small" />
+ Add View
+ </IconButton>
+
{
// // Closed beta period temporarily
// filterSorterFlag && (