fix: fix the network IP availability showing

By default policy configuration, only administrative users can retrieve IP availability. Otherwise, Not Found (404) will be returned

Closes-Bug: #2003303
Change-Id: I9e3232dc5828208d3ef08b033d953501fe93fed8
This commit is contained in:
xusongfu 2023-02-18 22:15:52 +08:00
parent 0a192be466
commit 520504e26d
7 changed files with 20 additions and 17 deletions

View File

@ -0,0 +1,10 @@
---
fixes:
- |
`Bug #2003303 <https://bugs.launchpad.net/skyline-console/+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.

View File

@ -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() {

View File

@ -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() {

View File

@ -45,6 +45,7 @@ export class SubnetDetail extends Base {
return {
...params,
inDetail: true,
canAddNetworkIPUsageInfo: this.store.hasAdminRole,
};
};

View File

@ -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 = () => {

View File

@ -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,

View File

@ -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 =