Initial import
This commit is contained in:
280
src/app/main/layout/buildSearchOptions.ts
Executable file
280
src/app/main/layout/buildSearchOptions.ts
Executable file
@@ -0,0 +1,280 @@
|
||||
import type { SearchKeywordOption } from '../../../components/search';
|
||||
import type { LoadedSampleEntry } from '../../../samples/registry';
|
||||
import {
|
||||
buildApisPath,
|
||||
buildChatPath,
|
||||
buildDocsPath,
|
||||
buildPlansPath,
|
||||
getDocsSectionLabel,
|
||||
PLAN_FILTER_LABELS,
|
||||
PLAN_GROUP_LABEL,
|
||||
PLAN_SIDEBAR_LABELS,
|
||||
} from '../routes';
|
||||
import { compactKeywords, scrollToElement } from '../mainView/utils';
|
||||
|
||||
type BuildSearchOptionsParams = {
|
||||
componentSamples: LoadedSampleEntry[];
|
||||
widgetSamples: LoadedSampleEntry[];
|
||||
docFolders: string[];
|
||||
docsDocuments: Array<{
|
||||
id: string;
|
||||
title: string;
|
||||
folder: string;
|
||||
preview?: string;
|
||||
}>;
|
||||
hasAccess: boolean;
|
||||
navigateTo: (path: string) => void;
|
||||
setFocusedComponentId: (value: string | null) => void;
|
||||
requestPlanQuickFilter: (filter: 'working' | 'release-pending-main' | 'automation-failed' | null) => void;
|
||||
};
|
||||
|
||||
export function buildSearchOptions({
|
||||
componentSamples,
|
||||
widgetSamples,
|
||||
docFolders,
|
||||
docsDocuments,
|
||||
hasAccess,
|
||||
navigateTo,
|
||||
setFocusedComponentId,
|
||||
requestPlanQuickFilter,
|
||||
}: BuildSearchOptionsParams): SearchKeywordOption[] {
|
||||
const onSelectWindow = () => {
|
||||
setFocusedComponentId(null);
|
||||
};
|
||||
|
||||
return [
|
||||
{
|
||||
id: 'page:apis:components',
|
||||
label: 'APIs / Components',
|
||||
group: 'Page',
|
||||
keywords: ['api', 'components', '컴포넌트'],
|
||||
onSelect: () => {
|
||||
requestPlanQuickFilter(null);
|
||||
navigateTo(buildApisPath('components'));
|
||||
setFocusedComponentId(null);
|
||||
},
|
||||
onSelectWindow,
|
||||
},
|
||||
{
|
||||
id: 'page:apis:widgets',
|
||||
label: 'APIs / Widgets',
|
||||
group: 'Page',
|
||||
keywords: ['api', 'widgets', '위젯'],
|
||||
onSelect: () => {
|
||||
requestPlanQuickFilter(null);
|
||||
navigateTo(buildApisPath('widgets'));
|
||||
setFocusedComponentId(null);
|
||||
},
|
||||
onSelectWindow,
|
||||
},
|
||||
{
|
||||
id: 'page:plans:all',
|
||||
label: `${PLAN_GROUP_LABEL} / ${PLAN_FILTER_LABELS.all}`,
|
||||
group: 'Page',
|
||||
keywords: ['plans', 'automation', '자동화', '실행', '현황', 'worker'],
|
||||
onSelect: () => {
|
||||
requestPlanQuickFilter(null);
|
||||
navigateTo(buildPlansPath('all'));
|
||||
setFocusedComponentId(null);
|
||||
},
|
||||
onSelectWindow,
|
||||
},
|
||||
...(hasAccess
|
||||
? [
|
||||
{
|
||||
id: 'page:plans:board',
|
||||
label: `${PLAN_GROUP_LABEL} / ${PLAN_SIDEBAR_LABELS.board}`,
|
||||
group: 'Page',
|
||||
keywords: ['plans', 'plan', '플랜', '게시판', 'board', '요청', '작업 요청', '접수', '계획'],
|
||||
onSelect: () => {
|
||||
requestPlanQuickFilter(null);
|
||||
navigateTo(buildPlansPath('board'));
|
||||
setFocusedComponentId(null);
|
||||
},
|
||||
onSelectWindow,
|
||||
} satisfies SearchKeywordOption,
|
||||
{
|
||||
id: 'page:plans:server-command',
|
||||
label: `Servers / ${PLAN_SIDEBAR_LABELS['server-command']}`,
|
||||
group: 'Page',
|
||||
keywords: ['plans', 'plan', 'server', 'command', 'server command', '서버', '명령', '재기동'],
|
||||
onSelect: () => {
|
||||
requestPlanQuickFilter(null);
|
||||
navigateTo(buildPlansPath('server-command'));
|
||||
setFocusedComponentId(null);
|
||||
},
|
||||
onSelectWindow,
|
||||
} satisfies SearchKeywordOption,
|
||||
]
|
||||
: []),
|
||||
{
|
||||
id: 'page:plans:release-review',
|
||||
label: `${PLAN_GROUP_LABEL} / ${PLAN_SIDEBAR_LABELS['release-review']}`,
|
||||
group: 'Page',
|
||||
keywords: ['release', 'review', '검수', '릴리즈', 'release 검수'],
|
||||
onSelect: () => {
|
||||
requestPlanQuickFilter(null);
|
||||
navigateTo(buildPlansPath('release-review'));
|
||||
setFocusedComponentId(null);
|
||||
},
|
||||
onSelectWindow,
|
||||
},
|
||||
{
|
||||
id: 'page:plans:charts',
|
||||
label: `${PLAN_GROUP_LABEL} / ${PLAN_SIDEBAR_LABELS.charts}`,
|
||||
group: 'Page',
|
||||
keywords: ['plans', 'plan', '차트', 'chart', '스케줄 차트'],
|
||||
onSelect: () => {
|
||||
requestPlanQuickFilter(null);
|
||||
navigateTo(buildPlansPath('charts'));
|
||||
setFocusedComponentId(null);
|
||||
},
|
||||
onSelectWindow,
|
||||
},
|
||||
{
|
||||
id: 'page:plans:schedule',
|
||||
label: `${PLAN_GROUP_LABEL} / ${PLAN_SIDEBAR_LABELS.schedule}`,
|
||||
group: 'Page',
|
||||
keywords: ['plans', 'plan', '스케줄', 'schedule', '반복 작업'],
|
||||
onSelect: () => {
|
||||
requestPlanQuickFilter(null);
|
||||
navigateTo(buildPlansPath('schedule'));
|
||||
setFocusedComponentId(null);
|
||||
},
|
||||
onSelectWindow,
|
||||
},
|
||||
...(hasAccess
|
||||
? [
|
||||
{
|
||||
id: 'page:plans:history',
|
||||
label: `${PLAN_GROUP_LABEL} / ${PLAN_SIDEBAR_LABELS.history}`,
|
||||
group: 'Page',
|
||||
keywords: ['plans', 'plan', '히스토리', 'history', '방문자 이력'],
|
||||
onSelect: () => {
|
||||
requestPlanQuickFilter(null);
|
||||
navigateTo(buildPlansPath('history'));
|
||||
setFocusedComponentId(null);
|
||||
},
|
||||
onSelectWindow,
|
||||
} satisfies SearchKeywordOption,
|
||||
]
|
||||
: []),
|
||||
{
|
||||
id: 'page:chat:live',
|
||||
label: 'Codex Live / Codex Live',
|
||||
group: 'Page',
|
||||
keywords: ['codex live', 'chat', 'codex', '채팅', '대화', '메시지'],
|
||||
onSelect: () => {
|
||||
requestPlanQuickFilter(null);
|
||||
navigateTo(buildChatPath('live'));
|
||||
setFocusedComponentId(null);
|
||||
},
|
||||
onSelectWindow,
|
||||
},
|
||||
{
|
||||
id: 'page:chat:changes',
|
||||
label: 'Codex Live / 변경 이력',
|
||||
group: 'Page',
|
||||
keywords: ['codex live', 'changes', 'source', 'diff', '변경', '소스', '채팅 변경', '채팅 diff'],
|
||||
onSelect: () => {
|
||||
requestPlanQuickFilter(null);
|
||||
navigateTo(buildChatPath('changes'));
|
||||
setFocusedComponentId(null);
|
||||
},
|
||||
onSelectWindow,
|
||||
},
|
||||
{
|
||||
id: 'page:chat:errors',
|
||||
label: '앱로그 / 에러 로그',
|
||||
group: 'Page',
|
||||
keywords: ['app log', 'applog', '앱로그', 'error', 'errors', '에러', '로그'],
|
||||
onSelect: () => {
|
||||
requestPlanQuickFilter(null);
|
||||
navigateTo(buildChatPath('errors'));
|
||||
setFocusedComponentId(null);
|
||||
},
|
||||
onSelectWindow,
|
||||
},
|
||||
...(hasAccess
|
||||
? [
|
||||
{
|
||||
id: 'page:chat:manage',
|
||||
label: '채팅 관리 / 유형 권한 관리',
|
||||
group: 'Page',
|
||||
keywords: ['chat manage', 'chat type', 'permission', '권한', '채팅 유형', '채팅 관리'],
|
||||
onSelect: () => {
|
||||
requestPlanQuickFilter(null);
|
||||
navigateTo(buildChatPath('manage'));
|
||||
setFocusedComponentId(null);
|
||||
},
|
||||
onSelectWindow,
|
||||
} satisfies SearchKeywordOption,
|
||||
]
|
||||
: []),
|
||||
...docFolders.map((folder) => ({
|
||||
id: `docs-folder:${folder}`,
|
||||
label: `Docs / ${getDocsSectionLabel(folder)}`,
|
||||
group: 'Docs Folder',
|
||||
keywords: [folder, 'docs', '문서'],
|
||||
onSelect: () => {
|
||||
requestPlanQuickFilter(null);
|
||||
navigateTo(buildDocsPath(folder));
|
||||
setFocusedComponentId(null);
|
||||
},
|
||||
onSelectWindow,
|
||||
})),
|
||||
...docsDocuments.map((document) => ({
|
||||
id: `doc:${document.id}`,
|
||||
label: document.title,
|
||||
group: `Docs / ${getDocsSectionLabel(document.folder)}`,
|
||||
keywords: [document.folder, document.id, document.title],
|
||||
description: document.preview,
|
||||
onSelect: () => {
|
||||
requestPlanQuickFilter(null);
|
||||
navigateTo(buildDocsPath(document.folder));
|
||||
setFocusedComponentId(`doc:${document.id}`);
|
||||
scrollToElement(`document-preview-${document.id}`);
|
||||
},
|
||||
onSelectWindow,
|
||||
})),
|
||||
...componentSamples.map((entry) => ({
|
||||
id: `component:${entry.sampleMeta.componentId}:${entry.sampleMeta.id}`,
|
||||
label: entry.sampleMeta.title,
|
||||
group: 'Component',
|
||||
keywords: compactKeywords([
|
||||
entry.sampleMeta.componentId,
|
||||
entry.sampleMeta.id,
|
||||
entry.sampleMeta.category,
|
||||
entry.sampleMeta.kind,
|
||||
entry.sampleMeta.variantLabel ?? '',
|
||||
]),
|
||||
description: entry.sampleMeta.description,
|
||||
onSelect: () => {
|
||||
requestPlanQuickFilter(null);
|
||||
navigateTo(buildApisPath('components'));
|
||||
setFocusedComponentId(`component:${entry.sampleMeta.componentId}`);
|
||||
scrollToElement(`component-sample-${entry.sampleMeta.componentId}`);
|
||||
},
|
||||
onSelectWindow,
|
||||
})),
|
||||
...widgetSamples.map((entry) => ({
|
||||
id: `widget:${entry.sampleMeta.componentId}:${entry.sampleMeta.id}`,
|
||||
label: entry.sampleMeta.title,
|
||||
group: 'Widget',
|
||||
keywords: compactKeywords([
|
||||
entry.sampleMeta.componentId,
|
||||
entry.sampleMeta.id,
|
||||
entry.sampleMeta.category,
|
||||
entry.sampleMeta.kind,
|
||||
entry.sampleMeta.variantLabel ?? '',
|
||||
]),
|
||||
description: entry.sampleMeta.description,
|
||||
onSelect: () => {
|
||||
requestPlanQuickFilter(null);
|
||||
navigateTo(buildApisPath('widgets'));
|
||||
setFocusedComponentId(`widget:${entry.sampleMeta.componentId}`);
|
||||
},
|
||||
onSelectWindow,
|
||||
})),
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user