Skip to content

Commit

Permalink
Feat: make the node dashboard plugin to work
Browse files Browse the repository at this point in the history
Signed-off-by: barnettZQG <[email protected]>
  • Loading branch information
barnettZQG committed Apr 2, 2023
1 parent 2e452d4 commit f10a8eb
Show file tree
Hide file tree
Showing 179 changed files with 1,372 additions and 824 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/server-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ jobs:
export ALIYUN_ACCESS_KEY_ID=${{ secrets.ALIYUN_ACCESS_KEY_ID }}
export ALIYUN_ACCESS_KEY_SECRET=${{ secrets.ALIYUN_ACCESS_KEY_SECRET }}
export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
docker run --rm -v `pwd`/e2e-plugins:/plugins oamdev/velaux:latest cp -r -a /app/velaux/plugins/app-demo /plugins/app-demo
docker run --rm -v `pwd`/e2e-plugins:/plugins oamdev/velaux:latest cp -r -a /app/velaux/plugins/ /plugins/
make e2e-server-test
- name: Upload coverage report
Expand Down
15 changes: 12 additions & 3 deletions e2e-test/plugin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,11 @@ limitations under the License.
package e2e_test

import (
"fmt"

"cuelang.org/go/pkg/strings"
"github.com/google/go-cmp/cmp"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"

apisv1 "github.com/kubevela/velaux/pkg/server/interfaces/api/dto/v1"
"github.com/kubevela/velaux/pkg/server/utils/bcode"
Expand Down Expand Up @@ -62,8 +61,18 @@ var _ = Describe("Test to request the dex plugin", func() {
res := get(baseDomain + "/dex/a")
var bcode bcode.Bcode
err := decodeResponseBody(res, &bcode)
fmt.Println(err.Error())
Expect(strings.HasPrefix(err.Error(), "response code is not 200")).Should(BeTrue())
Expect(cmp.Diff(bcode.BusinessCode, int32(404))).Should(BeEmpty())
})
})

