diff --git a/web/src/components/artifact-force-graph/index.tsx b/web/src/components/artifact-force-graph/index.tsx index 3c0b9d4275..8304ed4ed2 100644 --- a/web/src/components/artifact-force-graph/index.tsx +++ b/web/src/components/artifact-force-graph/index.tsx @@ -59,6 +59,16 @@ function ArtifactForceGraph({ [onNodeClick, mapNodeToValue], ); + const getLinkColor = useCallback(() => { + if (typeof window === 'undefined' || !containerRef.current) { + return '#b2b5b7'; + } + return window + .getComputedStyle(containerRef.current) + .getPropertyValue('--text-disabled') + .trim(); + }, []); + return (
({ onNodeClick={handleNodeClick} nodeCanvasObject={renderNodeLabel} nodeCanvasObjectMode={() => 'after'} + linkColor={getLinkColor} /> )}
diff --git a/web/src/hooks/use-chunk-request.ts b/web/src/hooks/use-chunk-request.ts index b8698dbd8d..1de0d3b7ae 100644 --- a/web/src/hooks/use-chunk-request.ts +++ b/web/src/hooks/use-chunk-request.ts @@ -20,7 +20,7 @@ export interface IChunkListResult { searchString?: string; handleInputChange?: React.ChangeEventHandler; pagination: PaginationProps; - setPagination?: (pagination: { page: number; pageSize: number }) => void; + setPagination?: (pagination: { page: number; pageSize?: number }) => void; available: number | undefined; handleSetAvailable: (available: number | undefined) => void; dataUpdatedAt?: number; // Timestamp when data was last updated - useful for cache busting diff --git a/web/src/hooks/use-compilation-template-group-request.ts b/web/src/hooks/use-compilation-template-group-request.ts index b07068e4b9..2721432db3 100644 --- a/web/src/hooks/use-compilation-template-group-request.ts +++ b/web/src/hooks/use-compilation-template-group-request.ts @@ -12,9 +12,11 @@ import { getCompilationTemplateGroup, updateCompilationTemplateGroup, } from '@/services/compilation-template-group-service'; +import { isCreateCompilationTemplateGroup } from '@/utils/compilation-template-util'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; import { useDebounce } from 'ahooks'; import { useCallback, useMemo } from 'react'; +import { useParams } from 'react-router'; import { useGetPaginationWithRouter, @@ -98,15 +100,18 @@ export const useFetchCompilationTemplateGroupsByPage = () => { }; }; -export const useFetchCompilationTemplateGroup = (id?: string) => { +export const useFetchCompilationTemplateGroup = () => { + const { id } = useParams<{ id: string }>(); + const isCreate = isCreateCompilationTemplateGroup(id); + const { data, isFetching: loading } = useQuery< ICompilationTemplateGroup | undefined >({ queryKey: CompilationTemplateGroupKeys.detail(id), - enabled: !!id && id !== 'create', + enabled: !isCreate, gcTime: 0, queryFn: async () => { - if (!id || id === 'create') return undefined; + if (isCreate) return undefined; const { data } = await getCompilationTemplateGroup(id); return data?.data as ICompilationTemplateGroup | undefined; }, diff --git a/web/src/interfaces/database/compilation-template.ts b/web/src/interfaces/database/compilation-template.ts index d68461a1f2..564611c3e6 100644 --- a/web/src/interfaces/database/compilation-template.ts +++ b/web/src/interfaces/database/compilation-template.ts @@ -27,6 +27,7 @@ export interface ICompilationTemplateConfig { [section: string]: | ICompilationTemplateSection | ICompilationTemplateRaptorConfig + | Record | string | boolean | undefined; diff --git a/web/src/interfaces/request/compilation-template.ts b/web/src/interfaces/request/compilation-template.ts index fe64c8ecd0..81058f246a 100644 --- a/web/src/interfaces/request/compilation-template.ts +++ b/web/src/interfaces/request/compilation-template.ts @@ -27,6 +27,7 @@ export interface ICompilationTemplateConfigRequest { [section: string]: | ICompilationTemplateSectionRequest | ICompilationTemplateRaptorConfigRequest + | Record | string | boolean | undefined; diff --git a/web/src/lib/editor/plugins/toolbar-plugin.tsx b/web/src/lib/editor/plugins/toolbar-plugin.tsx index e96ac43699..9c9ca7bf51 100644 --- a/web/src/lib/editor/plugins/toolbar-plugin.tsx +++ b/web/src/lib/editor/plugins/toolbar-plugin.tsx @@ -103,6 +103,7 @@ export default function ToolbarPlugin({ onToggleSource, showSource }: Props) { Source - diff --git a/web/src/pages/user-setting/compilation-templates/create-next/components/blueprints-step.tsx b/web/src/pages/user-setting/compilation-templates/create-next/components/blueprints-step.tsx index ff6d5f9a9a..f6b6857b7b 100644 --- a/web/src/pages/user-setting/compilation-templates/create-next/components/blueprints-step.tsx +++ b/web/src/pages/user-setting/compilation-templates/create-next/components/blueprints-step.tsx @@ -5,12 +5,13 @@ import { Textarea } from '@/components/ui/textarea'; import { TreeDataItem, TreeView } from '@/components/ui/tree-view'; import { useFetchWikiPresets } from '@/hooks/use-compilation-template-request'; import { IWikiPreset } from '@/interfaces/database/compilation-template'; +import { FormSchemaType } from '@/pages/user-setting/compilation-templates/create-next/schema'; import { groupBy } from 'lodash'; import { useCallback, useMemo, useState } from 'react'; import { UseFormReturn, useWatch } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; -import { FormSchemaType } from '@/pages/user-setting/compilation-templates/edit-template/schema'; +import { Checkbox } from '@/components/ui/checkbox'; type WikiPresetTreeItem = TreeDataItem & { _preset?: IWikiPreset; @@ -73,12 +74,34 @@ export function BlueprintsStep({ `templates.${selectedTemplateIndex}.config.instruction` as const; const pageExamplePath = `templates.${selectedTemplateIndex}.config.page_example` as const; + const useBlueprintPath = + `templates.${selectedTemplateIndex}.config.use_blueprint` as const; const pageExample = useWatch({ control: form.control, name: pageExamplePath, }); + const instruction = useWatch({ + control: form.control, + name: instructionPath, + }); + + const useBlueprint = useWatch({ + control: form.control, + name: useBlueprintPath, + }); + + const selectedTemplateName = useMemo(() => { + if (!selectedItemId) return ''; + const selectedItem = treeData + .flatMap((node) => node.children ?? []) + .find((child) => child.id === selectedItemId); + return selectedItem?.name ?? ''; + }, [treeData, selectedItemId]); + + const hasTemplateData = Boolean(selectedItemId || instruction || pageExample); + const handleSelect = useCallback( (item?: TreeDataItem) => { if (!item || item.children) return; @@ -97,6 +120,14 @@ export function BlueprintsStep({ [form, instructionPath, pageExamplePath], ); + const handleToggleBlueprint = useCallback( + (checked: boolean | 'indeterminate') => { + if (checked === 'indeterminate') return; + form.setValue(useBlueprintPath, checked, { shouldValidate: false }); + }, + [form, useBlueprintPath], + ); + const handlePageExampleChange = useCallback( (value: string) => { form.setValue(pageExamplePath, value, { shouldValidate: false }); @@ -120,7 +151,20 @@ export function BlueprintsStep({
- {selectedItemId ? ( + {hasTemplateData && ( +
+ {selectedTemplateName} +
+ + {t('setting.useBlueprint')} +
+
+ )} + {hasTemplateData ? (
)} -
+
diff --git a/web/src/pages/user-setting/compilation-templates/create-next/components/section-field-grid.tsx b/web/src/pages/user-setting/compilation-templates/create-next/components/section-field-grid.tsx index ee4f5f49b4..3fc7100bc4 100644 --- a/web/src/pages/user-setting/compilation-templates/create-next/components/section-field-grid.tsx +++ b/web/src/pages/user-setting/compilation-templates/create-next/components/section-field-grid.tsx @@ -11,8 +11,8 @@ import { } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; -import { FormSchemaType } from '@/pages/user-setting/compilation-templates/edit-template/schema'; -import { getTypeOptionsFromBuiltinSection } from '@/pages/user-setting/compilation-templates/edit-template/utils'; +import { FormSchemaType } from '@/pages/user-setting/compilation-templates/create-next/schema'; +import { getTypeOptionsFromBuiltinSection } from '@/pages/user-setting/compilation-templates/create-next/utils'; import { FieldCard } from './field-card'; diff --git a/web/src/pages/user-setting/compilation-templates/create-next/components/template-configuration.tsx b/web/src/pages/user-setting/compilation-templates/create-next/components/template-configuration.tsx index c3cb2b0b88..9ce473974a 100644 --- a/web/src/pages/user-setting/compilation-templates/create-next/components/template-configuration.tsx +++ b/web/src/pages/user-setting/compilation-templates/create-next/components/template-configuration.tsx @@ -12,10 +12,10 @@ import { UseFormReturn, useWatch } from 'react-hook-form'; import { useTranslation } from 'react-i18next'; import { CompilationTemplateKind } from '@/constants/compilation'; -import { TreeTemplateFields } from '@/pages/user-setting/compilation-templates/edit-template/components/tree-template-fields'; -import { useTemplateKindChange } from '@/pages/user-setting/compilation-templates/edit-template/hooks/use-template-kind-change'; -import { FormSchemaType } from '@/pages/user-setting/compilation-templates/edit-template/schema'; -import { SectionTitleKeyMap } from '@/pages/user-setting/compilation-templates/edit-template/utils'; +import { TreeTemplateFields } from '@/pages/user-setting/compilation-templates/create-next/components/tree-template-fields'; +import { useTemplateKindChange } from '@/pages/user-setting/compilation-templates/create-next/hooks/use-template-kind-change'; +import { FormSchemaType } from '@/pages/user-setting/compilation-templates/create-next/schema'; +import { SectionTitleKeyMap } from '@/pages/user-setting/compilation-templates/create-next/utils'; import { useActiveSectionTab } from '../hooks/use-active-section-tab'; import { useAvailableKindOptions } from '../hooks/use-available-kind-options'; @@ -233,7 +233,7 @@ export function TemplateConfiguration({
-