Skip to content

Commit

Permalink
Hiding privacy request source data behind plus flag
Browse files Browse the repository at this point in the history
  • Loading branch information
galvana committed Aug 16, 2024
1 parent 146df41 commit 9066caf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {

import ClipboardButton from "~/features/common/ClipboardButton";
import DaysLeftTag from "~/features/common/DaysLeftTag";
import { useFeatures } from "~/features/common/features";
import RequestStatusBadge from "~/features/common/RequestStatusBadge";
import RequestType from "~/features/common/RequestType";
import { PrivacyRequestEntity } from "~/features/privacy-requests/types";
Expand All @@ -25,6 +26,7 @@ type RequestDetailsProps = {
};

const RequestDetails = ({ subjectRequest }: RequestDetailsProps) => {
const { plus: hasPlus } = useFeatures();
const { id, status, policy } = subjectRequest;

return (
Expand Down Expand Up @@ -55,7 +57,7 @@ const RequestDetails = ({ subjectRequest }: RequestDetailsProps) => {
</Text>
<ClipboardButton copyText={id} />
</Flex>
{subjectRequest.source && (
{hasPlus && subjectRequest.source && (
<Flex>
<Text mb={4} mr={2} fontSize="sm" color="gray.900" fontWeight="500">
Source:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { useMemo, useState } from "react";
import { useDispatch, useSelector } from "react-redux";

import { selectToken } from "~/features/auth";
import { useFeatures } from "~/features/common/features";
import { DownloadLightIcon } from "~/features/common/Icon";
import {
FidesTableV2,
Expand All @@ -43,6 +44,7 @@ import { RequestTableFilterModal } from "~/features/privacy-requests/RequestTabl
import { PrivacyRequestEntity } from "~/features/privacy-requests/types";

export const RequestTable = ({ ...props }: BoxProps): JSX.Element => {
const { plus: hasPlus } = useFeatures();
const [requestIdFilter, setRequestIdFilter] = useState<string>();
const [revealPII, setRevealPII] = useState<boolean>(false);
const filters = useSelector(selectPrivacyRequestFilters);
Expand Down Expand Up @@ -124,7 +126,10 @@ export const RequestTable = ({ ...props }: BoxProps): JSX.Element => {
const tableInstance = useReactTable<PrivacyRequestEntity>({
getCoreRowModel: getCoreRowModel(),
data: requests,
columns: useMemo(() => getRequestTableColumns(revealPII), [revealPII]),
columns: useMemo(
() => getRequestTableColumns(revealPII, hasPlus),
[revealPII, hasPlus],
),
getRowId: (row) => `${row.status}-${row.id}`,
manualPagination: true,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ enum COLUMN_IDS {

const columnHelper = createColumnHelper<PrivacyRequestEntity>();

export const getRequestTableColumns = (revealPII = false) => [
export const getRequestTableColumns = (revealPII = false, hasPlus = false) => [
columnHelper.accessor((row) => row.status, {
id: COLUMN_IDS.STATUS,
cell: ({ getValue }) => <RequestStatusBadgeCell value={getValue()} />,
Expand All @@ -47,17 +47,21 @@ export const getRequestTableColumns = (revealPII = false) => [
),
header: (props) => <DefaultHeaderCell value="Days left" {...props} />,
}),
columnHelper.accessor((row) => row.source, {
id: COLUMN_IDS.SOURCE,
cell: (props) =>
props.getValue() ? (
<BadgeCell value={props.getValue()!} />
) : (
<DefaultCell value={undefined} />
),
header: (props) => <DefaultHeaderCell value="Source" {...props} />,
enableSorting: false,
}),
...(hasPlus
? [
columnHelper.accessor((row) => row.source, {
id: COLUMN_IDS.SOURCE,
cell: (props) =>
props.getValue() ? (
<BadgeCell value={props.getValue()!} />
) : (
<DefaultCell value={undefined} />
),
header: (props) => <DefaultHeaderCell value="Source" {...props} />,
enableSorting: false,
}),
]
: []),
columnHelper.accessor((row) => row.policy.rules, {
id: COLUMN_IDS.REQUEST_TYPE,
cell: ({ getValue }) => <RequestActionTypeCell value={getValue()} />,
Expand Down

0 comments on commit 9066caf

Please sign in to comment.