var _ = Describe("Test to request the kube API", func() {
It("Test to request the dex", func() {
defer GinkgoRecover()
res := get(baseDomain + "/proxy/plugins/node-dashboard/api/v1/nodes")
var nodeList corev1.NodeList
err := decodeResponseBody(res, &nodeList)
Expect(err).Should(BeNil())
Expect(cmp.Diff(len(nodeList.Items), int32(2))).Should(BeEmpty())
})
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"packages:theme": "yarn workspace @velaux/theme build",
"packages:ui": "yarn workspace @velaux/ui build",
"packages:data": "yarn workspace @velaux/data build",
"packages:plugins": "yarn workspace @velaux-plugins/app-demo build"
"packages:plugins": "yarn workspace @velaux-plugins/app-demo build && yarn workspace @velaux-plugins/node-dashboard build"
},
"workspaces": {
"packages": [
Expand Down
29 changes: 29 additions & 0 deletions packages/velaux-data/src/api/cluster.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
export interface Cluster {
name: string;
kubeConfig: string;
alias?: string;
status?: string;
icon?: string;
description?: string;
createTime?: string;
dashboardURL?: string;
labels?: {};
providerInfo?: {
provider: string;
clusterID: string;
clusterName?: string;
regionID?: string;
vpcID?: string;
zoneID?: string;
};
}

export interface CreateCluster {
name: string;
alias?: string;
icon?: string;
description?: string;
dashboardURL?: string;
kubeConfig: string;
labels?: {};
}
1 change: 1 addition & 0 deletions packages/velaux-data/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './cluster';
1 change: 1 addition & 0 deletions packages/velaux-data/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './types';
export * from './plugins';
export * from './api';
18 changes: 16 additions & 2 deletions packages/velaux-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.8.0",
"private": true,
"scripts": {
"build": "tsc -p ./tsconfig.build.json",
"build": "tsc -p ./tsconfig.build.json && rollup -c rollup.config.ts",
"test": "ts-mocha -p tsconfig.test.json src/**/**.test.ts",
"lint": "yarn lint:js && yarn lint:style && yarn lint:prettier",
"lint:js": "eslint --ext .js,.jsx,.ts,.tsx --format=pretty ./src",
Expand All @@ -21,11 +21,17 @@
"path": "./node_modules/cz-customizable"
}
},
"types": "./types.ts",
"types": "src/types.ts",
"main": "src/index.ts",
"directories": {
"src": "./src"
},
"publishConfig": {
"main": "dist/types.js",
"module": "dist/esm/types.js",
"types": "dist/types.d.ts",
"access": "public"
},
"browserslist": {
"production": [
">0.2%",
Expand All @@ -42,6 +48,7 @@
"@alifd/field": "1.6.2",
"@alifd/next": "1.26.14",
"@alifd/theme-2": "0.4.4",
"@kubernetes/client-node": "0.18.1",
"@sentry/browser": "7.45.0",
"@velaux/data": "0.0.1",
"@velaux/theme": "0.0.1",
Expand Down Expand Up @@ -87,6 +94,9 @@
"devDependencies": {
"@grafana/tsconfig": "^1.2.0-rc1",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.1",
"@rollup/plugin-commonjs": "23.0.2",
"@rollup/plugin-json": "5.0.1",
"@rollup/plugin-node-resolve": "15.0.1",
"@testing-library/react": "^12.1.2",
"@types/base-64": "^1.0.0",
"@types/chai": "^4.2.11",
Expand All @@ -104,6 +114,10 @@
"@types/webpack-env": "1.18.0",
"chai": "^4.2.0",
"mocha": "10.2.0",
"rollup": "2.79.1",
"rollup-plugin-dts": "^5.0.0",
"rollup-plugin-esbuild": "5.0.0",
"rollup-plugin-node-externals": "^5.0.0",
"ts-mocha": "10.0.0"
}
}
38 changes: 38 additions & 0 deletions packages/velaux-ui/rollup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import resolve from '@rollup/plugin-node-resolve';
import path from 'path';
import dts from 'rollup-plugin-dts';
import esbuild from 'rollup-plugin-esbuild';
import { externals } from 'rollup-plugin-node-externals';
import json from '@rollup/plugin-json';

const pkg = require('./package.json');

export default [
{
input: 'src/types.ts',
plugins: [externals({ deps: true, packagePath: './package.json' }), resolve(), esbuild(), json()],
output: [
{
format: 'cjs',
sourcemap: true,
dir: path.dirname(pkg.publishConfig.main),
},
{
format: 'esm',
sourcemap: true,
dir: path.dirname(pkg.publishConfig.module),
preserveModules: true,
// @ts-expect-error (TS cannot assure that `process.env.PROJECT_CWD` is a string)
preserveModulesRoot: path.join(process.env.PROJECT_CWD, `packages/velux-ui/src`),
},
],
},
{
input: './compiled/types.d.ts',
plugins: [dts()],
output: {
file: pkg.publishConfig.types,
format: 'es',
},
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import type { ApplicationCompareResponse } from '../../interface/application';
import './index.less';
import { DiffEditor } from '../DiffEditor';
import { If } from '../If';
import Translation from '../Translation';
import { Translation } from '../Translation';

type ApplicationDiffProps = {
baseName: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/velaux-ui/src/components/CustomSelect/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { SelectProps } from '@alifd/next/lib/select';
import { Select } from '@alifd/next';
import * as React from 'react';

import locale from '../../utils/locale';
import { locale } from '../../utils/locale';

interface CustomSelectProps extends SelectProps {
enableInput?: boolean;
Expand Down
16 changes: 3 additions & 13 deletions packages/velaux-ui/src/components/Drawer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { Component } from 'react';

import './index.less';
import { If } from '../If';
import Translation from '../Translation';
import { Translation } from '../Translation';

type Props = {
onOk?: () => void;
Expand All @@ -20,18 +20,8 @@ type Props = {

class DrawerWithFooter extends Component<Props, any> {
render() {
const {
visible,
children,
title,
placement,
width,
onOk,
onClose,
extButtons,
onOkButtonText,
onOkButtonLoading,
} = this.props;
const { visible, children, title, placement, width, onOk, onClose, extButtons, onOkButtonText, onOkButtonLoading } =
this.props;
return (
<Drawer
title={<>{title}</>}
Expand Down
2 changes: 1 addition & 1 deletion packages/velaux-ui/src/components/Empty/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import { If } from '../If';
import Translation from '../Translation';
import { Translation } from '../Translation';

import './index.less';

Expand Down
2 changes: 1 addition & 1 deletion packages/velaux-ui/src/components/ErrorShow/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { ErrorInfo } from 'react';
import Translation from '../Translation';
import { Translation } from '../Translation';

interface Props {
error: Error | null;
Expand Down
11 changes: 5 additions & 6 deletions packages/velaux-ui/src/components/ListTitle/index.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
import { Button } from '@alifd/next';
import React from 'react';

import Translation from '../Translation';
import { Translation } from '../Translation';
import './index.less';
import { If } from '../If';
type Props = {
export interface Props {
title: string;
subTitle?: string;
extButtons?: [React.ReactNode];
addButtonTitle?: string;
addButtonClick?: () => void;
buttonSize?: 'small' | 'medium' | 'large';
};
const ListTitle = function (props: Props) {
}

export const ListTitle = function (props: Props) {
const { title, subTitle, extButtons, addButtonTitle, addButtonClick, buttonSize } = props;

return (
Expand Down Expand Up @@ -43,5 +44,3 @@ const ListTitle = function (props: Props) {
</div>
);
};

export default ListTitle;
4 changes: 2 additions & 2 deletions packages/velaux-ui/src/components/PlatformSetting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { MdOutlineHelpCenter } from 'react-icons/md';
import { getDexConfig } from '../../api/authentication';
import { getProjectList, getProjectRoles } from '../../api/project';
import { updateSystemInfo } from '../../api/system_config';
import Translation from '../../components/Translation';
import { Translation } from '../../components/Translation';
import i18n from '../../i18n';
import type { Project, ProjectRoleBase } from '../../interface/project';
import type { DexConfig, SystemInfo } from '../../interface/system';
import type { LoginUserInfo } from '../../interface/user';
import locale from '../../utils/locale';
import { locale } from '../../utils/locale';
import { checkPermission } from '../../utils/permission';
import { CustomSelect } from '../CustomSelect';
import { If } from '../If';
Expand Down
6 changes: 3 additions & 3 deletions packages/velaux-ui/src/components/RunPipeline/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import { deletePipelineContext, listPipelineContexts, runPipeline } from '../../
import i18n from '../../i18n';
import type { KeyValue, PipelineListItem } from '../../interface/pipeline';
import './index.less';
import locale from '../../utils/locale';
import { locale } from '../../utils/locale';
import { If } from '../If';
import ListTitle from '../ListTitle';
import { ListTitle } from '../ListTitle';

import classNames from 'classnames';

import Permission from '../Permission';
import Translation from '../Translation';
import { Translation } from '../Translation';

import NewContext from './new-context';

Expand Down
26 changes: 11 additions & 15 deletions packages/velaux-ui/src/components/RunPipeline/new-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import KV from '../../extends/KV';
import i18n from '../../i18n';
import type { KeyValue, PipelineListItem } from '../../interface/pipeline';
import { checkName } from '../../utils/common';
import Translation from '../Translation';
import { Translation } from '../Translation';

const { Row, Col } = Grid;

Expand Down Expand Up @@ -58,21 +58,17 @@ class NewContext extends React.Component<NewContextProps> {
keyValues.push({ key: key, value: values.values[key] });
});
if (editMode) {
updatePipelineContext(project.name, name, { name: values.name, values: keyValues }).then(
(res) => {
if (res) {
this.props.onSuccess();
}
},
);
updatePipelineContext(project.name, name, { name: values.name, values: keyValues }).then((res) => {
if (res) {
this.props.onSuccess();
}
});
} else {
createPipelineContext(project.name, name, { name: values.name, values: keyValues }).then(
(res) => {
if (res) {
this.props.onSuccess();
}
},
);
createPipelineContext(project.name, name, { name: values.name, values: keyValues }).then((res) => {
if (res) {
this.props.onSuccess();
}
});
}
});
};
Expand Down
4 changes: 2 additions & 2 deletions packages/velaux-ui/src/components/StatusShow/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { Link } from 'dva/router';
import React from 'react';
import { AiOutlineQuestionCircle } from 'react-icons/ai';

import Translation from '../../components/Translation';
import { Translation } from '../../components/Translation';
import type { ApplicationStatus, Condition } from '../../interface/application';
import type { Resource } from '../../interface/observation';
import locale from '../../utils/locale';
import { locale } from '../../utils/locale';
import { If } from '../If';

type Props = {
Expand Down
8 changes: 3 additions & 5 deletions packages/velaux-ui/src/components/Title/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import { Grid } from '@alifd/next';
import React from 'react';

const { Col, Row } = Grid;
export type Props = {
export interface Props {
title: string | React.ReactNode;
actions: React.ReactNode[];
};
}

const Title: React.FC<Props> = (props) => {
export const Title: React.FC<Props> = (props) => {
return (
<Row>
<Col span={12}>
Expand All @@ -23,5 +23,3 @@ const Title: React.FC<Props> = (props) => {
</Row>
);
};

export default Title;
Loading

0 comments on commit f10a8eb

Please sign in to comment.