Skip to content

Commit

Permalink
Merge pull request #571 from xichen1/pureStandardTable
Browse files Browse the repository at this point in the history
Add option to disable table row selection
  • Loading branch information
fengyangsy authored Oct 21, 2023
2 parents 7845c81 + 4bc4939 commit dfb7858
Showing 1 changed file with 41 additions and 39 deletions.
80 changes: 41 additions & 39 deletions src/dashboard/src/components/StandardTable/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class StandardTable extends PureComponent {

render() {
const { selectedRowKeys, needTotalList } = this.state;
const { data = {}, rowKey, intl, ...rest } = this.props;
const { data = {}, disableSelect = false, rowKey, intl, ...rest } = this.props;
const { list = [], pagination } = data;

const paginationProps = {
Expand Down Expand Up @@ -95,48 +95,50 @@ class StandardTable extends PureComponent {

return (
<div className={styles.standardTable}>
<div className={styles.tableAlert}>
<Alert
message={
<Fragment>
{intl.formatMessage({
id: 'component.standardTable.selected',
defaultMessage: 'Selected',
})}
<a style={{ fontWeight: 600 }}>{selectedRowKeys.length}</a>{' '}
{intl.formatMessage({
id: 'component.standardTable.item',
defaultMessage: 'Item',
})}
&nbsp;&nbsp;
{needTotalList.map(item => (
<span style={{ marginLeft: 8 }} key={item.dataIndex}>
{item.title}
{intl.formatMessage({
id: 'component.standardTable.total',
defaultMessage: 'Total',
})}{' '}
&nbsp;
<span style={{ fontWeight: 600 }}>
{item.render ? item.render(item.total) : item.total}
</span>
</span>
))}
<a onClick={this.cleanSelectedKeys} style={{ marginLeft: 24 }}>
{!disableSelect && (
<div className={styles.tableAlert}>
<Alert
message={
<Fragment>
{intl.formatMessage({
id: 'component.standardTable.selected',
defaultMessage: 'Selected',
})}
<a style={{ fontWeight: 600 }}>{selectedRowKeys.length}</a>{' '}
{intl.formatMessage({
id: 'component.standardTable.clean',
defaultMessage: 'Clean',
id: 'component.standardTable.item',
defaultMessage: 'Item',
})}
</a>
</Fragment>
}
type="info"
showIcon
/>
</div>
&nbsp;&nbsp;
{needTotalList.map(item => (
<span style={{ marginLeft: 8 }} key={item.dataIndex}>
{item.title}
{intl.formatMessage({
id: 'component.standardTable.total',
defaultMessage: 'Total',
})}{' '}
&nbsp;
<span style={{ fontWeight: 600 }}>
{item.render ? item.render(item.total) : item.total}
</span>
</span>
))}
<a onClick={this.cleanSelectedKeys} style={{ marginLeft: 24 }}>
{intl.formatMessage({
id: 'component.standardTable.clean',
defaultMessage: 'Clean',
})}
</a>
</Fragment>
}
type="info"
showIcon
/>
</div>
)}
<Table
rowKey={rowKey || 'key'}
rowSelection={rowSelection}
rowSelection={!disableSelect && rowSelection}
dataSource={list}
pagination={paginationProps}
onChange={this.handleTableChange}
Expand Down

0 comments on commit dfb7858

Please sign in to comment.