-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor/add wrapped-table and fix table bug (#736)
* refactor: add wrapped-table * refactor: add wrapped-table * refactor: add wrapped-table and fix table bug * refactor: wrapped-table type check problem * refactor: wrapped-table type check problem * refactor: Wrapping the Table causes the unit test to change * refactor: add table header title * refactor: table columns width adjustment
- Loading branch information
1 parent
66e7161
commit 8f634b6
Showing
51 changed files
with
510 additions
and
353 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) 2021 Terminus, Inc. | ||
// | ||
// This program is free software: you can use, redistribute, and/or modify | ||
// it under the terms of the GNU Affero General Public License, version 3 | ||
// or later ("AGPL"), as published by the Free Software Foundation. | ||
// | ||
// This program is distributed in the hope that it will be useful, but WITHOUT | ||
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
// FITNESS FOR A PARTICULAR PURPOSE. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
import * as React from 'react'; | ||
import { Table } from 'antd'; | ||
import { ColumnProps as AntdColumnProps, TableProps } from 'antd/lib/table'; | ||
|
||
export interface ColumnProps<recordType> extends AntdColumnProps<recordType> { | ||
/** | ||
* id\number - 72 | ||
* user\status\type\cpu\memory - 120 | ||
* email\phone\roles\ip - 160 | ||
* time - 200 | ||
* operations - 80 * n, according to the number of buttons and the number of words | ||
* detail\content\description - No need to increase the width of the adaptive, and add the scroll.x of a certain number to the table | ||
* All width should be at least larger than the Title in English | ||
*/ | ||
width?: 64 | 72 | 80 | 96 | 120 | 160 | 176 | 200 | 240 | 280 | 320; | ||
} | ||
|
||
interface IProps<T extends object = any> extends TableProps<T> { | ||
columns: Array<ColumnProps<T>>; | ||
} | ||
|
||
function WrappedTable<T extends object = any>({ columns, ...props }: IProps<T>) { | ||
const newColumns = columns?.map(({ ...args }: ColumnProps<T>) => ({ | ||
ellipsis: true, | ||
...args, | ||
})); | ||
return <Table scroll={{ x: '100%' }} columns={newColumns} {...props} />; | ||
} | ||
|
||
export default WrappedTable; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.