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

Feat: support independent env management #294

Merged
merged 3 commits into from
Dec 25, 2021
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
76 changes: 38 additions & 38 deletions public/mock/getDeliveryTarget.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
{
"deliveryTargets": [
{
"id": "jijijifdj",
"name": "king",
"alias": "king1",
"namespace": "string",
"description": "string",
"cluster": {
"clusterName": "string",
"namespace": "string"
},
"variable": "any"
},
{
"id": "erere",
"name": "joker",
"alias": "joker1",
"namespace": "string",
"description": "string",
"cluster": {
"clusterName": "string",
"namespace": "string"
},
"variable": "any"
},
{
"id": "ijidfjidj",
"name": "amy",
"alias": "amy1",
"namespace": "string",
"description": "string",
"cluster": {
"clusterName": "string",
"namespace": "string"
},
"variable": "any"
}
]
"targets": [
{
"id": "jijijifdj",
"name": "king",
"alias": "king1",
"namespace": "string",
"description": "string",
"cluster": {
"clusterName": "string",
"namespace": "string"
},
"variable": "any"
},
{
"id": "erere",
"name": "joker",
"alias": "joker1",
"namespace": "string",
"description": "string",
"cluster": {
"clusterName": "string",
"namespace": "string"
},
"variable": "any"
},
{
"id": "ijidfjidj",
"name": "amy",
"alias": "amy1",
"namespace": "string",
"description": "string",
"cluster": {
"clusterName": "string",
"namespace": "string"
},
"variable": "any"
}
]
}
37 changes: 16 additions & 21 deletions src/api/addons.ts
Original file line number Diff line number Diff line change
@@ -1,59 +1,54 @@
import { post, get, rdelete, put } from './request';
import {
addons_mock,
addonsDetails_mock,
disabletAddonsCluster_mock,
enableAddonsCluster_mock,
addonsStatus_mock,
} from './devLink';
import { addons, addonRegistrys } from './productionLink';
import { addons, addonRegistrys, enabledAddon } from './productionLink';
import { getDomain } from '../utils/common';

const baseURLOject = getDomain();
const isMock = baseURLOject.MOCK;
const url = isMock ? addons_mock : addons;
const base = baseURLOject.MOCK || baseURLOject.APIBASE;

export function getAddonRegistrysList(params: any) {
return get(addonRegistrys, { params: params }).then((res) => res);
return get(base + addonRegistrys, { params: params }).then((res) => res);
}

export function createAddonRegistry(params: any) {
return post(addonRegistrys, params);
return post(base + addonRegistrys, params);
}

export function deleteAddonRegistry(params: { name: string }) {
return rdelete(addonRegistrys + '/' + params.name, params).then((res) => res);
return rdelete(base + addonRegistrys + '/' + params.name, params).then((res) => res);
}

export function getAddonsList(params: any) {
return get(url, { params: params }).then((res) => res);
return get(base + addons, { params: params }).then((res) => res);
}

export function createAddons(params: any) {
return post(url, params).then((res) => res);
return post(base + addons, params).then((res) => res);
}

export function getAddonsDetails(params: any) {
const gurl = isMock ? `${addonsDetails_mock}` : `${addons}/${params.name}`;
const gurl = `${base + addons}/${params.name}`;
return get(gurl, params).then((res) => res);
}

export function disableAddon(params: any) {
const gurl = isMock ? `${disabletAddonsCluster_mock}` : `${addons}/${params.name}/disable`;
const gurl = `${base + addons}/${params.name}/disable`;
return post(gurl, params).then((res) => res);
}

export function enableAddon(params: { name: string; properties: any }) {
const gurl = isMock ? `${enableAddonsCluster_mock}` : `${addons}/${params.name}/enable`;
const gurl = `${base + addons}/${params.name}/enable`;
return post(gurl, { args: params.properties }).then((res) => res);
}

export function upgradeAddon(params: { name: string; properties: any }) {
const gurl = isMock ? `${enableAddonsCluster_mock}` : `${addons}/${params.name}/update`;
const gurl = `${base + addons}/${params.name}/update`;
return put(gurl, { args: params.properties }).then((res) => res);
}

export function getAddonsStatus(params: any) {
const gurl = isMock ? `${addonsStatus_mock}` : `${addons}/${params.name}/status`;
const gurl = `${base + addons}/${params.name}/status`;
return get(gurl, params).then((res) => res);
}

