You've already forked DataMate
feat(dataset): 添加子数据集创建功能
- 在创建页面集成父数据集ID传递逻辑 - 使用useMemo缓存location状态中的parentDatasetId - 添加useEffect同步parentDatasetId到表单状态 - 实现handleCreateChildDataset函数用于导航到创建页面 - 在数据集详情页的操作菜单中添加"创建子数据集"选项 - 为子数据集创建按钮添加PlusOutlined图标 - 定义CreateDatasetLocationState接口规范传递参数类型
This commit is contained in:
@@ -1,12 +1,13 @@
|
||||
import { useEffect, useMemo, useState } from "react";
|
||||
import { Breadcrumb, App, Tabs } from "antd";
|
||||
import {
|
||||
ReloadOutlined,
|
||||
DownloadOutlined,
|
||||
UploadOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined,
|
||||
} from "@ant-design/icons";
|
||||
ReloadOutlined,
|
||||
DownloadOutlined,
|
||||
UploadOutlined,
|
||||
EditOutlined,
|
||||
DeleteOutlined,
|
||||
PlusOutlined,
|
||||
} from "@ant-design/icons";
|
||||
import DetailHeader from "@/components/DetailHeader";
|
||||
import { mapDataset, datasetTypeMap } from "../dataset.const";
|
||||
import type { Dataset } from "@/pages/DataManagement/dataset.model";
|
||||
@@ -45,7 +46,7 @@ export default function DatasetDetail() {
|
||||
const [parentDataset, setParentDataset] = useState<Dataset | null>(null);
|
||||
const filesOperation = useFilesOperation(dataset);
|
||||
|
||||
const [showUploadDialog, setShowUploadDialog] = useState(false);
|
||||
const [showUploadDialog, setShowUploadDialog] = useState(false);
|
||||
const navigateItems = useMemo(() => {
|
||||
const items = [
|
||||
{
|
||||
@@ -66,6 +67,14 @@ export default function DatasetDetail() {
|
||||
});
|
||||
return items;
|
||||
}, [dataset, parentDataset]);
|
||||
const handleCreateChildDataset = () => {
|
||||
if (!dataset?.id) {
|
||||
return;
|
||||
}
|
||||
navigate("/data/management/create", {
|
||||
state: { parentDatasetId: dataset.id },
|
||||
});
|
||||
};
|
||||
const fetchDataset = async () => {
|
||||
if (!id) {
|
||||
return;
|
||||
@@ -158,12 +167,22 @@ export default function DatasetDetail() {
|
||||
];
|
||||
|
||||
// 数据集操作列表
|
||||
const operations = [
|
||||
{
|
||||
key: "edit",
|
||||
label: "编辑",
|
||||
icon: <EditOutlined />,
|
||||
onClick: () => {
|
||||
const operations = [
|
||||
...(dataset?.id && !dataset.parentDatasetId
|
||||
? [
|
||||
{
|
||||
key: "create-child",
|
||||
label: "创建子数据集",
|
||||
icon: <PlusOutlined />,
|
||||
onClick: handleCreateChildDataset,
|
||||
},
|
||||
]
|
||||
: []),
|
||||
{
|
||||
key: "edit",
|
||||
label: "编辑",
|
||||
icon: <EditOutlined />,
|
||||
onClick: () => {
|
||||
setShowEditDialog(true);
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user