Skip to content

Commit

Permalink
Merge pull request #529 from logion-network/feature/add-item-desc-column
Browse files Browse the repository at this point in the history
Add description column to items table
  • Loading branch information
gdethier authored Nov 20, 2023
2 parents 1d422a8 + 68e477e commit 1958e9c
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 29 deletions.
5 changes: 5 additions & 0 deletions src/common/ButtonGroup.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
margin-left: 25px;
}

.ButtonGroup.narrow .Button,
.ButtonGroup.narrow .Button-container {
margin-left: 5px;
}

.ButtonGroup .Button:first-child,
.ButtonGroup .Button-container:first-child {
margin-left: 0;
Expand Down
3 changes: 2 additions & 1 deletion src/loc/CollectionLocItemChecker.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jest.mock("src/legal-officer/LegalOfficerContext");

import { render, screen, waitFor } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { LocData } from "@logion/client";
import { LocData, HashString } from "@logion/client";
import { UUID, Hash } from "@logion/node-api";

import { LOCollectionLocItemChecker, UserCollectionLocItemChecker, Props } from "./CollectionLocItemChecker";
Expand Down Expand Up @@ -71,6 +71,7 @@ const locId = new UUID("d97c99fd-9bcc-4f92-b9ea-b6be93abbbcd");
const itemId = toItemId("test")!;
const item = {
id: itemId,
description: HashString.fromValue("description"),
files: [],
termsAndConditions: [],
} as unknown as CollectionItem;
Expand Down
34 changes: 13 additions & 21 deletions src/loc/CollectionLocItemChecker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,12 @@ import CopyPasteButton from "../common/CopyPasteButton";
import { fullCollectionItemCertificate } from "../PublicPaths";

import "./CollectionLocItemChecker.css"
import StatementOfFactsButton from "./statement/StatementOfFactsButton";
import { toItemId } from './types';
import StatementOfFactsRequestButton from "./statement/StatementOfFactsRequestButton";
import { useUserLocContext } from "./UserLocContext";
import { useLocContext } from "./LocContext";
import { useLegalOfficerContext } from "src/legal-officer/LegalOfficerContext";
import PagedTable, { getPage, Page } from "src/components/pagedtable/PagedTable";
import Table, { ActionCell, Column, DateTimeCell, EmptyTableMessage } from "src/common/Table";
import Table, { ActionCell, Cell, Column, DateTimeCell, EmptyTableMessage } from "src/common/Table";
import ButtonGroup from "src/common/ButtonGroup";
import { useNavigate } from "react-router-dom";
import { dashboardCertificateRelativePath } from "src/RootPaths";
Expand Down Expand Up @@ -179,9 +177,18 @@ function CollectionLocItemChecker(props: LocalProps) {
render: item => <CellWithCopyPaste content={ item.id.toHex() } />,
align: "left",
},
{
header: "Description",
render: item => <Cell content={ item.description.validValue() } overflowing tooltipId={ `description-${ item.id.toHex() }` } />,
align: "left",
},
{
header: "Timestamp",
render: item => <DateTimeCell dateTime={ item.addedOn } />,
width: width({
onSmallScreen: "120px",
otherwise: "200px",
}),
},
{
header: "Certificate",
Expand All @@ -197,8 +204,8 @@ function CollectionLocItemChecker(props: LocalProps) {
</ActionCell>
),
width: width({
onSmallScreen: "100px",
otherwise: "300px",
onSmallScreen: "140px",
otherwise: "160px",
}),
},
{
Expand All @@ -211,25 +218,10 @@ function CollectionLocItemChecker(props: LocalProps) {
>
View
</Button>
{
(props.viewer === 'LegalOfficer' &&
<StatementOfFactsButton
item={ item }
/>
) ||
(props.viewer === 'User' &&
<StatementOfFactsRequestButton
itemId={ item.id }
/>
)
}
</ButtonGroup>
</ActionCell>
),
width: width({
onSmallScreen: "360px",
otherwise: "400px",
}),
width: "100px",
},
];