export function getEnabledAddons(params: any) {
return get(base + enabledAddon, params);
}
2 changes: 1 addition & 1 deletion src/api/devLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const getWorkFlowsRecord_mock = '/mock/getWorkFlowsRecord.json';
export const clusterCloudList_mock = '/mock/clusterCloudList.json';
export const connectClusterCloud_mock = '/mock/connectClusterCloud.json';
export const createApplicationEnv_mock = '/mock/createApplicationEnv.json';
export const getDeliveryTarget_mock = '/mock/getDeliveryTarget.json';
export const gettarget_mock = '/mock/gettarget.json';

export const getTraitDefinitionsDetails_mock = '/mock/getTraitDefinitionsDetails.json';
export const getTraitDefinitions_mock = '/mock/getTraitDefinitions.json';
Expand Down
27 changes: 27 additions & 0 deletions src/api/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { post, get, rdelete, put } from './request';
import { getDomain } from '../utils/common';
import type { Querytarget } from '../model/target';
import type { CreateEnvRequest } from '../interface/env';
import { envURL } from './productionLink';

const baseURLOject = getDomain();
const base = baseURLOject.MOCK || baseURLOject.APIBASE;
export function getEnvs(params: Querytarget) {
const url = base + envURL;
return get(url, { params: params }).then((res) => res);
}

export function createEnv(params: CreateEnvRequest) {
const url = base + envURL;
return post(url, params);
}

export function deleteEnv(params: { name: string }) {
const url = base + `${envURL}/${params.name}`;
return rdelete(url, params);
}

