Skip to content

Commit

Permalink
optimize: console display the version number (#6313)
Browse files Browse the repository at this point in the history
  • Loading branch information
liuqiufeng authored Jan 29, 2024
1 parent 7227cc1 commit 16689ad
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 8 deletions.
1 change: 1 addition & 0 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#6306](https://github.com/apache/incubator-seata/pull/6306)] replace some URL to org/apache/seata
- [[#6304](https://github.com/apache/incubator-seata/pull/6304)] disable Publish OSSRH workflow
- [[#6301](https://github.com/apache/incubator-seata/pull/6301)] upgrade console frontend dependencies and supported nodejs versions
- [[#6313](https://github.com/apache/incubator-seata/pull/6313)] console display the version number

### security:
- [[#6069](https://github.com/apache/incubator-seata/pull/6069)] Upgrade Guava dependencies to fix security vulnerabilities
Expand Down
1 change: 1 addition & 0 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
- [[#6306](https://github.com/apache/incubator-seata/pull/6306)] 替换一些URL 至 org/apache/seata
- [[#6304](https://github.com/apache/incubator-seata/pull/6304)] 禁用 OSSRH 发布工作流
- [[#6301](https://github.com/apache/incubator-seata/pull/6301)] 升级console前端依赖及支持的nodejs版本
- [[#6313](https://github.com/apache/incubator-seata/pull/6313)] console展示版本号

### security:
- [[#6069](https://github.com/apache/incubator-seata/pull/6069)] 升级Guava依赖版本,修复安全漏洞
Expand Down
3 changes: 3 additions & 0 deletions console/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@
<phase>generate-resources</phase>
<configuration>
<arguments>run build</arguments>
<environmentVariables>
<VERSION>${project.version}</VERSION>
</environmentVariables>
</configuration>
</execution>
</executions>
Expand Down
1 change: 1 addition & 0 deletions console/src/main/resources/static/console-fe/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ test/reports
test/screenshots/*
/public/saga-statemachine-designer/
/node
/public/version.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const mkdir = dir => {
}
};

const copyList = ['js/main.js', 'css/main.css'];
const copyList = ['js/main.js', 'css/main.css', 'version.json'];

copyList.forEach(_fileName => {
const srcFileName = path.join(srcDir, _fileName);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

const fs = require('fs')
const path = require('path')

class VersionPlugin{
apply(compiler){
if(process.env.VERSION){
fs.writeFileSync(path.join(__dirname,'../public/version.json'),JSON.stringify({"version":process.env.VERSION}))
}
}
}

module.exports = VersionPlugin;
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const VersionPlugin = require('./version-plugin')

const isDev = process.env.NODE_ENV !== 'production';

Expand Down Expand Up @@ -100,5 +101,6 @@ module.exports = {
}
},
]}),
new VersionPlugin()
],
};
34 changes: 33 additions & 1 deletion console/src/main/resources/static/console-fe/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export type AppPropsType = StateToPropsType & DispathToPropsType & RouteComponen

export type AppStateType = {
loading: object;
version: string;
};

class App extends React.Component<AppPropsType, AppStateType> {
Expand All @@ -54,6 +55,7 @@ class App extends React.Component<AppPropsType, AppStateType> {

state: AppStateType = {
loading: {},
version: '',
};

constructor(props: AppPropsType) {
Expand All @@ -64,8 +66,15 @@ class App extends React.Component<AppPropsType, AppStateType> {
console.log('this.props: ', this.props, history);
const language: string = getCurrentLanguage();
this.props.changeLanguage(language);
this.getVersion();
}

getVersion = () => {
fetch('version.json').then(response =>
response.json().then(json => this.setState({ ...this.state, version: json.version }))
);
};

get menu() {
const { locale }: AppPropsType = this.props;
const { MenuRouter = {} } = locale;
Expand Down Expand Up @@ -101,7 +110,30 @@ class App extends React.Component<AppPropsType, AppStateType> {
<Route path="/login" component={Login} />
<Layout
nav={({ location }: any) => (
<CCConsoleMenu {...this.menu} activeKey={location.pathname} />
<>
<div
style={{
height: 'calc(100% - 100px)',
minHeight: '300px',
}}
>
<CCConsoleMenu {...this.menu} activeKey={location.pathname} />
</div>
<div
style={{
backgroundColor: '#c2ccd0',
height: '100px',
textAlign: 'center',
paddingTop: '20px',
paddingBottom: '20px',
}}
>
<span>Apache Seata (Incubating)</span>
<br />
<br />
<span>Version:{this.state.version}</span>
</div>
</>
)}
>
<Route path={'/'} exact render={() => <Redirect to="/transaction/list" />} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
.navbar ul{
height: 100%;
}
.navbar{
overflow-y: auto;
.next-menu{
height: 100%;
}
}
2 changes: 1 addition & 1 deletion console/src/main/resources/static/css/main.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion console/src/main/resources/static/js/main.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions console/src/main/resources/static/version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"2.1.0-SNAPSHOT"}
2 changes: 1 addition & 1 deletion server/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ seata:
secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017
tokenValidityInMilliseconds: 1800000
ignore:
urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.jpeg,/**/*.ico,/api/v1/auth/login
urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.jpeg,/**/*.ico,/api/v1/auth/login,/version.json

0 comments on commit 16689ad

Please sign in to comment.