diff --git a/releasenotes/notes/Fix-Network-Availability-And-Usage-Stats-Showing-46c89740ccc36e04.yaml b/releasenotes/notes/Fix-Network-Availability-And-Usage-Stats-Showing-46c89740ccc36e04.yaml new file mode 100644 index 00000000..bb708e76 --- /dev/null +++ b/releasenotes/notes/Fix-Network-Availability-And-Usage-Stats-Showing-46c89740ccc36e04.yaml @@ -0,0 +1,10 @@ +--- +fixes: + - | + `Bug #2003303 `: + + Fix the network IP availability showing by role. + + By default policy configuration, only administrative users can retrieve IP availability. + + Otherwise, Not Found (404) will be returned. \ No newline at end of file diff --git a/src/pages/network/containers/Network/Detail/index.jsx b/src/pages/network/containers/Network/Detail/index.jsx index 89269497..96104707 100644 --- a/src/pages/network/containers/Network/Detail/index.jsx +++ b/src/pages/network/containers/Network/Detail/index.jsx @@ -17,7 +17,6 @@ import Base from 'containers/TabDetail'; import { NetworkStore } from 'stores/neutron/network'; import { networkStatus } from 'resources/neutron/network'; import Port from 'pages/network/containers/Port'; -import globalRootStore from 'stores/root'; import Subnet from 'pages/network/containers/Subnet'; import Detail from './Detail'; import actionConfigs from '../actions'; @@ -50,17 +49,14 @@ export class NetworkDetail extends Base { .fetchDetailWithAvailabilityAndUsage({ ...newParams, isAdminPage: this.isAdminPage, - currentProjectId: globalRootStore.user.project.id, + canAddNetworkIPUsageInfo: this.canAddNetworkIPUsageInfo, }) .catch(this.catch); } }; get canAddNetworkIPUsageInfo() { - return ( - this.isAdminPage || - globalRootStore.user.project.id === this.detailData.project_id - ); + return this.store.hasAdminRole; } get detailInfos() { diff --git a/src/pages/network/containers/Subnet/Detail/Detail.jsx b/src/pages/network/containers/Subnet/Detail/Detail.jsx index b64cb88b..74ea18f4 100644 --- a/src/pages/network/containers/Subnet/Detail/Detail.jsx +++ b/src/pages/network/containers/Subnet/Detail/Detail.jsx @@ -26,9 +26,7 @@ export class BaseDetail extends Base { } get canAddNetworkIPUsageInfo() { - return ( - this.isAdminPage || this.currentProjectId === this.detailData.project_id - ); + return this.store.hasAdminRole; } get networkCard() { diff --git a/src/pages/network/containers/Subnet/Detail/index.jsx b/src/pages/network/containers/Subnet/Detail/index.jsx index 0142e6e3..93abf66c 100644 --- a/src/pages/network/containers/Subnet/Detail/index.jsx +++ b/src/pages/network/containers/Subnet/Detail/index.jsx @@ -45,6 +45,7 @@ export class SubnetDetail extends Base { return { ...params, inDetail: true, + canAddNetworkIPUsageInfo: this.store.hasAdminRole, }; }; diff --git a/src/pages/network/containers/Subnet/index.jsx b/src/pages/network/containers/Subnet/index.jsx index 24c32874..20f74118 100644 --- a/src/pages/network/containers/Subnet/index.jsx +++ b/src/pages/network/containers/Subnet/index.jsx @@ -49,9 +49,7 @@ export class Subnets extends Base { }; get canAddNetworkIPUsageInfo() { - return ( - this.isAdminPage || this.currentProjectId === this.props.detail.project_id - ); + return this.store.hasAdminRole; } getColumns = () => { diff --git a/src/stores/neutron/network.js b/src/stores/neutron/network.js index 159be8e7..91798829 100644 --- a/src/stores/neutron/network.js +++ b/src/stores/neutron/network.js @@ -133,7 +133,7 @@ export class NetworkStore extends Base { async fetchDetailWithAvailabilityAndUsage({ id, isAdminPage, - currentProjectId, + canAddNetworkIPUsageInfo, }) { this.isLoading = true; const result = await this.client.show(id); @@ -167,8 +167,8 @@ export class NetworkStore extends Base { projectName: projectDetail.name, }; - // Only the administrator or the current network owner can view the number of IP addresses used - if (isAdminPage || currentProjectId === originData.project_id) { + // Only the administrator can view the number of IP addresses used + if (canAddNetworkIPUsageInfo) { const used = await this.ipClient.show(id); this.detail = { ...this.detail, diff --git a/src/stores/neutron/subnet.js b/src/stores/neutron/subnet.js index 365e3674..fe683e74 100644 --- a/src/stores/neutron/subnet.js +++ b/src/stores/neutron/subnet.js @@ -89,7 +89,7 @@ export class SubnetStore extends Base { } async detailDidFetch(item, allProjects, filters) { - const { inDetail = false } = filters; + const { inDetail = false, canAddNetworkIPUsageInfo = false } = filters; if (!inDetail) { return item; } @@ -97,7 +97,7 @@ export class SubnetStore extends Base { const networkParams = { id: network_id, isAdminPage: allProjects, - currentProjectId: this.currentProjectId, + canAddNetworkIPUsageInfo, }; const { NetworkStore } = require('stores/neutron/network'); const network =