From d8391fb1709b0d56f108ba86591d4e507595cbb7 Mon Sep 17 00:00:00 2001 From: mintsweet <0x1304570@gmail.com> Date: Mon, 13 May 2024 19:03:14 +1200 Subject: [PATCH] fix: remove auto create blueprint when creating project --- config-ui/src/api/blueprint/index.ts | 2 +- config-ui/src/routes/onboard/step-3.tsx | 18 ++++------------ config-ui/src/routes/project/home/index.tsx | 24 +++++---------------- 3 files changed, 10 insertions(+), 34 deletions(-) diff --git a/config-ui/src/api/blueprint/index.ts b/config-ui/src/api/blueprint/index.ts index c514ed74423..727c026de68 100644 --- a/config-ui/src/api/blueprint/index.ts +++ b/config-ui/src/api/blueprint/index.ts @@ -32,7 +32,7 @@ export const create = (data: any) => export const remove = (id: ID) => request(`/blueprints/${id}`, { method: 'delete' }); -export const update = (id: ID, data: IBlueprint) => request(`/blueprints/${id}`, { method: 'patch', data }); +export const update = (id: ID, data: Partial) => request(`/blueprints/${id}`, { method: 'patch', data }); export const pipelines = (id: ID) => request(`/blueprints/${id}/pipelines`); diff --git a/config-ui/src/routes/onboard/step-3.tsx b/config-ui/src/routes/onboard/step-3.tsx index 2e5b79c0b5b..4ee900bfac9 100644 --- a/config-ui/src/routes/onboard/step-3.tsx +++ b/config-ui/src/routes/onboard/step-3.tsx @@ -21,9 +21,7 @@ import { Flex, Button } from 'antd'; import dayjs from 'dayjs'; import API from '@/api'; -import { cronPresets } from '@/config'; import { Markdown } from '@/components'; -import { IBPMode } from '@/types'; import { DataScopeRemote, getPluginScopeId } from '@/plugins'; import { operator, formatTime } from '@/utils'; @@ -43,7 +41,6 @@ export const Step3 = () => { .then((text) => setQA(text)); }, [plugin]); - const presets = useMemo(() => cronPresets.map((preset) => preset.config), []); const connectionId = useMemo(() => { const record = records.find((it) => it.plugin === plugin); return record?.connectionId ?? null; @@ -57,7 +54,7 @@ export const Step3 = () => { const [success] = await operator( async () => { // 1. create a new project - await API.project.create({ + const { blueprint } = await API.project.create({ name: projectName, description: '', metrics: [ @@ -69,18 +66,11 @@ export const Step3 = () => { ], }); - // 2. add a data scope to the connection + // 2. add data scopes to the connection await API.scope.batch(plugin, connectionId, { data: scopes.map((it) => it.data) }); - // 3. create a new blueprint - const blueprint = await API.blueprint.create({ - name: `${projectName}-Blueprint`, - projectName, - mode: IBPMode.NORMAL, - enable: true, - cronConfig: presets[0], - isManual: false, - skipOnFail: true, + // 3. add data scopes to the blueprint + await API.blueprint.update(blueprint.id, { timeAfter: formatTime(dayjs().subtract(14, 'day').startOf('day').toDate(), 'YYYY-MM-DD[T]HH:mm:ssZ'), connections: [ { diff --git a/config-ui/src/routes/project/home/index.tsx b/config-ui/src/routes/project/home/index.tsx index 5a7a350f426..7c253d91e03 100644 --- a/config-ui/src/routes/project/home/index.tsx +++ b/config-ui/src/routes/project/home/index.tsx @@ -20,18 +20,17 @@ import { useState, useMemo, useRef } from 'react'; import { Link, useNavigate } from 'react-router-dom'; import { PlusOutlined, SettingOutlined } from '@ant-design/icons'; import { Flex, Table, Button, Modal, Input, Checkbox, message } from 'antd'; -import dayjs from 'dayjs'; import API from '@/api'; import { PageHeader, Block, ExternalLink, IconButton } from '@/components'; -import { getCron, cronPresets, PATHS } from '@/config'; +import { getCron, PATHS } from '@/config'; import { ConnectionName } from '@/features'; import { useRefreshData } from '@/hooks'; import { OnboardTour } from '@/routes/onboard/components'; import { DOC_URL } from '@/release'; import { formatTime, operator } from '@/utils'; import { PipelineStatus } from '@/routes/pipeline'; -import { IBlueprint, IBPMode } from '@/types'; +import { IBlueprint } from '@/types'; import { validName } from '../utils'; @@ -52,7 +51,6 @@ export const ProjectHomePage = () => { const navigate = useNavigate(); - const presets = useMemo(() => cronPresets.map((preset) => preset.config), []); const [dataSource, total] = useMemo( () => [ (data?.projects ?? []).map((it) => { @@ -85,8 +83,8 @@ export const ProjectHomePage = () => { } const [success] = await operator( - async () => { - await API.project.create({ + async () => + API.project.create({ name, description: '', metrics: [ @@ -96,19 +94,7 @@ export const ProjectHomePage = () => { enable: enableDora, }, ], - }); - return API.blueprint.create({ - name: `${name}-Blueprint`, - projectName: name, - mode: IBPMode.NORMAL, - enable: true, - cronConfig: presets[0], - isManual: false, - skipOnFail: true, - timeAfter: formatTime(dayjs().subtract(6, 'month').startOf('day').toDate(), 'YYYY-MM-DD[T]HH:mm:ssZ'), - connections: [], - }); - }, + }), { setOperating: setSaving, },