refactor: Refactor path jump

Refactor path jump by routeName which is defined in menu as key

Change-Id: I82cda19a2b92b29498238b85c75181848e51e072
This commit is contained in:
Jingwei.Zhang 2021-11-09 17:57:57 +08:00
parent 9d0e402048
commit 6d2ea1bf34
123 changed files with 858 additions and 607 deletions

View File

@ -175,7 +175,7 @@ English | [Chinese](../../zh/develop/3-1-BaseList-introduction.md)
{ {
title: t('ID/Name'), title: t('ID/Name'),
dataIndex: 'name', dataIndex: 'name',
linkPrefix: `/compute/${this.getUrl('image')}/detail`, routeName: this.getRouteName('imageDetail'),
}, },
{ {
title: t('Project ID/Name'), title: t('Project ID/Name'),
@ -526,7 +526,7 @@ English | [Chinese](../../zh/develop/3-1-BaseList-introduction.md)
- Is the current page a "management platform" page - Is the current page a "management platform" page
- `hasAdminRole` - `hasAdminRole`
- Whether the logged-in user role has an administrator role - Whether the logged-in user role has an administrator role
- `getUrl` - `getRoutePath`
- Function to generate page URL - Function to generate page URL
- For example, it is necessary to provide a jump function to the associated resources of the list page. Using this function, you can jump to the corresponding address of the console in the console, and jump to the corresponding address of the management platform in the management platform. - For example, it is necessary to provide a jump function to the associated resources of the list page. Using this function, you can jump to the corresponding address of the console in the console, and jump to the corresponding address of the management platform in the management platform.
- `params` - `params`

View File

@ -114,7 +114,7 @@ English | [Chinese](../../zh/develop/3-2-BaseTabList-introduction.md)
- Is the current page a "management platform" page - Is the current page a "management platform" page
- `hasAdminRole` - `hasAdminRole`
- Whether the logged-in user role has an administrator role - Whether the logged-in user role has an administrator role
- `getUrl` - `getRoutePath`
- Function to generate page URL - Function to generate page URL
- For example, it is necessary to provide a jump function for the associated resources of the list page. Using this function, you can jump to the corresponding address of the console in the console, and jump to the corresponding address of the management platform in the management platform. - For example, it is necessary to provide a jump function for the associated resources of the list page. Using this function, you can jump to the corresponding address of the console in the console, and jump to the corresponding address of the management platform in the management platform.

View File

@ -72,7 +72,7 @@ English | [Chinese](../../zh/develop/3-3-BaseDetail-introduction.md)
```javascript ```javascript
get listUrl() { get listUrl() {
return this.getUrl('/storage/volume'); return this.getRoutePath('volume');
} }
``` ```
@ -241,7 +241,7 @@ English | [Chinese](../../zh/develop/3-3-BaseDetail-introduction.md)
- `id` in routing information - `id` in routing information
- `isAdminPage` - `isAdminPage`
- Is the current page a "management platform" page - Is the current page a "management platform" page
- `getUrl` - `getRoutePath`
- Function to generate page URL - Function to generate page URL
- For example, it is necessary to provide a jump function to the associated resource. Using this function, you can jump to the corresponding address of the console in the console, and jump to the corresponding address of the management platform in the management platform. - For example, it is necessary to provide a jump function to the associated resource. Using this function, you can jump to the corresponding address of the console in the console, and jump to the corresponding address of the management platform in the management platform.
- `routing` - `routing`

View File

@ -131,7 +131,7 @@ English | [Chinese](../../zh/develop/3-4-BaseDetailInfo-introduction.md)
- `id` in routing information - `id` in routing information
- `isAdminPage` - `isAdminPage`
- Is the current page a "management platform" page - Is the current page a "management platform" page
- `getUrl` - `getRoutePath`
- Function to generate page URL - Function to generate page URL
- For example, it is necessary to provide a jump function to the associated resource. Using this function, you can jump to the corresponding address of the console in the console, and jump to the corresponding address of the management platform in the management platform. - For example, it is necessary to provide a jump function to the associated resource. Using this function, you can jump to the corresponding address of the console in the console, and jump to the corresponding address of the management platform in the management platform.
- `routing` - `routing`

View File

@ -147,7 +147,7 @@ English | [Chinese](../../zh/develop/3-6-FormAction-introduction.md)
```javascript ```javascript
get listUrl() { get listUrl() {
return this.getUrl('/storage/volume'); return this.getRoutePath('volume');
} }
``` ```
@ -381,7 +381,7 @@ English | [Chinese](../../zh/develop/3-6-FormAction-introduction.md)
- After the form is successfully validated, the updated form value - After the form is successfully validated, the updated form value
- `isAdminPage` - `isAdminPage`
- Is the current page a "management platform" page - Is the current page a "management platform" page
- `getUrl` - `getRoutePath`
- Function to generate page URL - Function to generate page URL
- For example, it is necessary to provide a jump function to the associated resource. Using this function, you can jump to the corresponding address of the console in the console, and jump to the corresponding address of the management platform in the management platform. - For example, it is necessary to provide a jump function to the associated resource. Using this function, you can jump to the corresponding address of the console in the console, and jump to the corresponding address of the management platform in the management platform.

View File

@ -286,7 +286,7 @@ English | [简体中文](../../zh/develop/3-9-StepAction-introduction.md)
- `isAdminPage` - `isAdminPage`
- Whether current page is a "management platform" page - Whether current page is a "management platform" page
- `getUrl` - `getRoutePath`
- Generate function of page URL - Generate function of page URL
- Such as: need to provide a ability of jump to the associated resource, use this function, you can jump to the corresponding address of the `console platform` in the `console platform`, and jump to the corresponding address of the `management platform` in the `management platform`. - Such as: need to provide a ability of jump to the associated resource, use this function, you can jump to the corresponding address of the `console platform` in the `console platform`, and jump to the corresponding address of the `management platform` in the `management platform`.

View File

@ -175,7 +175,7 @@
{ {
title: t('ID/Name'), title: t('ID/Name'),
dataIndex: 'name', dataIndex: 'name',
linkPrefix: `/compute/${this.getUrl('image')}/detail`, routeName: this.getRouteName('imageDetail'),
}, },
{ {
title: t('Project ID/Name'), title: t('Project ID/Name'),
@ -526,7 +526,7 @@
- 当前页面是否是“管理平台”的页面 - 当前页面是否是“管理平台”的页面
- `hasAdminRole` - `hasAdminRole`
- 登录的用户角色是否具有管理员角色 - 登录的用户角色是否具有管理员角色
- `getUrl` - `getRoutePath`
- 生成页面 Url 的函数 - 生成页面 Url 的函数
- 如:需要给列表页的关联资源提供跳转功能,使用该函数,可以在控制台跳转到控制台的相应地址,在管理平台跳转到管理平台的相应地址 - 如:需要给列表页的关联资源提供跳转功能,使用该函数,可以在控制台跳转到控制台的相应地址,在管理平台跳转到管理平台的相应地址
- `params` - `params`

View File

@ -114,7 +114,7 @@
- 当前页面是否是“管理平台”的页面 - 当前页面是否是“管理平台”的页面
- `hasAdminRole` - `hasAdminRole`
- 登录的用户角色是否具有管理员角色 - 登录的用户角色是否具有管理员角色
- `getUrl` - `getRoutePath`
- 生成页面 Url 的函数 - 生成页面 Url 的函数
- 如:需要给列表页的关联资源提供跳转功能,使用该函数,可以在控制台跳转到控制台的相应地址,在管理平台跳转到管理平台的相应地址 - 如:需要给列表页的关联资源提供跳转功能,使用该函数,可以在控制台跳转到控制台的相应地址,在管理平台跳转到管理平台的相应地址

View File

@ -72,7 +72,7 @@
```javascript ```javascript
get listUrl() { get listUrl() {
return this.getUrl('/storage/volume'); return this.getRoutePath('volume');
} }
``` ```
@ -241,7 +241,7 @@
- 路由信息中的`id` - 路由信息中的`id`
- `isAdminPage` - `isAdminPage`
- 当前页面是否是“管理平台”的页面 - 当前页面是否是“管理平台”的页面
- `getUrl` - `getRoutePath`
- 生成页面 Url 的函数 - 生成页面 Url 的函数
- 如:需要给关联资源提供跳转功能,使用该函数,可以在控制台跳转到控制台的相应地址,在管理平台跳转到管理平台的相应地址 - 如:需要给关联资源提供跳转功能,使用该函数,可以在控制台跳转到控制台的相应地址,在管理平台跳转到管理平台的相应地址
- `routing` - `routing`

View File

@ -131,7 +131,7 @@
- 路由信息中的`id` - 路由信息中的`id`
- `isAdminPage` - `isAdminPage`
- 当前页面是否是“管理平台”的页面 - 当前页面是否是“管理平台”的页面
- `getUrl` - `getRoutePath`
- 生成页面 Url 的函数 - 生成页面 Url 的函数
- 如:需要给关联资源提供跳转功能,使用该函数,可以在控制台跳转到控制台的相应地址,在管理平台跳转到管理平台的相应地址 - 如:需要给关联资源提供跳转功能,使用该函数,可以在控制台跳转到控制台的相应地址,在管理平台跳转到管理平台的相应地址
- `routing` - `routing`

View File

@ -147,7 +147,7 @@
```javascript ```javascript
get listUrl() { get listUrl() {
return this.getUrl('/storage/volume'); return this.getRoutePath('volume');
} }
``` ```
@ -381,7 +381,7 @@
- 表单验证成功后,更新的表单值 - 表单验证成功后,更新的表单值
- `isAdminPage` - `isAdminPage`
- 当前页面是否是“管理平台”的页面 - 当前页面是否是“管理平台”的页面
- `getUrl` - `getRoutePath`
- 生成页面 Url 的函数 - 生成页面 Url 的函数
- 如:需要给关联资源提供跳转功能,使用该函数,可以在控制台跳转到控制台的相应地址,在管理平台跳转到管理平台的相应地址 - 如:需要给关联资源提供跳转功能,使用该函数,可以在控制台跳转到控制台的相应地址,在管理平台跳转到管理平台的相应地址

View File

@ -282,7 +282,7 @@
- 表单验证成功后,更新的表单值 - 表单验证成功后,更新的表单值
- `isAdminPage` - `isAdminPage`
- 当前页面是否是“管理平台”的页面 - 当前页面是否是“管理平台”的页面
- `getUrl` - `getRoutePath`
- 生成页面 Url 的函数 - 生成页面 Url 的函数
- 如:需要给关联资源提供跳转功能,使用该函数,可以在控制台跳转到控制台的相应地址,在管理平台跳转到管理平台的相应地址 - 如:需要给关联资源提供跳转功能,使用该函数,可以在控制台跳转到控制台的相应地址,在管理平台跳转到管理平台的相应地址

View File

@ -22,6 +22,7 @@ import { isAdminPage, firstUpperCase, unescapeHtml } from 'utils/index';
import { parse } from 'qs'; import { parse } from 'qs';
import FormItem from 'components/FormItem'; import FormItem from 'components/FormItem';
import { CancelToken } from 'axios'; import { CancelToken } from 'axios';
import { getPath, getLinkRender } from 'utils/route-map';
import styles from './index.less'; import styles from './index.less';
export default class BaseForm extends React.Component { export default class BaseForm extends React.Component {
@ -137,6 +138,20 @@ export default class BaseForm extends React.Component {
return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path; return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path;
} }
getRouteName(routeName) {
return this.isAdminPage ? `${routeName}Admin` : routeName;
}
getRoutePath(routeName, params = {}, query = {}) {
const realName = this.getRouteName(routeName);
return getPath({ key: realName, params, query });
}
getLinkRender(routeName, value, params = {}, query = {}) {
const realName = this.getRouteName(routeName);
return getLinkRender({ key: realName, params, query, value });
}
get isStep() { get isStep() {
return false; return false;
} }

View File

@ -18,8 +18,8 @@ import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
import SelectTable from 'components/FormItem/SelectTable'; import SelectTable from 'components/FormItem/SelectTable';
import { ipValidate } from 'utils/validate'; import { ipValidate } from 'utils/validate';
import { isAdminPage } from 'utils/index'; import { isAdminPage } from 'utils/index';
import { Link } from 'react-router-dom';
import { Address4, Address6 } from 'ip-address'; import { Address4, Address6 } from 'ip-address';
import { getLinkRender } from 'utils/route-map';
import Item from './Item'; import Item from './Item';
const { isIPv4, isIpv6 } = ipValidate; const { isIPv4, isIpv6 } = ipValidate;
@ -34,9 +34,11 @@ const MemberAllocator = ({ componentProps, formItemProps }) => {
onChange && onChange(data); onChange && onChange(data);
}; };
function getUrl(path, adminStr) { function getLink(routerName, item) {
const { pathname } = window.location; const { pathname } = window.location;
return isAdminPage(pathname) ? `${path}${adminStr || '-admin'}` : path; const key = isAdminPage(pathname) ? `${routerName}Admin` : routerName;
const { id } = item;
return getLinkRender({ key, params: { id }, value: id });
} }
let addOuter = () => {}; let addOuter = () => {};
@ -60,16 +62,7 @@ const MemberAllocator = ({ componentProps, formItemProps }) => {
dataIndex: 'name', dataIndex: 'name',
render: (n, record) => ( render: (n, record) => (
<div> <div>
<div> <div>{getLink('virtualAdapterDetail', record)}</div>
<Link
to={`/network/${getUrl(
'virtual_adapter',
'_admin'
)}/detail/${record.id}`}
>
{record.id}
</Link>
</div>
<div>{n || '-'}</div> <div>{n || '-'}</div>
</div> </div>
), ),

View File

@ -19,6 +19,7 @@ import { NetworkStore } from 'stores/neutron/network';
import { yesNoOptions } from 'utils/constants'; import { yesNoOptions } from 'utils/constants';
import { networkColumns, networkSortProps } from 'resources/network'; import { networkColumns, networkSortProps } from 'resources/network';
import { isAdminPage } from 'utils/index'; import { isAdminPage } from 'utils/index';
import { getPath } from 'utils/route-map';
export class NetworkSelectTable extends Component { export class NetworkSelectTable extends Component {
constructor(props) { constructor(props) {
@ -87,8 +88,13 @@ export class NetworkSelectTable extends Component {
...networkSortProps, ...networkSortProps,
}); });
getUrl(path, adminStr) { getRouteName(routeName) {
return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path; return this.isAdminPage ? `${routeName}Admin` : routeName;
}
getRoutePath(routeName, params = {}, query = {}) {
const realName = this.getRouteName(routeName);
return getPath({ key: realName, params, query });
} }
getColumns = (tab) => { getColumns = (tab) => {

View File

@ -67,8 +67,6 @@ export default class VolumeSelectTable extends Component {
...volumeSortProps, ...volumeSortProps,
}); });
getUrl = () => {};
getColumns = (tab) => { getColumns = (tab) => {
const columns = volumeColumns; const columns = volumeColumns;
const { key } = tab; const { key } = tab;

View File

@ -20,6 +20,7 @@ import classnames from 'classnames';
import { firstUpperCase, unescapeHtml } from 'utils/index'; import { firstUpperCase, unescapeHtml } from 'utils/index';
import { parse } from 'qs'; import { parse } from 'qs';
import NotFound from 'components/Cards/NotFound'; import NotFound from 'components/Cards/NotFound';
import { getPath, getLinkRender } from 'utils/route-map';
import styles from './index.less'; import styles from './index.less';
export default class BaseStepForm extends React.Component { export default class BaseStepForm extends React.Component {
@ -92,7 +93,7 @@ export default class BaseStepForm extends React.Component {
} }
get listUrl() { get listUrl() {
return '/base/tmp'; return '';
} }
get checkEndpoint() { get checkEndpoint() {
@ -212,6 +213,20 @@ export default class BaseStepForm extends React.Component {
return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path; return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path;
} }
getRouteName(routeName) {
return this.isAdminPage ? `${routeName}Admin` : routeName;
}
getRoutePath(routeName, params = {}, query = {}) {
const realName = this.getRouteName(routeName);
return getPath({ key: realName, params, query });
}
getLinkRender(routeName, value, params = {}, query = {}) {
const realName = this.getRouteName(routeName);
return getLinkRender({ key: realName, params, query, value });
}
getPrevBtn() { getPrevBtn() {
const { current } = this.state; const { current } = this.state;
if (current === 0) { if (current === 0) {

View File

@ -15,6 +15,7 @@
import React, { Component } from 'react'; import React, { Component } from 'react';
import TableButton from 'components/TableButton'; import TableButton from 'components/TableButton';
import { getSelfColumns } from 'resources/security-group-rule'; import { getSelfColumns } from 'resources/security-group-rule';
import { getPath } from 'utils/route-map';
export default class RuleButton extends Component { export default class RuleButton extends Component {
getUrl(path, adminStr) { getUrl(path, adminStr) {
@ -22,7 +23,10 @@ export default class RuleButton extends Component {
} }
getDetailUrl(id) { getDetailUrl(id) {
return `${this.getUrl('/network/security-group')}/detail/${id}`; const key = this.isAdminPage
? 'securityGroupDetailAdmin'
: 'securityGroupDetail';
return getPath({ key, params: { id } });
} }
render() { render() {

View File

@ -17,7 +17,6 @@ import PropTypes from 'prop-types';
import classnames from 'classnames'; import classnames from 'classnames';
import isEqual from 'react-fast-compare'; import isEqual from 'react-fast-compare';
import { toJS } from 'mobx'; import { toJS } from 'mobx';
import { Link } from 'react-router-dom';
import { includes, get, isArray, isString } from 'lodash'; import { includes, get, isArray, isString } from 'lodash';
import { Button, Table, Dropdown, Input, Typography, Tooltip } from 'antd'; import { Button, Table, Dropdown, Input, Typography, Tooltip } from 'antd';
import MagicInput from 'components/MagicInput'; import MagicInput from 'components/MagicInput';
@ -39,10 +38,13 @@ import {
getStatusRender, getStatusRender,
getRender, getRender,
getValueRenderFunc, getValueRenderFunc,
getNameRenderByRouter,
getNameRender,
columnRender,
} from 'utils/table'; } from 'utils/table';
import { getNoValue } from 'utils/index'; import { getNoValue } from 'utils/index';
import { columnRender } from 'utils/render';
import { getLocalStorageItem, setLocalStorageItem } from 'utils/local-storage'; import { getLocalStorageItem, setLocalStorageItem } from 'utils/local-storage';
import { getLinkRender } from 'utils/route-map';
import { inject } from 'mobx-react'; import { inject } from 'mobx-react';
import globalRootStore from 'stores/root'; import globalRootStore from 'stores/root';
import CustomColumns from './CustomColumns'; import CustomColumns from './CustomColumns';
@ -50,6 +52,7 @@ import ItemActionButtons from './ItemActionButtons';
import PrimaryActionButtons from './PrimaryActionButtons'; import PrimaryActionButtons from './PrimaryActionButtons';
import BatchActionButtons from './BatchActionButtons'; import BatchActionButtons from './BatchActionButtons';
import Download from './Download'; import Download from './Download';
import styles from './index.less'; import styles from './index.less';
@inject('rootStore') @inject('rootStore')
@ -330,16 +333,14 @@ export default class BaseTable extends React.Component {
if (!projectId) { if (!projectId) {
return '-'; return '-';
} }
const url = `/identity/project-admin/detail/${projectId}`; const link = getLinkRender({
key: 'projectDetailAdmin',
params: { id: projectId },
value: projectId,
});
return ( return (
<> <>
<div> <div>{globalRootStore.hasAdminRole ? link : projectId}</div>
{globalRootStore.hasAdminRole ? (
<Link to={url}>{projectId}</Link>
) : (
projectId
)}
</div>
<div>{value || '-'}</div> <div>{value || '-'}</div>
</> </>
); );
@ -353,63 +354,6 @@ export default class BaseTable extends React.Component {
return (value) => getNoValue(value); return (value) => getNoValue(value);
}; };
getLinkUrl = (prefix, id) => {
if (!prefix) {
return null;
}
if (prefix[prefix.length - 1] === '/') {
return `${prefix}${id}`;
}
return `${prefix}/${id}`;
};
getNameRender = (render, column) => {
if (render) {
return render;
}
const {
linkPrefix,
dataIndex,
idKey,
linkPrefixFunc,
linkFunc,
hasNoDetail = false,
} = column;
const { rowKey } = this.props;
return (value, record) => {
const idValue = get(record, idKey || rowKey);
let url = null;
if (linkFunc) {
url = linkFunc(value, record);
} else {
const linkValue = linkPrefixFunc
? linkPrefixFunc(value, record)
: linkPrefix;
url = this.getLinkUrl(linkValue, idValue);
}
const nameValue = value || get(record, dataIndex) || '-';
if (hasNoDetail) {
return (
<div>
<div>{idValue}</div>
<div>{nameValue}</div>
</div>
);
}
if (!url && !hasNoDetail) {
return nameValue;
}
return (
<div>
<div>
<Link to={url}>{idValue}</Link>
</div>
<div>{nameValue}</div>
</div>
);
};
};
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
getPriceRender = (render, column) => { getPriceRender = (render, column) => {
if (render) { if (render) {
@ -469,6 +413,9 @@ export default class BaseTable extends React.Component {
tip, tip,
isStatus, isStatus,
isName, isName,
isLink,
routeName,
linkPrefix,
isPrice, isPrice,
...rest ...rest
} = column; } = column;
@ -485,8 +432,12 @@ export default class BaseTable extends React.Component {
if (dataIndex === 'project_name') { if (dataIndex === 'project_name') {
newRender = this.getProjectRender(newRender); newRender = this.getProjectRender(newRender);
} }
if (dataIndex === 'name' || isName) { if ((dataIndex === 'name' && routeName) || isLink) {
newRender = this.getNameRender(newRender, column); const { rowKey } = this.props;
newRender = getNameRenderByRouter(newRender, column, rowKey);
}
if ((dataIndex === 'name' && linkPrefix) || isName) {
newRender = getNameRender(newRender, column);
} }
if (dataIndex === 'cost' || isPrice) { if (dataIndex === 'cost' || isPrice) {
newRender = this.getPriceRender(newRender, column); newRender = this.getPriceRender(newRender, column);

View File

@ -13,6 +13,7 @@
// limitations under the License. // limitations under the License.
import BaseForm from 'components/Form'; import BaseForm from 'components/Form';
import { getPath } from 'utils/route-map';
export default class FormAction extends BaseForm { export default class FormAction extends BaseForm {
static id = 'formAction'; static id = 'formAction';
@ -36,4 +37,13 @@ export default class FormAction extends BaseForm {
getUrl(path, adminStr) { getUrl(path, adminStr) {
return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path; return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path;
} }
getRouteName(routeName) {
return this.isAdminPage ? `${routeName}Admin` : routeName;
}
getRoutePath(routeName, params = {}, query = {}) {
const realName = this.getRouteName(routeName);
return getPath({ key: realName, params, query });
}
} }

View File

@ -32,12 +32,4 @@ export default class StepAction extends StepForm {
get hasConfirmStep() { get hasConfirmStep() {
return true; return true;
} }
// get isAdminPage() {
// return this.props.isAdminPage || false;
// }
// getUrl(path, adminStr) {
// return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path;
// }
} }

View File

@ -18,6 +18,7 @@ import Card from 'components/DetailCard';
import { toJS } from 'mobx'; import { toJS } from 'mobx';
import { has } from 'lodash'; import { has } from 'lodash';
import { isAdminPage } from 'utils/index'; import { isAdminPage } from 'utils/index';
import { getPath, getLinkRender } from 'utils/route-map';
import styles from './index.less'; import styles from './index.less';
export default class BaseDetail extends React.Component { export default class BaseDetail extends React.Component {
@ -86,6 +87,20 @@ export default class BaseDetail extends React.Component {
return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path; return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path;
} }
getRouteName(routeName) {
return this.isAdminPage ? `${routeName}Admin` : routeName;
}
getRoutePath(routeName, params = {}, query = {}) {
const realName = this.getRouteName(routeName);
return getPath({ key: realName, params, query });
}
getLinkRender(routeName, value, params = {}, query = {}) {
const realName = this.getRouteName(routeName);
return getLinkRender({ key: realName, params, query, value });
}
fetchData = (params) => { fetchData = (params) => {
if (this.shouldFetchDetail && this.store.fetchDetail) { if (this.shouldFetchDetail && this.store.fetchDetail) {
this.store this.store

View File

@ -34,6 +34,7 @@ import { checkTimeIn } from 'utils/time';
import checkItemPolicy from 'resources/policy'; import checkItemPolicy from 'resources/policy';
import NotFound from 'components/Cards/NotFound'; import NotFound from 'components/Cards/NotFound';
import { getTags } from 'components/MagicInput'; import { getTags } from 'components/MagicInput';
import { getPath, getLinkRender } from 'utils/route-map';
import styles from './index.less'; import styles from './index.less';
const tabOtherHeight = 326; const tabOtherHeight = 326;
@ -169,6 +170,20 @@ export default class BaseList extends React.Component {
return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path; return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path;
} }
getRouteName(routeName) {
return this.isAdminPage ? `${routeName}Admin` : routeName;
}
getRoutePath(routeName, params = {}, query = {}) {
const realName = this.getRouteName(routeName);
return getPath({ key: realName, params, query });
}
getLinkRender(routeName, value, params = {}, query = {}) {
const realName = this.getRouteName(routeName);
return getLinkRender({ key: realName, params, query, value });
}
get prefix() { get prefix() {
return this.props.match.url; return this.props.match.url;
} }
@ -1064,7 +1079,7 @@ export default class BaseList extends React.Component {
} catch (e) { } catch (e) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log(e); console.log(e);
const link = this.getUrl('/base/overview'); const link = this.getRoutePath('overview');
return <NotFound title={this.name} link={link} codeError />; return <NotFound title={this.name} link={link} codeError />;
} }
} }
@ -1155,7 +1170,7 @@ export default class BaseList extends React.Component {
render() { render() {
if (this.endpointError) { if (this.endpointError) {
const link = this.getUrl('/base/overview'); const link = this.getRoutePath('overview');
return <NotFound title={this.name} link={link} endpointError />; return <NotFound title={this.name} link={link} endpointError />;
} }
const table = this.renderTable(); const table = this.renderTable();

View File

@ -26,6 +26,7 @@ import { toJS } from 'mobx';
import checkItemPolicy from 'resources/policy'; import checkItemPolicy from 'resources/policy';
import ItemActionButtons from 'components/Tables/Base/ItemActionButtons'; import ItemActionButtons from 'components/Tables/Base/ItemActionButtons';
import { emptyActionConfig } from 'utils/constants'; import { emptyActionConfig } from 'utils/constants';
import { getPath, getLinkRender } from 'utils/route-map';
import styles from './index.less'; import styles from './index.less';
export default class DetailBase extends React.Component { export default class DetailBase extends React.Component {
@ -71,6 +72,20 @@ export default class DetailBase extends React.Component {
return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path; return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path;
} }
getRouteName(routeName) {
return this.isAdminPage ? `${routeName}Admin` : routeName;
}
getRoutePath(routeName, params = {}, query = {}) {
const realName = this.getRouteName(routeName);
return getPath({ key: realName, params, query });
}
getLinkRender(routeName, value, params = {}, query = {}) {
const realName = this.getRouteName(routeName);
return getLinkRender({ key: realName, params, query, value });
}
get tabs() { get tabs() {
return []; return [];
} }
@ -166,7 +181,7 @@ export default class DetailBase extends React.Component {
} }
get listUrl() { get listUrl() {
return '/base/tmp'; return '';
} }
get detailData() { get detailData() {

View File

@ -17,6 +17,7 @@ import { parse } from 'qs';
import classnames from 'classnames'; import classnames from 'classnames';
import { Tabs } from 'antd'; import { Tabs } from 'antd';
import { isAdminPage } from 'utils/index'; import { isAdminPage } from 'utils/index';
import { getPath, getLinkRender } from 'utils/route-map';
import NotFound from 'components/Cards/NotFound'; import NotFound from 'components/Cards/NotFound';
import styles from './index.less'; import styles from './index.less';
@ -67,6 +68,20 @@ export default class TabList extends Component {
return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path; return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path;
} }
getRouteName(routeName) {
return this.isAdminPage ? `${routeName}Admin` : routeName;
}
getRoutePath(routeName, params = {}, query = {}) {
const realName = this.getRouteName(routeName);
return getPath({ key: realName, params, query });
}
getLinkRender(routeName, value, params = {}, query = {}) {
const realName = this.getRouteName(routeName);
return getLinkRender({ key: realName, params, query, value });
}
get tabs() { get tabs() {
const tabs = [ const tabs = [
{ {
@ -137,7 +152,7 @@ export default class TabList extends Component {
return null; return null;
} }
if (this.endpointError) { if (this.endpointError) {
const link = this.getUrl('/base/overview'); const link = this.getRoutePath('overview');
return <NotFound title={this.name} link={link} endpointError />; return <NotFound title={this.name} link={link} endpointError />;
} }
// if (this.tabs.length === 1) { // if (this.tabs.length === 1) {

View File

@ -21,6 +21,7 @@ import { toJS } from 'mobx';
import classnames from 'classnames'; import classnames from 'classnames';
import logoSmall from 'asset/image/logo-small.svg'; import logoSmall from 'asset/image/logo-small.svg';
import logoExtend from 'asset/image/logo-extend.svg'; import logoExtend from 'asset/image/logo-extend.svg';
import { getPath } from 'utils/route-map';
import styles from './index.less'; import styles from './index.less';
const { SubMenu } = Menu; const { SubMenu } = Menu;
@ -47,6 +48,15 @@ export class LayoutMenu extends Component {
return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path; return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path;
} }
getRouteName(routeName) {
return this.isAdminPage ? `${routeName}Admin` : routeName;
}
getRoutePath(routeName, params = {}, query = {}) {
const realName = this.getRouteName(routeName);
return getPath({ key: realName, params, query });
}
get rootStore() { get rootStore() {
return this.props.rootStore; return this.props.rootStore;
} }
@ -217,7 +227,7 @@ export class LayoutMenu extends Component {
const { collapsed, hover } = this.state; const { collapsed, hover } = this.state;
const isExtend = !collapsed || hover; const isExtend = !collapsed || hover;
const imageSvg = this.getImage(isExtend); const imageSvg = this.getImage(isExtend);
const homeUrl = this.getUrl('/base/overview'); const homeUrl = this.getRoutePath('overview');
return ( return (
<div <div
className={classnames( className={classnames(

View File

@ -20,6 +20,7 @@ import classnames from 'classnames';
import renderRoutes from 'utils/RouterConfig'; import renderRoutes from 'utils/RouterConfig';
import NotFound from 'components/Cards/NotFound'; import NotFound from 'components/Cards/NotFound';
import PageLoading from 'components/PageLoading'; import PageLoading from 'components/PageLoading';
import { getPath } from 'utils/route-map';
import styles from './index.less'; import styles from './index.less';
const { Content } = Layout; const { Content } = Layout;
@ -59,6 +60,15 @@ class Right extends Component {
return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path; return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path;
} }
getRouteName(routeName) {
return this.isAdminPage ? `${routeName}Admin` : routeName;
}
getRoutePath(routeName, params = {}, query = {}) {
const realName = this.getRouteName(routeName);
return getPath({ key: realName, params, query });
}
checkHasTab = () => { checkHasTab = () => {
const { currentRoutes = [] } = this.props; const { currentRoutes = [] } = this.props;
if (currentRoutes.length === 0) { if (currentRoutes.length === 0) {
@ -123,21 +133,12 @@ class Right extends Component {
return ( return (
<NotFound <NotFound
title={t('data')} title={t('data')}
link={this.getUrl('/base/overview')} link={this.getRoutePath('overview')}
codeError codeError
/> />
); );
} }
try { try {
// const { currentRoutes = [] } = this.props;
// if (currentRoutes.length === 0) {
// return (
// <NotFound
// title={t('data')}
// link={this.getUrl('/base/overview')}
// />
// );
// }
const children = ( const children = (
<div className={`${styles.main} ${mainBreadcrubClass} ${mainTabClass}`}> <div className={`${styles.main} ${mainBreadcrubClass} ${mainTabClass}`}>
{renderRoutes(this.routes, extraProps)} {renderRoutes(this.routes, extraProps)}
@ -147,13 +148,8 @@ class Right extends Component {
} catch (e) { } catch (e) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.log(e); console.log(e);
return ( const path = this.getRoutePath('overview');
<NotFound return <NotFound title={t('data')} link={path} codeError />;
title={t('data')}
link={this.getUrl('/base/overview')}
codeError
/>
);
} }
}; };

View File

@ -21,6 +21,7 @@ import { BellOutlined } from '@ant-design/icons';
import checkItemPolicy from 'resources/policy'; import checkItemPolicy from 'resources/policy';
import { Layout } from 'antd'; import { Layout } from 'antd';
import GlobalHeader from 'components/Layout/GlobalHeader'; import GlobalHeader from 'components/Layout/GlobalHeader';
import { setRouteMap, getPath } from 'utils/route-map';
import renderAdminMenu from '../admin-menu'; import renderAdminMenu from '../admin-menu';
import renderMenu from '../menu'; import renderMenu from '../menu';
import renderUserMenu from '../user-menu'; import renderUserMenu from '../user-menu';
@ -100,6 +101,15 @@ export class BaseLayout extends Component {
return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path; return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path;
} }
getRouteName(routeName) {
return this.isAdminPage ? `${routeName}Admin` : routeName;
}
getRoutePath(routeName, params = {}, query = {}) {
const realName = this.getRouteName(routeName);
return getPath({ key: realName, params, query });
}
filterMenuByHidden = (menu = []) => { filterMenuByHidden = (menu = []) => {
if (menu.length === 0) { if (menu.length === 0) {
return menu; return menu;
@ -208,6 +218,7 @@ export class BaseLayout extends Component {
window.location.href = '/base/overview'; window.location.href = '/base/overview';
} }
this.routes = this.props.route.routes; this.routes = this.props.route.routes;
setRouteMap(this.menu);
} }
renderNotice() { renderNotice() {

View File

@ -32,7 +32,7 @@ const renderMenu = (t) => {
{ {
path: '/base/overview-admin', path: '/base/overview-admin',
name: t('Home'), name: t('Home'),
key: '/home', key: 'overviewAdmin',
icon: <HomeOutlined />, icon: <HomeOutlined />,
level: 0, level: 0,
hasBreadcrumb: false, hasBreadcrumb: false,
@ -41,19 +41,20 @@ const renderMenu = (t) => {
{ {
path: '/compute', path: '/compute',
name: t('Compute'), name: t('Compute'),
key: '/compute', key: 'computeAdmin',
icon: <DesktopOutlined />, icon: <DesktopOutlined />,
children: [ children: [
{ {
path: '/compute/instance-admin', path: '/compute/instance-admin',
name: t('Instance'), name: t('Instance'),
key: '/compute/instance-admin', key: 'instanceAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/compute\/instance-admin\/detail\/.[^/]+$/, path: /^\/compute\/instance-admin\/detail\/.[^/]+$/,
name: t('Instance Detail'), name: t('Instance Detail'),
key: 'instance-detail', key: 'instanceDetailAdmin',
routePath: '/compute/instance-admin/detail/:id',
level: 2, level: 2,
}, },
], ],
@ -61,19 +62,20 @@ const renderMenu = (t) => {
{ {
path: '/compute/flavor-admin', path: '/compute/flavor-admin',
name: t('Flavor'), name: t('Flavor'),
key: '/compute/flavor', key: 'flavorAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: '/compute/flavor-admin/create', path: '/compute/flavor-admin/create',
name: t('Create Flavor'), name: t('Create Flavor'),
key: 'flavor-create', key: 'flavorCreateAdmin',
level: 2, level: 2,
}, },
{ {
path: /^\/compute\/flavor-admin\/detail\/[^/]+$/, path: /^\/compute\/flavor-admin\/detail\/[^/]+$/,
name: t('Flavor Detail'), name: t('Flavor Detail'),
key: 'flavor-detail', key: 'flavorDetailAdmin',
routePath: '/compute/flavor-admin/detail/:id',
level: 2, level: 2,
}, },
], ],
@ -81,13 +83,14 @@ const renderMenu = (t) => {
{ {
path: '/compute/server-group-admin', path: '/compute/server-group-admin',
name: t('Server Group'), name: t('Server Group'),
key: '/compute/server-group-admin', key: 'serverGroupAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/compute\/server-group-admin\/detail\/.[^/]+$/, path: /^\/compute\/server-group-admin\/detail\/.[^/]+$/,
name: t('Server Group Detail'), name: t('Server Group Detail'),
key: 'server-group-detail', key: 'serverGroupDetailAdmin',
routePath: '/compute/server-group-admin/detail/:id',
level: 2, level: 2,
}, },
], ],
@ -95,19 +98,20 @@ const renderMenu = (t) => {
{ {
path: '/compute/image-admin', path: '/compute/image-admin',
name: t('Image'), name: t('Image'),
key: '/compute/image-admin', key: 'imageAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/compute\/image-admin\/detail\/.[^/]+$/, path: /^\/compute\/image-admin\/detail\/.[^/]+$/,
name: t('Image Detail'), name: t('Image Detail'),
key: 'image-detail', key: 'imageDetailAdmin',
routePath: '/compute/image-admin/detail/:id',
level: 2, level: 2,
}, },
{ {
path: '/compute/image-admin/create', path: '/compute/image-admin/create',
name: t('Create Image'), name: t('Create Image'),
key: 'image-create', key: 'imageCreateAdmin',
level: 2, level: 2,
}, },
], ],
@ -115,13 +119,14 @@ const renderMenu = (t) => {
{ {
path: '/compute/hypervisors-admin', path: '/compute/hypervisors-admin',
name: t('Hypervisors'), name: t('Hypervisors'),
key: '/compute/hypervisors', key: 'hypervisorAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/compute\/hypervisors-admin\/detail\/.[^/]+$/, path: /^\/compute\/hypervisors-admin\/detail\/.[^/]+$/,
name: t('Hypervisor Detail'), name: t('Hypervisor Detail'),
key: 'hypervisor-detail', key: 'hypervisorDetailAdmin',
routePath: '/compute/hypervisors-admin/detail/:id',
level: 2, level: 2,
}, },
], ],
@ -129,32 +134,34 @@ const renderMenu = (t) => {
{ {
path: '/compute/aggregates-admin', path: '/compute/aggregates-admin',
name: t('Host Aggregates'), name: t('Host Aggregates'),
key: '/compute/aggregates', key: 'aggregateAdmin',
level: 1, level: 1,
children: [], children: [],
}, },
{ {
path: '/compute/baremetal-node-admin', path: '/compute/baremetal-node-admin',
name: t('Bare Metal Setting'), name: t('Bare Metal Setting'),
key: '/compute/baremetal-node', key: 'baremetalNodeAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/compute\/baremetal-node-admin\/detail\/.[^/]+$/, path: /^\/compute\/baremetal-node-admin\/detail\/.[^/]+$/,
name: t('Bare Metal Node Detail'), name: t('Bare Metal Node Detail'),
key: 'baremetal-node-detail', key: 'baremetaNodeDetailAdmin',
routePath: '/compute/baremetal-node-admin/detail/:id',
level: 2, level: 2,
}, },
{ {
path: /^\/compute\/baremetal-node-admin\/create$/, path: /^\/compute\/baremetal-node-admin\/create$/,
name: t('Create Bare Metal Node'), name: t('Create Bare Metal Node'),
key: 'baremetal-node-create', key: 'baremetalNodeCreateAdmin',
level: 2, level: 2,
}, },
{ {
path: /^\/compute\/baremetal-node-admin\/edit\/.[^/]+$/, path: /^\/compute\/baremetal-node-admin\/edit\/.[^/]+$/,
name: t('Bare Metal Node Edit'), name: t('Bare Metal Node Edit'),
key: 'baremetal-node-edit', key: 'baremetalNodeEditAdmin',
routePath: '/compute/baremetal-node-admin/detail/:id',
level: 2, level: 2,
}, },
], ],
@ -164,75 +171,80 @@ const renderMenu = (t) => {
{ {
path: '/storage', path: '/storage',
name: t('Storage'), name: t('Storage'),
key: '/storage', key: 'storageAdmin',
icon: <DatabaseOutlined />, icon: <DatabaseOutlined />,
children: [ children: [
{ {
path: '/storage/volume-admin', path: '/storage/volume-admin',
name: t('Volume'), name: t('Volume'),
key: '/storage/volume', key: 'volumeAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/storage\/volume-admin\/detail\/.[^/]+$/, path: /^\/storage\/volume-admin\/detail\/.[^/]+$/,
name: t('Volume Detail'), name: t('Volume Detail'),
key: 'volume-detail', key: 'volumeDetailAdmin',
level: 2, level: 2,
routePath: '/storage/volume-admin/detail/:id',
}, },
], ],
}, },
{ {
path: '/storage/backup-admin', path: '/storage/backup-admin',
name: t('Backups'), name: t('Backups'),
key: '/storage/backup', key: 'backupAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/storage\/backup-admin\/detail\/.[^/]+$/, path: /^\/storage\/backup-admin\/detail\/.[^/]+$/,
name: t('Backup Detail'), name: t('Backup Detail'),
key: 'backup-detail', key: 'backupDetailAdmin',
level: 2, level: 2,
routePath: '/storage/backup-admin/detail/:id',
}, },
], ],
}, },
{ {
path: '/storage/snapshot-admin', path: '/storage/snapshot-admin',
name: t('Volume Snapshot'), name: t('Volume Snapshot'),
key: '/storage/snapshot', key: 'snapshotAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/storage\/snapshot-admin\/detail\/.[^/]+$/, path: /^\/storage\/snapshot-admin\/detail\/.[^/]+$/,
name: t('Snapshot Detail'), name: t('Snapshot Detail'),
key: 'snapshot-detail', key: 'snapshotDetailAdmin',
level: 2, level: 2,
routePath: '/storage/snapshot-admin/detail/:id',
}, },
], ],
}, },
{ {
path: '/storage/volume-type-admin', path: '/storage/volume-type-admin',
name: t('Volume Type'), name: t('Volume Type'),
key: '/storage/volume-type', key: 'volumeTypeAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/storage\/volume-type-admin\/detail\/.[^/]+$/, path: /^\/storage\/volume-type-admin\/detail\/.[^/]+$/,
name: t('Volume Type Detail'), name: t('Volume Type Detail'),
key: 'volume-type-detail', key: 'volumeTypeDetailAdmin',
level: 2, level: 2,
routePath: '/storage/volume-type-admin/detail/:id',
}, },
{ {
path: /^\/storage\/volume-type-admin\/qos\/detail\/.[^/]+$/, path: /^\/storage\/volume-type-admin\/qos\/detail\/.[^/]+$/,
name: t('QoS Detail'), name: t('QoS Detail'),
key: 'volume-type-qos-detail', key: 'volumeTypeQosDetailAdmin',
level: 2, level: 2,
routePath: '/storage/volume-type-admin/qos/detail/:id',
}, },
], ],
}, },
{ {
path: '/storage/storage-admin', path: '/storage/storage-admin',
name: t('Storage Backend'), name: t('Storage Backend'),
key: '/storage/storage', key: 'storageBackendAdmin',
level: 1, level: 1,
children: [], children: [],
}, },
@ -241,130 +253,141 @@ const renderMenu = (t) => {
{ {
path: '/network', path: '/network',
name: t('Network'), name: t('Network'),
key: '/network', key: '/networkAdmin',
icon: <GlobalOutlined />, icon: <GlobalOutlined />,
children: [ children: [
{ {
path: '/network/networks-admin', path: '/network/networks-admin',
name: t('Networks'), name: t('Networks'),
key: '/network/networks', key: 'networkAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/network\/networks-admin\/detail\/.[^/]+$/, path: /^\/network\/networks-admin\/detail\/.[^/]+$/,
name: t('Network Detail'), name: t('Network Detail'),
key: 'network_detail', key: 'networkDetailAdmin',
level: 2, level: 2,
routePath: '/network/networks-admin/detail/:id',
}, },
], ],
}, },
{ {
path: '/network/virtual_adapter_admin', path: '/network/virtual_adapter_admin',
name: t('Virtual Adapter'), name: t('Virtual Adapter'),
key: '/network/virtual_adapter_admin', key: 'virtualAdapterAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/network\/virtual_adapter_admin\/detail\/.[^/]+$/, path: /^\/network\/virtual_adapter_admin\/detail\/.[^/]+$/,
name: t('Virtual Adapter Detail'), name: t('Virtual Adapter Detail'),
key: 'virtual_adapter-detail', key: 'virtualAdapterDetailAdmin',
level: 2, level: 2,
routePath: '/network/virtual_adapter_admin/detail/:id',
}, },
], ],
}, },
{ {
path: '/network/qos-policy-admin', path: '/network/qos-policy-admin',
name: t('QoS Policy'), name: t('QoS Policy'),
key: '/network/qos-policy-admin', key: 'networkQosAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/network\/qos-policy-admin\/detail\/.[^/]+$/, path: /^\/network\/qos-policy-admin\/detail\/.[^/]+$/,
name: t('QoS Policy Detail'), name: t('QoS Policy Detail'),
key: 'qos-policy-detail', key: 'networkQosDetailAdmin',
level: 2, level: 2,
routePath: '/network/qos-policy-admin/detail/:id',
}, },
], ],
}, },
{ {
path: '/network/router-admin', path: '/network/router-admin',
name: t('Routers'), name: t('Routers'),
key: '/network/router-admin', key: 'routerAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/network\/router-admin\/detail\/.[^/]+$/, path: /^\/network\/router-admin\/detail\/.[^/]+$/,
name: t('Router Detail'), name: t('Router Detail'),
key: 'router-detail', key: 'routerDetailAdmin',
level: 2, level: 2,
routePath: '/network/router-admin/detail/:id',
}, },
{ {
path: /^\/network\/router-admin\/.[^/]+\/port\/.[^/]+$/, path: /^\/network\/router-admin\/.[^/]+\/port\/.[^/]+$/,
name: t('Port Detail'), name: t('Port Detail'),
key: 'port-detail', key: 'routerPortDetailAdmin',
level: 2, level: 2,
routePath: '/network/router-admin/:routerId/port/:id',
}, },
], ],
}, },
{ {
path: '/network/floatingip-admin', path: '/network/floatingip-admin',
name: t('Floating IPs'), name: t('Floating IPs'),
key: '/network/floatingip-admin', key: 'fipAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/network\/floatingip-admin\/detail\/.[^/]+$/, path: /^\/network\/floatingip-admin\/detail\/.[^/]+$/,
name: t('Floating Ip Detail'), name: t('Floating Ip Detail'),
key: 'floatingip-detail', key: 'fipDetailAdmin',
level: 2, level: 2,
routePath: '/network/floatingip-admin/detail/:id',
}, },
], ],
}, },
{ {
path: '/network/load-balancers-admin', path: '/network/load-balancers-admin',
name: t('Load Balancers'), name: t('Load Balancers'),
key: '/network/load-balancers-admin', key: 'lbAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/network\/load-balancers-admin\/detail\/.[^/]+$/, path: /^\/network\/load-balancers-admin\/detail\/.[^/]+$/,
name: t('Load Balancer Detail'), name: t('Load Balancer Detail'),
key: 'load-balancer-detail', key: 'lbDetailAdmin',
level: 2, level: 2,
routePath: '/network/load-balancers-admin/detail/:id',
}, },
{ {
path: /^\/network\/load-balancers-admin\/.[^/]+\/listener\/.[^/]+$/, path: /^\/network\/load-balancers-admin\/.[^/]+\/listener\/.[^/]+$/,
name: t('Listener Detail'), name: t('Listener Detail'),
key: 'listener-detail', key: 'lbListenerDetailAdmin',
level: 2, level: 2,
routePath:
'/network/load-balancers-admin/:loadBalancerId/listener/:id',
}, },
], ],
}, },
{ {
path: '/network/vpn-admin', path: '/network/vpn-admin',
name: t('VPN'), name: t('VPN'),
key: '/network/vpn-admin', key: 'vpnAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/network\/ipsec-site-connection-admin\/detail\/.[^/]+$/, path: /^\/network\/ipsec-site-connection-admin\/detail\/.[^/]+$/,
name: t('IPsec site connection Detail'), name: t('IPsec site connection Detail'),
key: 'ipsec-site-connection-detail', key: 'ipsecDetailAdmin',
level: 2, level: 2,
routePath: '/network/ipsec-site-connection-admin/detail/:id',
}, },
], ],
}, },
{ {
path: '/network/security-group-admin', path: '/network/security-group-admin',
name: t('Security Groups'), name: t('Security Groups'),
key: '/network/security-group', key: 'securityGroupAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/network\/security-group-admin\/detail\/.[^/]+$/, path: /^\/network\/security-group-admin\/detail\/.[^/]+$/,
name: t('Security Group Detail'), name: t('Security Group Detail'),
key: 'security-group-detail', key: 'securityGroupDetailAdmin',
level: 2, level: 2,
routePath: '/network/security-group-admin/detail/:id',
}, },
], ],
}, },
@ -379,118 +402,127 @@ const renderMenu = (t) => {
{ {
path: '/identity/domain-admin', path: '/identity/domain-admin',
name: t('Domains'), name: t('Domains'),
key: '/identity/domain', key: 'domainAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: '/identity/domain-admin/create', path: '/identity/domain-admin/create',
name: t('Create Domain'), name: t('Create Domain'),
key: 'domain-create', key: 'domainCreateAdmin',
level: 2, level: 2,
}, },
{ {
path: /^\/identity\/domain-admin\/edit\/.[^/]+$/, path: /^\/identity\/domain-admin\/edit\/.[^/]+$/,
name: t('Domain Edit'), name: t('Domain Edit'),
key: 'domain-edit', key: 'domainEditAdmin',
level: 2, level: 2,
routePath: '/identity/domain-admin/edit/:id',
}, },
{ {
path: /^\/identity\/domain-admin\/detail\/.[^/]+$/, path: /^\/identity\/domain-admin\/detail\/.[^/]+$/,
name: t('Domain Detail'), name: t('Domain Detail'),
key: 'domain-detail', key: 'domainDetailAdmin',
level: 2, level: 2,
routePath: '/identity/domain-admin/detail/:id',
}, },
], ],
}, },
{ {
path: '/identity/project-admin', path: '/identity/project-admin',
name: t('Projects'), name: t('Projects'),
key: '/identity/project', key: 'projectAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/identity\/project-admin\/detail\/.[^/]+$/, path: /^\/identity\/project-admin\/detail\/.[^/]+$/,
name: t('Project Detail'), name: t('Project Detail'),
key: 'project-detail', key: 'projectDetailAdmin',
level: 2, level: 2,
routePath: '/identity/project-admin/detail/:id',
}, },
{ {
path: '/identity/project-admin/create', path: '/identity/project-admin/create',
name: t('Create Project'), name: t('Create Project'),
key: 'project-create', key: 'projectCreateAdmin',
level: 2, level: 2,
}, },
{ {
path: /^\/identity\/project-admin\/edit\/.[^/]+$/, path: /^\/identity\/project-admin\/edit\/.[^/]+$/,
name: t('Edit Project'), name: t('Edit Project'),
key: 'project-edit', key: 'projectEditAdmin',
level: 2, level: 2,
routePath: '/identity/project-admin/edit/:id',
}, },
], ],
}, },
{ {
path: '/identity/user-admin', path: '/identity/user-admin',
name: t('Users'), name: t('Users'),
key: '/identity/user', key: 'userAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/identity\/user-admin\/detail\/.[^/]+$/, path: /^\/identity\/user-admin\/detail\/.[^/]+$/,
name: t('User Detail'), name: t('User Detail'),
key: 'user-detail', key: 'userDetailAdmin',
level: 2, level: 2,
routePath: '/identity/user-admin/detail/:id',
}, },
{ {
path: '/identity/user-admin/create', path: '/identity/user-admin/create',
name: t('Create User'), name: t('Create User'),
key: 'user-create', key: 'userCreateAdmin',
level: 2, level: 2,
}, },
{ {
path: /^\/identity\/user-admin\/edit\/.[^/]+$/, path: /^\/identity\/user-admin\/edit\/.[^/]+$/,
name: t('User Edit'), name: t('User Edit'),
key: 'user-edit', key: 'userEditAdmin',
level: 2, level: 2,
routePath: '/identity/user-admin/edit/:id',
}, },
], ],
}, },
{ {
path: '/identity/user-group-admin', path: '/identity/user-group-admin',
name: t('User Groups'), name: t('User Groups'),
key: '/identity/user-group', key: 'userGroupAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/identity\/user-group-admin\/detail\/.[^/]+$/, path: /^\/identity\/user-group-admin\/detail\/.[^/]+$/,
name: t('User Group Detail'), name: t('User Group Detail'),
key: 'project-detail', key: 'userGroupDetailAdmin',
level: 2, level: 2,
routePath: '/identity/user-group-admin/detail/:id',
}, },
{ {
path: '/identity/user-group-admin/create', path: '/identity/user-group-admin/create',
name: t('Create User Group'), name: t('Create User Group'),
key: 'user-group-create', key: 'userGroupCreateAdmin',
level: 2, level: 2,
}, },
{ {
path: /^\/identity\/user-group-admin\/edit\/.[^/]+$/, path: /^\/identity\/user-group-admin\/edit\/.[^/]+$/,
name: t('Edit User Group'), name: t('Edit User Group'),
key: 'user-group-edit', key: 'userGroupEditAdmin',
level: 2, level: 2,
routePath: '/identity/user-group-admin/edit/:id',
}, },
], ],
}, },
{ {
path: '/identity/role-admin', path: '/identity/role-admin',
name: t('Roles'), name: t('Roles'),
key: '/identity/role-admin', key: 'roleAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/identity\/role-admin\/detail\/.[^/]+$/, path: /^\/identity\/role-admin\/detail\/.[^/]+$/,
name: t('Role Detail'), name: t('Role Detail'),
key: 'role-detail', key: 'roleDetailAdmin',
level: 2, level: 2,
routePath: '/identity/role-admin/detail/:id',
}, },
], ],
}, },
@ -505,14 +537,15 @@ const renderMenu = (t) => {
// { // {
// path: '/management/recycle-bin-admin', // path: '/management/recycle-bin-admin',
// name: t('Recycle Bin'), // name: t('Recycle Bin'),
// key: '/management/recycle-bin-admin', // key: 'recycleBinAdmin',
// level: 1, // level: 1,
// children: [ // children: [
// { // {
// path: /^\/management\/recycle-bin-admin\/detail\/.[^/]+$/, // path: /^\/management\/recycle-bin-admin\/detail\/.[^/]+$/,
// name: t('Instance Detail'), // name: t('Instance Detail'),
// key: 'recycle-bin-detail', // key: 'recycleBinDetailAdmin',
// level: 2, // level: 2,
// routePath: '/management/recycle-bin-admin/detail/:id',
// }, // },
// ], // ],
// }, // },
@ -521,32 +554,34 @@ const renderMenu = (t) => {
{ {
path: '/heat', path: '/heat',
name: t('Orchestration'), name: t('Orchestration'),
key: '/heat', key: 'heatAdmin',
icon: <AppstoreOutlined />, icon: <AppstoreOutlined />,
children: [ children: [
{ {
path: '/heat/stack-admin', path: '/heat/stack-admin',
name: t('Stacks'), name: t('Stacks'),
key: '/heat/stack-admin', key: 'stackAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/heat\/stack-admin\/detail\/.[^/]+\/.[^/]+$/, path: /^\/heat\/stack-admin\/detail\/.[^/]+\/.[^/]+$/,
name: t('Stack Detail'), name: t('Stack Detail'),
key: 'stack-detail', key: 'stackDetailAdmin',
level: 2, level: 2,
routePath: '/heat/stack-admin/detail/:id/:name',
}, },
{ {
path: '/heat/stack-admin/create', path: '/heat/stack-admin/create',
name: t('Create Stack'), name: t('Create Stack'),
key: 'stack-create', key: 'stackCreateAdmin',
level: 2, level: 2,
}, },
{ {
path: /^\/heat\/stack-admin\/edit\/.[^/]+\/.[^/]+$/, path: /^\/heat\/stack-admin\/edit\/.[^/]+\/.[^/]+$/,
name: t('Update Template'), name: t('Update Template'),
key: 'stack-edit', key: 'stackEditAdmin',
level: 2, level: 2,
routePath: '/heat/stack-admin/edit/:id/:name',
}, },
], ],
}, },
@ -555,40 +590,42 @@ const renderMenu = (t) => {
{ {
path: '/configuration-admin', path: '/configuration-admin',
name: t('Global Setting'), name: t('Global Setting'),
key: '/configuration-admin', key: 'configurationAdmin',
icon: <SettingOutlined />, icon: <SettingOutlined />,
children: [ children: [
{ {
path: '/configuration-admin/info', path: '/configuration-admin/info',
name: t('System Info'), name: t('System Info'),
key: '/configuration-admin/info', key: 'systemInfoAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/configuration-admin\/neutron\/detail\/.[^/]+$/, path: /^\/configuration-admin\/neutron\/detail\/.[^/]+$/,
name: t('Neutron Agent Detail'), name: t('Neutron Agent Detail'),
key: 'neutron-detail', key: 'neutronAgentDetailAdmin',
level: 2, level: 2,
routePath: '/configuration-admin/neutron/detail/:id',
}, },
], ],
}, },
{ {
path: '/configuration-admin/setting', path: '/configuration-admin/setting',
name: t('System Config'), name: t('System Config'),
key: '/configuration-admin/setting', key: 'settingAdmin',
level: 1, level: 1,
}, },
{ {
path: '/configuration-admin/metadata', path: '/configuration-admin/metadata',
name: t('Metadata Definitions'), name: t('Metadata Definitions'),
key: '/configuration-admin/metadata', key: 'metadataAdmin',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/configuration-admin\/metadata\/detail\/.[^/]+$/, path: /^\/configuration-admin\/metadata\/detail\/.[^/]+$/,
name: t('Metadata Detail'), name: t('Metadata Detail'),
key: 'metadata-detail', key: 'metadataDetailAdmin',
level: 2, level: 2,
routePath: '/configuration-admin/metadata/detail/:id',
}, },
], ],
}, },

