feat: support component in the table header

Support custom component in the table header of the list page, the custom component is placed in front of the magicSearch component

Change-Id: I980552818bcb6375d3b412b63732c02597ff2a94
This commit is contained in:
Jingwei.Zhang 2022-12-06 17:37:43 +08:00
parent 719e26ebaa
commit ef353362fb
2 changed files with 15 additions and 0 deletions

View File

@ -98,6 +98,7 @@ export class BaseTable extends React.Component {
primaryActionsExtra: PropTypes.any, primaryActionsExtra: PropTypes.any,
isAdminPage: PropTypes.bool, isAdminPage: PropTypes.bool,
containerProps: PropTypes.any, containerProps: PropTypes.any,
middleComponentInHeader: PropTypes.node,
}; };
static defaultProps = { static defaultProps = {
@ -653,6 +654,14 @@ export class BaseTable extends React.Component {
); );
} }
renderMiddleInHeader() {
const { middleComponentInHeader } = this.props;
if (middleComponentInHeader) {
return middleComponentInHeader;
}
return null;
}
renderActions() { renderActions() {
const { const {
isAdminPage, isAdminPage,
@ -791,6 +800,7 @@ export class BaseTable extends React.Component {
{this.renderRefreshAuto()} {this.renderRefreshAuto()}
</div> </div>
{this.renderTimeFilter()} {this.renderTimeFilter()}
{this.renderMiddleInHeader()}
{this.renderSearch()} {this.renderSearch()}
</div> </div>
); );

View File

@ -440,6 +440,10 @@ export default class BaseList extends React.Component {
return false; return false;
} }
get middleComponentInTableHeader() {
return null;
}
setRefreshDataTimerTransition = () => { setRefreshDataTimerTransition = () => {
this.stopRefreshAuto(); this.stopRefreshAuto();
if (this.dataTimerTransition) { if (this.dataTimerTransition) {
@ -557,6 +561,7 @@ export default class BaseList extends React.Component {
primaryActionsExtra: this.primaryActionsExtra, primaryActionsExtra: this.primaryActionsExtra,
isAdminPage: this.isAdminPage, isAdminPage: this.isAdminPage,
initFilter: this.initFilter, initFilter: this.initFilter,
middleComponentInHeader: this.middleComponentInTableHeader,
...this.getEnabledTableProps(), ...this.getEnabledTableProps(),
}; };
} }