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

PROD-2230: Fix table cell formatting for vendors #5013

Merged
merged 3 commits into from
Jun 20, 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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ The types of changes are:
- Fixed validations for privacy declaration taxonomy labels when creating/updating a System [#4982](https://github.com/ethyca/fides/pull/4982)
- Allow property-specific messaging to work with non-custom templates [#4986](https://github.com/ethyca/fides/pull/4986)
- Fixed an issue where config object was being passed twice to `fides.js` output [#5010](https://github.com/ethyca/fides/pull/5010)
- Disabling Fides initializtion now also disables GPP initialization [#5010](https://github.com/ethyca/fides/pull/5010)
- Disabling Fides initialization now also disables GPP initialization [#5010](https://github.com/ethyca/fides/pull/5010)
eastandwestwind marked this conversation as resolved.
Show resolved Hide resolved
- Fixes Vendor table formatting [#5013](https://github.com/ethyca/fides/pull/5013)

## [2.38.1](https://github.com/ethyca/fides/compare/2.38.0...2.38.1)

Expand Down
32 changes: 32 additions & 0 deletions clients/admin-ui/src/features/common/table/v2/cells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,38 @@ export const BadgeCell = ({
</BadgeCellContainer>
);

export const BadgeCellCount = ({
count,
singSuffix,
plSuffix,
...badgeProps
}: {
count: number;
singSuffix?: string;
plSuffix?: string;
} & BadgeProps) => {
// If count is 1, display count with singular suffix
let badge = null;
if (count === 1) {
badge = (
<FidesBadge {...badgeProps}>
{count}
{singSuffix ? ` ${singSuffix}` : null}
</FidesBadge>
);
}
// If count is 0 or > 1, display count with plural suffix
else {
badge = (
<FidesBadge {...badgeProps}>
{count}
{plSuffix ? ` ${plSuffix}` : null}
</FidesBadge>
);
}
return <BadgeCellContainer>{badge}</BadgeCellContainer>;
};

export const GroupCountBadgeCell = ({
value,
suffix,
Expand Down
1 change: 1 addition & 0 deletions clients/admin-ui/src/features/common/table/v2/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export {
BadgeCell,
BadgeCellCount,
DefaultCell,
DefaultHeaderCell,
GroupCountBadgeCell,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "@tanstack/react-table";
import { useFeatures } from "common/features";
import {
BadgeCell,
BadgeCellCount,
DefaultCell,
DefaultHeaderCell,
FidesTableV2,
Expand Down Expand Up @@ -163,33 +163,55 @@ export const ConsentManagementTable = () => {
columnHelper.accessor((row) => row.data_uses, {
id: "tcf_purpose",
cell: (props) => (
<BadgeCell suffix="purposes" value={props.getValue()} />
<BadgeCellCount
plSuffix="purposes"
singSuffix="purpose"
count={props.getValue()}
/>
),
header: (props) => <DefaultHeaderCell value="TCF purpose" {...props} />,
}),
columnHelper.accessor((row) => row.data_uses, {
id: "data_uses",
cell: (props) => (
<BadgeCell suffix="data uses" value={props.getValue()} />
<BadgeCellCount
plSuffix="data uses"
singSuffix="data use"
count={props.getValue()}
/>
),
header: (props) => <DefaultHeaderCell value="Data use" {...props} />,
}),
columnHelper.accessor((row) => row.legal_bases, {
id: "legal_bases",
cell: (props) => <BadgeCell suffix="bases" value={props.getValue()} />,
cell: (props) => (
<BadgeCellCount
plSuffix="bases"
singSuffix="basis"
count={props.getValue()}
/>
),
header: (props) => <DefaultHeaderCell value="Legal basis" {...props} />,
}),
columnHelper.accessor((row) => row.consent_categories, {
id: "consent_categories",
cell: (props) => (
<BadgeCell suffix="Categories" value={props.getValue()} />
<BadgeCellCount
plSuffix="categories"
singSuffix="category"
count={props.getValue()}
/>
),
header: (props) => <DefaultHeaderCell value="Categories" {...props} />,
}),
columnHelper.accessor((row) => row.cookies, {
id: "cookies",
cell: (props) => (
<BadgeCell suffix="Cookies" value={props.getValue()} />
<BadgeCellCount
plSuffix="cookies"
singSuffix="cookie"
count={props.getValue()}
/>
),
header: (props) => <DefaultHeaderCell value="Cookies" {...props} />,
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,7 @@ export const DatamapReportTable = () => {
id: COLUMN_IDS.RESPONSIBILITY,
cell: (props) => (
<GroupCountBadgeCell
suffix="responsibilitlies"
suffix="responsibilities"
value={props.getValue()}
{...props}
/>
Expand Down
Loading