From 5fcc3b053ea8bbc42eb73abfff3c4c106f07feb6 Mon Sep 17 00:00:00 2001 From: zhangjingwei Date: Wed, 31 Jan 2024 14:21:55 +0800 Subject: [PATCH] feat: support refresh button for SelectTable component 1. Support refresh button to refresh data for the SelectTable component. 2. When creating an instance/ironic/container, you can click to create a network/security group, then create a new resource in a new window, refresh the data in the previous window and select the newly created resource. Closes-Bug: 2042928 Change-Id: I66bdbf848d375e45f0ab8941b0989165ad86a137 --- ...ton-For-Select-Table-5312ff8105325055.yaml | 13 +++++ src/components/FormItem/SelectTable/index.jsx | 54 ++++++++++++++++++- .../FormItem/SelectTable/index.less | 18 +++++++ .../actions/StepCreate/NetworkStep/index.jsx | 2 + .../actions/StepCreate/StepNetworks/index.jsx | 1 + .../actions/StepCreate/StepNetworks/index.jsx | 1 + src/styles/variables-custom.less | 1 + src/styles/variables.less | 1 + src/utils/route-map.jsx | 14 ++++- 9 files changed, 101 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/Support-Refresh-Button-For-Select-Table-5312ff8105325055.yaml diff --git a/releasenotes/notes/Support-Refresh-Button-For-Select-Table-5312ff8105325055.yaml b/releasenotes/notes/Support-Refresh-Button-For-Select-Table-5312ff8105325055.yaml new file mode 100644 index 00000000..c7352af2 --- /dev/null +++ b/releasenotes/notes/Support-Refresh-Button-For-Select-Table-5312ff8105325055.yaml @@ -0,0 +1,13 @@ +--- +features: + - | + `Feature #2042928 `_: + + Support refresh button for SelectTable component: + + * Support refresh button to refresh data for the SelectTable component + + * When creating an instance/ironic/container, you can click to create + a network/security group, then create a new resource in a new window, + refresh the data in the previous window and select the newly created + resource. diff --git a/src/components/FormItem/SelectTable/index.jsx b/src/components/FormItem/SelectTable/index.jsx index 0e7cba12..a1b092c7 100644 --- a/src/components/FormItem/SelectTable/index.jsx +++ b/src/components/FormItem/SelectTable/index.jsx @@ -14,7 +14,7 @@ import React from 'react'; import { Radio, Tag, Button, Tooltip } from 'antd'; -import { ClearOutlined } from '@ant-design/icons'; +import { ClearOutlined, SyncOutlined } from '@ant-design/icons'; import { observer } from 'mobx-react'; import PropTypes from 'prop-types'; import MagicInput from 'components/MagicInput'; @@ -102,6 +102,8 @@ export default class SelectTable extends React.Component { onRow: PropTypes.func, childrenColumnName: PropTypes.string, imageTabAuto: PropTypes.bool, + refreshFunc: PropTypes.func, + hideRefresh: PropTypes.bool, }; static defaultProps = { @@ -127,6 +129,8 @@ export default class SelectTable extends React.Component { defaultSortOrder: '', childrenColumnName: 'children', imageTabAuto: false, + refreshFunc: null, + hideRefresh: false, }; constructor(props) { @@ -388,6 +392,7 @@ export default class SelectTable extends React.Component { }; handleFilterInput = (tags) => { + this.setState({ tags }); const { backendPageStore } = this.props; const filters = {}; tags.forEach((n) => { @@ -606,6 +611,19 @@ export default class SelectTable extends React.Component { }); }; + handleRefresh = () => { + console.log('handleRefresh'); + const { backendPageStore, refreshFunc } = this.props; + const { tags = [] } = this.state; + if (refreshFunc) { + refreshFunc(); + return; + } + if (backendPageStore) { + this.handleFilterInput(tags); + } + }; + initTabChange() { const { defaultTabValue, onTabChange, value } = this.props; if (defaultTabValue !== undefined && onTabChange !== undefined) { @@ -615,6 +633,28 @@ export default class SelectTable extends React.Component { } } + renderRefresh() { + const { hideRefresh, backendPageStore, refreshFunc } = this.props; + let showButton = false; + if (!hideRefresh) { + if (backendPageStore) { + showButton = true; + } else if (refreshFunc) { + showButton = true; + } + } + if (!showButton) { + return null; + } + return ( +