-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add a basic table component - add a tree table component
- Loading branch information
Showing
5 changed files
with
133 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import type { ReactElement } from "react"; | ||
|
||
import { FormattedMessage } from "react-intl"; | ||
|
||
import { Table, TableHead, TableHeader, TableRow } from "../ui/table" | ||
|
||
interface IBaseTable { | ||
headers: string[]; | ||
body: ReactElement; | ||
} | ||
|
||
const BaseTable = ({headers, body}: IBaseTable) : JSX.Element => { | ||
return ( | ||
<div> | ||
<Table className="rounded-lg text-black bg-white w-full"> | ||
<TableHeader className="bg-mediumGray"> | ||
<TableRow> | ||
{headers.map((column) => ( | ||
<TableHead className="text-black border-b" key={column}> | ||
<FormattedMessage id={column}/> | ||
</TableHead> | ||
))} | ||
</TableRow> | ||
</TableHeader> | ||
{body} | ||
</Table> | ||
</div> | ||
); | ||
}; | ||
|
||
export default BaseTable; |
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,94 @@ | ||
import { useMemo } from "react"; | ||
|
||
import { TableRow, TableCell } from "../ui/table"; | ||
|
||
import BaseTable from "./BaseTable"; | ||
|
||
interface ITreeTableBody { | ||
name: string; | ||
branch: string; | ||
commit: string; | ||
buildStatus: string; | ||
testStatus: string; | ||
} | ||
|
||
const treeTableColumnsLabelId = [ | ||
'treeTable.tree', | ||
'treeTable.branch', | ||
'treeTable.commit', | ||
'treeTable.build', | ||
'treeTable.test' | ||
]; | ||
|
||
const treeTableRows: ITreeTableBody[] = [ | ||
{ | ||
name: "stable-rc", | ||
branch: "linux-5.15", | ||
commit: "asidnasidn-oqiwejeoij-oaidnosdnk", | ||
buildStatus: "150 completed", | ||
testStatus: "80 completed" | ||
}, | ||
{ | ||
name: "stable-rc", | ||
branch: "linux-5.15", | ||
commit: "asidnasidn-oqiwejeoij-oaidnosdnk", | ||
buildStatus: "10 completed", | ||
testStatus: "150 completed" | ||
}, | ||
{ | ||
name: "stable-rc", | ||
branch: "linux-5.15", | ||
commit: "asidnasidn-oqiwejeoij-oaidnosdnk", | ||
buildStatus: "10 completed", | ||
testStatus: "150 completed" | ||
}, | ||
{ | ||
name: "stable-rc", | ||
branch: "linux-5.15", | ||
commit: "asidnasidn-oqiwejeoij-oaidnosdnk", | ||
buildStatus: "10 completed", | ||
testStatus: "150 completed" | ||
}, | ||
{ | ||
name: "stable-rc", | ||
branch: "linux-5.15", | ||
commit: "asidnasidn-oqiwejeoij-oaidnosdnk", | ||
buildStatus: "10 completed", | ||
testStatus: "150 completed" | ||
} | ||
]; | ||
|
||
const TreeTableRow = (row: ITreeTableBody): JSX.Element => { | ||
return ( | ||
<TableRow> | ||
<TableCell>{row.name}</TableCell> | ||
<TableCell>{row.branch}</TableCell> | ||
<TableCell>{row.commit}</TableCell> | ||
<TableCell><div className="bg-lightGray w-fit h-fit p-1 rounded-lg">{row.buildStatus}</div></TableCell> | ||
<TableCell><div className="bg-lightGray w-fit h-fit p-1 rounded-lg">{row.testStatus}</div></TableCell> | ||
</TableRow> | ||
); | ||
}; | ||
|
||
const TreeTable = () : JSX.Element => { | ||
const treeTableBody = useMemo(() => { | ||
return ( | ||
treeTableRows.map((row: ITreeTableBody) => ( | ||
<TreeTableRow | ||
key={row.commit} | ||
name={row.name} | ||
branch={row.branch} | ||
commit={row.commit} | ||
buildStatus={row.buildStatus} | ||
testStatus={row.testStatus}/> | ||
)) | ||
); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [treeTableRows]); | ||
|
||
return( | ||
<BaseTable headers={treeTableColumnsLabelId} body={<>{treeTableBody}</>} /> | ||
); | ||
} | ||
|
||
export default TreeTable; |
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