Skip to content

Commit

Permalink
fix: closes alibaba#2451
Browse files Browse the repository at this point in the history
  • Loading branch information
loadchange committed Mar 15, 2020
1 parent c22a593 commit 8733f83
Show file tree
Hide file tree
Showing 11 changed files with 76 additions and 294 deletions.
11 changes: 1 addition & 10 deletions console/src/main/resources/static/console-fe/src/globalLib.js
Original file line number Diff line number Diff line change
Expand Up @@ -527,16 +527,7 @@ const request = (function(_global) {
[401, 403].includes(status) &&
['unknown user!', 'token invalid', 'token expired!'].includes(responseJSON.message)
) {
// 跳转至login页
// TODO: 用 react-router 重写,改造成本比较高,这里先hack
const url = window.location.href;
// TODO: 后端返回细致的错误码,如果原始密码不对 不应该直接跳到登陆页
if (url.includes('password')) {
return error;
}
localStorage.removeItem('token');
const base_url = url.split('#')[0];
window.location = `${base_url}#/login`;
goLogin();
}
return error;
}
Expand Down
2 changes: 0 additions & 2 deletions console/src/main/resources/static/console-fe/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { LANGUAGE_KEY, REDUX_DEVTOOLS } from './constants';

import Login from './pages/Login';
import Namespace from './pages/NameSpace';
import Password from './pages/Password';
import Newconfig from './pages/ConfigurationManagement/NewConfig';
import Configsync from './pages/ConfigurationManagement/ConfigSync';
import Configdetail from './pages/ConfigurationManagement/ConfigDetail';
Expand Down Expand Up @@ -75,7 +74,6 @@ const MENU = [
{ path: '/', exact: true, render: () => <Redirect to="/welcome" /> },
{ path: '/welcome', component: Welcome },
{ path: '/namespace', component: Namespace },
{ path: '/password', component: Password },
{ path: '/newconfig', component: Newconfig },
{ path: '/configsync', component: Configsync },
{ path: '/configdetail', component: Configdetail },
Expand Down
96 changes: 57 additions & 39 deletions console/src/main/resources/static/console-fe/src/layouts/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import { connect } from 'react-redux';
import { ConfigProvider, Dropdown, Menu } from '@alifd/next';
import siteConfig from '../config';
import { changeLanguage } from '@/reducers/locale';
import PasswordReset from '../pages/AuthorityControl/UserManagement/PasswordReset';
import { passwordReset } from '../reducers/authority';

import './index.scss';

Expand All @@ -35,6 +37,8 @@ class Header extends React.Component {
changeLanguage: PropTypes.func,
};

state = { passwordResetUser: '' };

switchLang = () => {
const { language = 'en-US', changeLanguage } = this.props;
const currentLanguage = language === 'en-US' ? 'zh-CN' : 'en-US';
Expand All @@ -47,7 +51,9 @@ class Header extends React.Component {
};

changePassword = () => {
this.props.history.push('/password');
this.setState({
passwordResetUser: this.getUsername(),
});
};

getUsername = () => {
Expand All @@ -73,6 +79,7 @@ class Header extends React.Component {
location: { pathname },
} = this.props;
const { home, docs, blog, community, languageSwitchButton } = locale;
const { passwordResetUser = '' } = this.state;
const BASE_URL = `https://nacos.io/${language.toLocaleLowerCase()}/`;
const NAV_MENU = [
{ id: 1, title: home, link: BASE_URL },
Expand All @@ -81,45 +88,56 @@ class Header extends React.Component {
{ id: 4, title: community, link: `${BASE_URL}community/index.html` },
];
return (
<header className="header-container header-container-primary">
<div className="header-body">
<a
href={`https://nacos.io/${language.toLocaleLowerCase()}/`}
target="_blank"
rel="noopener noreferrer"
>
<img
src="img/logo-2000-390.svg"
className="logo"
alt={siteConfig.name}
title={siteConfig.name}
/>
</a>
{/* if is login page, we will show logout */}
{pathname !== '/login' && (
<Dropdown trigger={<div className="logout">{this.getUsername()}</div>}>
<Menu>
<Menu.Item onClick={this.logout}>{locale.logout}</Menu.Item>
<Menu.Item onClick={this.changePassword}>{locale.changePassword}</Menu.Item>
</Menu>
</Dropdown>
)}
<span className="language-switch language-switch-primary" onClick={this.switchLang}>
{languageSwitchButton}
</span>
<div className="header-menu header-menu-open">
<ul>
{NAV_MENU.map(item => (
<li key={item.id} className="menu-item menu-item-primary">
<a href={item.link} target="_blank" rel="noopener noreferrer">
{item.title}
</a>
</li>
))}
</ul>
<>
<header className="header-container header-container-primary">
<div className="header-body">
<a
href={`https://nacos.io/${language.toLocaleLowerCase()}/`}
target="_blank"
rel="noopener noreferrer"
>
<img
src="img/logo-2000-390.svg"
className="logo"
alt={siteConfig.name}
title={siteConfig.name}
/>
</a>
{/* if is login page, we will show logout */}
{pathname !== '/login' && (
<Dropdown trigger={<div className="logout">{this.getUsername()}</div>}>
<Menu>
<Menu.Item onClick={this.logout}>{locale.logout}</Menu.Item>
<Menu.Item onClick={this.changePassword}>{locale.changePassword}</Menu.Item>
</Menu>
</Dropdown>
)}
<span className="language-switch language-switch-primary" onClick={this.switchLang}>
{languageSwitchButton}
</span>
<div className="header-menu header-menu-open">
<ul>
{NAV_MENU.map(item => (
<li key={item.id} className="menu-item menu-item-primary">
<a href={item.link} target="_blank" rel="noopener noreferrer">
{item.title}
</a>
</li>
))}
</ul>
</div>
</div>
</div>
</header>
</header>
<PasswordReset
username={passwordResetUser}
onOk={user =>
passwordReset(user).then(res => {
return res;
})
}
onCancel={() => this.setState({ passwordResetUser: undefined })}
/>
</>
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import React from 'react';
import PropTypes from 'prop-types';
import { Button, Field, Form, Input, Dialog, Pagination, Table, ConfigProvider } from '@alifd/next';
import { Button, Dialog, Pagination, Table, ConfigProvider } from '@alifd/next';
import { connect } from 'react-redux';
import { getUsers, createUser, deleteUser, passwordReset } from '../../../reducers/authority';
import RegionGroup from '../../../components/RegionGroup';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@ class ConfigurationManagement extends React.Component {
{!this.inApp && <Table.Column title={locale.application} dataIndex="appName" />}
<Table.Column title={locale.operation} cell={this.renderCol.bind(this)} />
</Table>
{configurations.totalCount && (
{configurations.totalCount > 0 && (
<>
<div style={{ float: 'left' }}>
{[
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 8733f83

Please sign in to comment.