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 ( +