Expand Down
26 changes: 25 additions & 1 deletion src/loc/DashboardCertificate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ import FrameTitle from "src/components/frametitle/FrameTitle";

import "./DashboardCertificate.css";
import CheckFileFrame from "../components/checkfileframe/CheckFileFrame";
import StatementOfFactsButton from "./statement/StatementOfFactsButton";
import StatementOfFactsRequestButton from "./statement/StatementOfFactsRequestButton";
import Frame from "src/common/Frame";

export default function DashboardCertificate() {
const itemId = useParams<"itemId">().itemId;
Expand All @@ -27,7 +30,7 @@ export default function DashboardCertificate() {
const collectionItem = useMemo(() => collectionItems.find(item => item.id.toHex() === itemId), [ itemId, collectionItems ]);
const [ deliveries, setDeliveries ] = useState<ItemDeliveriesResponse>();
const { axiosFactory } = useLogionChain();
const { colorTheme } = useCommonContext();
const { colorTheme, viewer } = useCommonContext();
const [ checkCertifiedCopyResult, setCheckCertifiedCopyResult ] = useState<CheckCertifiedCopyResult>();
const [ checkHashResult, setCheckHashResult ] = useState<CheckHashResult>();

Expand Down Expand Up @@ -113,6 +116,27 @@ export default function DashboardCertificate() {
}
</>
}
<div className="frame-container">
<Frame
title={
<FrameTitle text="Statement of Facts"/>
}
border="2px solid #3B6CF4"
>
{
(viewer === 'LegalOfficer' &&
<StatementOfFactsButton
item={ collectionItem }
/>
) ||
(viewer === 'User' &&
<StatementOfFactsRequestButton
itemId={ collectionItem.id }
/>
)
}
</Frame>
</div>
</LocPane>
);
}
24 changes: 18 additions & 6 deletions src/loc/__snapshots__/CollectionLocItemChecker.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -149,19 +149,25 @@ Object {
</div>
<div
class="Col"
style="text-align: center;"
style="text-align: left;"
>
Description
</div>
<div
class="Col"
style="width: 200px; text-align: center;"
>
Timestamp
</div>
<div
class="Col"
style="width: 300px; text-align: center;"
style="width: 160px; text-align: center;"
>
Certificate
</div>
<div
class="Col"
style="width: 400px; text-align: center;"
style="width: 100px; text-align: center;"
/>
</div>
</div>
Expand Down Expand Up @@ -360,19 +366,25 @@ Object {
</div>
<div
class="Col"
style="text-align: center;"
style="text-align: left;"
>
Description
</div>
<div
class="Col"
style="width: 200px; text-align: center;"
>
Timestamp
</div>
<div
class="Col"
style="width: 300px; text-align: center;"
style="width: 160px; text-align: center;"
>
Certificate
</div>
<div
class="Col"
style="width: 400px; text-align: center;"
style="width: 100px; text-align: center;"
/>
</div>
</div>
Expand Down
53 changes: 53 additions & 0 deletions src/loc/__snapshots__/DashboardCertificate.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,58 @@ exports[`DashboardCertificate renders item 1`] = `
}
/>
</PolkadotFrame>
<div
className="frame-container"
>
<Frame
border="2px solid #3B6CF4"
title={
<FrameTitle
text="Statement of Facts"
/>
}
>
<StatementOfFactsRequestButton
itemId={
Hash {
"_bytes": Uint8Array [
154,
174,
187,
189,
63,
143,
230,
81,
184,
126,
131,
99,
4,
85,
167,
10,
67,
150,
76,
105,
145,
7,
123,
180,
80,
191,
26,
62,
210,
210,
92,
204,
],
}
}
/>
</Frame>
</div>
</LocPane>
`;

0 comments on commit 1958e9c

Please sign in to comment.