feat: hide masakari menu

Hide masakari menu when no masakari service is available

Change-Id: If8857cd57012b809b20d10dcd8026c9fa30ae649
This commit is contained in:
zhangjingwei 2024-04-02 15:06:02 +08:00
parent 36483416f2
commit 813ee6a330
7 changed files with 106 additions and 39 deletions

View File

@ -88,6 +88,7 @@ export const swiftEndpoint = () => getOriginEndpoint('swift');
export const cinderEndpoint = () => getOriginEndpoint('cinder');
export const manilaEndpoint = () => getOriginEndpoint('manilav2');
export const zunEndpoint = () => getOriginEndpoint('zun');
export const masakariEndpoint = () => getOriginEndpoint('masakari');
export const apiVersionMaps = {
nova: {

View File

@ -980,7 +980,7 @@ const renderMenu = (t) => {
name: t('Instance-HA'),
key: 'masakari',
icon: <DeploymentUnitOutlined />,
// endpoints: 'masakari',
endpoints: 'masakari',
children: [
{
path: '/ha/segments-admin',

View File

@ -13,9 +13,10 @@
import React from 'react';
import { observer, inject } from 'mobx-react';
import Base from 'containers/List';
import actionConfigs from './actions';
import globalHostStore, { HostStore } from 'src/stores/masakari/hosts';
import { Link } from 'react-router-dom';
import { masakariEndpoint } from 'client/client/constants';
import actionConfigs from './actions';
export class Hosts extends Base {
init() {
@ -23,6 +24,14 @@ export class Hosts extends Base {
this.downloadStore = new HostStore();
}
get endpoint() {
return masakariEndpoint();
}
get checkEndpoint() {
return true;
}
get policy() {
if (this.isAdminPage) {
return 'os_compute_api:servers:index:get_all_tenants';
@ -66,11 +75,11 @@ export class Hosts extends Base {
},
...(this.isAdminPage
? [
{
label: t('Project Name'),
name: 'project_name',
},
]
{
label: t('Project Name'),
name: 'project_name',
},
]
: []),
];
}
@ -80,9 +89,13 @@ export class Hosts extends Base {
title: t('Name'),
dataIndex: 'name',
render: (value, row) => {
const path = this.getRoutePath('masakariHostDetail', { id: row.failover_segment_id }, { uuid: row.uuid });
const path = this.getRoutePath(
'masakariHostDetail',
{ id: row.failover_segment_id },
{ uuid: row.uuid }
);
return <Link to={path}>{value}</Link>;
}
},
},
{
title: t('UUID'),
@ -93,7 +106,7 @@ export class Hosts extends Base {
title: t('Reserved'),
dataIndex: 'reserved',
isHideable: true,
valueRender: 'yesNo'
valueRender: 'yesNo',
},
{
title: t('Type'),
@ -103,24 +116,31 @@ export class Hosts extends Base {
{
title: t('Control Attribute'),
dataIndex: 'control_attributes',
isHideable: true
isHideable: true,
},
{
title: t('On Maintenance'),
dataIndex: 'on_maintenance',
isHideable: true,
valueRender: 'yesNo'
valueRender: 'yesNo',
},
{
title: t('Failover Segment'),
dataIndex: 'failover_segment',
isHideable: true,
render: (value, row) => {
return <Link to={this.getRoutePath('masakariSegmentDetail', { id: row.failover_segment_id })}>{row.failover_segment.name}</Link>
}
}
return (
<Link
to={this.getRoutePath('masakariSegmentDetail', {
id: row.failover_segment_id,
})}
>
{row.failover_segment.name}
</Link>
);
},
},
];
}
export default inject('rootStore')(observer(Hosts));

View File

@ -13,8 +13,11 @@
import React from 'react';
import { observer, inject } from 'mobx-react';
import Base from 'containers/List';
import globalNotificationStore, { NotificationStore } from 'stores/masakari/notifications';
import globalNotificationStore, {
NotificationStore,
} from 'stores/masakari/notifications';
import { Link } from 'react-router-dom';
import { masakariEndpoint } from 'client/client/constants';
export class Notifications extends Base {
init() {
@ -37,6 +40,14 @@ export class Notifications extends Base {
return 'updated_at';
}
get endpoint() {
return masakariEndpoint();
}
get checkEndpoint() {
return true;
}
get searchFilters() {
return [
{
@ -47,7 +58,7 @@ export class Notifications extends Base {
label: t('UUID'),
name: 'notification_uuid',
},
]
];
}
getColumns = () => [
@ -55,10 +66,12 @@ export class Notifications extends Base {
title: t('UUID'),
dataIndex: 'notification_uuid',
render: (value) => {
const path = this.getRoutePath("masakariNotificationDetail", {id: value});
return <Link to={path}>{value}</Link>
const path = this.getRoutePath('masakariNotificationDetail', {
id: value,
});
return <Link to={path}>{value}</Link>;
},
isHideable: true
isHideable: true,
},
{
title: t('Host'),
@ -73,13 +86,18 @@ export class Notifications extends Base {
{
title: t('Status'),
dataIndex: 'status',
isHideable: true
isHideable: true,
},
{
title: t('Payload'),
dataIndex: 'payload',
isHideable: true,
render: (value) => Object.keys(value).map(it =><React.Fragment><div>{it}: {value[it]}</div></React.Fragment>)
render: (value) =>
Object.keys(value).map((it) => (
<div key={it}>
{it}: {value[it]}
</div>
)),
},
];
}

View File

@ -12,14 +12,14 @@
import { inject, observer } from 'mobx-react';
import Base from 'containers/TabDetail';
import { SegmentStore } from 'src/stores/masakari/segments';
import { SegmentStore } from 'stores/masakari/segments';
import BaseDetail from './BaseDetail';
import actionConfigs from '../actions';
import HostDetail from '../../Hosts';
export class SegmentsDetail extends Base {
init() {
this.store = new SegmentStore;
this.store = new SegmentStore();
}
get name() {

View File

@ -12,8 +12,9 @@
import { observer, inject } from 'mobx-react';
import Base from 'containers/List';
import actionConfigs from './actions';
import globalSegmentStore, { SegmentStore } from 'stores/masakari/segments';
import { masakariEndpoint } from 'client/client/constants';
import actionConfigs from './actions';
export class Segments extends Base {
init() {
@ -28,6 +29,14 @@ export class Segments extends Base {
return 'os_compute_api:servers:index';
}
get endpoint() {
return masakariEndpoint();
}
get checkEndpoint() {
return true;
}
get name() {
return t('segments');
}
@ -52,11 +61,11 @@ export class Segments extends Base {
},
...(this.isAdminPage
? [
{
label: t('Project Name'),
name: 'project_name',
},
]
{
label: t('Project Name'),
name: 'project_name',
},
]
: []),
];
}
@ -89,8 +98,8 @@ export class Segments extends Base {
{
title: t('Description'),
dataIndex: 'description',
isHideable: true
}
isHideable: true,
},
];
}

View File

@ -27,13 +27,32 @@ export default [
component: BaseLayout,
routes: [
{ path: `${PATH}/segments-admin`, component: Segments, exact: true },
{ path: `${PATH}/segments-admin`, component: Segments, exact: true },
{ path: `${PATH}/segments-admin/create-step-admin`, component: StepCreate, exact: true },
{ path: `${PATH}/segments-admin/detail/:id`, component: SegmentsDetail, exact: true },
{
path: `${PATH}/segments-admin/create-step-admin`,
component: StepCreate,
exact: true,
},
{
path: `${PATH}/segments-admin/detail/:id`,
component: SegmentsDetail,
exact: true,
},
{ path: `${PATH}/hosts-admin`, component: Hosts, exact: true },
{ path: `${PATH}/hosts-admin/detail/:id`, component: HostsDetail, exact: true, },
{ path: `${PATH}/notifications-admin`, component: Notifications, exact: true },
{ path: `${PATH}/notifications-admin/detail/:id`, component: NotificationsDetail, exact: true },
{
path: `${PATH}/hosts-admin/detail/:id`,
component: HostsDetail,
exact: true,
},
{
path: `${PATH}/notifications-admin`,
component: Notifications,
exact: true,
},
{
path: `${PATH}/notifications-admin/detail/:id`,
component: NotificationsDetail,
exact: true,
},
{ path: '*', component: E404 },
],
},