Skip to content

Commit

Permalink
reviewable
Browse files Browse the repository at this point in the history
Signed-off-by: Qiaozp <[email protected]>
  • Loading branch information
chivalryq committed Apr 17, 2023
1 parent 22ce481 commit bc75135
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 28 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,5 @@ tsconfig.tsbuildinfo

e2e-plugins

npm-artifacts
npm-artifacts
bin
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ require (
gopkg.in/warnings.v0 v0.1.2 // indirect
istio.io/api v0.0.0-20220512212136-561ffec82582 // indirect
istio.io/gogo-genproto v0.0.0-20211208193508-5ab4acc9eb1e // indirect
k8s.io/klog v1.0.0
k8s.io/klog v1.0.0 // indirect
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
oras.land/oras-go v1.2.0 // indirect
sigs.k8s.io/apiserver-network-proxy v0.0.30 // indirect
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
]
},
"dependencies": {
"@alifd/next": "^1.26.15",
"history": "4.10.1",
"react": "^17.0.2",
"react-dom": "^17.0.0",
Expand Down
1 change: 1 addition & 0 deletions packages/velaux-ui/src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './plugin';
export * from './pipeline';
1 change: 0 additions & 1 deletion packages/velaux-ui/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import RouterView from './router';
import { createModel } from './store';
import { locationService } from './services/LocationService';
import './i18n';
export * from './api/';

const app = dva({
history: locationService.getHistory(),
Expand Down
8 changes: 8 additions & 0 deletions packages/velaux-ui/src/interface/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export * from './pipeline';
export * from './project';
export * from './application';
export * from './env';
export * from './cluster';
export * from './user';
export * from './addon';
export * from './configs';
1 change: 0 additions & 1 deletion packages/velaux-ui/src/layout/AppRootPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export function AppConfigPage({ pluginId }: Props) {
)
}

console.log(app)
return (
<div>
<app.configPages.body plugin={app} query={{}} />
Expand Down
11 changes: 2 additions & 9 deletions packages/velaux-ui/src/layout/LayoutRouter/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Route, Switch, Redirect } from 'dva/router';
import { Redirect, Route, Switch } from 'dva/router';
import React from 'react';

import Addons from '../../pages/Addons/index';
Expand Down Expand Up @@ -37,7 +37,7 @@ import DefinitionsLayout from '../Definitions';
import ProjectLayout from '../Project';
import MyProjectList from '../../pages/MyProjectList';
import PlatformSetting from '../../pages/PlatformSetting';
import { AppRootPage,AppConfigPage } from '../AppRootPage';
import { AppRootPage } from '../AppRootPage';

export default function Router() {
return (
Expand Down Expand Up @@ -404,13 +404,6 @@ export default function Router() {
return <AppRootPage pluginId={props.match.params.pluginId}></AppRootPage>;
}}
/>
<Route
exact
path={"/plugin-config/:pluginId"}
render={(props: any) => {
return <AppConfigPage pluginId={props.match.params.pluginId}></AppConfigPage>;
}}
/>
<Route path="/notFound" component={NotFound} />
<Redirect to="/notFound" />
</Switch>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class PluginConfig extends React.Component<Props, State> {
<div className="plugin-config">
<AppConfigPage pluginId={plugin.id}></AppConfigPage>;
</div>
);
)
}

}
Expand Down
22 changes: 11 additions & 11 deletions packages/velaux-ui/src/pages/Addons/components/plugin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class Plugin extends React.Component<Props, State> {
>
{(() => {
if (currentPlugin) {
return <PluginConfig plugin={currentPlugin} />;
return <PluginConfig plugin={currentPlugin} />
}
return <Empty />
})()}
Expand All @@ -156,7 +156,7 @@ class Plugin extends React.Component<Props, State> {
<div>{plugin.id}</div>
<div>
<Box spacing={8} direction="row">
{isInstalled && isEnabled && (
{isInstalled && isEnabled && (
<Button onClick={() => {
console.log('plugin', plugin)
this.setState({
Expand All @@ -166,15 +166,15 @@ class Plugin extends React.Component<Props, State> {
console.log('currentPlugin', this.state.currentPlugin)
})
}}>Config</Button>
)}
)}

{!isInstalled && (
{!isInstalled && (
<Button type="primary" onClick={() => this.installPlugin(plugin.id, plugin.url)}>
Install
</Button>
)}
)}

{isInstalled && !isEnabled && (
{isInstalled && !isEnabled && (
<Button type={"primary"} onClick={() => {
console.log('hit `Enable` plugin', plugin)
this.setState({
Expand All @@ -184,17 +184,17 @@ class Plugin extends React.Component<Props, State> {
console.log('currentPlugin', this.state.currentPlugin)
})
}}>Enable</Button>
)}
)}

{isInstalled && isEnabled && (
{isInstalled && isEnabled && (
<Button onClick={() => this.disablePlugin(plugin.id)}>Disable</Button>
)}
)}

{isInstalled && !isEnabled && (
{isInstalled && !isEnabled && (
<Button warning onClick={() => this.uninstallPlugin(plugin.id)}>
Uninstall
</Button>
)}
)}
</Box>
</div>
</div>
Expand Down
9 changes: 8 additions & 1 deletion packages/velaux-ui/src/services/BackendService.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AxiosInstance, AxiosResponse } from 'axios';
import { Message } from '@alifd/next';
import axios from 'axios';
import { Message } from '@alifd/next';
import { getDomain } from '../utils/common';
import { getMessage } from '../api/status';
import ResetLogin from '../utils/resetLogin';
Expand Down Expand Up @@ -37,15 +37,20 @@ async function getRefreshTokenFunc() {

export interface BackendSrv {
getAxiosInstance: () => AxiosInstance;

post<R, P>(url: string, params?: P, customError?: boolean): Promise<R>;

get<R, P>(url: string, params?: P, customError?: boolean): Promise<R>;

delete<R, P>(url: string, params?: P, customError?: boolean): Promise<R>;

put<R, P>(url: string, params?: P, customError?: boolean): Promise<R>;
}

/** @internal */
export class BackendWrapper implements BackendSrv {
private axiosInstance: AxiosInstance;

constructor() {
this.axiosInstance = axios.create({
baseURL: baseURL,
Expand Down Expand Up @@ -128,6 +133,7 @@ export class BackendWrapper implements BackendSrv {
}
);
}

getAxiosInstance(): AxiosInstance {
return this.axiosInstance;
}
Expand All @@ -144,6 +150,7 @@ export class BackendWrapper implements BackendSrv {
}

get(url: string, params?: any, customError?: boolean) {
console.log('get', url, params,)
return this.axiosInstance
.get(baseURL + url, params)
.then((res) => {
Expand Down
2 changes: 2 additions & 0 deletions packages/velaux-ui/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ export * from './utils/common';
export * from './utils/permission';
export * from './utils/locale';
export * from './api/plugin';
export * from './interface';
export * from './api/';
7 changes: 5 additions & 2 deletions pkg/server/domain/service/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/oam-dev/kubevela/pkg/utils/common"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog"
"k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"

Expand Down Expand Up @@ -318,7 +318,7 @@ func shouldRemoveTopLevelFolder(tarReader *tar.Reader) (bool, error) {
entries := make(map[string]bool)
for {
header, err := tarReader.Next()
if err == io.EOF {
if errors.Is(err, io.EOF) {
break
}
if err != nil {
Expand Down Expand Up @@ -379,6 +379,8 @@ func decompressTarGzTo(gzipReader *gzip.Reader, destFolder string) error {
return fmt.Errorf("error creating directory: %w", err)
}
case tar.TypeReg:

//nolint:gosec
outFile, err := os.Create(targetPath)
if err != nil {
return fmt.Errorf("error creating file: %w", err)
Expand Down Expand Up @@ -411,6 +413,7 @@ func downloadAndDecompressTarGz(ctx context.Context, url, destFolder string, opt
if err != nil {
return fmt.Errorf("error creating gzip reader: %w", err)
}
// nolint:errcheck
defer gzipReader.Close()

return decompressTarGzTo(gzipReader, destFolder)
Expand Down
28 changes: 28 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,33 @@ __metadata:
languageName: node
linkType: hard

"@alifd/next@npm:^1.26.15":
version: 1.26.15
resolution: "@alifd/next@npm:1.26.15"
dependencies:
"@alifd/field": ~1.5.5
"@alifd/overlay": ^0.2.9
"@alifd/validate": ~1.2.0
babel-runtime: ^6.26.0
big.js: ^6.2.0
classnames: ^2.2.3
dayjs: ^1.9.6
hoist-non-react-statics: ^3.0.0
lodash.clonedeep: ^4.5.0
prop-types: ^15.6.0
react-lifecycles-compat: ^3.0.4
react-transition-group: ^2.2.1
resize-observer-polyfill: ^1.5.1
shallow-element-equals: ^1.0.1
peerDependencies:
"@alifd/meet-react": ^2.0.0
moment: ^2.22.1
react: ">=16.0.0"
react-dom: ">=16.0.0"
checksum: 00d9e13cc156a44b34f71bf57da09242fc356fcf264f421cf7678474d40deee02889e50276eb94187e3fb4e64737f571e23704e7efc74f288ce12b85aad5ff8c
languageName: node
linkType: hard

"@alifd/next@npm:~1.25.x":
version: 1.25.51
resolution: "@alifd/next@npm:1.25.51"
Expand Down Expand Up @@ -28670,6 +28697,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "velaux@workspace:."
dependencies:
"@alifd/next": ^1.26.15
"@babel/core": 7.20.5
"@babel/plugin-proposal-class-properties": 7.18.6
"@babel/plugin-proposal-nullish-coalescing-operator": 7.18.6
Expand Down

0 comments on commit bc75135

Please sign in to comment.