Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(#19): add table UI #32

Merged
merged 4 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"@radix-ui/react-separator": "^1.1.0",
"@tanstack/react-query": "^5.45.1",
"@vitejs/plugin-react": "^4.3.1",
"@tanstack/react-table": "^8.17.3",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.1",
"flat": "^6.0.1",
Expand Down
22 changes: 22 additions & 0 deletions dashboard/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 2 additions & 4 deletions dashboard/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import "./App.css";
import LateralMenu from "./components/SideMenu/SideMenu";
import Dashboard from "./components/Dashboard/Dashboard";

function App(): JSX.Element {
return (
<>
<div className="w-screen h-screen">
<LateralMenu />
<Dashboard />
</div>
</>
);
}

Expand Down
47 changes: 0 additions & 47 deletions dashboard/src/components/Button/Button.tsx

This file was deleted.

30 changes: 0 additions & 30 deletions dashboard/src/components/Button/button.css

This file was deleted.

17 changes: 17 additions & 0 deletions dashboard/src/components/Dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import SideMenu from "../SideMenu/SideMenu";
import TreeTable from "../Table/TreeTable";

const Dashboard = () : JSX.Element => {
return (
<div className="w-full h-full">
<div className="flex flex-row w-full justify-between">
<SideMenu />
<div className="w-full px-16 pt-64">
<TreeTable />
</div>
</div>
</div>
);
};

export default Dashboard;
2 changes: 1 addition & 1 deletion dashboard/src/components/SideMenu/SideMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const SideMenu = (): JSX.Element => {

return (
<NavigationMenu
className="fixed h-screen justify-start bg-bgSecondary pt-6 flex-col"
className="h-screen justify-start bg-bgSecondary pt-6 flex-col"
orientation="vertical"
>
<div className="w-full px-4">
Expand Down
31 changes: 31 additions & 0 deletions dashboard/src/components/Table/BaseTable.tsx
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;
94 changes: 94 additions & 0 deletions dashboard/src/components/Table/TreeTable.tsx
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;
Loading