-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #519 from GoogleChromeLabs/ref/service-worker-prov…
…ider Refactor: Extension UI and Service Worker.
- Loading branch information
Showing
85 changed files
with
2,661 additions
and
1,402 deletions.
There are no files selected for viewing
91 changes: 91 additions & 0 deletions
91
...s/siteReport/tabs/cookies/cookiesLandingContainer/cookieLanding/blockedCookiesSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
/** | ||
* External dependencies | ||
*/ | ||
import React from 'react'; | ||
import { | ||
CookiesLandingContainer, | ||
CookiesMatrix, | ||
MessageBox, | ||
prepareCookieStatsComponents, | ||
prepareCookiesCount, | ||
type DataMapping, | ||
} from '@ps-analysis-tool/design-system'; | ||
import type { TabCookies, TabFrames } from '@ps-analysis-tool/common'; | ||
|
||
interface BlockedCookiesSectionProps { | ||
tabCookies: TabCookies | null; | ||
affectedCookies: TabCookies | null; | ||
tabFrames: TabFrames | null; | ||
} | ||
const BlockedCookiesSection = ({ | ||
tabCookies, | ||
affectedCookies, | ||
tabFrames, | ||
}: BlockedCookiesSectionProps) => { | ||
const cookiesStats = prepareCookiesCount(tabCookies); | ||
|
||
const cookiesStatsComponents = prepareCookieStatsComponents(cookiesStats); | ||
|
||
const cookieBlockedDataMapping: DataMapping[] = [ | ||
{ | ||
title: 'Blocked cookies', | ||
count: cookiesStats.blockedCookies.total, | ||
data: cookiesStatsComponents.blocked, | ||
}, | ||
]; | ||
|
||
const blockedCookieStats = prepareCookiesCount(affectedCookies); | ||
const blockedCookiesStatsComponents = | ||
prepareCookieStatsComponents(blockedCookieStats); | ||
|
||
return ( | ||
<CookiesLandingContainer | ||
dataMapping={cookieBlockedDataMapping} | ||
testId="blocked-cookies-insights" | ||
> | ||
{!cookiesStats || | ||
(cookiesStats?.firstParty.total === 0 && | ||
cookiesStats?.thirdParty.total === 0 && ( | ||
<MessageBox | ||
headerText="No cookies found on this page" | ||
bodyText="Please try reloading the page" | ||
/> | ||
))} | ||
<CookiesMatrix | ||
tabCookies={affectedCookies} | ||
componentData={cookiesStatsComponents.blockedCookiesLegend} | ||
tabFrames={tabFrames} | ||
description="" | ||
infoIconTitle="Cookies that have been blocked by the browser.(The total count might not be same as cumulative reason count because cookie might be blocked due to more than 1 reason)." | ||
showInfoIcon={true} | ||
showHorizontalMatrix={false} | ||
allowExpand={true} | ||
/> | ||
<CookiesMatrix | ||
tabCookies={affectedCookies} | ||
componentData={blockedCookiesStatsComponents.legend} | ||
tabFrames={tabFrames} | ||
description="" | ||
showInfoIcon={false} | ||
showHorizontalMatrix={false} | ||
allowExpand={false} | ||
/> | ||
</CookiesLandingContainer> | ||
); | ||
}; | ||
export default BlockedCookiesSection; |
70 changes: 70 additions & 0 deletions
70
...mponents/siteReport/tabs/cookies/cookiesLandingContainer/cookieLanding/cookiesSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
/** | ||
* External dependencies | ||
*/ | ||
import React from 'react'; | ||
import { | ||
CookiesLandingContainer, | ||
CookiesMatrix, | ||
MessageBox, | ||
prepareCookieDataMapping, | ||
prepareCookieStatsComponents, | ||
prepareCookiesCount, | ||
} from '@ps-analysis-tool/design-system'; | ||
import type { TabCookies, TabFrames } from '@ps-analysis-tool/common'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
|
||
interface CookiesSectionProps { | ||
tabCookies: TabCookies | null; | ||
tabFrames: TabFrames | null; | ||
} | ||
const CookiesSection = ({ tabCookies, tabFrames }: CookiesSectionProps) => { | ||
const cookieStats = prepareCookiesCount(tabCookies); | ||
const cookiesStatsComponents = prepareCookieStatsComponents(cookieStats); | ||
const cookieClassificationDataMapping = prepareCookieDataMapping( | ||
cookieStats, | ||
cookiesStatsComponents | ||
); | ||
|
||
return ( | ||
<CookiesLandingContainer | ||
dataMapping={cookieClassificationDataMapping} | ||
testId="cookies-insights" | ||
> | ||
{!cookieStats || | ||
(cookieStats?.firstParty.total === 0 && | ||
cookieStats?.thirdParty.total === 0 && ( | ||
<MessageBox | ||
headerText="No cookies found on this page" | ||
bodyText="Please try reloading the page" | ||
/> | ||
))} | ||
<CookiesMatrix | ||
tabCookies={tabCookies} | ||
componentData={cookiesStatsComponents.legend} | ||
tabFrames={tabFrames} | ||
description="" | ||
showInfoIcon={true} | ||
showHorizontalMatrix={false} | ||
allowExpand={true} | ||
/> | ||
</CookiesLandingContainer> | ||
); | ||
}; | ||
export default CookiesSection; |
17 changes: 17 additions & 0 deletions
17
...ard/src/components/siteReport/tabs/cookies/cookiesLandingContainer/cookieLanding/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
export { default as CookiesSection } from './cookiesSection'; | ||
export { default as BlockedCookiesSection } from './blockedCookiesSection'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.