From 772b1b5d460a0c4067e353b874861ca75ea8b729 Mon Sep 17 00:00:00 2001 From: zhangjingwei Date: Tue, 14 Nov 2023 14:17:11 +0800 Subject: [PATCH] feat: support editing pool admin_state_up 1. support editing admin_state_up when edit listener's pool of lb 2. support display admin_state_up info in the pool info card in the listener detail page 3. update lb algorithm display in the pool info card in the listener detail page Change-Id: I80a500c6d67b51203c1d2e5868f94c4800c72714 --- ...te-Editing-Pool-Info-7094e9265fe01b84.yaml | 10 +++++++++ .../Listener/Actions/EditPoolInfo.jsx | 21 ++++++++++--------- .../Listener/Detail/BaseDetail.jsx | 12 ++++++++--- src/resources/octavia/pool.js | 2 +- 4 files changed, 31 insertions(+), 14 deletions(-) create mode 100644 releasenotes/notes/Update-Editing-Pool-Info-7094e9265fe01b84.yaml diff --git a/releasenotes/notes/Update-Editing-Pool-Info-7094e9265fe01b84.yaml b/releasenotes/notes/Update-Editing-Pool-Info-7094e9265fe01b84.yaml new file mode 100644 index 00000000..9fcfabd6 --- /dev/null +++ b/releasenotes/notes/Update-Editing-Pool-Info-7094e9265fe01b84.yaml @@ -0,0 +1,10 @@ +--- +features: + - | + Update editing admin_state_up for listener's pool: + + * Support editing admin_state_up when edit listener's pool of lb. + + * Support display admin_state_up info in the pool info card in the listener detail page. + + * Update lb algorithm display in the pool info card in the listener detail page. diff --git a/src/pages/network/containers/LoadBalancers/Listener/Actions/EditPoolInfo.jsx b/src/pages/network/containers/LoadBalancers/Listener/Actions/EditPoolInfo.jsx index 54d5beb9..a2310ffc 100644 --- a/src/pages/network/containers/LoadBalancers/Listener/Actions/EditPoolInfo.jsx +++ b/src/pages/network/containers/LoadBalancers/Listener/Actions/EditPoolInfo.jsx @@ -50,20 +50,13 @@ export class EditPoolInfo extends ModalAction { get defaultValue() { const { pool } = this.state; - const { name, description, protocol, lb_algorithm } = pool; - if (name && this.formRef.current) { - this.formRef.current.setFieldsValue({ - name, - description, - protocol, - lb_algorithm, - }); - } + const { name, description, protocol, lb_algorithm, admin_state_up } = pool; return { name, description, protocol, lb_algorithm, + admin_state_up, }; } @@ -84,7 +77,9 @@ export class EditPoolInfo extends ModalAction { async getPoolDetail() { const { default_pool_id } = this.item; const pool = await this.store.fetchDetail({ id: default_pool_id }); - this.setState({ pool }); + this.setState({ pool }, () => { + this.updateDefaultValue(); + }); } get formItems() { @@ -115,6 +110,12 @@ export class EditPoolInfo extends ModalAction { options: Algorithm, required: true, }, + { + name: 'admin_state_up', + label: t('Admin State Up'), + type: 'switch', + tip: t('Defines the admin state of the pool.'), + }, ]; } diff --git a/src/pages/network/containers/LoadBalancers/Listener/Detail/BaseDetail.jsx b/src/pages/network/containers/LoadBalancers/Listener/Detail/BaseDetail.jsx index e167d4c9..1680fd0a 100644 --- a/src/pages/network/containers/LoadBalancers/Listener/Detail/BaseDetail.jsx +++ b/src/pages/network/containers/LoadBalancers/Listener/Detail/BaseDetail.jsx @@ -16,8 +16,9 @@ import { inject, observer } from 'mobx-react'; import globalListenerStore from 'stores/octavia/listener'; import Base from 'containers/BaseDetail'; import { HealthMonitorStore } from 'stores/octavia/health-monitor'; -import { getInsertHeaderCard } from 'src/resources/octavia/lb'; +import { getInsertHeaderCard } from 'resources/octavia/lb'; import { isEmpty } from 'lodash'; +import { algorithmDict } from 'resources/octavia/pool'; export class BaseDetail extends Base { componentDidMount() { @@ -63,7 +64,8 @@ export class BaseDetail extends Base { get PoolInfo() { const { default_pool = {} } = this.detailData || {}; - const { name, protocol, lb_algorithm, description } = default_pool; + const { name, protocol, lb_algorithm, description, admin_state_up } = + default_pool; const options = [ { label: t('Name'), @@ -75,7 +77,11 @@ export class BaseDetail extends Base { }, { label: t('LB Algorithm'), - content: lb_algorithm || '-', + content: algorithmDict[lb_algorithm] || lb_algorithm || '-', + }, + { + label: t('Admin State Up'), + content: admin_state_up ? t('On') : t('Off'), }, { label: t('Description'), diff --git a/src/resources/octavia/pool.js b/src/resources/octavia/pool.js index 53dbeb1f..9512613e 100644 --- a/src/resources/octavia/pool.js +++ b/src/resources/octavia/pool.js @@ -23,7 +23,7 @@ export const BackendProtocol = [ }, ]; -const algorithmDict = { +export const algorithmDict = { LEAST_CONNECTIONS: t('LEAST_CONNECTIONS'), ROUND_ROBIN: t('ROUND_ROBIN'), SOURCE_IP: t('SOURCE_IP'),