Skip to content

RAGFlow is an agent-native database: a Retrieval-Augmented Generation (RAG) engine that grew into context infrastructure.

1.9 KB
Raw Blame
/*
 *  Copyright 2026 The InfiniFlow Authors. All Rights Reserved.
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

import { useTranslation } from 'react-i18next';

import { JsonPreviewSheet } from './json-preview-sheet';

interface TemplatePreviewHeaderProps {
  templateName: string | undefined;
  jsonSheetOpen: boolean;
  onJsonSheetOpenChange: (open: boolean) => void;
  workflowSheetOpen: boolean;
  onWorkflowSheetOpenChange: (open: boolean) => void;
  allFormValues: Record<string, unknown>;
}

export function TemplatePreviewHeader({
  templateName,
  jsonSheetOpen,
  onJsonSheetOpenChange,
  allFormValues,
}: TemplatePreviewHeaderProps) {
  const { t } = useTranslation();

  return (
    <section className="shrink-0 flex justify-between items-center gap-4 px-5 py-4 border-b border-border-button">
      {/* The preview title mirrors the template name as the user types it;
          keep a very long name inside the header instead of letting it
          overlap the actions on the right. */}
      <span
        className="min-w-0 flex-1 truncate text-lg font-medium text-text-primary"
        title={templateName || undefined}
      >
        {templateName || t('common.name')}
      </span>
      <div className="flex shrink-0 items-center gap-2">
        <JsonPreviewSheet
          open={jsonSheetOpen}
          onOpenChange={onJsonSheetOpenChange}
          value={allFormValues}
        />
      </div>
    </section>
  );
}