Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

1.2 KB
Raw Blame
import { IAINoContentFallback } from 'common/components/IAIImageFallback';
import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import { useDebouncedImageWorkflow } from 'services/api/hooks/useDebouncedImageWorkflow';
import type { ImageDTO } from 'services/api/types';

import DataViewer from './DataViewer';

type Props = {
  image: ImageDTO;
  searchTerm?: string;
  showSearchInput?: boolean;
};

const ImageMetadataWorkflowTabContent = ({ image, searchTerm, showSearchInput }: Props) => {
  const { t } = useTranslation();
  const { currentData } = useDebouncedImageWorkflow(image);
  const workflow = useMemo(() => {
    if (currentData?.workflow) {
      try {
        return JSON.parse(currentData.workflow);
      } catch {
        return null;
      }
    }
    return null;
  }, [currentData]);

  if (!workflow) {
    return <IAINoContentFallback label={t('nodes.noWorkflow')} />;
  }

  return (
    <DataViewer
      fileName={`${image.image_name.replace('.png', '')}_workflow`}
      data={workflow}
      label={t('metadata.workflow')}
      withSearch
      searchTerm={searchTerm}
      showSearchInput={showSearchInput}
    />
  );
};

export default memo(ImageMetadataWorkflowTabContent);