View File

@ -30,7 +30,7 @@ const renderMenu = (t) => {
{ {
path: '/base/overview', path: '/base/overview',
name: t('Home'), name: t('Home'),
key: '/home', key: 'overview',
icon: <HomeOutlined />, icon: <HomeOutlined />,
level: 0, level: 0,
hasBreadcrumb: false, hasBreadcrumb: false,
@ -39,31 +39,32 @@ const renderMenu = (t) => {
{ {
path: '/compute', path: '/compute',
name: t('Compute'), name: t('Compute'),
key: '/compute', key: 'compute',
icon: <DesktopOutlined />, icon: <DesktopOutlined />,
children: [ children: [
{ {
path: '/compute/instance', path: '/compute/instance',
name: t('Instance'), name: t('Instance'),
key: '/compute/instance', key: 'instance',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/compute\/instance\/detail\/.[^/]+$/, path: /^\/compute\/instance\/detail\/.[^/]+$/,
name: t('Instance Detail'), name: t('Instance Detail'),
key: 'instance-detail', key: 'instanceDetail',
level: 2, level: 2,
routePath: '/compute/instance/detail/:id',
}, },
{ {
path: '/compute/instance/create', path: '/compute/instance/create',
name: t('Create Instance'), name: t('Create Instance'),
key: 'instance-create', key: 'instanceCreate',
level: 2, level: 2,
}, },
{ {
path: '/compute/ironic-instance/create', path: '/compute/ironic-instance/create',
name: t('Create Ironic Instance'), name: t('Create Ironic Instance'),
key: 'ironic-instance-create', key: 'ironicCreate',
level: 2, level: 2,
}, },
], ],
@ -71,47 +72,50 @@ const renderMenu = (t) => {
{ {
path: '/compute/flavor', path: '/compute/flavor',
name: t('Flavor'), name: t('Flavor'),
key: '/compute/flavor', key: 'flavor',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/compute\/flavor\/detail\/.[^/]+$/, path: /^\/compute\/flavor\/detail\/.[^/]+$/,
name: t('Flavor Detail'), name: t('Flavor Detail'),
key: 'flavor-detail', key: 'flavorDetail',
level: 2, level: 2,
routePath: '/compute/flavor/detail/:id',
}, },
], ],
}, },
{ {
path: '/compute/server-group', path: '/compute/server-group',
name: t('Server Group'), name: t('Server Group'),
key: '/compute/server-group', key: 'serverGroup',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/compute\/server-group\/detail\/.[^/]+$/, path: /^\/compute\/server-group\/detail\/.[^/]+$/,
name: t('Server Group Detail'), name: t('Server Group Detail'),
key: 'server-group-detail', key: 'serverGroupDetail',
level: 2, level: 2,
routePath: '/compute/server-group/detail/:id',
}, },
], ],
}, },
{ {
path: '/compute/image', path: '/compute/image',
name: t('Image'), name: t('Image'),
key: '/compute/image', key: 'image',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/compute\/image\/detail\/.[^/]+$/, path: /^\/compute\/image\/detail\/.[^/]+$/,
name: t('Image Detail'), name: t('Image Detail'),
key: 'image-detail', key: 'imageDetail',
level: 2, level: 2,
routePath: '/compute/image/detail/:id',
}, },
{ {
path: '/compute/image/create', path: '/compute/image/create',
name: t('Create Image'), name: t('Create Image'),
key: 'image-create', key: 'imageCreate',
level: 2, level: 2,
}, },
], ],
@ -119,14 +123,15 @@ const renderMenu = (t) => {
{ {
path: '/compute/keypair', path: '/compute/keypair',
name: t('Key Pairs'), name: t('Key Pairs'),
key: '/compute/keypair', key: 'keypair',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/compute\/keypair\/detail\/.[^/]*$/, path: /^\/compute\/keypair\/detail\/.[^/]*$/,
name: t('Keypair Detail'), name: t('Keypair Detail'),
key: 'keypair-detail', key: 'keypairDetail',
level: 2, level: 2,
routePath: '/compute/keypair/detail/:id',
}, },
], ],
}, },
@ -135,54 +140,57 @@ const renderMenu = (t) => {
{ {
path: '/storage', path: '/storage',
name: t('Storage'), name: t('Storage'),
key: '/storage', key: 'storage',
icon: <DatabaseOutlined />, icon: <DatabaseOutlined />,
children: [ children: [
{ {
path: '/storage/volume', path: '/storage/volume',
name: t('Volume'), name: t('Volume'),
key: '/storage/volume', key: 'volume',
level: 1, level: 1,
children: [ children: [
{ {
path: '/storage/volume/create', path: '/storage/volume/create',
name: t('Create Volume'), name: t('Create Volume'),
key: 'volume-create', key: 'volumeCreate',
level: 2, level: 2,
}, },
{ {
path: /^\/storage\/volume\/detail\/.[^/]+$/, path: /^\/storage\/volume\/detail\/.[^/]+$/,
name: t('Volume Detail'), name: t('Volume Detail'),
key: 'volume-detail', key: 'volumeDetail',
level: 2, level: 2,
routePath: '/storage/volume/detail/:id',
}, },
], ],
}, },
{ {
path: '/storage/backup', path: '/storage/backup',
name: t('Backups'), name: t('Backups'),
key: '/storage/backup', key: 'backup',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/storage\/backup\/detail\/.[^/]+$/, path: /^\/storage\/backup\/detail\/.[^/]+$/,
name: t('Backup Detail'), name: t('Backup Detail'),
key: 'backup-detail', key: 'backupDetail',
level: 2, level: 2,
routePath: '/storage/backup/detail/:id',
}, },
], ],
}, },
{ {
path: '/storage/snapshot', path: '/storage/snapshot',
name: t('Volume Snapshot'), name: t('Volume Snapshot'),
key: '/storage/snapshot', key: 'snapshot',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/storage\/snapshot\/detail\/.[^/]+$/, path: /^\/storage\/snapshot\/detail\/.[^/]+$/,
name: t('Snapshot Detail'), name: t('Snapshot Detail'),
key: 'snapshot-detail', key: 'snapshotDetail',
level: 2, level: 2,
routePath: '/storage/snapshot/detail/:id',
}, },
], ],
}, },
@ -197,137 +205,147 @@ const renderMenu = (t) => {
{ {
path: '/network/networks', path: '/network/networks',
name: t('Networks'), name: t('Networks'),
key: '/network/networks', key: 'network',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/network\/networks\/detail\/.[^/]+$/, path: /^\/network\/networks\/detail\/.[^/]+$/,
name: t('Network Detail'), name: t('Network Detail'),
key: 'network_detail', key: 'networkDetail',
level: 2, level: 2,
routePath: '/network/networks/detail/:id',
}, },
], ],
}, },
{ {
path: '/network/virtual_adapter', path: '/network/virtual_adapter',
name: t('Virtual Adapter'), name: t('Virtual Adapter'),
key: '/network/virtual_adapter', key: 'virtualAdapter',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/network\/virtual_adapter\/detail\/.[^/]+$/, path: /^\/network\/virtual_adapter\/detail\/.[^/]+$/,
name: t('Virtual Adapter Detail'), name: t('Virtual Adapter Detail'),
key: 'virtual_adapter-detail', key: 'virtualAdapterDetail',
level: 2, level: 2,
routePath: '/network/virtual_adapter/detail/:id',
}, },
], ],
}, },
{ {
path: '/network/qos-policy', path: '/network/qos-policy',
name: t('QoS Policy'), name: t('QoS Policy'),
key: '/network/qos-policy', key: 'networkQos',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/network\/qos-policy\/detail\/.[^/]+$/, path: /^\/network\/qos-policy\/detail\/.[^/]+$/,
name: t('QoS Policy Detail'), name: t('QoS Policy Detail'),
key: 'qos-policy-detail', key: 'networkQosDetail',
level: 2, level: 2,
routePath: '/network/qos-policy/detail/:id',
}, },
], ],
}, },
{ {
path: '/network/router', path: '/network/router',
name: t('Routers'), name: t('Routers'),
key: '/network/router', key: 'router',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/network\/router\/detail\/.[^/]+$/, path: /^\/network\/router\/detail\/.[^/]+$/,
name: t('Router Detail'), name: t('Router Detail'),
key: 'router-detail', key: 'routerDetail',
level: 2, level: 2,
routePath: '/network/router/detail/:id',
}, },
{ {
path: /^\/network\/router\/.[^/]+\/port\/.[^/]+$/, path: /^\/network\/router\/.[^/]+\/port\/.[^/]+$/,
name: t('Port Detail'), name: t('Port Detail'),
key: 'port-detail', key: 'routerPortDetail',
level: 2, level: 2,
routePath: '/network/router/:routerId/port/:id',
}, },
], ],
}, },
{ {
path: '/network/floatingip', path: '/network/floatingip',
name: t('Floating IPs'), name: t('Floating IPs'),
key: '/network/floatingip', key: 'floatingip',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/network\/floatingip\/detail\/.[^/]+$/, path: /^\/network\/floatingip\/detail\/.[^/]+$/,
name: t('Floating Ip Detail'), name: t('Floating Ip Detail'),
key: 'floatingip-detail', key: 'fipDetail',
level: 2, level: 2,
routePath: '/network/floatingip/detail/:id',
}, },
], ],
}, },
{ {
path: '/network/topo', path: '/network/topo',
name: t('Topology'), name: t('Topology'),
key: '/network/topo', key: 'networkTopo',
level: 1, level: 1,
children: [], children: [],
}, },
{ {
path: '/network/load-balancers', path: '/network/load-balancers',
name: t('Load Balancers'), name: t('Load Balancers'),
key: '/network/load-balancers', key: 'lb',
level: 1, level: 1,
children: [ children: [
{ {
path: '/network/load-balancers/create', path: '/network/load-balancers/create',
name: t('Create Loadbalancer'), name: t('Create Loadbalancer'),
key: 'load-balancer-create', key: 'lbCreate',
level: 2, level: 2,
}, },
{ {
path: /^\/network\/load-balancers\/detail\/.[^/]+$/, path: /^\/network\/load-balancers\/detail\/.[^/]+$/,
name: t('Load Balancer Detail'), name: t('Load Balancer Detail'),
key: 'load-balancer-detail', key: 'lbDetail',
level: 2, level: 2,
routePath: '/network/load-balancers/detail/:id',
}, },
{ {
path: /^\/network\/load-balancers\/.[^/]+\/listener\/.[^/]+$/, path: /^\/network\/load-balancers\/.[^/]+\/listener\/.[^/]+$/,
name: t('Listener Detail'), name: t('Listener Detail'),
key: 'listener-detail', key: 'lbListenerDetail',
level: 2, level: 2,
routePath: '/network/load-balancers/:loadBalancerId/listener/:id',
}, },
], ],
}, },
{ {
path: '/network/vpn', path: '/network/vpn',
name: t('VPN'), name: t('VPN'),
key: '/network/vpn', key: 'vpn',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/network\/ipsec-site-connection\/detail\/.[^/]+$/, path: /^\/network\/ipsec-site-connection\/detail\/.[^/]+$/,
name: t('IPsec site connection Detail'), name: t('IPsec site connection Detail'),
key: 'ipsec-site-connection-detail', key: 'ipsecDetail',
level: 2, level: 2,
routePath: '/network/ipsec-site-connection/detail/:id',
}, },
], ],
}, },
{ {
path: '/network/security-group', path: '/network/security-group',
name: t('Security Groups'), name: t('Security Groups'),
key: '/network/security-group', key: 'securityGroup',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/network\/security-group\/detail\/.[^/]+$/, path: /^\/network\/security-group\/detail\/.[^/]+$/,
name: t('Security Group Detail'), name: t('Security Group Detail'),
key: 'security-group-detail', key: 'securityGroupDetail',
level: 2, level: 2,
routePath: '/network/security-group/detail/:id',
}, },
], ],
}, },
@ -342,14 +360,15 @@ const renderMenu = (t) => {
// { // {
// path: '/management/recycle-bin', // path: '/management/recycle-bin',
// name: t('Recycle Bin'), // name: t('Recycle Bin'),
// key: '/management/recycle-bin', // key: 'recycleBin',
// level: 1, // level: 1,
// children: [ // children: [
// { // {
// path: /^\/management\/recycle-bin\/detail\/.[^/]+$/, // path: /^\/management\/recycle-bin\/detail\/.[^/]+$/,
// name: t('Instance Detail'), // name: t('Instance Detail'),
// key: 'recycle-bin-detail', // key: 'recycleBinDetail',
// level: 2, // level: 2,
// routePath: '/management/recycle-bin/detail/:id',
// }, // },
// ], // ],
// }, // },
@ -358,32 +377,34 @@ const renderMenu = (t) => {
{ {
path: '/heat', path: '/heat',
name: t('Orchestration'), name: t('Orchestration'),
key: '/heat', key: 'heat',
icon: <AppstoreOutlined />, icon: <AppstoreOutlined />,
children: [ children: [
{ {
path: '/heat/stack', path: '/heat/stack',
name: t('Stacks'), name: t('Stacks'),
key: '/heat/stack', key: 'stack',
level: 1, level: 1,
children: [ children: [
{ {
path: /^\/heat\/stack\/detail\/.[^/]+\/.[^/]+$/, path: /^\/heat\/stack\/detail\/.[^/]+\/.[^/]+$/,
name: t('Stack Detail'), name: t('Stack Detail'),
key: 'stack-detail', key: 'stackDetail',
level: 2, level: 2,
routePath: '/heat/stack/detail/:id/:name',
}, },
{ {
path: '/heat/stack/create', path: '/heat/stack/create',
name: t('Create Stack'), name: t('Create Stack'),
key: 'stack-create', key: 'stackCreate',
level: 2, level: 2,
}, },
{ {
path: /^\/heat\/stack\/edit\/.[^/]+\/.[^/]+$/, path: /^\/heat\/stack\/edit\/.[^/]+\/.[^/]+$/,
name: t('Update Template'), name: t('Update Template'),
key: 'stack-edit', key: 'stackEdit',
level: 2, level: 2,
routePath: '/heat/stack/edit/:id/:name',
}, },
], ],
}, },

View File

@ -34,7 +34,7 @@ export default class Detail extends Base {
} }
get listUrl() { get listUrl() {
return '/compute/baremetal-node-admin'; return this.getRoutePath('baremetalNode');
} }
get actionConfigs() { get actionConfigs() {

View File

@ -42,7 +42,7 @@ export default class Create extends StepAction {
} }
get listUrl() { get listUrl() {
return '/compute/baremetal-node-admin'; return this.getRoutePath('baremetalNode');
} }
get name() { get name() {

View File

@ -27,7 +27,7 @@ export default class Edit extends Create {
static path = (item) => `/compute/baremetal-node-admin/edit/${item.uuid}`; static path = (item) => `/compute/baremetal-node-admin/edit/${item.uuid}`;
get listUrl() { get listUrl() {
return '/compute/baremetal-node-admin'; return this.getRoutePath('baremetalNode');
} }
get name() { get name() {

View File

@ -54,8 +54,7 @@ export default class BareMetalNode extends Base {
{ {
title: t('Node ID/Name'), title: t('Node ID/Name'),
dataIndex: 'name', dataIndex: 'name',
idKey: 'uuid', routerName: 'baremetalNodeDetail',
linkPrefix: '/compute/baremetal-node-admin/detail',
}, },
{ {
title: t('Ironic Instance Name'), title: t('Ironic Instance Name'),

View File

@ -32,7 +32,7 @@ export class Detail extends Base {
} }
get listUrl() { get listUrl() {
return this.getUrl('/compute/flavor'); return this.getRoutePath('flavor');
} }
get actionConfigs() { get actionConfigs() {

View File

@ -50,10 +50,8 @@ class StepCreate extends StepAction {
get listUrl() { get listUrl() {
const { architecture } = this.values || {}; const { architecture } = this.values || {};
if (architecture) { const tab = architecture || this.tab;
return `/compute/flavor-admin?tab=${architecture}`; return this.getRoutePath('flavor', null, { tab });
}
return `/compute/flavor-admin?tab=${this.tab}`;
} }
get name() { get name() {
@ -126,7 +124,7 @@ class StepCreate extends StepAction {
ram: memoryGb * 1024, ram: memoryGb * 1024,
disk: 0, disk: 0,
}; };
const isPublic = accessType === 'public' const isPublic = accessType === 'public';
body['os-flavor-access:is_public'] = isPublic; body['os-flavor-access:is_public'] = isPublic;
if (categoryHasEphemeral) { if (categoryHasEphemeral) {
body['OS-FLV-EXT-DATA:ephemeral'] = ephemeral; body['OS-FLV-EXT-DATA:ephemeral'] = ephemeral;

View File

@ -29,7 +29,7 @@ export class HypervisorDetail extends Base {
} }
get listUrl() { get listUrl() {
return '/compute/hypervisors-admin'; return this.getRoutePath('hypervisor');
} }
get detailInfos() { get detailInfos() {

View File

@ -47,8 +47,8 @@ export class Hypervisors extends Base {
columns[0] = { columns[0] = {
title: t('ID/Name'), title: t('ID/Name'),
dataIndex: 'hypervisor_hostname', dataIndex: 'hypervisor_hostname',
linkPrefix: '/compute/hypervisors-admin/detail', routeName: 'hypervisorDetailAdmin',
isName: true, isLink: true,
}; };
return columns; return columns;
}; };

View File

@ -12,13 +12,11 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import React from 'react';
import { toJS } from 'mobx'; import { toJS } from 'mobx';
import { inject, observer } from 'mobx-react'; import { inject, observer } from 'mobx-react';
import { imageProperties, imageVisibility, imageOS } from 'resources/image'; import { imageProperties, imageVisibility, imageOS } from 'resources/image';
import Base from 'containers/BaseDetail'; import Base from 'containers/BaseDetail';
import { isObject, isArray } from 'lodash'; import { isObject, isArray } from 'lodash';
import { Link } from 'react-router-dom';
export class BaseDetail extends Base { export class BaseDetail extends Base {
get isImageDetail() { get isImageDetail() {
@ -122,15 +120,14 @@ export class BaseDetail extends Base {
return '-'; return '-';
} }
if (value.server_name) { if (value.server_name) {
return ( const { server_id, server_name } = value;
<Link const link = this.getLinkRender(
to={`${this.getUrl('/compute/instance')}/detail/${ 'instanceDetail',
value.server_id server_name,
}?tab=snapshots`} { id: server_id },
> { tab: 'snapshots' }
{value.server_name}
</Link>
); );
return link;
} }
return value.server_id; return value.server_id;
}, },

View File

@ -34,7 +34,7 @@ export class ImageDetail extends Base {
} }
get listUrl() { get listUrl() {
return this.getUrl('/compute/image'); return this.getRoutePath('image');
} }
get actionConfigs() { get actionConfigs() {

View File

@ -120,7 +120,7 @@ export class Image extends Base {
{ {
title: t('ID/Name'), title: t('ID/Name'),
dataIndex: 'name', dataIndex: 'name',
linkPrefix: `/compute/${this.getUrl('image')}/detail`, routeName: this.getRouteName('imageDetail'),
}, },
{ {
title: t('Project ID/Name'), title: t('Project ID/Name'),

View File

@ -46,7 +46,7 @@ export class CreateForm extends FormAction {
}; };
get listUrl() { get listUrl() {
return this.getUrl('/compute/image'); return this.getRoutePath('image');
} }
get name() { get name() {

View File

@ -146,7 +146,7 @@ export class BaseDetail extends Base {
get imageCard() { get imageCard() {
const item = this.detailData.itemInList || {}; const item = this.detailData.itemInList || {};
const { image, image_name } = item; const { image, image_name } = item;
const url = `${this.getUrl('/compute/image')}/detail/${image}`; const url = this.getRoutePath('imageDetail', { id: image });
const options = [ const options = [
{ {
label: t('Name'), label: t('Name'),

View File

@ -34,6 +34,7 @@ import { CaretRightOutlined } from '@ant-design/icons';
import ItemActionButtons from 'components/Tables/Base/ItemActionButtons'; import ItemActionButtons from 'components/Tables/Base/ItemActionButtons';
import { getSelfColumns } from 'resources/security-group-rule'; import { getSelfColumns } from 'resources/security-group-rule';
import { isAdminPage } from 'utils/index'; import { isAdminPage } from 'utils/index';
import { getPath } from 'utils/route-map';
import styles from './index.less'; import styles from './index.less';
import Detach from './action/Detach'; import Detach from './action/Detach';
import ManageSecurityGroup from './action/ManageSecurityGroup'; import ManageSecurityGroup from './action/ManageSecurityGroup';
@ -68,12 +69,11 @@ export class SecurityGroup extends React.Component {
return !this.isAdminPage; return !this.isAdminPage;
} }
getUrl(path, adminStr) {
return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path;
}
getDetailUrl(id) { getDetailUrl(id) {
return `${this.getUrl('/network/security-group')}/detail/${id}`; const key = this.isAdminPage
? 'securityGroupDetailAdmin'
: 'securityGroupDetail';
return getPath({ key, params: { id } });
} }
actionCallback = async (first) => { actionCallback = async (first) => {

View File

@ -46,9 +46,9 @@ export class InstanceDetail extends Base {
get listUrl() { get listUrl() {
if (this.isRecycleBinDetail) { if (this.isRecycleBinDetail) {
return this.getUrl('/management/recycle-bin'); return this.getRoutePath('recycleBin');
} }
return this.getUrl('/compute/instance'); return this.getRoutePath('instance');
} }
get actionConfigs() { get actionConfigs() {
@ -63,9 +63,8 @@ export class InstanceDetail extends Base {
get detailData() { get detailData() {
const { id, status } = this.store.detail; const { id, status } = this.store.detail;
if (id && status === 'soft_deleted' && !this.isRecycleBinDetail) { if (id && status === 'soft_deleted' && !this.isRecycleBinDetail) {
this.routing.push( const path = this.getRoutePath('recycleBinDetail', { id });
`${this.getUrl('/management/recycle-bin')}/detail/${id}` this.routing.push(path);
);
} }
return toJS(this.store.detail) || {}; return toJS(this.store.detail) || {};
} }

View File

@ -88,15 +88,15 @@ export class CreateIronic extends StepAction {
get listUrl() { get listUrl() {
const { image, volume, servergroup } = this.locationParams; const { image, volume, servergroup } = this.locationParams;
if (image) { if (image) {
return '/compute/image'; return this.getRoutePath('image');
} }
if (volume) { if (volume) {
return '/storage/volume'; return this.getRoutePath('volume');
} }
if (servergroup) { if (servergroup) {
return `/compute/server-group/detail/${servergroup}`; return this.getRoutePath('serverGroupDetail', { id: servergroup });
} }
return '/compute/instance'; return this.getRoutePath('instance');
} }
get checkEndpoint() { get checkEndpoint() {

View File

@ -83,15 +83,15 @@ export class StepCreate extends StepAction {
get listUrl() { get listUrl() {
const { image, volume, servergroup } = this.locationParams; const { image, volume, servergroup } = this.locationParams;
if (image) { if (image) {
return '/compute/image'; return this.getRoutePath('image');
} }
if (volume) { if (volume) {
return '/storage/volume'; return this.getRoutePath('volume');
} }
if (servergroup) { if (servergroup) {
return `/compute/server-group/detail/${servergroup}`; return this.getRoutePath('serverGroupDetail', { id: servergroup });
} }
return '/compute/instance'; return this.getRoutePath('instance');
} }
get hasConfirmStep() { get hasConfirmStep() {

View File

@ -131,7 +131,7 @@ export class Instance extends Base {
{ {
title: t('ID/Name'), title: t('ID/Name'),
dataIndex: 'name', dataIndex: 'name',
linkPrefix: `/compute/${this.getUrl('instance')}/detail`, routeName: this.getRouteName('instanceDetail'),
sortKey: 'display_name', sortKey: 'display_name',
}, },
{ {

View File

@ -30,7 +30,7 @@ export default class KeypairDetail extends Base {
} }
get listUrl() { get listUrl() {
return '/compute/keypair'; return this.getRoutePath('keypair');
} }
get actionConfigs() { get actionConfigs() {

View File

@ -12,11 +12,9 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import React from 'react';
import { observer, inject } from 'mobx-react'; import { observer, inject } from 'mobx-react';
import Base from 'containers/List'; import Base from 'containers/List';
import keypairStore from 'stores/nova/keypair'; import keypairStore from 'stores/nova/keypair';
import { Link } from 'react-router-dom';
import actionConfigs from './actions'; import actionConfigs from './actions';
@inject('rootStore') @inject('rootStore')
@ -50,14 +48,8 @@ export default class Keypair extends Base {
{ {
title: t('Name'), title: t('Name'),
dataIndex: 'name', dataIndex: 'name',
render: (name, record) => { idKey: 'name',
if (name) { routeName: this.getRouteName('keypairDetail'),
return (
<Link to={`/compute/keypair/detail/${record.name}`}>{name}</Link>
);
}
return '-';
},
}, },
{ {
title: t('Fingerprint'), title: t('Fingerprint'),

View File

@ -31,7 +31,7 @@ export default class ServerGroupDetail extends Base {
} }
get listUrl() { get listUrl() {
return this.getUrl('/compute/server-group'); return this.getRoutePath('serverGroup');
} }
get actionConfigs() { get actionConfigs() {

View File

@ -44,7 +44,7 @@ export default class ServerGroup extends Base {
{ {
title: t('ID/Name'), title: t('ID/Name'),
dataIndex: 'name', dataIndex: 'name',
linkPrefix: `/compute/${this.getUrl('server-group')}/detail`, routeName: this.getRouteName('serverGroupDetail'),
}, },
{ {
title: t('Project ID/Name'), title: t('Project ID/Name'),

View File

@ -30,7 +30,7 @@ export default class MetadataDetail extends Base {
} }
get listUrl() { get listUrl() {
return '/configuration-admin/metadata'; return this.getRoutePath('metadata');
} }
get actionConfigs() { get actionConfigs() {

View File

@ -36,7 +36,7 @@ export default class KeypairDetail extends Base {
} }
get listUrl() { get listUrl() {
return '/configuration-admin/info?tab=neutronAgent'; return this.getRoutePath('systemInfo', null, { tab: 'neutronAgent' });
} }
get actionConfigs() { get actionConfigs() {

View File

@ -48,8 +48,8 @@ export default class NeutronAgent extends Base {
{ {
title: t('ID/Name'), title: t('ID/Name'),
dataIndex: 'binary', dataIndex: 'binary',
isName: true, isLink: true,
linkPrefix: '/configuration-admin/neutron/detail', routeName: 'neutronAgentDetailAdmin',
}, },
{ {
title: t('Type'), title: t('Type'),

View File

@ -12,12 +12,10 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import React from 'react';
import { observer, inject } from 'mobx-react'; import { observer, inject } from 'mobx-react';
import Base from 'containers/List'; import Base from 'containers/List';
import { StackResourceStore } from 'stores/heat/resource'; import { StackResourceStore } from 'stores/heat/resource';
import { stackStatus } from 'resources/stack'; import { stackStatus } from 'resources/stack';
import { Link } from 'react-router-dom';
export class Resource extends Base { export class Resource extends Base {
init() { init() {
@ -41,138 +39,112 @@ export class Resource extends Base {
{ {
key: 'OS::Cinder::EncryptedVolumeType', key: 'OS::Cinder::EncryptedVolumeType',
isAdmin: true, isAdmin: true,
getUrl: (value) => routeName: 'volumeTypeDetail',
`${this.getUrl('/storage/volume-type')}/detail/${value}`,
}, },
{ {
key: 'OS::Cinder::QoSAssociation', key: 'OS::Cinder::QoSAssociation',
isAdmin: true, isAdmin: true,
getUrl: (value) => routeName: 'volumeTypeQosDetail',
`${this.getUrl('/storage/volume-type')}/qos/detail/${value}`,
}, },
{ {
key: 'OS::Cinder::QoSSpecs', key: 'OS::Cinder::QoSSpecs',
isAdmin: true, isAdmin: true,
getUrl: (value) => routeName: 'volumeTypeQosDetail',
`${this.getUrl('/storage/volume-type')}/qos/detail/${value}`,
}, },
{ {
key: 'OS::Cinder::Volume', key: 'OS::Cinder::Volume',
getUrl: (value) => `${this.getUrl('/storage/volume')}/detail/${value}`, routeName: 'volumeDetail',
}, },
{ {
key: 'OS::Cinder::VolumeType', key: 'OS::Cinder::VolumeType',
isAdmin: true, isAdmin: true,
getUrl: (value) => routeName: 'volumeTypeDetail',
`${this.getUrl('/storage/volume-type')}/detail/${value}`,
}, },
{ {
key: 'OS::Glance::WebImage', key: 'OS::Glance::WebImage',
getUrl: (value) => `${this.getUrl('/compute/image')}/detail/${value}`, routeName: 'imageDetail',
},
{
key: 'OS::Glance::WebImage',
getUrl: (value) => `${this.getUrl('/compute/image')}/detail/${value}`,
}, },
{ {
key: 'OS::Heat::Stack', key: 'OS::Heat::Stack',
getUrl: (value) => `${this.getUrl('/heat/stack')}/detail/${value}`, routeName: 'stackDetail',
}, },
{ {
key: 'OS::Ironic::Port', key: 'OS::Ironic::Port',
getUrl: (value) => routeName: 'virtualAdapterDetail',
`${this.getUrl(
'/network/virtual_adapter',
'_admin'
)}/detail/${value}`,
}, },
{ {
key: 'OS::Keystone::Domain', key: 'OS::Keystone::Domain',
routeName: 'domainDetail',
isAdmin: true, isAdmin: true,
getUrl: (value) => `${this.getUrl('/identity/domain')}/detail/${value}`,
}, },
{ {
key: 'OS::Keystone::Group', key: 'OS::Keystone::Group',
routeName: 'userGroupDetail',
isAdmin: true, isAdmin: true,
getUrl: (value) =>
`${this.getUrl('/identity/user-group')}/detail/${value}`,
}, },
{ {
key: 'OS::Keystone::Project', key: 'OS::Keystone::Project',
routeName: 'projectDetail',
isAdmin: true, isAdmin: true,
getUrl: (value) =>
`${this.getUrl('/identity/project')}/detail/${value}`,
}, },
{ {
key: 'OS::Keystone::Role', key: 'OS::Keystone::Role',
routeName: 'roleDetail',
isAdmin: true, isAdmin: true,
getUrl: (value) => `${this.getUrl('/identity/role')}/detail/${value}`,
}, },
{ {
key: 'OS::Keystone::User', key: 'OS::Keystone::User',
routeName: 'userDetail',
isAdmin: true, isAdmin: true,
getUrl: (value) => `${this.getUrl('/identity/user')}/detail/${value}`,
}, },
{ {
key: 'OS::Neutron::FloatingIP', key: 'OS::Neutron::FloatingIP',
getUrl: (value) => routeName: 'fipDetail',
`${this.getUrl('/network/floatingip')}/detail/${value}`,
}, },
{ {
key: 'OS::Neutron::LBaaS::LoadBalancer', key: 'OS::Neutron::LBaaS::LoadBalancer',
getUrl: (value) => routeName: 'lbDetail',
`${this.getUrl('/network/load-balancers')}/detail/${value}`,
}, },
{ {
key: 'OS::Neutron::Net', key: 'OS::Neutron::Net',
getUrl: (value) => routeName: 'networkDetail',
`${this.getUrl('/network/networks')}/detail/${value}`,
}, },
{ {
key: 'OS::Neutron::Port', key: 'OS::Neutron::Port',
getUrl: (value) => routeName: 'virtualAdapterDetail',
`${this.getUrl(
'/network/virtual_adapter',
'_admin'
)}/detail/${value}`,
}, },
{ {
key: 'OS::Neutron::QoSPolicy', key: 'OS::Neutron::QoSPolicy',
getUrl: (value) => routeName: 'networkQosDetail',
`${this.getUrl('/network/qos-policy')}/detail/${value}`,
}, },
{ {
key: 'OS::Neutron::Router', key: 'OS::Neutron::Router',
getUrl: (value) => `${this.getUrl('/network/router')}/detail/${value}`, routeName: 'routerDetail',
}, },
{ {
key: 'OS::Neutron::SecurityGroup', key: 'OS::Neutron::SecurityGroup',
getUrl: (value) => routeName: 'securityGroupDetail',
`${this.getUrl('/network/security-group')}/detail/${value}`,
}, },
{ {
key: 'OS::Nova::Flavor', key: 'OS::Nova::Flavor',
isAdmin: true, isAdmin: true,
getUrl: (value) => `${this.getUrl('/compute/flavor')}/detail/${value}`, routeName: 'flavorDetail',
}, },
{ {
key: 'OS::Nova::KeyPair', key: 'OS::Nova::KeyPair',
getUrl: (value) => `/compute/keypair/detail/${value}`, routeName: 'keypairDetail',
}, },
{ {
key: 'OS::Nova::Server', key: 'OS::Nova::Server',
getUrl: (value) => routeName: 'instanceDetail',
`${this.getUrl('/compute/instance')}/detail/${value}`,
}, },
{ {
key: 'OS::Nova::ServerGroup', key: 'OS::Nova::ServerGroup',
getUrl: (value) => routeName: 'serverGroupDetail',
`${this.getUrl('/compute/server-group')}/detail/${value}`,
}, },
{ {
key: 'OS::Octavia::LoadBalancer', key: 'OS::Octavia::LoadBalancer',
getUrl: (value) => routeName: 'lbDetail',
`${this.getUrl('/network/load-balancers')}/detail/${value}`,
}, },
]; ];
} }
@ -186,16 +158,13 @@ export class Resource extends Base {
if (!item) { if (!item) {
return value; return value;
} }
const { isAdmin, getUrl } = item; const { isAdmin, routeName } = item;
const link = this.getLinkRender(routeName, value, { id: value });
if (isAdmin) { if (isAdmin) {
return this.isAdminPage ? ( return this.isAdminPage ? link : value;
<Link to={getUrl(value, record)}>{value}</Link>
) : (
value
);
} }
if (getUrl) { if (routeName) {
return <Link to={getUrl(value, record)}>{value}</Link>; return link;
} }
return value; return value;
}; };

View File

@ -32,7 +32,7 @@ export class StackDetail extends Base {
} }
get listUrl() { get listUrl() {
return this.getUrl('/heat/stack'); return this.getRoutePath('stack');
} }
init() { init() {

View File

@ -37,7 +37,7 @@ export class StepCreate extends StepAction {
} }
get listUrl() { get listUrl() {
return this.getUrl('/heat/stack'); return this.getRoutePath('stack');
} }
get name() { get name() {

View File

@ -13,6 +13,7 @@
// limitations under the License. // limitations under the License.
import { inject, observer } from 'mobx-react'; import { inject, observer } from 'mobx-react';
import { getPath } from 'utils/route-map';
import Create from './Create'; import Create from './Create';
@inject('rootStore') @inject('rootStore')
@ -24,14 +25,13 @@ export default class Edit extends Create {
static path = (item, containerProp) => { static path = (item, containerProp) => {
const { isAdminPage } = containerProp; const { isAdminPage } = containerProp;
const prefix = isAdminPage const key = isAdminPage ? 'stackEditAdmin' : 'stackEdit';
? '/heat/stack-admin/edit/' const { id, stack_name: name } = item;
: '/heat/stack/edit/'; return getPath({ key, params: { id, name } });
return `${prefix}${item.id}/${item.stack_name}`;
}; };
get listUrl() { get listUrl() {
return this.getUrl('/heat/stack'); return this.getRoutePath('stack');
} }
get name() { get name() {

View File

@ -59,9 +59,14 @@ export class Stack extends Base {
{ {
title: t('ID/Name'), title: t('ID/Name'),
dataIndex: 'stack_name', dataIndex: 'stack_name',
linkFunc: (value, record) => routeName: this.getRouteName('stackDetail'),
`/heat/${this.getUrl('stack')}/detail/${record.id}/${value}`, routeParamsFunc: (data) => {
isName: true, return {
id: data.id,
name: data.stack_name,
};
},
isLink: true,
}, },
{ {
title: t('Project ID/Name'), title: t('Project ID/Name'),

View File

@ -31,7 +31,7 @@ export default class DomainDetail extends Base {
} }
get listUrl() { get listUrl() {
return '/identity/domain-admin'; return this.getRoutePath('domain');
} }
get detailInfos() { get detailInfos() {

View File

@ -37,7 +37,7 @@ class CreateForm extends FormAction {
} }
get listUrl() { get listUrl() {
return '/identity/domain-admin'; return this.getRoutePath('domain');
} }
get name() { get name() {

View File

@ -46,7 +46,7 @@ class EditForm extends FormAction {
} }
get listUrl() { get listUrl() {
return '/identity/domain-admin'; return this.getRoutePath('domain');
} }
get data() { get data() {

View File

@ -43,8 +43,7 @@ export default class Domains extends Base {
{ {
title: t('Domain ID/Name'), title: t('Domain ID/Name'),
dataIndex: 'name', dataIndex: 'name',
// isHideable: true, routeName: 'domainDetailAdmin',
linkPrefix: '/identity/domain-admin/detail',
}, },
{ {
title: t('Member Num'), title: t('Member Num'),

View File

@ -32,7 +32,7 @@ export class Detail extends Base {
} }
get listUrl() { get listUrl() {
return this.getUrl('/identity/project'); return this.getRoutePath('project');
} }
get actionConfigs() { get actionConfigs() {

View File

@ -66,7 +66,7 @@ export class Projects extends Base {
{ {
title: t('Project ID/Name'), title: t('Project ID/Name'),
dataIndex: 'name', dataIndex: 'name',
linkPrefix: `/identity/${this.getUrl('project')}/detail`, routeName: 'projectDetailAdmin',
}, },
{ {
title: t('Role'), title: t('Role'),

View File

@ -29,7 +29,7 @@ export class RoleDetail extends Base {
} }
get listUrl() { get listUrl() {
return '/identity/role-admin'; return this.getRoutePath('role');
} }
init() { init() {

View File

@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import React from 'react';
import { Link } from 'react-router-dom';
import { observer, inject } from 'mobx-react'; import { observer, inject } from 'mobx-react';
import Base from 'containers/List'; import Base from 'containers/List';
import globalRoleStore from 'stores/keystone/role'; import globalRoleStore from 'stores/keystone/role';
@ -45,15 +43,7 @@ export default class Role extends Base {
{ {
title: t('Role Name'), title: t('Role Name'),
dataIndex: 'name', dataIndex: 'name',
linkPrefix: '/identity/role-admin/detail', routeName: 'roleDetailAdmin',
render: (name, record) => {
if (name) {
return (
<Link to={`/identity/role-admin/detail/${record.id}`}>{name}</Link>
);
}
return '-';
},
}, },
{ {
title: t('ID'), title: t('ID'),

View File

@ -33,7 +33,7 @@ export class UserDetail extends Base {
} }
get listUrl() { get listUrl() {
return '/identity/user-admin'; return this.getRoutePath('user');
} }
get actionConfigs() { get actionConfigs() {

View File

@ -93,7 +93,7 @@ export class CreateForm extends FormAction {
} }
get listUrl() { get listUrl() {
return '/identity/user-admin'; return this.getRoutePath('user');
} }
get defaultValue() { get defaultValue() {

View File

@ -81,7 +81,7 @@ export class User extends Base {
{ {
title: t('User ID/Name'), title: t('User ID/Name'),
dataIndex: 'name', dataIndex: 'name',
linkPrefix: `/identity/${this.getUrl('user')}/detail`, routeName: 'userDetailAdmin',
}, },
{ {
title: t('Project Scope'), title: t('Project Scope'),

View File

@ -36,7 +36,7 @@ export default class Detail extends Base {
} }
get listUrl() { get listUrl() {
return '/identity/user-group-admin'; return this.getRoutePath('userGroup');
} }
get actionConfigs() { get actionConfigs() {

View File

@ -51,7 +51,7 @@ export default class UserGroups extends Base {
{ {
title: t('User Group ID/Name'), title: t('User Group ID/Name'),
dataIndex: 'name', dataIndex: 'name',
linkPrefix: '/identity/user-group-admin/detail', routeName: 'userGroupDetailAdmin',
}, },
{ {
title: t('Project Scope'), title: t('Project Scope'),

View File

@ -60,7 +60,7 @@ export default class RecycleBin extends Base {
{ {
title: t('ID/Name'), title: t('ID/Name'),
dataIndex: 'name', dataIndex: 'name',
linkPrefix: `/management/${this.getUrl('recycle-bin')}/detail`, routeName: this.getRouteName('recycleBinDetail'),
sortKey: 'display_name', sortKey: 'display_name',
}, },
{ {

View File

@ -12,10 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import React from 'react';
import { inject, observer } from 'mobx-react'; import { inject, observer } from 'mobx-react';
import { FloatingIpStore } from 'stores/neutron/floatingIp'; import { FloatingIpStore } from 'stores/neutron/floatingIp';
import { Link } from 'react-router-dom';
import Base from 'containers/BaseDetail'; import Base from 'containers/BaseDetail';
export class BaseDetail extends Base { export class BaseDetail extends Base {
@ -70,12 +68,11 @@ export class BaseDetail extends Base {
if (router_name === '-' && network_name === '-') { if (router_name === '-' && network_name === '-') {
return data; return data;
} }
return ( const value = router_name ? `${data} (${router_name})` : data;
<Link to={`${this.getUrl('/network/router')}/detail/${data}`}> const link = this.getLinkRender('routerDetail', value, {
{`${data}`} id: data,
{router_name && `(${router_name})`} });
</Link> return link;
);
} }
return '-'; return '-';
}, },

View File

@ -31,7 +31,7 @@ export class FloatingIpDetail extends Base {
} }
get listUrl() { get listUrl() {
return this.getUrl('/network/floatingip'); return this.getRoutePath('floatingip');
} }
get actionConfigs() { get actionConfigs() {

View File

@ -17,7 +17,6 @@ import { observer, inject } from 'mobx-react';
import Base from 'containers/List'; import Base from 'containers/List';
import { floatingIpStatus, transitionStatuses } from 'resources/floatingip'; import { floatingIpStatus, transitionStatuses } from 'resources/floatingip';
import { FloatingIpStore } from 'stores/neutron/floatingIp'; import { FloatingIpStore } from 'stores/neutron/floatingIp';
import { Link } from 'react-router-dom';
import { emptyActionConfig } from 'utils/constants'; import { emptyActionConfig } from 'utils/constants';
import { Col, Popover, Row } from 'antd'; import { Col, Popover, Row } from 'antd';
import { FileTextOutlined } from '@ant-design/icons'; import { FileTextOutlined } from '@ant-design/icons';
@ -122,17 +121,15 @@ export class FloatingIps extends Base {
{ {
title: t('ID/Floating IP'), title: t('ID/Floating IP'),
dataIndex: 'floating_ip_address', dataIndex: 'floating_ip_address',
isName: true, isLink: true,
linkPrefix: `/network/${this.getUrl('floatingip')}/detail`, routeName: this.getRouteName('fipDetail'),
}, },
{ {
title: t('QoS Policy'), title: t('QoS Policy'),
dataIndex: 'qos_policy_id', dataIndex: 'qos_policy_id',
render: (value) => ( isLink: true,
<Link to={`/network/${this.getUrl('qos-policy')}/detail/${value}`}> routeName: 'qosPolicyDetail',
{value} idKey: 'qos_policy_id',
</Link>
),
hidden: !this.qosEndpoint, hidden: !this.qosEndpoint,
}, },
{ {

View File

@ -32,8 +32,8 @@ export default class ListenerDetail extends Base {
} }
get listUrl() { get listUrl() {
const { loadBalancerId } = this.params; const { loadBalancerId: id } = this.params;
return `/network/${this.getUrl('load-balancers')}/detail/${loadBalancerId}`; return this.getRoutePath('lbDetail', { id });
} }
get actionConfigs() { get actionConfigs() {

View File

@ -61,11 +61,13 @@ export default class Listeners extends Base {
{ {
title: t('ID/Name'), title: t('ID/Name'),
dataIndex: 'name', dataIndex: 'name',
isName: true, routeName: this.getRouteName('lbDetail'),
linkPrefix: `/network/${this.getUrl('load-balancers')}/${ routeParamsFunc: (data) => {
this.id return {
}/listener/`, loadBalancerId: this.id,
idKey: 'id', id: data.id,
};
},
}, },
{ {
title: t('Status'), title: t('Status'),

View File

@ -42,7 +42,7 @@ export default class LoadBalancerDetail extends Base {
}; };
get listUrl() { get listUrl() {
return this.getUrl('/network/load-balancers'); return this.getRoutePath('lb');
} }
get actionConfigs() { get actionConfigs() {

View File

@ -46,7 +46,7 @@ class StepCreate extends StepAction {
} }
get listUrl() { get listUrl() {
return '/network/load-balancers'; return this.getRoutePath('lb');
} }
get hasConfirmStep() { get hasConfirmStep() {

View File

@ -89,9 +89,7 @@ export default class LoadBalancerInstance extends Base {
{ {
title: t('ID/Name'), title: t('ID/Name'),
dataIndex: 'name', dataIndex: 'name',
isName: true, routeName: this.getRouteName('lbDetail'),
linkPrefix: `/network/${this.getUrl('load-balancers')}/detail/`,
idKey: 'id',
}, },
{ {
title: t('Project ID/Name'), title: t('Project ID/Name'),

View File

@ -32,7 +32,7 @@ export class NetworkDetail extends Base {
} }
get listUrl() { get listUrl() {
return this.getUrl('/network/networks'); return this.getRoutePath('network');
} }
get actionConfigs() { get actionConfigs() {

View File

@ -30,7 +30,7 @@ export default class QoSPolicyDetail extends Base {
} }
get listUrl() { get listUrl() {
return this.getUrl('/network/qos-policy'); return this.getRoutePath('qosPolicy');
} }
get actionConfigs() { get actionConfigs() {

View File

@ -33,7 +33,7 @@ export class RouterDetail extends Base {
} }
get listUrl() { get listUrl() {
return this.getUrl('/network/router'); return this.getRoutePath('router');
} }
get actionConfigs() { get actionConfigs() {

View File

@ -29,9 +29,11 @@ export class PortDetail extends Base {
get listUrl() { get listUrl() {
const { routerId } = this.params; const { routerId } = this.params;
return `/network/${this.getUrl( return this.getRoutePath(
'router' 'routerDetail',
)}/detail/${routerId}?tab=interfaces`; { id: routerId },
{ tab: 'interfaces' }
);
} }
get detailInfos() { get detailInfos() {

View File

@ -51,8 +51,12 @@ export default class Ports extends Base {
{ {
title: t('ID/Name'), title: t('ID/Name'),
dataIndex: 'name', dataIndex: 'name',
linkPrefix: `/network/${this.getUrl('router')}/${this.id}/port`,
stringify: (name, record) => name || record.id, stringify: (name, record) => name || record.id,
routeName: this.getRouteName('routerPortDetail'),
routeParamsFunc: (data) => ({
routeId: this.id,
id: data.id,
}),
}, },
{ {
title: t('IP Address'), title: t('IP Address'),

View File

@ -16,6 +16,7 @@ import { observer, inject } from 'mobx-react';
import Base from 'containers/List'; import Base from 'containers/List';
import globalSecurityGroupRuleStore from 'stores/neutron/security-rule'; import globalSecurityGroupRuleStore from 'stores/neutron/security-rule';
import { filterParams, getSelfColumns } from 'resources/security-group-rule'; import { filterParams, getSelfColumns } from 'resources/security-group-rule';
import { getPath } from 'utils/route-map';
import actionConfigs from './actions'; import actionConfigs from './actions';
export class Rule extends Base { export class Rule extends Base {
@ -32,7 +33,10 @@ export class Rule extends Base {
} }
getDetailUrl(id) { getDetailUrl(id) {
return `${this.getUrl('/network/security-group')}/detail/${id}`; const key = this.isAdminPage
? 'securityGroupDetailAdmin'
: 'securityGroupDetail';
return getPath({ key, params: { id } });
} }
getColumns = () => getSelfColumns(this); getColumns = () => getSelfColumns(this);

View File

@ -29,7 +29,7 @@ export class SecurityGroupDetail extends Base {
} }
get listUrl() { get listUrl() {
return this.getUrl('/network/security-group'); return this.getRoutePath('securityGroup');
} }
get actionConfigs() { get actionConfigs() {

View File

@ -60,15 +60,11 @@ export class SecurityGroups extends Base {
return true; return true;
} }
get detailLink() {
return `/network/${this.getUrl('security-group')}/detail`;
}
getColumns = () => [ getColumns = () => [
{ {
title: t('ID/Name'), title: t('ID/Name'),
dataIndex: 'name', dataIndex: 'name',
linkPrefix: this.detailLink, routeName: this.getRouteName('securityGroupDetail'),
}, },
{ {
title: t('Project ID/Name'), title: t('Project ID/Name'),

View File

@ -165,7 +165,8 @@ export default class Create extends ModalAction {
{ {
title: t('Name'), title: t('Name'),
dataIndex: 'name', dataIndex: 'name',
isName: true, // todo: what?
isLink: true,
}, },
{ {
title: t('CIDR'), title: t('CIDR'),

View File

@ -34,7 +34,7 @@ export default class IPsecSiteConnection extends Base {
} }
get listUrl() { get listUrl() {
return `${this.getUrl('/network/vpn')}?tab=ipsec_site_connections`; return this.getRoutePath('vpn', null, { tab: 'ipsec_site_connections' });
} }
get actionConfigs() { get actionConfigs() {

View File

@ -58,8 +58,7 @@ export default class Index extends Base {
{ {
title: t('ID/Name'), title: t('ID/Name'),
dataIndex: 'name', dataIndex: 'name',
isName: true, routeName: this.getRouteName('ipsecDetail'),
linkPrefix: `/network/${this.getUrl('ipsec-site-connection')}/detail`,
}, },
{ {
title: t('Project ID/Name'), title: t('Project ID/Name'),

View File

@ -43,15 +43,14 @@ export default class BaseDetail extends Base {
const { itemInList: { device_id, device_owner, server_name } = {} } = const { itemInList: { device_id, device_owner, server_name } = {} } =
record; record;
if (device_id && device_owner === 'compute:nova') { if (device_id && device_owner === 'compute:nova') {
return ( const value = server_name
<Link ? `${device_id} (${server_name})`
to={`${this.getUrl( : device_id;
'/compute/instance' return this.getLinkRender(
)}/detail/${device_id}?tab=interface`} 'instanceDetail',
> value,
{`${device_id}`} { id: device_id },
{server_name && `(${server_name})`} { tab: 'interface' }
</Link>
); );
} }
return data || '-'; return data || '-';

View File

@ -25,6 +25,7 @@ import PrimaryActionButtons from 'components/Tables/Base/PrimaryActionButtons';
import ItemActionButtons from 'components/Tables/Base/ItemActionButtons'; import ItemActionButtons from 'components/Tables/Base/ItemActionButtons';
import { getSelfColumns } from 'resources/security-group-rule'; import { getSelfColumns } from 'resources/security-group-rule';
import { isAdminPage } from 'utils/index'; import { isAdminPage } from 'utils/index';
import { getPath } from 'utils/route-map';
import Detach from './actions/Detach'; import Detach from './actions/Detach';
import styles from './index.less'; import styles from './index.less';
@ -40,12 +41,11 @@ export class SecurityGroup extends React.Component {
this.refreshSecurityGroup(); this.refreshSecurityGroup();
} }
getUrl(path, adminStr) {
return this.isAdminPage ? `${path}${adminStr || '-admin'}` : path;
}
getDetailUrl(id) { getDetailUrl(id) {
return `${this.getUrl('/network/security-group')}/detail/${id}`; const key = this.isAdminPage
? 'securityGroupDetailAdmin'
: 'securityGroupDetail';
return getPath({ key, params: { id } });
} }
get portId() { get portId() {

View File

@ -32,7 +32,7 @@ export class VirtualAdapterDetail extends Base {
} }
get listUrl() { get listUrl() {
return this.getUrl('/network/virtual_adapter', '_admin'); return this.getRoutePath('virtualAdapter');
} }
get actionConfigs() { get actionConfigs() {

View File

@ -13,7 +13,6 @@
// limitations under the License. // limitations under the License.
import React from 'react'; import React from 'react';
import { Link } from 'react-router-dom';
import { observer, inject } from 'mobx-react'; import { observer, inject } from 'mobx-react';
import Base from 'containers/List'; import Base from 'containers/List';
import { VirtualAdapterStore } from 'stores/neutron/virtual-adapter'; import { VirtualAdapterStore } from 'stores/neutron/virtual-adapter';
@ -120,10 +119,7 @@ export class VirtualAdapter extends Base {
{ {
title: t('ID/Name'), title: t('ID/Name'),
dataIndex: 'name', dataIndex: 'name',
linkPrefix: `/network/${this.getUrl( routeName: this.getRouteName('virtualAdapterDetail'),
'virtual_adapter',
'_admin'
)}/detail`,
}, },
{ {
title: t('Project ID/Name'), title: t('Project ID/Name'),
@ -145,18 +141,22 @@ export class VirtualAdapter extends Base {
`; `;
}, },
render: (server_name, item) => { render: (server_name, item) => {
if (item.device_id && item.device_owner === 'compute:nova') { const { device_id, device_owner } = item;
if (device_id && device_owner === 'compute:nova') {
const value = server_name
? `${device_id} (${server_name})`
: device_id;
const link = this.getLinkRender(
'instanceDetail',
value,
{ id: item.device_id },
{ tab: 'interface' }
);
return ( return (
<> <>
{item.device_owner} {item.device_owner}
<br /> <br />
<Link {link}
to={`${this.getUrl('/compute/instance')}/detail/${item.device_id
}?tab=interface`}
>
{`${item.device_id}`}
{server_name && `(${server_name})`}
</Link>
</> </>
); );
} }
@ -174,8 +174,8 @@ export class VirtualAdapter extends Base {
{ {
title: t('Owned Network'), title: t('Owned Network'),
dataIndex: 'network_name', dataIndex: 'network_name',
isName: true, isLink: true,
linkPrefix: `/network/${this.getUrl('networks')}/detail`, routeName: this.getRouteName('networkDetail'),
idKey: 'network_id', idKey: 'network_id',
sorter: false, sorter: false,
}, },

View File

@ -12,10 +12,8 @@
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
import React from 'react';
import { inject, observer } from 'mobx-react'; import { inject, observer } from 'mobx-react';
import Base from 'containers/BaseDetail'; import Base from 'containers/BaseDetail';
import { Link } from 'react-router-dom';
@inject('rootStore') @inject('rootStore')
@observer @observer
@ -33,11 +31,8 @@ export default class BaseDetail extends Base {
copyable: { copyable: {
text: this.detailData.volume_id, text: this.detailData.volume_id,
}, },
render: (value) => ( render: (value) =>
<Link to={`${this.getUrl('/storage/volume')}/detail/${value}`}> this.getLinkRender('volumeDetail', value, { id: value }),
{value}
</Link>
),
}, },
{ {
label: t('Volume'), label: t('Volume'),

View File

@ -31,7 +31,7 @@ export default class Detail extends Base {
} }
get listUrl() { get listUrl() {
return this.getUrl('/storage/backup'); return this.getRoutePath('backup');
} }
get actionConfigs() { get actionConfigs() {

View File

@ -71,7 +71,7 @@ export default class Backup extends Base {
{ {
title: t('ID/Name'), title: t('ID/Name'),
dataIndex: 'name', dataIndex: 'name',
linkPrefix: `/storage/${this.getUrl('backup')}/detail`, routeName: this.getRouteName('backupDetail'),
sortKey: 'id', sortKey: 'id',
}, },
{ {
@ -83,11 +83,9 @@ export default class Backup extends Base {
{ {
title: t('Volume ID/Name'), title: t('Volume ID/Name'),
dataIndex: 'volume_name', dataIndex: 'volume_name',
isName: true, isLink: true,
linkFunc: (value, record) => routeQuery: { tab: 'backup' },
`/storage/${this.getUrl('volume')}/detail/${ routeName: this.getRouteName('volumeDetail'),
record.volume_id
}?tab=backup`,
idKey: 'volume_id', idKey: 'volume_id',
sortKey: 'volume_id', sortKey: 'volume_id',
}, },

Some files were not shown because too many files have changed in this diff Show More