Merge "fix: Fix manage port security group"
This commit is contained in:
commit
d4300f113e
@ -35,7 +35,8 @@ export default class ManageSecurityGroup extends ModalAction {
|
|||||||
|
|
||||||
static policy = 'update_port:port_security_enabled';
|
static policy = 'update_port:port_security_enabled';
|
||||||
|
|
||||||
static allowed = (item) => Promise.resolve(item.port_security_enabled);
|
static allowed = (item) =>
|
||||||
|
Promise.resolve(item.origin_data.allowed_address_pairs.length === 0);
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
this.securityGroupStore = new SecurityGroupStore();
|
this.securityGroupStore = new SecurityGroupStore();
|
||||||
@ -61,6 +62,7 @@ export default class ManageSecurityGroup extends ModalAction {
|
|||||||
const { selectedRowKeys = [] } = sgInitValue || {};
|
const { selectedRowKeys = [] } = sgInitValue || {};
|
||||||
if (selectedRowKeys.length) {
|
if (selectedRowKeys.length) {
|
||||||
return {
|
return {
|
||||||
|
port_security_enabled: this.item.port_security_enabled,
|
||||||
securityGroup: sgInitValue,
|
securityGroup: sgInitValue,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -68,7 +70,7 @@ export default class ManageSecurityGroup extends ModalAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getPortDetail() {
|
async getPortDetail() {
|
||||||
const { id, security_groups } = this.item;
|
const { id, security_groups, port_security_enabled } = this.item;
|
||||||
let sgs = security_groups;
|
let sgs = security_groups;
|
||||||
if (!security_groups) {
|
if (!security_groups) {
|
||||||
const detail = await globalVirtualAdapterStore.fetchDetail({ id });
|
const detail = await globalVirtualAdapterStore.fetchDetail({ id });
|
||||||
@ -83,15 +85,24 @@ export default class ManageSecurityGroup extends ModalAction {
|
|||||||
};
|
};
|
||||||
this.setState({
|
this.setState({
|
||||||
sgInitValue,
|
sgInitValue,
|
||||||
|
port_security_enabled,
|
||||||
});
|
});
|
||||||
this.updateFormValue('securityGroup', sgInitValue);
|
this.updateFormValue('securityGroup', sgInitValue);
|
||||||
|
this.updateFormValue('port_security_enabled', port_security_enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
onSubmit = (values) => {
|
onSubmit = (values) => {
|
||||||
const { securityGroup: { selectedRowKeys: security_groups = [] } = {} } =
|
const {
|
||||||
values;
|
securityGroup: { selectedRowKeys: security_groups = [] } = {},
|
||||||
|
port_security_enabled,
|
||||||
|
} = values;
|
||||||
const { id } = this.item;
|
const { id } = this.item;
|
||||||
const reqBody = { port: { security_groups } };
|
const reqBody = {
|
||||||
|
port: {
|
||||||
|
security_groups: port_security_enabled ? security_groups : [],
|
||||||
|
port_security_enabled,
|
||||||
|
},
|
||||||
|
};
|
||||||
return this.securityGroupStore.updatePortSecurityGroup({ id, reqBody });
|
return this.securityGroupStore.updatePortSecurityGroup({ id, reqBody });
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -101,8 +112,19 @@ export default class ManageSecurityGroup extends ModalAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get formItems() {
|
get formItems() {
|
||||||
const { sgInitValue } = this.state;
|
const { sgInitValue, port_security_enabled } = this.state;
|
||||||
return [
|
return [
|
||||||
|
{
|
||||||
|
name: 'port_security_enabled',
|
||||||
|
label: t('Port Security'),
|
||||||
|
type: 'switch',
|
||||||
|
onChange: (e) => {
|
||||||
|
this.setState({
|
||||||
|
port_security_enabled: e,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'securityGroup',
|
name: 'securityGroup',
|
||||||
label: t('Security Group'),
|
label: t('Security Group'),
|
||||||
@ -113,11 +135,11 @@ export default class ManageSecurityGroup extends ModalAction {
|
|||||||
backendPageStore: this.securityGroupStore,
|
backendPageStore: this.securityGroupStore,
|
||||||
extraParams: { project_id: this.currentProjectId },
|
extraParams: { project_id: this.currentProjectId },
|
||||||
initValue: sgInitValue,
|
initValue: sgInitValue,
|
||||||
required: true,
|
|
||||||
isMulti: true,
|
isMulti: true,
|
||||||
filterParams: securityGroupFilter,
|
filterParams: securityGroupFilter,
|
||||||
columns: securityGroupColumns,
|
columns: securityGroupColumns,
|
||||||
onRow: () => {},
|
onRow: () => {},
|
||||||
|
hidden: !port_security_enabled,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user