diff --git a/src/api/application.ts b/src/api/application.ts
index eda4ecc82..111fcac97 100644
--- a/src/api/application.ts
+++ b/src/api/application.ts
@@ -1,22 +1,6 @@
import { post, get, rdelete, put } from './request';
-import {
- application_mock,
- getApplicationDetails_mock,
- getApplicationComponents_mock,
- createApplicationComponent_mock,
- getComponentDetails_mock,
- updateApplication_mock,
- getPolicyList_mock,
- createPolicy_mock,
- getPolicyDetails_mock,
- createApplicationTemplate_mock,
- createApplicationEnv_mock,
- getTraitDefinitionsDetails_mock,
- getTraitDefinitions_mock,
- getTrait_mock,
- updateApplicationEnv_mock,
-} from './devLink';
-import { application, definition } from './productionLink';
+
+import { application } from './productionLink';
import { getDomain } from '../utils/common';
import type {
ApplicationDeployRequest,
@@ -45,8 +29,7 @@ interface listRevisionsQuery {
}
const baseURLOject = getDomain();
-const isMock = baseURLOject.MOCK;
-const url = isMock ? application_mock : application;
+const url = baseURLOject.APIBASE + application;
export function getApplicationList(params: ApplicationQuery) {
return get(url, { params: params }).then((res) => res);
@@ -58,204 +41,141 @@ export function createApplication(params: any) {
}
export function getApplicationDetails(params: any) {
- const gurl = isMock ? `${getApplicationDetails_mock}` : `${application}/${params.name}`;
- return get(gurl, params).then((res) => res);
+ return get(`${url}/${params.name}`, params).then((res) => res);
}
export function getApplicationStatus(params: { name: string; envName: string }) {
- const gurl = isMock
- ? `${getApplicationDetails_mock}`
- : `${application}/${params.name}/envs/${params.envName}/status`;
- return get(gurl, params).then((res) => res);
+ return get(`${url}/${params.name}/envs/${params.envName}/status`, params).then((res) => res);
}
-export function deleteApplicationPlan(params: { name: string }) {
+export function deleteApplication(params: { name: string }) {
return rdelete(url + '/' + params.name, params);
}
export function getApplicationComponents(params: { appName: string }) {
const { appName } = params;
- const gurl = isMock ? `${getApplicationComponents_mock}` : `${application}/${appName}/components`;
- return get(gurl, {}).then((res) => res);
+ return get(`${url}/${appName}/components`, {}).then((res) => res);
}
export function createApplicationComponent(
params: ApplicationComponentConfig,
query: { appName: string },
) {
- const gurl = isMock
- ? `${createApplicationComponent_mock}`
- : `${application}/${query.appName}/components`;
- return post(gurl, params).then((res) => res);
+ return post(`${url}/${query.appName}/components`, params).then((res) => res);
}
export function getComponentDetails(params: any) {
- const gurl = isMock
- ? `${getComponentDetails_mock}`
- : `${application}/${params.name}/components/${params.componentName}`;
- return post(gurl, params).then((res) => res);
+ return post(`${url}/${params.name}/components/${params.componentName}`, params).then(
+ (res) => res,
+ );
}
export function deployApplication(params: ApplicationDeployRequest, customError?: boolean) {
- const gurl = isMock ? `${updateApplication_mock}` : `${application}/${params.appName}/deploy`;
- return post(gurl, params, customError);
+ return post(`${url}/${params.appName}/deploy`, params, customError);
}
export function getPolicyList(params: { appName: string }) {
- const gurl = isMock ? `${getPolicyList_mock}` : `${application}/${params.appName}/policies`;
- return get(gurl, params).then((res) => res);
+ return get(`${url}/${params.appName}/policies`, params).then((res) => res);
}
export function createPolicy(appName: string, params: CreatePolicyRequest) {
- const gurl = isMock ? `${createPolicy_mock}` : `${application}/${appName}/policies`;
- return post(gurl, params).then((res) => res);
+ return post(`${url}/${appName}/policies`, params).then((res) => res);
}
export function updatePolicy(appName: string, policyName: string, params: UpdatePolicyRequest) {
- const gurl = `${application}/${appName}/policies/${policyName}`;
- return put(gurl, params).then((res) => res);
+ return put(`${url}/${appName}/policies/${policyName}`, params).then((res) => res);
}
export function getPolicyDetail(params: { appName: string; policyName: string }) {
- const gurl = isMock
- ? `${getPolicyDetails_mock}`
- : `${application}/${params.appName}/policies/${params.policyName}`;
- return get(gurl, params).then((res) => res);
+ return get(`${url}/${params.appName}/policies/${params.policyName}`, params).then((res) => res);
}
export function deletePolicy(params: { appName: string; policyName: string; force?: boolean }) {
- const gurl = `${application}/${params.appName}/policies/${params.policyName}`;
+ const gURL = `${url}/${params.appName}/policies/${params.policyName}`;
if (params.force) {
- return rdelete(gurl, { params: { force: true } }, true).then((res) => res);
+ return rdelete(gURL, { params: { force: true } }, true).then((res) => res);
}
- return rdelete(gurl, {}, true).then((res) => res);
+ return rdelete(gURL, {}, true).then((res) => res);
}
export function createApplicationTemplate(params: any) {
- const gurl = isMock
- ? `${createApplicationTemplate_mock}`
- : `${application}/${params.name}/template`;
- return post(gurl, params).then((res) => res);
-}
-
-export function getComponentDefinitions() {
- const gurl = isMock ? `${getPolicyDetails_mock}` : `${definition}`;
- return get(gurl, { params: { type: 'component' } }).then((res) => res);
-}
-
-export function detailComponentDefinition(params: { name: string }) {
- const gurl = isMock ? `${getPolicyDetails_mock}` : `${definition}/${params.name}`;
- return get(gurl, { params: { type: 'component' } }).then((res) => res);
-}
-
-export function getPolicyDefinitions() {
- const gurl = isMock ? `${getPolicyDetails_mock}` : `${definition}`;
- return get(gurl, { params: { type: 'policy' } }).then((res) => res);
-}
-
-export function detailPolicyDefinition(params: { name: string }) {
- const gurl = isMock ? `${getPolicyDetails_mock}` : `${definition}/${params.name}`;
- return get(gurl, { params: { type: 'policy' } }).then((res) => res);
+ return post(`${url}/${params.name}/template`, params).then((res) => res);
}
export function createApplicationEnv(params: { appName?: string }) {
- const gurl = isMock ? `${createApplicationEnv_mock}` : `${application}/${params.appName}/envs`;
delete params.appName;
- return post(gurl, params).then((res) => res);
+ return post(`${url}/${params.appName}/envs`, params).then((res) => res);
}
export function updateApplicationEnv(params: { appName?: string; name: string }) {
- const gurl = isMock
- ? `${updateApplicationEnv_mock}`
- : `${application}/${params.appName}/envs/${params.name}`;
- return put(gurl, params).then((res) => res);
+ return put(`${url}/${params.appName}/envs/${params.name}`, params).then((res) => res);
}
export function getApplicationEnvbinding(params: { appName: string }) {
- return get(`${application}/${params.appName}/envs`, params).then((res) => res);
+ return get(`${url}/${params.appName}/envs`, params).then((res) => res);
}
export function deleteApplicationEnvbinding(params: { appName: string; envName: string }) {
- return rdelete(`${application}/${params.appName}/envs/${params.envName}`, {}).then((res) => res);
+ return rdelete(`${url}/${params.appName}/envs/${params.envName}`, {}).then((res) => res);
}
export function recycleApplicationEnvbinding(params: { appName: string; envName: string }) {
- return post(`${application}/${params.appName}/envs/${params.envName}/recycle`, {}).then(
- (res) => res,
- );
-}
-
-export function getTraitDefinitions(params: { appliedWorkload: string }) {
- const gurl = isMock ? `${getTraitDefinitions_mock}` : `${definition}`;
- return get(gurl, { params: { type: 'trait', appliedWorkload: params.appliedWorkload } }).then(
- (res) => res,
- );
-}
-
-export function detailTraitDefinition(params: { name: string }) {
- const gurl = isMock ? `${getTraitDefinitionsDetails_mock}` : `${definition}/${params.name}`;
- return get(gurl, { params: { type: 'trait' } }).then((res) => res);
+ return post(`${url}/${params.appName}/envs/${params.envName}/recycle`, {}).then((res) => res);
}
export function getApplicationComponent(appName: string, componentName: string) {
- const gurl = isMock
- ? `${getTrait_mock}`
- : `${application}/${appName}/components/${componentName}`;
- return get(gurl, {}).then((res) => res);
+ return get(`${url}/${appName}/components/${componentName}`, {}).then((res) => res);
}
export function createTrait(params: Trait, query: TraitQuery) {
const { appName, componentName } = query;
- const gurl = isMock
- ? `${getTrait_mock}`
- : `${application}/${appName}/components/${componentName}/traits`;
- return post(gurl, params).then((res) => res);
+ return post(`${url}/${appName}/components/${componentName}/traits`, params).then((res) => res);
}
export function updateTrait(params: Trait, query: TraitQuery) {
const { appName, componentName, traitType } = query;
- const gurl = isMock
- ? `${getTrait_mock}`
- : `${application}/${appName}/components/${componentName}/traits/${traitType}`;
- return put(gurl, params).then((res) => res);
+ return put(`${url}/${appName}/components/${componentName}/traits/${traitType}`, params).then(
+ (res) => res,
+ );
}
export function deleteTrait(query: TraitQuery) {
const { appName, componentName, traitType } = query;
- const gurl = isMock
- ? `${getTrait_mock}`
- : `${application}/${appName}/components/${componentName}/traits/${traitType}`;
- return rdelete(gurl, {}).then((res) => res);
+ return rdelete(`${url}/${appName}/components/${componentName}/traits/${traitType}`, {}).then(
+ (res) => res,
+ );
}
export function listRevisions(query: listRevisionsQuery) {
const { appName } = query;
- const gurl = isMock ? `${getTrait_mock}` : `${application}/${appName}/revisions`;
- return get(gurl, { params: query }).then((res) => res);
+ return get(`${url}/${appName}/revisions`, { params: query }).then((res) => res);
}
export function detailRevision(query: { appName: string; revision: string }) {
const { appName, revision } = query;
- const gurl = isMock ? `${getTrait_mock}` : `${application}/${appName}/revisions/${revision}`;
- return get(gurl, {}).then((res) => res);
+ return get(`${url}/${appName}/revisions/${revision}`, {}).then((res) => res);
+}
+
+export function rollbackWithRevision(query: { appName: string; revision: string }) {
+ const { appName, revision } = query;
+ return post(`${url}/${appName}/revisions/${revision}/rollback`, {}).then((res) => res);
}
export function getApplicationStatistics(params: { appName: string }) {
- return get(`${application}/${params.appName}/statistics`, params).then((res) => res);
+ return get(`${url}/${params.appName}/statistics`, params).then((res) => res);
}
export function getApplicationWorkflowRecord(params: { appName: string }) {
- return get(`${application}/${params.appName}/records`, params).then((res) => res);
+ return get(`${url}/${params.appName}/records`, params).then((res) => res);
}
export function updateComponentProperties(
params: ApplicationComponentConfig,
query: { appName: string; componentName: string },
) {
- const gurl = isMock
- ? `${getComponentDetails_mock}`
- : `${application}/${query.appName}/components/${query.componentName}`;
- return put(gurl, params).then((res) => res);
+ return put(`${url}/${query.appName}/components/${query.componentName}`, params).then(
+ (res) => res,
+ );
}
export function resumeApplicationWorkflowRecord(params: {
@@ -264,10 +184,9 @@ export function resumeApplicationWorkflowRecord(params: {
recordName: string;
}) {
const { appName, workflowName, recordName } = params;
- return get(
- `${application}/${appName}/workflows/${workflowName}/records/${recordName}/resume`,
- {},
- ).then((res) => res);
+ return get(`${url}/${appName}/workflows/${workflowName}/records/${recordName}/resume`, {}).then(
+ (res) => res,
+ );
}
export function rollbackApplicationWorkflowRecord(params: {
@@ -276,10 +195,9 @@ export function rollbackApplicationWorkflowRecord(params: {
recordName: string;
}) {
const { appName, workflowName, recordName } = params;
- return get(
- `${application}/${appName}/workflows/${workflowName}/records/${recordName}/rollback`,
- {},
- ).then((res) => res);
+ return get(`${url}/${appName}/workflows/${workflowName}/records/${recordName}/rollback`, {}).then(
+ (res) => res,
+ );
}
export function terminateApplicationWorkflowRecord(params: {
@@ -289,47 +207,41 @@ export function terminateApplicationWorkflowRecord(params: {
}) {
const { appName, workflowName, recordName } = params;
return get(
- `${application}/${appName}/workflows/${workflowName}/records/${recordName}/terminate`,
+ `${url}/${appName}/workflows/${workflowName}/records/${recordName}/terminate`,
{},
).then((res) => res);
}
export function getApplicationTriggers(params: { appName: string }) {
const { appName } = params;
- const gurl = isMock ? `${getTrait_mock}` : `${application}/${appName}/triggers`;
- return get(gurl, {}).then((res) => res);
+ return get(`${url}/${appName}/triggers`, {}).then((res) => res);
}
export function updateApplication(params: any) {
- const _url = isMock ? `${updateApplicationEnv_mock}` : `${application}/${params.name}`;
- return put(_url, params).then((res) => res);
+ return put(`${url}/${params.name}`, params).then((res) => res);
}
export function createTriggers(params: Trigger, query: { appName: string }) {
const { appName } = query;
- const gurl = isMock ? `${getTrait_mock}` : `${application}/${appName}/triggers`;
- return post(gurl, params).then((res) => res);
+ return post(`${url}/${appName}/triggers`, params).then((res) => res);
}
export function deleteTriggers(params: { appName: string; token: string }) {
const { appName, token } = params;
- const gurl = isMock ? `${getTrait_mock}` : `${application}/${appName}/triggers/${token}`;
- return rdelete(gurl, {}).then((res) => res);
+ return rdelete(`${url}/${appName}/triggers/${token}`, {}).then((res) => res);
}
export function deleteComponent(query: { appName: string; componentName: string }) {
- const gurl = isMock
- ? `${getTrait_mock}`
- : `${application}/${query.appName}/components/${query.componentName}`;
- return rdelete(gurl, {}).then((res) => res);
+ return rdelete(`${url}/${query.appName}/components/${query.componentName}`, {}).then(
+ (res) => res,
+ );
}
export function compareApplication(appName: string, params: ApplicationCompareRequest) {
- const gurl = `${application}/${appName}/compare`;
- return post(gurl, params).then((res) => res);
+ const _url = `${url}/${appName}/compare`;
+ return post(_url, params).then((res) => res);
}
export function dryRunApplication(appName: string, params: ApplicationDryRunRequest) {
- const gurl = `${application}/${appName}/dry-run`;
- return post(gurl, params, true).then((res) => res);
+ return post(`${url}/${appName}/dry-run`, params, true).then((res) => res);
}
diff --git a/src/api/definitions.ts b/src/api/definitions.ts
index 060e5a5fc..d45523e11 100644
--- a/src/api/definitions.ts
+++ b/src/api/definitions.ts
@@ -45,3 +45,35 @@ export function updateUISchema(params: {
};
return put(url, paramsData).then((res) => res);
}
+
+export function getComponentDefinitions() {
+ const _url = base + definition;
+ return get(_url, { params: { type: 'component' } }).then((res) => res);
+}
+
+export function detailComponentDefinition(params: { name: string }) {
+ const _url = `${base + definition}/${params.name}`;
+ return get(_url, { params: { type: 'component' } }).then((res) => res);
+}
+
+export function getPolicyDefinitions() {
+ const _url = base + definition;
+ return get(_url, { params: { type: 'policy' } }).then((res) => res);
+}
+
+export function detailPolicyDefinition(params: { name: string }) {
+ const _url = `${base + definition}/${params.name}`;
+ return get(_url, { params: { type: 'policy' } }).then((res) => res);
+}
+
+export function getTraitDefinitions(params: { appliedWorkload: string }) {
+ const _url = base + definition;
+ return get(_url, { params: { type: 'trait', appliedWorkload: params.appliedWorkload } }).then(
+ (res) => res,
+ );
+}
+
+export function detailTraitDefinition(params: { name: string }) {
+ const _url = `${base + definition}/${params.name}`;
+ return get(_url, { params: { type: 'trait' } }).then((res) => res);
+}
diff --git a/src/components/ApplicationDiff/index.less b/src/components/ApplicationDiff/index.less
index 6ace48c46..c955942c3 100644
--- a/src/components/ApplicationDiff/index.less
+++ b/src/components/ApplicationDiff/index.less
@@ -1,5 +1,5 @@
.diff-box {
- max-height: 600px;
+ height: 600px;
overflow-y: auto;
background: #000;
p {
diff --git a/src/components/ApplicationDiff/index.tsx b/src/components/ApplicationDiff/index.tsx
index e0c32d5af..6cc77b17a 100644
--- a/src/components/ApplicationDiff/index.tsx
+++ b/src/components/ApplicationDiff/index.tsx
@@ -1,9 +1,10 @@
import * as React from 'react';
-import { Dialog } from '@b-design/ui';
+import { Dialog, Message } from '@b-design/ui';
import type { ApplicationCompareResponse } from '../../interface/application';
-const Convert = require('ansi-to-html');
-const convert = new Convert();
import './index.less';
+import { DiffEditor } from '../DiffEditor';
+import { If } from 'tsx-control-statements/components';
+import Translation from '../Translation';
type ApplicationDiffProps = {
baseName: string;
@@ -14,15 +15,8 @@ type ApplicationDiffProps = {
};
export const ApplicationDiff = (props: ApplicationDiffProps) => {
- const lines = props.compare.diffReport.split('\n');
- const parseToDOM = (str: string, padding: number) => {
- return (
-
- );
- };
+ const { baseName, targetName, compare } = props;
+ const container = 'revision' + baseName + targetName;
return (