([]);
+
+ const [operating, setOperating] = useState(false);
const {
token: { colorPrimary },
} = theme.useToken();
- const handleHideDialog = () => setType(undefined);
+ const [modal, contextHolder] = Modal.useModal();
- const handleCheckScopeConfig = async () => {
- if (!id) return;
+ const handleHideDialog = () => setType(undefined);
+ const handleCheckScopeConfig = async (id: ID) => {
const [success, res] = await operator(() => API.scopeConfig.check(plugin, id), { hideToast: true });
if (success) {
@@ -64,7 +76,7 @@ export const ScopeConfig = ({ plugin, connectionId, scopeId, scopeName, id, name
scopes: it.scopes,
}));
- if (projects.length > 0) {
+ if (projects.length > 1) {
setRelatedProjects(projects);
setType('relatedProjects');
} else {
@@ -73,9 +85,82 @@ export const ScopeConfig = ({ plugin, connectionId, scopeId, scopeName, id, name
}
};
+ const handleRun = async (pname: string, blueprintId: ID, data?: { skipCollectors?: boolean; fullSync?: boolean }) => {
+ const [success] = await operator(() => API.blueprint.trigger(blueprintId, data), {
+ setOperating,
+ });
+
+ if (success) {
+ window.open(PATHS.PROJECT(pname, { tab: 'status' }));
+ }
+ };
+
+ const handleShowProjectsModal = (projects: RelatedProjects) => {
+ if (!projects || !projects.length) {
+ onSuccess();
+ } else if (projects.length === 1) {
+ const [{ name, blueprintId }] = projects;
+ modal.success({
+ closable: true,
+ centered: true,
+ width: 550,
+ title: 'Scope Config Saved',
+ content: 'Please re-transform data to apply the updated scope config.',
+ footer: (
+
+
+
+ ),
+ onCancel: onSuccess,
+ });
+ } else {
+ modal.success({
+ closable: true,
+ centered: true,
+ width: 830,
+ title: 'Scope Config Saved',
+ content: (
+ <>
+
+ The listed projects are impacted. Please re-transform the data to apply the updated scope config.
+
+
+ {projects.map(({ name, blueprintId }: { name: string; blueprintId: ID }) => (
+ -
+
+ {name}
+
+
+
+ ))}
+
+ >
+ ),
+ footer: null,
+ onCancel: onSuccess,
+ });
+ }
+ };
+
const handleAssociate = async (trId: ID) => {
- const [success] = await operator(
- () => API.scope.update(plugin, connectionId, scopeId, { scopeConfigId: trId !== 'None' ? +trId : null }),
+ const [success, res] = await operator(
+ async () => {
+ await API.scope.update(plugin, connectionId, scopeId, { scopeConfigId: trId === 'None' ? null : +trId });
+ return API.scope.get(plugin, connectionId, scopeId, { blueprints: true });
+ },
{
hideToast: true,
},
@@ -83,18 +168,35 @@ export const ScopeConfig = ({ plugin, connectionId, scopeId, scopeName, id, name
if (success) {
handleHideDialog();
- onSuccess?.(trId);
+ handleShowProjectsModal(
+ (res.blueprints ?? []).map((it: any) => ({
+ name: it.projectName,
+ blueprintId: it.id,
+ scopes: [
+ {
+ scopeId,
+ scopeName,
+ },
+ ],
+ })),
+ );
}
};
- const handleUpdate = (trId: ID) => {
+ const handleUpdate = async (trId: ID) => {
handleHideDialog();
- onSuccess?.(trId);
+
+ const [success, res] = await operator(() => API.scopeConfig.check(plugin, trId), { hideToast: true });
+
+ if (success) {
+ handleShowProjectsModal(res.projects ?? []);
+ }
};
return (
- {id ? name : 'N/A'}
+ {contextHolder}
+ {scopeConfigId ? scopeConfigName : 'N/A'}
}
helptip="Associate Scope Config"
@@ -104,13 +206,13 @@ export const ScopeConfig = ({ plugin, connectionId, scopeId, scopeName, id, name
setType('associate');
}}
/>
- {id && (
+ {scopeConfigId && (
}
helptip=" Edit Scope Config"
type="link"
size="small"
- onClick={handleCheckScopeConfig}
+ onClick={() => handleCheckScopeConfig(scopeConfigId)}
/>
)}
{type === 'associate' && (
@@ -126,7 +228,7 @@ export const ScopeConfig = ({ plugin, connectionId, scopeId, scopeName, id, name
@@ -148,7 +250,7 @@ export const ScopeConfig = ({ plugin, connectionId, scopeId, scopeName, id, name
plugin={plugin}
connectionId={connectionId}
showWarning
- scopeConfigId={id}
+ scopeConfigId={scopeConfigId}
scopeId={scopeId}
onCancel={handleHideDialog}
onSubmit={handleUpdate}
@@ -162,7 +264,7 @@ export const ScopeConfig = ({ plugin, connectionId, scopeId, scopeName, id, name
connectionId={connectionId}
showWarning
forceCreate
- scopeConfigId={id}
+ scopeConfigId={scopeConfigId}
scopeId={scopeId}
onCancel={handleHideDialog}
onSubmit={handleAssociate}
@@ -175,7 +277,7 @@ export const ScopeConfig = ({ plugin, connectionId, scopeId, scopeName, id, name
width={830}
centered
footer={null}
- title={`Edit '${name}' for '${scopeName}'`}
+ title={`Edit '${scopeConfigName}' for '${scopeName}'`}
onCancel={handleHideDialog}
>
diff --git a/config-ui/src/plugins/register/webhook/components/create-dialog.tsx b/config-ui/src/plugins/register/webhook/components/create-dialog.tsx
index 233ee908fa9..d293508f78e 100644
--- a/config-ui/src/plugins/register/webhook/components/create-dialog.tsx
+++ b/config-ui/src/plugins/register/webhook/components/create-dialog.tsx
@@ -80,13 +80,13 @@ export const CreateDialog = ({ open, onCancel, onSubmitAfter }: Props) => {
"title":"a feature from DLK",
"type":"INCIDENT",
"original_status":"TODO",
- "status":"TODO",
+ "status":"TODO",
"created_date":"2020-01-01T12:00:00+00:00",
"updated_date":"2020-01-01T12:00:00+00:00"
}'`,
closeIssuesEndpoint: `curl ${prefix}${res.closeIssuesEndpoint} -X 'POST' -H 'Authorization: Bearer ${res.apiKey}'`,
postDeploymentsCurl: `curl ${prefix}${res.postPipelineDeployTaskEndpoint} -X 'POST' -H 'Authorization: Bearer ${res.apiKey}' -d '{
- "deploymentCommits":[
+ "deployment_commits":[
{
"commit_sha":"the sha of deployment commit1",
"repo_url":"the repo URL of the deployment commit"
diff --git a/config-ui/src/plugins/register/webhook/components/view-dialog.tsx b/config-ui/src/plugins/register/webhook/components/view-dialog.tsx
index 342f701e84b..bb44c7a39ab 100644
--- a/config-ui/src/plugins/register/webhook/components/view-dialog.tsx
+++ b/config-ui/src/plugins/register/webhook/components/view-dialog.tsx
@@ -41,7 +41,7 @@ const transformURI = (prefix: string, webhook: IWebhook, apiKey: string) => {
"title":"a feature from DLK",
"type":"INCIDENT",
"original_status":"TODO",
- "status":"TODO",
+ "status":"TODO",
"created_date":"2020-01-01T12:00:00+00:00",
"updated_date":"2020-01-01T12:00:00+00:00"
}'`,
@@ -51,7 +51,7 @@ const transformURI = (prefix: string, webhook: IWebhook, apiKey: string) => {
postDeploymentsCurl: `curl ${prefix}${webhook.postPipelineDeployTaskEndpoint} -X 'POST' -H 'Authorization: Bearer ${
apiKey ?? '{API_KEY}'
}' -d '{
- "deploymentCommits":[
+ "deployment_commits":[
{
"commit_sha":"the sha of deployment commit1",
"repo_url":"the repo URL of the deployment commit"
diff --git a/config-ui/src/routes/blueprint/connection-detail/index.tsx b/config-ui/src/routes/blueprint/connection-detail/index.tsx
index d0c66d4bc2d..665d0ca1fb7 100644
--- a/config-ui/src/routes/blueprint/connection-detail/index.tsx
+++ b/config-ui/src/routes/blueprint/connection-detail/index.tsx
@@ -223,13 +223,7 @@ export const BlueprintConnectionDetailPage = () => {
Manage Data Scope
-
+
void;
}
-export const BlueprintConnectionDetailTable = ({ plugin, connectionId, scopeIds, operating, onRun }: Props) => {
+export const BlueprintConnectionDetailTable = ({ plugin, connectionId, scopeIds }: Props) => {
const [version, setVersion] = useState(1);
const { ready, data } = useRefreshData(async () => {
@@ -44,59 +42,34 @@ export const BlueprintConnectionDetailTable = ({ plugin, connectionId, scopeIds,
}));
}, [version]);
- const [modal, contextHolder] = Modal.useModal();
-
- const handleChangeScopeConfig = () => {
- modal.success({
- closable: true,
- centered: true,
- width: 550,
- title: 'Scope Config Saved',
- content: 'Please re-transform data to apply the updated scope config.',
- footer: (
-
-
-
- ),
- onCancel: () => {
- setVersion(version + 1);
- },
- });
- };
-
return (
- <>
- (
-
- ),
- },
- ]}
- dataSource={data ?? []}
- />
- {contextHolder}
- >
+ (
+ setVersion(version + 1)}
+ />
+ ),
+ },
+ ]}
+ dataSource={data ?? []}
+ />
);
};
diff --git a/config-ui/src/routes/connection/connection.tsx b/config-ui/src/routes/connection/connection.tsx
index 74533aa54f1..d2d81e6233b 100644
--- a/config-ui/src/routes/connection/connection.tsx
+++ b/config-ui/src/routes/connection/connection.tsx
@@ -69,8 +69,6 @@ export const Connection = () => {
token: { colorPrimary },
} = theme.useToken();
- const [modal, contextHolder] = Modal.useModal();
-
const dispatch = useAppDispatch();
const connection = useAppSelector((state) => selectConnection(state, `${plugin}-${connectionId}`)) as IConnection;
@@ -230,65 +228,6 @@ export const Connection = () => {
}
};
- const handleRun = async (pname: string, blueprintId: ID, data?: { skipCollectors?: boolean; fullSync?: boolean }) => {
- const [success] = await operator(() => API.blueprint.trigger(blueprintId, data), {
- setOperating,
- hideToast: true,
- });
-
- if (success) {
- window.open(PATHS.PROJECT(pname, { tab: 'status' }));
- }
- };
-
- const handleScopeConfigChange = async (scopeConfigId?: ID) => {
- if (!scopeConfigId) {
- setVersion(version + 1);
- return;
- }
-
- const [success, res] = await operator(() => API.scopeConfig.check(plugin, scopeConfigId), { hideToast: true });
-
- if (success) {
- if (!res.projects) {
- setVersion(version + 1);
- return;
- }
-
- modal.success({
- closable: true,
- centered: true,
- width: 830,
- title: 'Scope Config Saved',
- content: (
- <>
-
- The listed projects are impacted. Please re-transform the data to apply the updated scope config.
-
-
- {res.projects.map(({ name, blueprintId }: { name: string; blueprintId: ID }) => (
- -
-
- {name}
-
-
-
- ))}
-
- >
- ),
- footer: null,
- onCancel: () => setVersion(version + 1),
- });
- }
- };
-
return (
{
connectionId={connectionId}
scopeId={id}
scopeName={name}
- id={configId}
- name={configName}
- onSuccess={handleScopeConfigChange}
+ scopeConfigId={configId}
+ scopeConfigName={configName}
+ onSuccess={() => setVersion(version + 1)}
/>
),
},
@@ -579,7 +518,6 @@ export const Connection = () => {
)}
)}
- {contextHolder}
);
};
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,
},