export function updateEnv(params: CreateEnvRequest) {
const url = base + `${envURL}/${params.name}`;
return put(url, params);
}
2 changes: 1 addition & 1 deletion src/api/observation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export function listCloudResourceSecrets(params: { appNs: string; appName?: stri

export function listApplicationService(params: {
appNs: string;
appName?: string;
appName: string;
cluster?: string;
clusterNs?: string;
}) {
Expand Down
4 changes: 3 additions & 1 deletion src/api/productionLink.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
export const application = `/api/v1/applications`;
export const componentdefinition = `/api/v1/definitions`;
export const addons = `/api/v1/addons`;
export const enabledAddon = `/api/v1/enabled_addon`;
export const addonRegistrys = `/api/v1/addon_registries`;
export const cluster = '/api/v1/clusters';
export const workflows = '/api/v1/applications';
export const project = `/api/v1/projects`;
export const target = `/api/v1/targets`;
export const targetURL = `/api/v1/targets`;
export const envURL = `/api/v1/envs`;
24 changes: 12 additions & 12 deletions src/api/target.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import { post, get, rdelete, put } from './request';
import { getDeliveryTarget_mock } from './devLink';
import { target } from './productionLink';
import { gettarget_mock } from './devLink';
import { targetURL } from './productionLink';
import { getDomain } from '../utils/common';
import type { DeliveryTarget } from '../interface/deliveryTarget';
import type { QueryDeliveryTarget } from '../model/deliveryTarget';
import type { Target } from '../interface/target';
import type { Querytarget } from '../model/target';

const baseURLOject = getDomain();
const isMock = baseURLOject.MOCK;

export function getDeliveryTarget(params: QueryDeliveryTarget) {
const url = isMock ? getDeliveryTarget_mock : target;
export function getTarget(params: Querytarget) {
const url = isMock ? gettarget_mock : targetURL;
return get(url, { params: params }).then((res) => res);
}

export function createDeliveryTarget(params: DeliveryTarget) {
const url = isMock ? getDeliveryTarget_mock : target;
export function createTarget(params: Target) {
const url = isMock ? gettarget_mock : targetURL;
return post(url, params);
}

export function deleteDeliveryTarget(params: { name: string }) {
const url = isMock ? getDeliveryTarget_mock : `${target}/${params.name}`;
export function deleteTarget(params: { name: string }) {
const url = isMock ? gettarget_mock : `${targetURL}/${params.name}`;
return rdelete(url, params);
}

export function updateDeliveryTarget(params: DeliveryTarget) {
const url = isMock ? getDeliveryTarget_mock : `${target}/${params.name}`;
export function updateTarget(params: Target) {
const url = isMock ? gettarget_mock : `${targetURL}/${params.name}`;
return put(url, params);
}
14 changes: 6 additions & 8 deletions src/components/EnvPlan/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import './index.less';
import type { EnvBinding } from '../../interface/application';
import Translation from '../Translation';
import { checkName } from '../../utils/common';
import type { DeliveryTarget } from '../../interface/deliveryTarget';
import TargetDialog from '../../pages/DeliveryTargetList/components/TargetDialog';
import type { Target } from '../../interface/target';
import TargetDialog from '../../pages/TargetList/components/TargetDialog';
import type { Project } from '../../interface/project';
import type { Cluster } from '../../interface/cluster';
import locale from '../../utils/locale';
Expand All @@ -16,7 +16,7 @@ const { Col, Row } = Grid;
type Props = {
project?: string;
value: EnvBinding[];
targetList?: DeliveryTarget[];
targetList?: Target[];
envList?: EnvBinding[];
t: (key: string) => string;
onUpdateTarget: () => void;
Expand Down Expand Up @@ -232,8 +232,8 @@ export default class EnvPlan extends React.Component<Props, State> {

render() {
const { envList, showAddTarget } = this.state;
const { targetList, project, projects, clusterList } = this.props;
const dataSource = (targetList || []).map((item: DeliveryTarget) => ({
const { targetList, project, clusterList } = this.props;
const dataSource = (targetList || []).map((item: Target) => ({
value: item.name,
label: item.alias || item.name,
}));
Expand Down Expand Up @@ -263,7 +263,7 @@ export default class EnvPlan extends React.Component<Props, State> {
</div>
<div className="env-plan-option">
<Button onClick={this.addEnvPlanItem} type="secondary">
<Translation>New Environment</Translation>
<Translation>New Envbinding</Translation>
</Button>
</div>
<If condition={showAddTarget}>
Expand All @@ -272,8 +272,6 @@ export default class EnvPlan extends React.Component<Props, State> {
this.props.onUpdateTarget();
this.setState({ showAddTarget: false });
}}
syncProjectList={this.props.syncProjectList}
projects={projects || []}
clusterList={clusterList || []}
project={project}
onClose={() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/StatusShow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class StatusShow extends React.Component<Props> {
<Card
locale={locale.Card}
style={{ marginTop: '8px' }}
title={<Translation>Progress</Translation>}
title={<Translation>Conditions</Translation>}
>
<Step current={getCurrent(applicationStatus?.conditions)}>
{allConditions.map((condition) => {
Expand Down
1 change: 0 additions & 1 deletion src/components/UISchema/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,6 @@ class UISchema extends Component<Props, State> {
/>,
);
case 'SecretSelect':
console.log(this.props.value);
return (
<Form.Item
labelAlign={inline ? 'inset' : 'left'}
Expand Down
5 changes: 5 additions & 0 deletions src/interface/addon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,8 @@ export interface AddonRegistry {
git: RegistryGitSource;
oss: RegistryOssSource;
}

export interface AddonBaseStatus {
name: string;
phase: 'disabled' | 'enabled' | 'enabling' | 'suspend' | 'disabling';
}
12 changes: 5 additions & 7 deletions src/interface/application.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { DeliveryTarget } from './deliveryTarget';
import type { Target } from './target';
import type { Project } from './project';

export interface ApplicationDetail {
Expand All @@ -23,13 +23,11 @@ export interface EnvBinding {
alias?: string;
description?: string;
targetNames: string[];
deliveryTargets?: DeliveryTarget[];
componentSelector?: {
components: string[];
};
targets?: Target[];
createTime?: string;
updateTime?: string;
appDeployName?: string;
appDeployName: string;
appDeployNamespace: string;
}

export interface WorkflowStatus {
Expand Down Expand Up @@ -205,7 +203,7 @@ export interface Revisions {

export interface ApplicationStatistics {
envCount: number;
deliveryTargetCount: number;
targetCount: number;
revisonCount: number;
workflowCount: number;
}
Expand Down
28 changes: 28 additions & 0 deletions src/interface/env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export interface CreateEnvRequest {
name: string;
alias?: string;
description?: string;
targets: string[];
namespace?: string;
}

export interface Env {
name: string;
alias?: string;
description?: string;
namespace: string;
targets: NameAlias[];
project: NameAlias;
createTime?: string;
updateTime?: string;
}

export interface EnvListResponse {
envs: Env[];
total: number;
}

export interface NameAlias {
name: string;
alias: string;
}
1 change: 0 additions & 1 deletion src/interface/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export interface Project {
name: string;
alias?: string;
description?: string;
namespace: string;
createTime?: string;
updateTime?: string;
}
Loading