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

Refactor: Rename column cookie affected column to issues #580

Merged
merged 3 commits into from
Apr 2, 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
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,28 @@ import { type CookieTableData } from '@ps-analysis-tool/common';
/**
* Internal dependencies.
*/
import useCookieListing from '../../hooks/useCookieListing.tsx';
import useCookieListing from '../../hooks/useCookieListing';

interface AffectedCookiesProps {
interface CookiesWithIssuesProps {
cookies: CookieTableData[];
selectedSite: string | null;
}

const AffectedCookies = ({ cookies, selectedSite }: AffectedCookiesProps) => {
const CookiesWithIssues = ({
cookies,
selectedSite,
}: CookiesWithIssuesProps) => {
const [selectedFrameCookie, setSelectedFrameCookie] = useState<{
[frame: string]: CookieTableData | null;
} | null>(null);

const { tableColumns, filters, searchKeys, tablePersistentSettingsKey } =
useCookieListing(cookies, 'frame', 'affectedCookiesListing', selectedSite);
useCookieListing(
cookies,
'frame',
'cookiesWithIssuesListing',
selectedSite
);

return (
<div className="w-full h-full flex flex-col">
Expand All @@ -58,7 +66,7 @@ const AffectedCookies = ({ cookies, selectedSite }: AffectedCookiesProps) => {
className="h-full flex"
>
<CookieTable
data={cookies.map((cookie) => ({ ...cookie, isBlocked: undefined }))} // Hot Fix: To unhighlight cookies in the Affected Cookie table.
data={cookies.map((cookie) => ({ ...cookie, isBlocked: undefined }))} // Hot Fix: To unhighlight cookies in the Cookies with issues table.
tableColumns={tableColumns}
tableFilters={filters}
tableSearchKeys={searchKeys}
Expand All @@ -77,4 +85,4 @@ const AffectedCookies = ({ cookies, selectedSite }: AffectedCookiesProps) => {
);
};

export default AffectedCookies;
export default CookiesWithIssues;
12 changes: 6 additions & 6 deletions packages/cli-dashboard/src/components/siteMapReport/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
* Internal dependencies.
*/
import SiteReport from '../siteReport';
import SiteMapAffectedCookies from './sitemapAffectedCookies';
import SiteMapCookiesWithIssues from './sitemapCookiesWithIssues';
import CookiesLandingContainer from '../siteReport/tabs/cookies/cookiesLandingContainer';
import reshapeCookies from '../utils/reshapeCookies';
import sidebarData from './sidebarData';
Expand Down Expand Up @@ -85,7 +85,7 @@ const SiteMapReport = ({
[landingPageCookies]
);

const affectedCookies = useMemo(
const cookiesWithIssues = useMemo(
() =>
Object.fromEntries(
Object.entries(reshapedCookies).filter(([, cookie]) => cookie.isBlocked)
Expand Down Expand Up @@ -135,7 +135,7 @@ const SiteMapReport = ({
<CookiesLandingContainer
tabCookies={reshapedCookies}
tabFrames={frames}
affectedCookies={affectedCookies}
cookiesWithIssues={cookiesWithIssues}
downloadReport={() => {
if (!Array.isArray(completeJson)) {
return;
Expand Down Expand Up @@ -168,8 +168,8 @@ const SiteMapReport = ({
{}
);

_data['sitemap-affected-cookies'].panel = (
<SiteMapAffectedCookies
_data['sitemap-cookies-with-issues'].panel = (
<SiteMapCookiesWithIssues
cookies={Object.values(reshapedCookies).filter(
(cookie) => cookie.isBlocked
)}
Expand All @@ -179,7 +179,7 @@ const SiteMapReport = ({
return _data;
});
}, [
affectedCookies,
cookiesWithIssues,
completeJson,
frames,
isKeySelected,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const sidebarData: SidebarItems = {
title: 'Sitemap Report',
children: {},
},
'sitemap-affected-cookies': {
title: 'Affected Cookies',
'sitemap-cookies-with-issues': {
title: 'Cookies With Issues',
children: {},
icon: <CookieIcon />,
selectedIcon: <CookieIconWhite />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ import type { CookieTableData } from '@ps-analysis-tool/common';
/**
* Internal dependencies.
*/
import AffectedCookies from '../affectedCookies';
import CookiesWithIssues from '../cookiesWithIssues';

interface SiteMapAffectedCookiesProps {
interface SiteMapCookiesWithIssuesProps {
cookies: CookieTableData[];
}

const SiteMapAffectedCookies = ({ cookies }: SiteMapAffectedCookiesProps) => {
return <AffectedCookies cookies={cookies} selectedSite={null} />;
const SiteMapCookiesWithIssues = ({
cookies,
}: SiteMapCookiesWithIssuesProps) => {
return <CookiesWithIssues cookies={cookies} selectedSite={null} />;
};

export default SiteMapAffectedCookies;
export default SiteMapCookiesWithIssues;
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { useContentStore } from '../stateProviders/contentStore';
import { UNKNOWN_FRAME_KEY } from '@ps-analysis-tool/common';
import TABS from '../tabs';
import CookiesTab from '../tabs/cookies';
import SiteAffectedCookies from '../tabs/siteAffectedCookies';
import SiteCookiesWithIssues from '../tabs/siteCookiesWithIssues';
import Technologies from '../tabs/technologies';

interface LayoutProps {
Expand Down Expand Up @@ -112,8 +112,8 @@ const Layout = ({ selectedSite }: LayoutProps) => {
{}
);

_data['affected-cookies'].panel = (
<SiteAffectedCookies selectedSite={selectedSite} />
_data['cookies-with-issues'].panel = (
<SiteCookiesWithIssues selectedSite={selectedSite} />
);

if (technologies && technologies.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ import type { TabCookies, TabFrames } from '@ps-analysis-tool/common';

interface BlockedCookiesSectionProps {
tabCookies: TabCookies | null;
affectedCookies: TabCookies | null;
cookiesWithIssues: TabCookies | null;
tabFrames: TabFrames | null;
}
const BlockedCookiesSection = ({
tabCookies,
affectedCookies,
cookiesWithIssues,
tabFrames,
}: BlockedCookiesSectionProps) => {
const cookiesStats = prepareCookiesCount(tabCookies);
Expand All @@ -49,7 +49,7 @@ const BlockedCookiesSection = ({
},
];

const blockedCookieStats = prepareCookiesCount(affectedCookies);
const blockedCookieStats = prepareCookiesCount(cookiesWithIssues);
const blockedCookiesStatsComponents =
prepareCookieStatsComponents(blockedCookieStats);

Expand All @@ -67,7 +67,7 @@ const BlockedCookiesSection = ({
/>
))}
<CookiesMatrix
tabCookies={affectedCookies}
tabCookies={cookiesWithIssues}
componentData={cookiesStatsComponents.blockedCookiesLegend}
tabFrames={tabFrames}
description=""
Expand All @@ -77,7 +77,7 @@ const BlockedCookiesSection = ({
allowExpand={true}
/>
<CookiesMatrix
tabCookies={affectedCookies}
tabCookies={cookiesWithIssues}
componentData={blockedCookiesStatsComponents.legend}
tabFrames={tabFrames}
description=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ import { CookiesSection, BlockedCookiesSection } from './cookieLanding';
interface CookiesLandingContainerProps {
tabFrames: TabFrames;
tabCookies: TabCookies;
affectedCookies: TabCookies;
cookiesWithIssues: TabCookies;
downloadReport?: () => void;
}

const CookiesLandingContainer = ({
tabFrames,
tabCookies,
affectedCookies,
cookiesWithIssues,
downloadReport,
}: CookiesLandingContainerProps) => {
return (
Expand All @@ -53,7 +53,7 @@ const CookiesLandingContainer = ({
<CookiesSection tabCookies={tabCookies} tabFrames={tabFrames} />
<BlockedCookiesSection
tabCookies={tabCookies}
affectedCookies={affectedCookies}
cookiesWithIssues={cookiesWithIssues}
tabFrames={tabFrames}
/>
</CookiesLanding>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import type { CookieTableData } from '@ps-analysis-tool/common';
/**
* Internal dependencies
*/
import useCookieListing from '../../../../../hooks/useCookieListing.tsx';
import useCookieListing from '../../../../../hooks/useCookieListing';
import { useContentStore } from '../../../stateProviders/contentStore';

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const CookiesTab = ({ selectedFrameUrl, selectedSite }: CookiesTabProps) => {
[tabCookies]
);

const affectedCookies = useMemo(
const cookiesWithIssues = useMemo(
() =>
Object.fromEntries(
Object.entries(tabCookies).filter(([, cookie]) => cookie.isBlocked)
Expand Down Expand Up @@ -78,7 +78,7 @@ const CookiesTab = ({ selectedFrameUrl, selectedSite }: CookiesTabProps) => {
<CookiesLandingContainer
tabFrames={tabFrames}
tabCookies={tabCookies}
affectedCookies={affectedCookies}
cookiesWithIssues={cookiesWithIssues}
downloadReport={downloadReport}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ const Tabs: SidebarItems = {
icon: <CookieIcon />,
selectedIcon: <CookieIconWhite />,
},
'affected-cookies': {
title: 'Affected Cookies',
'cookies-with-issues': {
title: 'Cookies With Issues',
children: {},
icon: <CookieIcon />,
selectedIcon: <CookieIconWhite />,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,23 @@ import React from 'react';
/**
* Internal dependencies
*/
import AffectedCookies from '../../../affectedCookies';
import CookiesWithIssues from '../../../cookiesWithIssues';
import { useContentStore } from '../../stateProviders/contentStore';

interface SiteAffectedCookiesProps {
interface SiteCookiesWithIssuesProps {
selectedSite: string | null;
}

const SiteAffectedCookies = ({ selectedSite }: SiteAffectedCookiesProps) => {
const SiteCookiesWithIssues = ({
selectedSite,
}: SiteCookiesWithIssuesProps) => {
const { tabCookies } = useContentStore(({ state }) => ({
tabCookies: Object.values(state.tabCookies).filter(
(cookie) => cookie.isBlocked
),
}));

return <AffectedCookies cookies={tabCookies} selectedSite={selectedSite} />;
return <CookiesWithIssues cookies={tabCookies} selectedSite={selectedSite} />;
};

export default SiteAffectedCookies;
export default SiteCookiesWithIssues;
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
import type JSZip from 'jszip';
import {
generateAffectedCookiesCSV,
generateCookiesWithIssuesCSV,
generateAllCookiesCSV,
generateSummaryDataCSV,
generateTechnologyCSV,
Expand All @@ -32,13 +32,13 @@ const generateCSVFiles = (data: CompleteJson) => {
if (data.technologyData.length > 0) {
technologyDataCSV = generateTechnologyCSV(data);
}
const affectedCookiesDataCSV = generateAffectedCookiesCSV(data);
const cookiesWithIssuesDataCSV = generateCookiesWithIssuesCSV(data);
const summaryDataCSV = generateSummaryDataCSV(data);

return {
allCookiesCSV,
technologyDataCSV,
affectedCookiesDataCSV,
cookiesWithIssuesDataCSV,
summaryDataCSV,
};
};
Expand All @@ -47,15 +47,15 @@ export const createZip = (analysisData: CompleteJson, zipObject: JSZip) => {
const {
allCookiesCSV,
technologyDataCSV,
affectedCookiesDataCSV,
cookiesWithIssuesDataCSV,
summaryDataCSV,
} = generateCSVFiles(analysisData);

zipObject.file('cookies.csv', allCookiesCSV);
if (technologyDataCSV) {
zipObject.file('technologies.csv', technologyDataCSV);
}
zipObject.file('affected-cookies.csv', affectedCookiesDataCSV);
zipObject.file('cookies-with-issues.csv', cookiesWithIssuesDataCSV);
zipObject.file('report.csv', summaryDataCSV);
zipObject.file('report.json', JSON.stringify(analysisData, null, 4));
};
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/utils/generateCSVfiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
import {
CompleteJson,
generateAffectedCookiesCSV,
generateCookiesWithIssuesCSV,
generateAllCookiesCSV,
generateSummaryDataCSV,
generateTechnologyCSV,
Expand All @@ -30,13 +30,13 @@ const generateCSVFiles = (data: CompleteJson) => {
if (data.technologyData.length > 0) {
technologyDataCSV = generateTechnologyCSV(data);
}
const affectedCookiesDataCSV = generateAffectedCookiesCSV(data);
const cookiesWithIssuesDataCSV = generateCookiesWithIssuesCSV(data);
const summaryDataCSV = generateSummaryDataCSV(data);

return {
allCookiesCSV,
technologyDataCSV,
affectedCookiesDataCSV,
cookiesWithIssuesDataCSV,
summaryDataCSV,
};
};
Expand Down
16 changes: 8 additions & 8 deletions packages/cli/src/utils/saveCSVReports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const saveCSVReports = async (outDir: string, result: CompleteJson[]) => {
const {
allCookiesCSV,
technologyDataCSV,
affectedCookiesDataCSV,
cookiesWithIssuesDataCSV,
summaryDataCSV,
} = generateCSVFiles(siteReport);

Expand All @@ -64,10 +64,10 @@ const saveCSVReports = async (outDir: string, result: CompleteJson[]) => {
);
}

await ensureFile(path.join(fileDir, 'affected-cookies.csv'));
await ensureFile(path.join(fileDir, 'cookies-with-issues.csv'));
await writeFile(
path.join(fileDir, 'affected-cookies.csv'),
affectedCookiesDataCSV
path.join(fileDir, 'cookies-with-issues.csv'),
cookiesWithIssuesDataCSV
);

await ensureFile(path.join(fileDir, 'report.csv'));
Expand All @@ -79,7 +79,7 @@ const saveCSVReports = async (outDir: string, result: CompleteJson[]) => {
const {
allCookiesCSV,
technologyDataCSV,
affectedCookiesDataCSV,
cookiesWithIssuesDataCSV,
summaryDataCSV,
} = generateCSVFiles(result[0]);
await ensureFile(path.join(outDir, 'cookies.csv'));
Expand All @@ -90,10 +90,10 @@ const saveCSVReports = async (outDir: string, result: CompleteJson[]) => {
await writeFile(path.join(outDir, 'technologies.csv'), technologyDataCSV);
}

await ensureFile(path.join(outDir, 'affected-cookies.csv'));
await ensureFile(path.join(outDir, 'cookies-with-issues.csv'));
await writeFile(
path.join(outDir, 'affected-cookies.csv'),
affectedCookiesDataCSV
path.join(outDir, 'cookies-with-issues.csv'),
cookiesWithIssuesDataCSV
);

await ensureFile(path.join(outDir, 'report.csv'));
Expand Down
Loading
Loading