Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove auto create blueprint when creating project #7462

Merged
merged 1 commit into from
May 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion config-ui/src/api/blueprint/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<IBlueprint>) => request(`/blueprints/${id}`, { method: 'patch', data });

export const pipelines = (id: ID) => request(`/blueprints/${id}/pipelines`);

Expand Down
18 changes: 4 additions & 14 deletions config-ui/src/routes/onboard/step-3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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;
Expand All @@ -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: [
Expand All @@ -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: [
{
Expand Down
24 changes: 5 additions & 19 deletions config-ui/src/routes/project/home/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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) => {
Expand Down Expand Up @@ -85,8 +83,8 @@ export const ProjectHomePage = () => {
}

const [success] = await operator(
async () => {
await API.project.create({
async () =>
API.project.create({
name,
description: '',
metrics: [
Expand All @@ -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,
},
Expand Down
Loading