Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✨ feat: polish acceptance rejection flow (#18168)

Arvin Xu8abf30d72cb1
diff --git a/locales/en-US/electron.json b/locales/en-US/electron.json
index eb2c4289779..a9a1240bc9a 100644
--- a/locales/en-US/electron.json
+++ b/locales/en-US/electron.json
@@ -39,6 +39,13 @@
"navigation.profile": "Agent Profile",
"navigation.provider": "Provider",
"navigation.recentView": "Recent pages",
+ "navigation.resourceAll": "All",
+ "navigation.resourceAudios": "Audio",
+ "navigation.resourceDocuments": "Documents",
+ "navigation.resourceFiles": "Files",
+ "navigation.resourceImages": "Images",
+ "navigation.resourcePages": "Pages",
+ "navigation.resourceVideos": "Videos",
"navigation.resources": "Resources",
"navigation.settings": "Settings",
"navigation.stats": "Statistics",
diff --git a/locales/zh-CN/electron.json b/locales/zh-CN/electron.json
index 0eaf7bf3290..ef765e97e46 100644
--- a/locales/zh-CN/electron.json
+++ b/locales/zh-CN/electron.json
@@ -39,6 +39,13 @@
"navigation.profile": "助理档案",
"navigation.provider": "模型服务商",
"navigation.recentView": "最近访问",
+ "navigation.resourceAll": "全部",
+ "navigation.resourceAudios": "语音",
+ "navigation.resourceDocuments": "文档",
+ "navigation.resourceFiles": "文件",
+ "navigation.resourceImages": "图片",
+ "navigation.resourcePages": "文稿",
+ "navigation.resourceVideos": "视频",
"navigation.resources": "资源",
"navigation.settings": "设置",
"navigation.stats": "统计",
diff --git a/packages/locales/src/default/electron.ts b/packages/locales/src/default/electron.ts
index 15503ea5a04..9b9904179a1 100644
--- a/packages/locales/src/default/electron.ts
+++ b/packages/locales/src/default/electron.ts
@@ -33,6 +33,13 @@ export default {
'navigation.provider': 'Provider',
'navigation.recentView': 'Recent pages',
'navigation.resources': 'Resources',
+ 'navigation.resourceAll': 'All',
+ 'navigation.resourceAudios': 'Audio',
+ 'navigation.resourceDocuments': 'Documents',
+ 'navigation.resourceFiles': 'Files',
+ 'navigation.resourceImages': 'Images',
+ 'navigation.resourcePages': 'Pages',
+ 'navigation.resourceVideos': 'Videos',
'navigation.settings': 'Settings',
'navigation.stats': 'Statistics',
'navigation.task': 'Task',
diff --git a/src/features/ResourceHome/index.test.ts b/src/features/ResourceHome/index.test.ts
new file mode 100644
index 00000000000..4a91cea02dc
--- /dev/null
+++ b/src/features/ResourceHome/index.test.ts
@@ -0,0 +1,20 @@
+import { describe, expect, it } from 'vitest';
+
+import { resolveResourcePathCategory } from './index';
+
+describe('resolveResourcePathCategory', () => {
+ it.each(['all', 'documents', 'images', 'videos', 'audios', 'files', 'page'])(
+ 'recovers the %s category for a static resource route',
+ (category) => {
+ expect(resolveResourcePathCategory(undefined, `/resource/${category}`)).toBe(category);
+ },
+ );
+
+ it('preserves a dynamic category param when one exists', () => {
+ expect(resolveResourcePathCategory('websites', '/resource/websites')).toBe('websites');
+ });
+
+ it('keeps the resource dashboard uncategorized', () => {
+ expect(resolveResourcePathCategory(undefined, '/resource')).toBeUndefined();
+ });
+});
diff --git a/src/features/ResourceHome/index.tsx b/src/features/ResourceHome/index.tsx
index 7bea32ec56d..e7130e516aa 100644
--- a/src/features/ResourceHome/index.tsx
+++ b/src/features/ResourceHome/index.tsx
@@ -36,6 +36,11 @@ const SEGMENT_BY_CATEGORY = Object.fromEntries(
export const resourceCategoryPath = (category: FilesTabs): string =>
SEGMENT_BY_CATEGORY[category] ? `/resource/${SEGMENT_BY_CATEGORY[category]}` : '/resource';
+export const resolveResourcePathCategory = (
+ category: string | undefined,
+ pathname: string,
+): string | undefined => category ?? pathname.match(/\/resource\/([^/]+)\/?$/)?.[1];
+
/** Path segment of the cross-topic Work gallery: /resource/works */
export const WORKS_PATH_SEGMENT = 'works';
@@ -49,10 +54,9 @@ const ResourceHomePage = memo(() => {
s.setLibraryId,
]);
- // /resource/page is a static route (no :category param) — recover the
- // segment from the pathname there.
- const pathCategory =
- params.category ?? (/\/resource\/page\/?$/.test(location.pathname) ? 'page' : undefined);
+ // Category-specific route metadata uses static sibling routes, so recover
+ // their segment from the pathname when React Router has no :category param.
+ const pathCategory = resolveResourcePathCategory(params.category, location.pathname);
const segmentCategory = pathCategory ? CATEGORY_BY_SEGMENT[pathCategory] : undefined;
const isValidPathCategory = segmentCategory !== undefined;
// The Work gallery owns its own path segment; `?works=<key>` narrows it
diff --git a/src/features/Verify/Acceptance/CheckList.test.ts b/src/features/Verify/Acceptance/CheckList.test.ts
index 00a9f88bf16..b56d8cc182c 100644
--- a/src/features/Verify/Acceptance/CheckList.test.ts
+++ b/src/features/Verify/Acceptance/CheckList.test.ts
@@ -8,10 +8,16 @@ import {
hasAnnotatableEvidence,
hasVisualEvidence,
isCheckWorkActionable,
+ shouldCollapseAfterReview,
shouldGroupChecks,
userReviewState,
} from './CheckList';
-import { mergeRejectComments } from './CheckRejectModal';
+import {
+ canDismissRejectModal,
+ CHECK_REJECT_MODAL_SIZE,
+ mergeRejectComments,
+ rejectModalTitle,
+} from './CheckRejectModal';
const check = (id: string, category: string | null, surface: AcceptanceCheck['surface']) =>
({ category, id, surface }) as AcceptanceCheck;
@@ -133,6 +139,29 @@ describe('mergeRejectComments', () => {
});
});
+describe('check reject modal presentation', () => {
+ it('keeps 1% viewport breathing room around the annotation surface', () => {
+ expect(CHECK_REJECT_MODAL_SIZE).toEqual({ height: '98dvh', width: '98vw' });
+ });
+
+ it('shows the acceptance item description below its title', () => {
+ expect(
+ rejectModalTitle(
+ 'C1 · Select Set Goal from the slash menu',
+ 'The selected goal chip appears after pressing Enter.',
+ ),
+ ).toEqual({
+ description: 'The selected goal chip appears after pressing Enter.',
+ title: 'C1 · Select Set Goal from the slash menu',
+ });
+ });
+
+ it('prevents outside dismissal while the reject request is pending', () => {
+ expect(canDismissRejectModal(true)).toBe(false);
+ expect(canDismissRejectModal(false)).toBe(true);
+ });
+});
+
describe('userReviewState', () => {
const withReview = (userReview: AcceptanceCheck['userReview']) =>
({ userReview }) as AcceptanceCheck;
@@ -203,6 +232,17 @@ describe('isCheckWorkActionable', () => {
});
});
+describe('shouldCollapseAfterReview', () => {
+ it('folds an expanded check after its reject is recorded', () => {
+ expect(shouldCollapseAfterReview(true, true)).toBe(true);
+ });
+
+ it('keeps the row unchanged when the review fails or it is already folded', () => {
+ expect(shouldCollapseAfterReview(false, true)).toBe(false);
+ expect(shouldCollapseAfterReview(true, false)).toBe(false);
+ });
+});
+
describe('checkFilterState', () => {
const reject = (stale: boolean): AcceptanceCheck['userReview'] => ({
action: 'reject',
diff --git a/src/features/Verify/Acceptance/CheckList.tsx b/src/features/Verify/Acceptance/CheckList.tsx
index f5ac5e4ad8b..926aef1ed91 100644
--- a/src/features/Verify/Acceptance/CheckList.tsx
+++ b/src/features/Verify/Acceptance/CheckList.tsx
@@ -97,6 +97,10 @@ export const userReviewState = (check: AcceptanceCheck): UserReviewState => {
export const isCheckWorkActionable = (check: AcceptanceCheck): boolean =>
['pending', 'rejected'].includes(userReviewState(check));
+/** A successful review decision moves the reviewer forward by folding the finished row. */
+export const shouldCollapseAfterReview = (succeeded: boolean, expanded: boolean): boolean =>
+ succeeded && expanded;
+
/** Every reviewable check in the group is user-accepted — settled business. */
export const isGroupFullyAccepted = (checks: AcceptanceCheck[]): boolean => {
const reviewable = checks.filter((check) => check.result);
@@ -875,6 +879,7 @@ const CheckRow = memo<{
const openReject = () =>
openCheckRejectModal({
+ checkDescription: check.planItem?.description,
checkTitle: `C${check.seq} · ${check.title}`,
draftKey: check.id,
evidence: check.evidence
@@ -889,7 +894,10 @@ const CheckRow = memo<{
comment: comment || undefined,
fileIds: fileIds.length > 0 ? fileIds : undefined,
});
- if (ok) setReviewComment('');
+ if (ok) {
+ setReviewComment('');
+ if (shouldCollapseAfterReview(ok, expanded)) onToggle();
+ }
return ok;
},
});
@@ -907,7 +915,7 @@ const CheckRow = memo<{
});
setAccepting(false);
if (ok) setReviewComment('');
- if (ok && expanded) onToggle();
+ if (shouldCollapseAfterReview(ok, expanded)) onToggle();
};
const handleReject = async (event: { stopPropagation: () => void }) => {
@@ -918,6 +926,7 @@ const CheckRow = memo<{
const ok = await onReview({ action: 'reject', checkItemIds: [check.id], comment });
setRejecting(false);
if (ok) setReviewComment('');
+ if (shouldCollapseAfterReview(ok, expanded)) onToggle();
};
const handleIgnore = async (event: { stopPropagation: () => void }) => {
@@ -925,7 +934,7 @@ const CheckRow = memo<{
setIgnoring(true);
const ok = await onReview({ action: 'ignore', checkItemIds: [check.id] });
setIgnoring(false);
- if (ok && expanded) onToggle();
+ if (shouldCollapseAfterReview(ok, expanded)) onToggle();
};
// The user's standing verdict owns the head slot: a reject replaces the
diff --git a/src/features/Verify/Acceptance/CheckRejectModal.tsx b/src/features/Verify/Acceptance/CheckRejectModal.tsx
index 293960365eb..4f835f10bee 100644
--- a/src/features/Verify/Acceptance/CheckRejectModal.tsx
+++ b/src/features/Verify/Acceptance/CheckRejectModal.tsx
@@ -2,18 +2,24 @@
import type { AcceptanceReviewAnnotation } from '@lobechat/types';
import { ActionIcon, Flexbox, Text, TextArea } from '@lobehub/ui';
-import { Button, Drawer } from '@lobehub/ui/base-ui';
+import { Button, createModal, useModalContext } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar, cx } from 'antd-style';
import { ZoomIn, ZoomOut } from 'lucide-react';
import { memo, useEffect, useLayoutEffect, useRef, useState } from 'react';
import { useTranslation } from 'react-i18next';
-import { mountImperative } from '@/components/ImperativeMount';
-
import { AnnotationCanvas } from './Annotation';
import { AttachmentStrip, AttachmentUploadButton, useFeedbackAttachments } from './attachments';
+import { frostedModalStyles } from './modals';
const styles = createStaticStyles(({ css }) => ({
+ modalPopup: css`
+ > div {
+ display: flex;
+ flex-direction: column;
+ height: 100%;
+ }
+ `,
fullscreenBody: css`
display: flex;
flex: 1;
@@ -25,6 +31,20 @@ const styles = createStaticStyles(({ css }) => ({
gap: 12px;
}
`,
+ modalBody: css`
+ overflow: hidden;
+ display: flex;
+ flex: 1;
+ flex-direction: column;
+
+ min-height: 0;
+ `,
+ modalFooter: css`
+ flex: none;
+ padding-block: 12px;
+ padding-inline: 20px;
+ border-block-start: 1px solid ${cssVar.colorBorderSecondary};
+ `,
regionIndex: css`
flex: none;
@@ -164,7 +184,17 @@ const readDraft = (key: string | undefined): RejectDraft | null => {
const ZOOM_STEPS = [0.5, 0.75, 1, 1.5, 2, 3, 4];
+export const CHECK_REJECT_MODAL_SIZE = { height: '98dvh', width: '98vw' } as const;
+
+export const rejectModalTitle = (title: string, description?: string) => ({
+ description: description?.trim() || undefined,
+ title,
+});
+
+export const canDismissRejectModal = (loading: boolean) => !loading;
+
interface CheckRejectModalProps {
+ checkDescription?: string;
checkTitle: string;
/** Stable key (the check id) for the refresh-surviving draft cache. */
draftKey?: string;
@@ -179,11 +209,6 @@ interface CheckRejectModalProps {
}) => Promise<boolean>;
}
-interface CheckRejectDrawerProps extends CheckRejectModalProps {
- onClose: () => void;
- open: boolean;
-}
-
export const mergeRejectComments = (initialComment = '', storedComment = '') => {
const initial = initialComment.trim();
const stored = storedComment.trim();
@@ -192,9 +217,10 @@ export const mergeRejectComments = (initialComment = '', storedComment = '') =>
return `${initial}\n\n${stored}`;
};
-const CheckRejectDrawer = memo<CheckRejectDrawerProps>(
- ({ checkTitle, draftKey, evidence, initialComment, onClose, onConfirm, open }) => {
+const CheckRejectModalContent = memo<CheckRejectModalProps>(
+ ({ checkTitle, draftKey, evidence, initialComment, onConfirm }) => {
const { t: translate } = useTranslation('verify');
+ const { close, setCanDismissByClickOutside } = useModalContext();
const [draft] = useState(() => readDraft(draftKey));
const [comment, setComment] = useState(() =>
mergeRejectComments(initialComment, draft?.comment),
@@ -210,6 +236,10 @@ const CheckRejectDrawer = memo<CheckRejectDrawerProps>(
.map((entry) => ({ ...entry, key: nextAnnotationKey() })),
);
+ useEffect(() => {
+ setCanDismissByClickOutside(canDismissRejectModal(loading));
+ }, [loading, setCanDismissByClickOutside]);
+
// Your own screenshots (paste or upload) — attached to the reject alongside
// the note and any circled regions.
const { attachments, fileIds, handlePaste, remove, uploadFiles, uploading } =
@@ -219,7 +249,7 @@ const CheckRejectDrawer = memo<CheckRejectDrawerProps>(
const viewportRef = useRef<HTMLDivElement>(null);
const [viewportWidth, setViewportWidth] = useState<number>();
useLayoutEffect(() => {
- if (!open || evidence.length === 0) return;
+ if (evidence.length === 0) return;
let observer: ResizeObserver | undefined;
let raf = 0;
// The Modal body mounts async (portal + open animation), so the ref may
@@ -242,7 +272,7 @@ const CheckRejectDrawer = memo<CheckRejectDrawerProps>(
cancelAnimationFrame(raf);
observer?.disconnect();
};
- }, [activeEvidenceId, evidence.length, open]);
+ }, [activeEvidenceId, evidence.length]);
// Persist the draft as it is typed; an empty draft cleans the slot up.
useEffect(() => {
@@ -294,7 +324,7 @@ const CheckRejectDrawer = memo<CheckRejectDrawerProps>(
});
if (confirmed) {
if (draftKey) localStorage.removeItem(draftStorageKey(draftKey));
- onClose();
+ close();
}
} finally {
setLoading(false);
@@ -384,7 +414,7 @@ const CheckRejectDrawer = memo<CheckRejectDrawerProps>(
onRemove={remove}
/>
</Flexbox>
- <Button disabled={loading} onClick={onClose}>
+ <Button disabled={loading} onClick={close}>
{translate('acceptance.actions.cancel')}
</Button>
<Button
@@ -400,85 +430,100 @@ const CheckRejectDrawer = memo<CheckRejectDrawerProps>(
);
return (
- <Drawer
- containerMaxWidth={'100%'}
- footer={footer}
- maskClosable={!loading}
- open={open}
- placement={'right'}
- title={translate('acceptance.review.reject')}
- width={hasEvidence ? '100vw' : 'min(92vw, 520px)'}
- styles={{
- bodyContent: { height: '100%', padding: hasEvidence ? 16 : 20 },
- content: { minHeight: 0 },
- footer: { paddingBlock: 12 },
- header: { paddingBlock: 10 },
- }}
- onClose={loading ? undefined : onClose}
- >
- {activeEvidence ? (
- <Flexbox gap={12} height={'100%'} style={{ minHeight: 0 }}>
- {thumbnails}
- <div className={styles.fullscreenBody} style={{ position: 'relative' }}>
- <div className={styles.viewport} ref={viewportRef}>
- <div className={styles.viewportInner}>
- <AnnotationCanvas
- annotations={activeAnnotations}
- imageWidth={viewportWidth ? Math.max(viewportWidth * zoom - 2, 0) : undefined}
- src={activeEvidence.fileUrl}
- {...canvasHandlers}
+ <div className={styles.modalBody}>
+ <Flexbox flex={1} gap={12} padding={hasEvidence ? 16 : 20} style={{ minHeight: 0 }}>
+ {activeEvidence ? (
+ <Flexbox gap={12} height={'100%'} style={{ minHeight: 0 }}>
+ {thumbnails}
+ <div className={styles.fullscreenBody} style={{ position: 'relative' }}>
+ <div className={styles.viewport} ref={viewportRef}>
+ <div className={styles.viewportInner}>
+ <AnnotationCanvas
+ annotations={activeAnnotations}
+ imageWidth={viewportWidth ? Math.max(viewportWidth * zoom - 2, 0) : undefined}
+ src={activeEvidence.fileUrl}
+ {...canvasHandlers}
+ />
+ </div>
+ </div>
+ <div className={styles.zoomBar}>
+ <ActionIcon
+ disabled={zoom <= ZOOM_STEPS[0]}
+ icon={ZoomOut}
+ size={'small'}
+ title={translate('acceptance.review.zoomOut')}
+ onClick={() => stepZoom(-1)}
+ />
+ <span className={styles.zoomLabel}>{Math.round(zoom * 100)}%</span>
+ <ActionIcon
+ disabled={zoom >= ZOOM_STEPS.at(-1)!}
+ icon={ZoomIn}
+ size={'small'}
+ title={translate('acceptance.review.zoomIn')}
+ onClick={() => stepZoom(1)}
/>
</div>
+ <div className={styles.sidePanel}>
+ <Flexbox gap={2}>
+ <Text strong fontSize={13}>
+ {translate('acceptance.review.regionComments')}
+ </Text>
+ <Text fontSize={12} type={'secondary'}>
+ {translate('acceptance.review.annotateHint')}
+ </Text>
+ </Flexbox>
+ {activeAnnotations.length === 0 && (
+ <Text fontSize={12} type={'secondary'}>
+ {translate('acceptance.review.regionCommentsEmpty')}
+ </Text>
+ )}
+ {annotationInputs}
+ </div>
</div>
- <div className={styles.zoomBar}>
- <ActionIcon
- disabled={zoom <= ZOOM_STEPS[0]}
- icon={ZoomOut}
- size={'small'}
- title={translate('acceptance.review.zoomOut')}
- onClick={() => stepZoom(-1)}
- />
- <span className={styles.zoomLabel}>{Math.round(zoom * 100)}%</span>
- <ActionIcon
- disabled={zoom >= ZOOM_STEPS.at(-1)!}
- icon={ZoomIn}
- size={'small'}
- title={translate('acceptance.review.zoomIn')}
- onClick={() => stepZoom(1)}
- />
- </div>
- <div className={styles.sidePanel}>
- <Flexbox gap={2}>
- <Text strong fontSize={13}>
- {translate('acceptance.review.regionComments')}
- </Text>
- <Text fontSize={12} type={'secondary'}>
- {translate('acceptance.review.annotateHint')}
- </Text>
- </Flexbox>
- {activeAnnotations.length === 0 && (
- <Text fontSize={12} type={'secondary'}>
- {translate('acceptance.review.regionCommentsEmpty')}
- </Text>
- )}
- {annotationInputs}
- </div>
- </div>
- </Flexbox>
- ) : (
- <Text fontSize={13} type={'secondary'}>
- {translate('acceptance.review.rejectDescription', { title: checkTitle })}
- </Text>
- )}
- </Drawer>
+ </Flexbox>
+ ) : (
+ <Text fontSize={13} type={'secondary'}>
+ {translate('acceptance.review.rejectDescription', { title: checkTitle })}
+ </Text>
+ )}
+ </Flexbox>
+ <div className={styles.modalFooter}>{footer}</div>
+ </div>
);
},
);
-CheckRejectDrawer.displayName = 'AcceptanceCheckRejectDrawer';
-
-/** Per-check reject drawer — media enters the fullscreen annotation surface immediately. */
-export const openCheckRejectModal = (options: CheckRejectModalProps) =>
- mountImperative(({ close, open }) => (
- <CheckRejectDrawer {...options} open={open} onClose={close} />
- ));
+CheckRejectModalContent.displayName = 'AcceptanceCheckRejectModalContent';
+
+/** Per-check reject modal — media gets a near-fullscreen annotation surface without losing context. */
+export const openCheckRejectModal = (options: CheckRejectModalProps) => {
+ const modalTitle = rejectModalTitle(options.checkTitle, options.checkDescription);
+
+ return createModal({
+ classNames: { popup: styles.modalPopup },
+ content: <CheckRejectModalContent {...options} />,
+ footer: null,
+ maskClosable: true,
+ styles: {
+ ...frostedModalStyles,
+ content: { display: 'flex', flex: 1, minHeight: 0, overflow: 'hidden', padding: 0 },
+ popup: {
+ display: 'flex',
+ flexDirection: 'column',
+ height: CHECK_REJECT_MODAL_SIZE.height,
+ maxWidth: CHECK_REJECT_MODAL_SIZE.width,
+ },
+ },
+ title: (
+ <Flexbox gap={2}>
+ <Text strong>{modalTitle.title}</Text>
+ {modalTitle.description && (
+ <Text fontSize={12} type={'secondary'}>
+ {modalTitle.description}
+ </Text>
+ )}
+ </Flexbox>
+ ),
+ width: CHECK_REJECT_MODAL_SIZE.width,
+ });
+};
diff --git a/src/spa/router/desktopRouter.meta.desktop.test.ts b/src/spa/router/desktopRouter.meta.desktop.test.ts
index c2e1893c02b..b34c2513faa 100644
--- a/src/spa/router/desktopRouter.meta.desktop.test.ts
+++ b/src/spa/router/desktopRouter.meta.desktop.test.ts
@@ -1,4 +1,4 @@
-import { MessageSquarePlus } from 'lucide-react';
+import { ImageIcon, MessageSquarePlus } from 'lucide-react';
import { describe, expect, it } from 'vitest';
import { matchRouteMeta } from '@/features/Electron/titlebar/TabBar/resolveRouteMeta';
@@ -26,6 +26,13 @@ describe('mainAreaMetaRoutes (Electron adapter)', () => {
expect(staticMeta.icon).toBeDefined();
});
+ it('uses the active resource category for the tab title and icon', () => {
+ const { static: staticMeta } = matchRouteMeta(mainAreaMetaRoutes, '/resource/images');
+
+ expect(staticMeta.titleKey).toBe('navigation.resourceImages');
+ expect(staticMeta.icon).toBe(ImageIcon);
+ });
+
it('resolves a static agent meta and its DynamicMeta runner', () => {
const matched = matchRouteMeta(mainAreaMetaRoutes, '/agent/agt_1');
diff --git a/src/spa/router/desktopRouter.shared.tsx b/src/spa/router/desktopRouter.shared.tsx
index 1d09ad00c21..e49c5b6b4c9 100644
--- a/src/spa/router/desktopRouter.shared.tsx
+++ b/src/spa/router/desktopRouter.shared.tsx
@@ -4,11 +4,17 @@ import {
BrainCircuit,
Download,
FilePenIcon,
+ FilesIcon,
+ FileText,
Image,
+ ImageIcon,
+ LayoutPanelTopIcon,
LibraryBigIcon,
MessageSquarePlus,
+ Mic2,
Settings,
ShapesIcon,
+ SquarePlay,
} from 'lucide-react';
import { cloneElement, isValidElement, type ReactElement, Suspense } from 'react';
import type { RouteObject } from 'react-router';
@@ -57,6 +63,23 @@ const groupChatElement = dynamicElement(
{ preloadId: 'group' },
);
+const resourceCategoryRoutes: RouteObject[] = [
+ { icon: LayoutPanelTopIcon, path: 'all', titleKey: 'navigation.resourceAll' },
+ { icon: FileText, path: 'documents', titleKey: 'navigation.resourceDocuments' },
+ { icon: ImageIcon, path: 'images', titleKey: 'navigation.resourceImages' },
+ { icon: SquarePlay, path: 'videos', titleKey: 'navigation.resourceVideos' },
+ { icon: Mic2, path: 'audios', titleKey: 'navigation.resourceAudios' },
+ { icon: FilesIcon, path: 'files', titleKey: 'navigation.resourceFiles' },
+].map(({ icon, path, titleKey }) => ({
+ element: dynamicElement(
+ () => import('@/routes/(main)/resource/(home)'),
+ `Desktop > Resource > Home > ${path}`,
+ { preloadId: 'resource' },
+ ),
+ handle: { meta: routeMeta({ icon, titleKey }) },
+ path,
+}));
+
export interface MainAreaRouteOptions {
/** Electron renders Home inside each tab router; Web renders it beside the router outlet. */
createHomeElement?: () => ReactElement;
@@ -491,6 +514,7 @@ export const sharedMainAreaChildren: RouteObject[] = [
index: true,
},
...BusinessResourceRoutes,
+ ...resourceCategoryRoutes,
// /resource/page needs a static segment: the dynamic `:category`
// ties with the workspace mirror `/:workspaceSlug/page` on route
// score, and the workspace tree would swallow it into a slug 404.
@@ -501,7 +525,7 @@ export const sharedMainAreaChildren: RouteObject[] = [
{ preloadId: 'resource' },
),
handle: {
- meta: routeMeta({ icon: LibraryBigIcon, titleKey: 'navigation.resources' }),
+ meta: routeMeta({ icon: FilePenIcon, titleKey: 'navigation.resourcePages' }),
},
path: 'page',
},