Merge "fix: Fix the permission of QosPolicy"

This commit is contained in:
Zuul 2021-10-11 02:13:51 +00:00 committed by Gerrit Code Review
commit 6b1f119db7
10 changed files with 87 additions and 24 deletions

View File

@ -67,6 +67,7 @@ export const octaviaBase = () => getOpenstackEndpoint('octavia');
export const ironicOriginEndpoint = () => getOriginEndpoint('ironic'); export const ironicOriginEndpoint = () => getOriginEndpoint('ironic');
export const vpnEndpoint = () => getOriginEndpoint('neutron_vpn'); export const vpnEndpoint = () => getOriginEndpoint('neutron_vpn');
export const lbEndpoint = () => getOriginEndpoint('octavia'); export const lbEndpoint = () => getOriginEndpoint('octavia');
export const qosEndpoint = () => getOriginEndpoint('neutron_qos');
export const apiVersionMaps = { export const apiVersionMaps = {
nova: { nova: {

View File

@ -21,6 +21,7 @@ import globalProjectStore from 'stores/keystone/project';
import globalSubnetStore from 'stores/neutron/subnet'; import globalSubnetStore from 'stores/neutron/subnet';
import { QoSPolicyStore } from 'stores/neutron/qos-policy'; import { QoSPolicyStore } from 'stores/neutron/qos-policy';
import { getQoSPolicyTabs } from 'resources/qos-policy'; import { getQoSPolicyTabs } from 'resources/qos-policy';
import { qosEndpoint } from 'client/client/constants';
export class Allocate extends ModalAction { export class Allocate extends ModalAction {
static id = 'allocate'; static id = 'allocate';
@ -32,11 +33,15 @@ export class Allocate extends ModalAction {
} }
static get modalSize() { static get modalSize() {
return 'large'; return qosEndpoint() ? 'large' : 'small';
} }
getModalSize() { getModalSize() {
return 'large'; return qosEndpoint() ? 'large' : 'small';
}
get qosEndpoint() {
return qosEndpoint();
} }
init() { init() {
@ -221,6 +226,7 @@ export class Allocate extends ModalAction {
isMulti: false, isMulti: false,
tip: t('Choosing a QoS policy can limit bandwidth and DSCP'), tip: t('Choosing a QoS policy can limit bandwidth and DSCP'),
onChange: this.onQosChange, onChange: this.onQosChange,
display: !!this.qosEndpoint,
}, },
]; ];
} }

View File

@ -17,6 +17,7 @@ import { ModalAction } from 'containers/Action';
import globalFloatingIpsStore from 'stores/neutron/floatingIp'; import globalFloatingIpsStore from 'stores/neutron/floatingIp';
import { getQoSPolicyTabs } from 'resources/qos-policy'; import { getQoSPolicyTabs } from 'resources/qos-policy';
import { QoSPolicyStore } from 'stores/neutron/qos-policy'; import { QoSPolicyStore } from 'stores/neutron/qos-policy';
import { qosEndpoint } from 'client/client/constants';
export class Edit extends ModalAction { export class Edit extends ModalAction {
static id = 'edit-floating-ip'; static id = 'edit-floating-ip';
@ -24,11 +25,15 @@ export class Edit extends ModalAction {
static policy = 'update_floatingip'; static policy = 'update_floatingip';
static get modalSize() { static get modalSize() {
return 'large'; return qosEndpoint() ? 'large' : 'small';
} }
getModalSize() { getModalSize() {
return 'large'; return qosEndpoint() ? 'large' : 'small';
}
get qosEndpoint() {
return qosEndpoint();
} }
init() { init() {
@ -39,17 +44,21 @@ export class Edit extends ModalAction {
const { item } = this.props; const { item } = this.props;
return { return {
description: this.item.description, description: this.item.description,
qos_policy_id: { ...(this.qosEndpoint
selectedRowKeys: item.qos_policy_id ? [item.qos_policy_id] : [], ? {
selectedRows: item.qos_policy_id qos_policy_id: {
? [ selectedRowKeys: item.qos_policy_id ? [item.qos_policy_id] : [],
{ selectedRows: item.qos_policy_id
id: item.qos_policy_id, ? [
name: item.qos_policy_id, {
}, id: item.qos_policy_id,
] name: item.qos_policy_id,
: [], },
}, ]
: [],
},
}
: {}),
}; };
} }
@ -86,6 +95,7 @@ export class Edit extends ModalAction {
tabs: getQoSPolicyTabs.call(this), tabs: getQoSPolicyTabs.call(this),
isMulti: false, isMulti: false,
tip: t('Choosing a QoS policy can limit bandwidth and DSCP'), tip: t('Choosing a QoS policy can limit bandwidth and DSCP'),
display: !!this.qosEndpoint,
}, },
]; ];
} }

View File

@ -21,6 +21,7 @@ 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';
import { qosEndpoint } from 'client/client/constants';
import styles from './styles.less'; import styles from './styles.less';
import actionConfigs from './actions'; import actionConfigs from './actions';
@ -30,6 +31,10 @@ export class FloatingIps extends Base {
this.downloadStore = new FloatingIpStore(); this.downloadStore = new FloatingIpStore();
} }
get qosEndpoint() {
return qosEndpoint();
}
get isFilterByBackend() { get isFilterByBackend() {
return true; return true;
} }
@ -128,6 +133,7 @@ export class FloatingIps extends Base {
{value} {value}
</Link> </Link>
), ),
hidden: !this.qosEndpoint,
}, },
{ {
title: t('Project ID/Name'), title: t('Project ID/Name'),

View File

@ -14,6 +14,7 @@
import { inject, observer } from 'mobx-react'; import { inject, observer } from 'mobx-react';
import Base from 'containers/BaseDetail'; import Base from 'containers/BaseDetail';
import { qosEndpoint } from 'client/client/constants';
@inject('rootStore') @inject('rootStore')
@observer @observer
@ -23,6 +24,10 @@ export default class BaseDetail extends Base {
return cards; return cards;
} }
get qosEndpoint() {
return qosEndpoint();
}
get baseInfoCard() { get baseInfoCard() {
const options = [ const options = [
{ {
@ -55,17 +60,19 @@ export default class BaseDetail extends Base {
label: t('Segmentation ID'), label: t('Segmentation ID'),
dataIndex: 'provider:segmentation_id', dataIndex: 'provider:segmentation_id',
}, },
{
label: t('QoS Policy'),
dataIndex: 'qos_policy_id',
render: (data) => data || '-',
},
{ {
label: t('Port Security Enabled'), label: t('Port Security Enabled'),
dataIndex: 'port_security_enabled', dataIndex: 'port_security_enabled',
valueRender: 'yesNo', valueRender: 'yesNo',
}, },
]; ];
if (this.qosEndpoint) {
options.push({
label: t('QoS Policy'),
dataIndex: 'qos_policy_id',
render: (data) => data || '-',
});
}
return { return {
title: t('Base Info'), title: t('Base Info'),
options, options,

View File

@ -16,6 +16,7 @@ import { observer, inject } from 'mobx-react';
import Base from 'containers/List'; import Base from 'containers/List';
import { QoSPolicyStore } from 'stores/neutron/qos-policy'; import { QoSPolicyStore } from 'stores/neutron/qos-policy';
import { getQosPolicyColumns, getQosPolicyFilters } from 'resources/qos-policy'; import { getQosPolicyColumns, getQosPolicyFilters } from 'resources/qos-policy';
import { qosEndpoint } from 'client/client/constants';
import actionConfigs from './actions'; import actionConfigs from './actions';
export class QoSPolicy extends Base { export class QoSPolicy extends Base {
@ -29,6 +30,14 @@ export class QoSPolicy extends Base {
all_projects: this.tabKey === 'allQoSPolicy' || this.isAdminPage, all_projects: this.tabKey === 'allQoSPolicy' || this.isAdminPage,
}); });
get checkEndpoint() {
return true;
}
get endpoint() {
return qosEndpoint();
}
get policy() { get policy() {
return 'get_policy'; return 'get_policy';
} }

View File

@ -14,11 +14,20 @@
import { observer, inject } from 'mobx-react'; import { observer, inject } from 'mobx-react';
import Base from 'containers/TabList'; import Base from 'containers/TabList';
import { qosEndpoint } from 'client/client/constants';
import QoSPolicyComponent from './QoSPolicy'; import QoSPolicyComponent from './QoSPolicy';
@inject('rootStore') @inject('rootStore')
@observer @observer
export default class QoSPolicy extends Base { export default class QoSPolicy extends Base {
get checkEndpoint() {
return true;
}
get endpoint() {
return qosEndpoint();
}
get tabs() { get tabs() {
const tabs = [ const tabs = [
{ {

View File

@ -17,6 +17,7 @@ import { Link } from 'react-router-dom';
import { inject, observer } from 'mobx-react'; import { inject, observer } from 'mobx-react';
import Base from 'containers/BaseDetail'; import Base from 'containers/BaseDetail';
import { bindingTypes } from 'resources/port'; import { bindingTypes } from 'resources/port';
import { qosEndpoint } from 'client/client/constants';
@inject('rootStore') @inject('rootStore')
@observer @observer
@ -25,6 +26,10 @@ export default class BaseDetail extends Base {
return [this.baseInfoCard]; return [this.baseInfoCard];
} }
get qosEndpoint() {
return qosEndpoint();
}
get baseInfoCard() { get baseInfoCard() {
const options = [ const options = [
{ {
@ -57,7 +62,9 @@ export default class BaseDetail extends Base {
dataIndex: 'binding:vnic_type', dataIndex: 'binding:vnic_type',
render: (value) => bindingTypes[value] || '-', render: (value) => bindingTypes[value] || '-',
}, },
{ ];
if (this.qosEndpoint) {
options.push({
label: t('QoS Policy'), label: t('QoS Policy'),
dataIndex: 'qos_policy_id', dataIndex: 'qos_policy_id',
copyable: false, copyable: false,
@ -67,8 +74,8 @@ export default class BaseDetail extends Base {
) : ( ) : (
'-' '-'
), ),
}, });
]; }
return { return {
title: t('Base Info'), title: t('Base Info'),
options, options,

View File

@ -24,6 +24,7 @@ import globalVirtualAdapterStore from 'stores/neutron/virtual-adapter';
import globalProjectStore from 'stores/keystone/project'; import globalProjectStore from 'stores/keystone/project';
import { SubnetStore } from 'stores/neutron/subnet'; import { SubnetStore } from 'stores/neutron/subnet';
import { getQoSPolicyTabs } from 'resources/qos-policy'; import { getQoSPolicyTabs } from 'resources/qos-policy';
import { qosEndpoint } from 'client/client/constants';
const portTypes = const portTypes =
'normal,macvtap,direct,baremetal,direct-physical,virtio-forwarder,smart-nic'; 'normal,macvtap,direct,baremetal,direct-physical,virtio-forwarder,smart-nic';
@ -33,6 +34,10 @@ export class CreateAction extends ModalAction {
static title = t('Create Virtual Adapter'); static title = t('Create Virtual Adapter');
get qosEndpoint() {
return qosEndpoint();
}
init() { init() {
this.networkStore = new NetworkStore(); this.networkStore = new NetworkStore();
this.securityGroupStore = new SecurityGroupStore(); this.securityGroupStore = new SecurityGroupStore();
@ -312,6 +317,7 @@ export class CreateAction extends ModalAction {
}); });
}, },
hidden: !more, hidden: !more,
display: !!this.qosEndpoint,
}, },
{ {
name: 'qos_policy_id', name: 'qos_policy_id',
@ -322,6 +328,7 @@ export class CreateAction extends ModalAction {
required: enableQosPolicy, required: enableQosPolicy,
tip: t('Choosing a QoS policy can limit bandwidth and DSCP'), tip: t('Choosing a QoS policy can limit bandwidth and DSCP'),
hidden: !(more && enableQosPolicy), hidden: !(more && enableQosPolicy),
display: !!this.qosEndpoint,
}, },
{ {
name: 'bindingProfile', name: 'bindingProfile',

View File

@ -18,6 +18,7 @@ import { ModalAction } from 'containers/Action';
import { QoSPolicyStore } from 'stores/neutron/qos-policy'; import { QoSPolicyStore } from 'stores/neutron/qos-policy';
import globalVirtualAdapterStore from 'stores/neutron/virtual-adapter'; import globalVirtualAdapterStore from 'stores/neutron/virtual-adapter';
import { getQoSPolicyTabs } from 'resources/qos-policy'; import { getQoSPolicyTabs } from 'resources/qos-policy';
import { qosEndpoint } from 'client/client/constants';
export class ModifyQoS extends ModalAction { export class ModifyQoS extends ModalAction {
static id = 'modify_qos'; static id = 'modify_qos';
@ -87,7 +88,7 @@ export class ModifyQoS extends ModalAction {
static policy = 'update_port'; static policy = 'update_port';
static allowed = () => Promise.resolve(true); static allowed = () => Promise.resolve(!!qosEndpoint());
onSubmit = (values) => { onSubmit = (values) => {
const { id } = this.item; const { id } = this.item;