From c397b865246ec9aa0b6acf0172cd01fed46c7086 Mon Sep 17 00:00:00 2001 From: csawatzky Date: Mon, 17 Mar 2025 11:19:00 -0600 Subject: [PATCH] added bin history, fixed some column stuff in the DiffHistory --- src/bin/BinHistory.tsx | 23 ++++++++++++----------- src/common/DiffHistory.tsx | 18 +++++++++++------- src/pages/Bin.tsx | 2 +- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/bin/BinHistory.tsx b/src/bin/BinHistory.tsx index 16b30c7..2634452 100644 --- a/src/bin/BinHistory.tsx +++ b/src/bin/BinHistory.tsx @@ -1,14 +1,14 @@ -import { Box, Card, Typography } from "@material-ui/core"; -import { createStyles, makeStyles, Theme } from "@material-ui/core/styles"; -import { MatchParams } from "navigation/Routes"; +import { Box, Card, Typography, Theme } from "@mui/material"; +import { createStyles, makeStyles } from "@mui/styles"; +//import { MatchParams } from "navigation/Routes"; import DiffHistory, { ListResult, Record } from "common/DiffHistory"; import { useSnackbar, useMobile } from "hooks"; import { useBinAPI } from "providers"; import { Bin } from "models"; import { TranslateKey, TranslateValue } from "pbHelpers/Bin"; import { pond } from "protobuf-ts/pond"; -import React, { useEffect, useState } from "react"; -import { useParams } from "react-router"; +import { useEffect, useState } from "react"; +//import { useParams } from "react-router"; import { or } from "utils/types"; const useStyles = makeStyles((theme: Theme) => @@ -29,16 +29,17 @@ const useStyles = makeStyles((theme: Theme) => ); interface Props { - binID?: string; + binID: string; drawer?: boolean; } export default function BinHistory(props: Props) { - const params = useParams(); + //const params = useParams(); + const {binID, drawer} = props const classes = useStyles(); const { openSnack } = useSnackbar(); const binAPI = useBinAPI(); - const binID = props.binID ?? params.binID; + //const binID = props.binID ?? params.binID; const [bin, setBin] = useState(Bin.any({ settings: { binId: binID } })); const binName = bin.name(); const isMobile = useMobile(); @@ -92,7 +93,7 @@ export default function BinHistory(props: Props) { }; return ( - + {binName} History @@ -103,10 +104,10 @@ export default function BinHistory(props: Props) { list={list} translateKey={translateKey} translateValue={translateValue} - cellStyle={{ margin: "0px", padding: "0.5rem" }} + cellStyle={{ margin: "0px", padding: 1 }} showTitle={false} headerStyle={{ margin: "0px" }} - drawer={props.drawer} + drawer={drawer} /> diff --git a/src/common/DiffHistory.tsx b/src/common/DiffHistory.tsx index 6f3df5e..206140e 100644 --- a/src/common/DiffHistory.tsx +++ b/src/common/DiffHistory.tsx @@ -8,7 +8,8 @@ import { ListItemIcon, Chip, Avatar, - Grid2 as Grid + Grid2 as Grid, + SxProps } from "@mui/material"; import { Add, ChangeHistory, Remove, Face, Sync } from "@mui/icons-material"; import { amber, red, blue, green } from "@mui/material/colors"; @@ -258,7 +259,7 @@ interface Props { translateKey: (key: keyof any, type?: pond.ObjectType) => string; translateValue: (key: keyof any, obj: any, type?: pond.ObjectType) => string; headerStyle?: React.CSSProperties; - cellStyle?: React.CSSProperties | ((data: RowData[], rowData: RowData) => React.CSSProperties); + cellStyle?: SxProps; noPaging?: boolean; sortingEnabled?: boolean; filteringEnabled?: boolean; @@ -391,6 +392,7 @@ export default function DiffHistory(props: Props) { const columns = (): Column[] => { return [{ title: "Time", + cellStyle: cellStyle, render: (row: RowData) => (
{moment(row.timestamp).calendar()} @@ -402,16 +404,17 @@ export default function DiffHistory(props: Props) { }, { title: "Object Type", + cellStyle: cellStyle, render: row => { if (row.type) { - return (
ObjectDescriber(row.type).name
) + return (
{ObjectDescriber(row.type).name}
) } return
} }, { title: "User", - // cellStyle: cellStyle, + cellStyle: cellStyle, // field: "user", render: row => { const profile = getProfile(row.user); @@ -435,11 +438,12 @@ export default function DiffHistory(props: Props) { }, { title: "Status", - render: row =>
row.status
+ cellStyle: cellStyle, + render: row =>
{row.status}
}, { title: "Summary", - // cellStyle: cellStyle, + cellStyle: cellStyle, // hidden: isMobile || drawer, render: row => ( - title={name + " History"} + title={showTitle ? name + " History" : undefined} rows={data} columns={columns()} total={0} diff --git a/src/pages/Bin.tsx b/src/pages/Bin.tsx index 1cda075..a4f63e6 100644 --- a/src/pages/Bin.tsx +++ b/src/pages/Bin.tsx @@ -542,7 +542,7 @@ export default function Bin(props: Props) { - {/* */} + );