Skip to content

Commit

Permalink
Fix: Can't submit the platform settings (#778)
Browse files Browse the repository at this point in the history
Signed-off-by: barnettZQG <[email protected]>
  • Loading branch information
barnettZQG authored Apr 17, 2023
1 parent 000b65c commit dabd21b
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 26 deletions.
12 changes: 2 additions & 10 deletions Dockerfile.local
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
ARG BASE_IMAGE

FROM node:16-alpine as ui-builder
ARG VERSION
WORKDIR /app/velaux
ADD . .
ENV VERSION=${VERSION}
RUN apk add --no-cache git && yarn install && yarn build

ARG BASE_IMAG
# Build the manager binary
FROM --platform=${BUILDPLATFORM:-linux/amd64} golang:1.19-alpine@sha256:2381c1e5f8350a901597d633b2e517775eeac7a6682be39225a93b22cfd0f8bb as server-builder
ARG GOPROXY
Expand Down Expand Up @@ -41,6 +33,6 @@ WORKDIR /app/velaux
ARG TARGETARCH
ENV PATH=$PATH:/app/velaux
COPY --from=server-builder /workspace/apiserver-${TARGETARCH} /app/velaux/server
COPY --from=ui-builder /app/velaux/public /app/velaux/public
COPY ./public /app/velaux/public

CMD ["server"]
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,11 @@ check-diff: reviewable

run-server:
go run ./cmd/server/main.go

build-ui:
@$(INFO) Building UI
yarn build

build-test-image: build-ui
@$(INFO) Building image
docker build -t velaux:latest -f Dockerfile.local .
2 changes: 1 addition & 1 deletion packages/velaux-ui/src/layout/LeftMenu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const LeftMenuModule = (props: Props) => {
menuService.loadPluginMenus().then(() => {
const workspace = menuService.loadCurrentWorkspace();
const menus = workspace && props.userInfo ? menuService.loadMenus(workspace, props.userInfo) : [];
if (grafanaConfigs) {
if (grafanaConfigs && workspace?.name === 'extension') {
const grafanaLeftMenu: LeftMenu = { catalog: 'Grafana', menus: [] };
grafanaConfigs.map((g) => {
if (g.properties && g.properties['endpoint']) {
Expand Down
4 changes: 2 additions & 2 deletions packages/velaux-ui/src/locals/Zh/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@
"User authentication configuration": "用户认证配置",
"User login mode": "用户登录方式",
"VelaUX address": "VelaUX 访问地址",
"Update the platform configuration success": "更新平台配置成功",
"Platform settings updated successfully": "平台配置更新成功",
"There will auto get the domain for access the VelaUX": "平台访问地址,这里自动获取了当前访问的地址",
"Deployed Clusters": "自定义部署集群",
"Config Properties": "配置属性",
Expand Down Expand Up @@ -650,4 +650,4 @@
"Click me to open the dex login page": "点击我打开 Dex 登录页面",
"Setting the default projects for the dex login user": "设置 Dex 登录用户的默认项目",
"Join Time": "加入时间"
}
}
50 changes: 37 additions & 13 deletions packages/velaux-ui/src/pages/PlatformSetting/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,17 +65,9 @@ class PlatformSetting extends React.Component<Props, State> {
}

componentDidMount() {
this.loadSystemInfo();
this.listProjects();
this.onGetDexConfig();
this.field.setValues({
loginType: this.props.systemInfo.loginType,
enableCollection: this.props.systemInfo.enableCollection,
});
const items: Array<{ id: string; name: string; roles: string[] }> = [];
this.props.systemInfo.dexUserDefaultProjects?.map((item) => {
items.push({ id: uuid(), ...item });
});
this.setState({ defaultProjectItems: items });
}

onGetDexConfig = () => {
Expand All @@ -88,6 +80,23 @@ class PlatformSetting extends React.Component<Props, State> {
});
};

loadSystemInfo = () => {
this.props.dispatch({
type: 'user/getSystemInfo',
callback: (systemInfo: SystemInfo) => {
this.field.setValues({
loginType: systemInfo.loginType,
enableCollection: systemInfo.enableCollection,
});
const items: Array<{ id: string; name: string; roles: string[] }> = [];
systemInfo.dexUserDefaultProjects?.map((item) => {
items.push({ id: uuid(), ...item });
});
this.setState({ defaultProjectItems: items });
},
});
};

onUpdate = () => {
this.field.validate((errs: any, values: any) => {
if (errs) {
Expand Down Expand Up @@ -131,8 +140,8 @@ class PlatformSetting extends React.Component<Props, State> {
updateSystemInfo(param)
.then((res) => {
if (res) {
Message.success(i18n.t('Update the platform configuration success'));
this.props.syncPlatformSetting();
Message.success(i18n.t('Platform settings updated successfully'));
this.loadSystemInfo();
}
})
.catch((err) => {
Expand Down Expand Up @@ -209,15 +218,13 @@ class PlatformSetting extends React.Component<Props, State> {
const { businessGuideCode } = this.state;
if (businessGuideCode === 12011) {
this.dialogGuideDex?.hide();
this.props.onClose();
this.props.dispatch(
routerRedux.push({
pathname: '/configs/dex-connector/config',
})
);
} else if (businessGuideCode === 14010) {
this.dialogGuideUser?.hide();
this.props.onClose();
this.props.dispatch(
routerRedux.push({
pathname: '/users',
Expand Down Expand Up @@ -293,6 +300,18 @@ class PlatformSetting extends React.Component<Props, State> {
const { defaultProjectItems } = this.state;
return (
<div className="container">
<Card locale={locale().Card} contentHeight="auto" style={{ marginBottom: 'var(--spacing-4)' }}>
<div className="setting-version">
<Row>
<Col span={12}>
<Item label="Version" value={systemInfo.systemVersion?.velaVersion}></Item>
</Col>
<Col span={12}>
<Item label="GitVersion" value={systemInfo.systemVersion?.gitVersion}></Item>
</Col>
</Row>
</div>
</Card>
<Form field={this.field} labelCol={{ fixedSpan: 8 }} wrapperCol={{ span: 16 }}>
<Card
style={{ marginBottom: '16px' }}
Expand Down Expand Up @@ -417,6 +436,11 @@ class PlatformSetting extends React.Component<Props, State> {
}
/>
</Card>
<div className="flexright">
<Button type="primary" onClick={this.onUpdate}>
<Translation>Submit</Translation>
</Button>
</div>
</Form>
</div>
);
Expand Down
21 changes: 21 additions & 0 deletions pkg/server/domain/service/authentication.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package service

import (
"context"
"encoding/json"
"errors"
"fmt"
"net/http"
Expand Down Expand Up @@ -380,6 +381,26 @@ func restartDex(ctx context.Context, kubeClient client.Client) error {
}
return err
}
for i, comp := range dexApp.Spec.Components {
if comp.Name == keyDex {
var v model.JSONStruct
err := json.Unmarshal(comp.Properties.Raw, &v)
if err != nil {
return err
}
// restart the dex server
if _, ok := v["values"]; ok {
v["values"].(map[string]interface{})["env"] = map[string]string{
"TIME_STAMP": time.Now().Format(time.RFC3339),
}
}
dexApp.Spec.Components[i].Properties = v.RawExtension()
if err := kubeClient.Update(ctx, dexApp); err != nil {
return err
}
break
}
}
oam.SetPublishVersion(dexApp, apiutils.GenerateVersion("addon"))
return kubeClient.Update(ctx, dexApp)
}
Expand Down

0 comments on commit dabd21b

Please sign in to comment.