Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ISSUE#12410] fix beta publish #12411

Merged
merged 1 commit into from
Jul 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 31 additions & 2 deletions console-ui/src/components/NameSpaceList/NameSpaceList.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@

import React from 'react';
import PropTypes from 'prop-types';
import { ConfigProvider, Dialog } from '@alifd/next';
import { ConfigProvider, Dialog, Select } from '@alifd/next';
import { getParams, setParams, request } from '../../globalLib';

import './index.scss';
import { NAME_SHOW } from '../../constants';

/**
* 命名空间列表
Expand All @@ -42,6 +43,7 @@ class NameSpaceList extends React.Component {
this.state = {
nownamespace: window.nownamespace || this._namespace || '',
namespaceList: window.namespaceList || [],
nameShow: localStorage.getItem(NAME_SHOW),
// namespaceShowName: window.namespaceShowName || this._namespaceShowName || '',
// _dingdingLink: "",
// _forumLink: ""
Expand Down Expand Up @@ -100,6 +102,11 @@ class NameSpaceList extends React.Component {
this.props.setNowNameSpace && this.props.setNowNameSpace(nsName, ns, nsDesc);
}

changeName(...value) {
let space = value[2];
this.changeNameSpace(space.namespace, space.namespaceShowName, space.namespaceDesc);
}

calleeParent(needclean = false) {
this.props.namespaceCallBack && this.props.namespaceCallBack(needclean);
}
Expand Down Expand Up @@ -166,7 +173,29 @@ class NameSpaceList extends React.Component {
}

rendernamespace(namespaceList) {
const { nownamespace } = this.state; // 获得当前namespace
const { nownamespace, nameShow } = this.state; // 获得当前namespace
if (nameShow && nameShow === 'select') {
let de = {
value: nownamespace,
};
namespaceList.forEach(obj => {
obj.label = obj.namespaceShowName + ' ' + (obj.namespaceDesc ? obj.namespaceDesc : '');
obj.value = obj.namespace;
if (obj.value !== undefined && obj.value === de.value) {
de = obj;
}
});
return (
<Select
style={{ width: 200 }}
size="medium"
dataSource={namespaceList}
value={de}
onChange={this.changeName.bind(this)}
showSearch
/>
);
}
const namespacesBtn = namespaceList.map((obj, index) => {
return (
<div key={index} style={{ cursor: 'pointer' }}>
Expand Down
7 changes: 7 additions & 0 deletions console-ui/src/components/NameSpaceList/show.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { NAME_SHOW } from '../../constants';

const changeNameShow = show => dispatch => {
localStorage.setItem(NAME_SHOW, show);
};

export default changeNameShow;
2 changes: 2 additions & 0 deletions console-ui/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,6 @@ export const LOGINPAGE_ENABLED = 'docsite_loginpage';

export const THEME = 'setting_theme';

export const NAME_SHOW = 'setting_name_show';

export const SERVER_GUIDE = 'SERVER_GUIDE';
13 changes: 11 additions & 2 deletions console-ui/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { ConfigProvider, Loading } from '@alifd/next';
import './lib';

import Layout from './layouts/MainLayout';
import { LANGUAGE_KEY, REDUX_DEVTOOLS, THEME } from './constants';
import { LANGUAGE_KEY, NAME_SHOW, REDUX_DEVTOOLS, THEME } from './constants';

import Login from './pages/Login';
import Register from './pages/Register';
Expand Down Expand Up @@ -57,6 +57,7 @@ import reducers from './reducers';
import { changeLanguage } from './reducers/locale';
import { getState } from './reducers/base';
import changeTheme from './theme';
import changeNameShow from './components/NameSpaceList/show';

import './index.scss';
import PropTypes from 'prop-types';
Expand Down Expand Up @@ -100,7 +101,12 @@ const MENU = [
{ path: '/settingCenter', component: SettingCenter },
];

@connect(state => ({ ...state.locale, ...state.base }), { changeLanguage, getState, changeTheme })
@connect(state => ({ ...state.locale, ...state.base }), {
changeLanguage,
getState,
changeTheme,
changeNameShow,
})
class App extends React.Component {
static propTypes = {
locale: PropTypes.object,
Expand All @@ -109,6 +115,7 @@ class App extends React.Component {
loginPageEnabled: PropTypes.string,
consoleUiEnable: PropTypes.string,
changeTheme: PropTypes.func,
changeNameShow: PropTypes.func,
};

constructor(props) {
Expand All @@ -124,8 +131,10 @@ class App extends React.Component {
this.props.getState();
const language = localStorage.getItem(LANGUAGE_KEY);
const theme = localStorage.getItem(THEME);
const nameShow = localStorage.getItem(NAME_SHOW);
this.props.changeLanguage(language);
this.props.changeTheme(theme);
this.props.changeNameShow(nameShow);
}

get router() {
Expand Down
3 changes: 3 additions & 0 deletions console-ui/src/locales/en-US.js
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,9 @@ const I18N_CONF = {
settingTheme: 'Themes',
settingLight: 'light',
settingDark: 'dark',
settingShowSelect: 'select',
settingShowLabel: 'label',
settingShow: 'namespace select style',
settingLocale: 'Language',
settingSubmit: 'Apply',
},
Expand Down
3 changes: 3 additions & 0 deletions console-ui/src/locales/zh-CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -680,6 +680,9 @@ const I18N_CONF = {
settingTheme: '样式主题',
settingLight: '明亮',
settingDark: '深色',
settingShowSelect: '下拉框',
settingShowLabel: '标签',
settingShow: '命名空间样式',
settingLocale: '系统语言',
settingSubmit: '应用',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,14 @@ class ConfigEditor extends React.Component {
}

_publishConfig(beta = false) {
const { betaIps, isNewConfig } = this.state;
const { betaIps, isNewConfig, isBeta } = this.state;
const headers = { 'Content-Type': 'application/x-www-form-urlencoded' };
if (beta) {
headers.betaIps = betaIps;
}
headers.casMd5 = this.state.casMd5;
if (!isBeta) {
headers.casMd5 = this.state.casMd5;
}
const form = { ...this.state.form, content: this.getCodeVal(), betaIps };
const payload = {};
Object.keys(form).forEach(key => {
Expand Down
33 changes: 29 additions & 4 deletions console-ui/src/pages/SettingCenter/SettingCenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,13 @@ import { Button, ConfigProvider, Radio } from '@alifd/next';
import PageTitle from '../../components/PageTitle';
import { changeLanguage } from '@/reducers/locale';
import changeTheme from '../../theme';
import changeNameShow from '../../components/NameSpaceList/show';
import { connect } from 'react-redux';
import { LANGUAGE_KEY, THEME } from '../../constants';
import { LANGUAGE_KEY, NAME_SHOW, THEME } from '../../constants';

const { Group: RadioGroup } = Radio;

@connect(state => ({ ...state.locale }), { changeLanguage, changeTheme })
@connect(state => ({ ...state.locale }), { changeLanguage, changeTheme, changeNameShow })
@ConfigProvider.config
class SettingCenter extends React.Component {
static displayName = 'SettingCenter';
Expand All @@ -35,14 +36,18 @@ class SettingCenter extends React.Component {
locale: PropTypes.object,
changeLanguage: PropTypes.func,
changeTheme: PropTypes.func,
changeNameShow: PropTypes.func,
};

constructor(props) {
super(props);
const defaultTheme = localStorage.getItem(THEME);
const defaultShow = localStorage.getItem(NAME_SHOW);
const defaultLanguage = localStorage.getItem(LANGUAGE_KEY);
this.state = {
theme: defaultTheme === 'dark' ? 'dark' : 'light',
language: localStorage.getItem(LANGUAGE_KEY),
language: defaultLanguage === 'en-US' ? 'en-US' : 'zh-CN',
nameShow: defaultShow === 'select' ? 'select' : 'label',
};
}

Expand All @@ -58,12 +63,20 @@ class SettingCenter extends React.Component {
});
}

newNameShow(value) {
this.setState({
nameShow: value,
});
}

submit() {
const { changeLanguage, changeTheme } = this.props;
const { changeLanguage, changeTheme, changeNameShow } = this.props;
const currentLanguage = this.state.language;
const currentTheme = this.state.theme;
const currentNameShow = this.state.nameShow;
changeLanguage(currentLanguage);
changeTheme(currentTheme);
changeNameShow(currentNameShow);
}

render() {
Expand All @@ -76,6 +89,10 @@ class SettingCenter extends React.Component {
{ value: 'en-US', label: 'English' },
{ value: 'zh-CN', label: '中文' },
];
const nameShowList = [
{ value: 'select', label: locale.settingShowSelect },
{ value: 'label', label: locale.settingShowLabel },
];
return (
<>
<PageTitle title={locale.settingTitle} />
Expand All @@ -97,6 +114,14 @@ class SettingCenter extends React.Component {
onChange={this.newLanguage.bind(this)}
/>
</div>
<div className="setting-checkbox">
<div className="setting-span">{locale.settingShow}</div>
<RadioGroup
dataSource={nameShowList}
value={this.state.nameShow}
onChange={this.newNameShow.bind(this)}
/>
</div>
</div>
<Button type="primary" onClick={this.submit.bind(this)}>
{locale.settingSubmit}
Expand Down
5 changes: 3 additions & 2 deletions console-ui/src/pages/SettingCenter/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
}

.text-box {
height: 140px;
width: 100%;
flex-wrap: wrap;
display: flex;
}

.setting-checkbox {
flex: 1;
flex: 0 0 50%;
height: 100px;
box-sizing: border-box;
}
Expand Down
5 changes: 4 additions & 1 deletion console-ui/src/theme/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ $dark-input-color: #585858;
//contain
.dark {
filter: grayscale(.25);
.login-header {
color: $dark-color-deep;
}
//侧边栏背景
.next-shell-navigation.next-shell-mini.next-shell-aside, .next-menu-item:not(.next-disabled).next-focused {
background-color: $dark-menu-bac !important;
Expand Down Expand Up @@ -303,4 +306,4 @@ $dark-input-color: #585858;
border-color: $dark-input-border-focus !important;
background-color: $dark-pull-bac !important;
}
}
}
Loading
Loading