dataset-card.tsx

Overview

The dataset-card.tsx file defines two React functional components, DatasetCard and SeeAllCard, which are used to display dataset information and navigation options within a user interface. These components are part of a system that manages and presents datasets (referred to as "knowledge" entities) and provide interactive elements such as dropdown menus, badges, and navigation hooks.

This file heavily interacts with UI components (HomeCard, MoreButton, SharedBadge, Card, CardContent), hooks (useNavigatePage, useRenameDataset), and interfaces (IKnowledge) that are part of a larger application ecosystem.


Components and Functions

1. DatasetCard

Description

DatasetCard is a React component that renders a card representing a single dataset. It shows dataset details, a badge with the dataset's nickname, and a dropdown menu for additional dataset actions. Clicking the card navigates the user to the detailed page of the dataset.

Props

type DatasetCardProps = {
  dataset: IKnowledge;
} & Pick<ReturnType<typeof useRenameDataset>, 'showDatasetRenameModal'>;

Usage

<DatasetCard
  dataset={myDataset}
  showDatasetRenameModal={handleRenameModalOpen}
/>

Behavior


2. SeeAllCard

Description

SeeAllCard renders a card UI element labeled "See All" with a right arrow icon. When clicked, it navigates the user to the full list of datasets.

Props

Usage

<SeeAllCard />

Behavior


Key Implementation Details


Interactions with Other Parts of the Application

The components in this file are likely used within a dashboard or homepage to list datasets and allow users to manage or explore them.


Visual Diagram

componentDiagram
    direction TB
    DatasetCard --> HomeCard : renders
    DatasetCard --> DatasetDropdown : uses
    DatasetDropdown --> MoreButton : wraps
    DatasetCard --> SharedBadge : displays badge
    DatasetCard --> useNavigatePage : uses navigateToDataset()
    DatasetCard --> useRenameDataset : uses showDatasetRenameModal()
    SeeAllCard --> Card : renders
    SeeAllCard --> CardContent : renders inside Card
    SeeAllCard --> useNavigatePage : uses navigateToDatasetList()

Summary

Component

Purpose

Key Props/Functions

DatasetCard

Displays a dataset's summary info with action menus and navigates to dataset detail

dataset: IKnowledge, showDatasetRenameModal

SeeAllCard

Provides a card to navigate to the full dataset list

None

Both components rely on navigation hooks and modular UI components to provide a clean, user-friendly interface for dataset management.


Example Usage Snippet

import { DatasetCard, SeeAllCard } from './dataset-card';
import { useRenameDataset } from './use-rename-dataset';

function DatasetList({ datasets }: { datasets: IKnowledge[] }) {
  const { showDatasetRenameModal } = useRenameDataset();

  return (
    <div className="dataset-list">
      {datasets.map(ds => (
        <DatasetCard 
          key={ds.id} 
          dataset={ds} 
          showDatasetRenameModal={showDatasetRenameModal} 
        />
      ))}
      <SeeAllCard />
    </div>
  );
}

This example demonstrates rendering multiple DatasetCard components with a SeeAllCard at the end, providing navigation and management capabilities for datasets.


End of Documentation for dataset-card.tsx