Skip to content

Commit

Permalink
[CE-399] Fix edit host error in operator dashboard
Browse files Browse the repository at this point in the history
Change host router in operator dashboard.
Remove k8s_ssl when update type is not kubernetes.

Change-Id: I408af8a594c1903bcbc2a5bba1e49d4b6ab6b937
Signed-off-by: Haitao Yue <hightall@me.com>
  • Loading branch information
hightall committed Jun 28, 2018
1 parent b814ccf commit 86a55d3
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/modules/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,9 +232,9 @@ def update(self, id, d):
if "log_type" in d and d["log_type"] == CLUSTER_LOG_TYPES[0]:
d["log_server"] = ""
if "autofill" in d:
d["autofill"] = d["autofill"] == "true"
d["autofill"] = d["autofill"] == "on"
if "schedulable" in d:
d["schedulable"] = d["schedulable"] == "true"
d["schedulable"] = d["schedulable"] == "on"
self.db_set_by_id(id, **d)
h_new = self.get_by_id(id)
return self._schema(h_new)
Expand Down
18 changes: 12 additions & 6 deletions src/static/dashboard/src/common/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,18 @@ const menuData = [
name: intl.formatMessage(messages.menus.host),
icon: 'laptop',
path: 'host',
},
{
name: 'Create Host',
path: 'host-create',
hideInMenu: true,
hideInBreadcrumb: false,
children: [
{
name: intl.formatMessage(messages.menus.host),
path: 'index',
},
{
name: 'Create Host',
path: 'create',
hideInMenu: true,
hideInBreadcrumb: false,
}
],
},
{
name: intl.formatMessage(messages.menus.chain),
Expand Down
4 changes: 2 additions & 2 deletions src/static/dashboard/src/common/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ export const getRouterData = app => {
'/overview': {
component: dynamicWrapper(app, ['overview'], () => import('../routes/Overview')),
},
'/host': {
'/host/index': {
component: dynamicWrapper(app, ['host'], () => import('../routes/Host')),
},
'/create-host': {
'/host/create': {
component: dynamicWrapper(app, ['host'], () => import('../routes/Host/CreateHost')),
},
'/chain': {
Expand Down
6 changes: 5 additions & 1 deletion src/static/dashboard/src/components/SiderMenu/SiderMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,11 @@ export default class SiderMenu extends PureComponent {
* get SubMenu or Item
*/
getSubMenuOrItem = item => {
if (item.children && item.children.some(child => child.name)) {
let shownChildrenLen = 1;
if (item.children) {
shownChildrenLen = item.children.filter(subItem => typeof subItem.hideInMenu === 'undefined').length;
}
if (item.children && item.children.some(child => child.name) && shownChildrenLen > 1) {
const childrenItems = this.getNavMenuItems(item.children);
// 当无子菜单时就不展示菜单
if (childrenItems && childrenItems.length > 0) {
Expand Down
29 changes: 13 additions & 16 deletions src/static/dashboard/src/routes/Host/CreateHost/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,29 +287,26 @@ class CreateHost extends PureComponent {
this.setState({
submitting: true,
});
let data = {
...values,
schedulable: schedulable ? 'on' : 'off',
autofill: autofill ? 'on' : 'off',
callback: this.submitCallback,
};
if (values.host_type === 'kubernetes') {
data.k8s_ssl = k8sUseSSL ? 'on' : 'off';
}
if (action === 'create') {
this.props.dispatch({
type: 'host/createHost',
payload: {
...values,
schedulable: schedulable ? 'on' : 'off',
autofill: autofill ? 'on' : 'off',
k8s_ssl: k8sUseSSL ? 'on' : 'off',
callback: this.submitCallback,
},
payload: data,
});
} else {
delete values.host_type;
data.id = hostId;
delete data.host_type;
this.props.dispatch({
type: 'host/updateHost',
payload: {
...values,
schedulable: schedulable ? 'true' : 'false',
autofill: autofill ? 'true' : 'false',
k8s_ssl: k8sUseSSL ? 'on' : 'off',
id: hostId,
callback: this.submitCallback,
},
payload: data,
});
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/static/dashboard/src/routes/Host/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ class Host extends PureComponent {
onClickAddHost = () => {
this.props.dispatch(
routerRedux.push({
pathname: '/create-host',
pathname: '/host/create',
})
);
};
Expand Down Expand Up @@ -129,7 +129,7 @@ class Host extends PureComponent {
editHost = host => {
this.props.dispatch(
routerRedux.push({
pathname: '/create-host',
pathname: '/host/create',
search: stringify({
id: host.id,
action: 'update',
Expand Down

0 comments on commit 86a55d3

Please sign in to comment.