This commit is contained in:
Arkadiusz Wieczorek 2022-06-29 19:31:20 +02:00
parent 58c40efc79
commit 6e121234f1
2 changed files with 53 additions and 42 deletions

View File

@ -109,6 +109,11 @@ body {
} }
.about { .about {
&__no-errors {
text-align: center;
padding-bottom: 1.5rem;
}
p { p {
font-size: 0.875rem; font-size: 0.875rem;
font-weight: 700; font-weight: 700;

View File

@ -24,6 +24,10 @@ const Toolbar = () => {
null null
); );
const first_sentence_cookie = 'Strona dokonała zapisu i odczytu plików Cookie dla domen ';
const first_sentence_history =
'Część informacji o Twojej historii przeglądania została wysłana do ';
React.useEffect(() => { React.useEffect(() => {
const listener = async () => { const listener = async () => {
const tab = await getCurrentTab(); const tab = await getCurrentTab();
@ -51,29 +55,24 @@ const Toolbar = () => {
.filter((cluster) => cluster.exposesOrigin()) .filter((cluster) => cluster.exposesOrigin())
.map((cluster) => cluster.id); .map((cluster) => cluster.id);
setExposedOriginDomainCopy(''); setExposedOriginDomainCopy('');
const first_sentence = `Strona ${origin} wysłała informacje o części Twojej historii przeglądania do `;
switch (exposedOriginDomains.length) { switch (exposedOriginDomains.length) {
case 0: case 0:
return null; return null;
case 1: case 1:
return setExposedOriginDomainCopy(first_sentence + `${exposedOriginDomains[0]}.`); return setExposedOriginDomainCopy(`${exposedOriginDomains[0]}.`);
case 2: case 2:
return setExposedOriginDomainCopy( return setExposedOriginDomainCopy(
first_sentence + `${exposedOriginDomains[0]} oraz ${exposedOriginDomains[1]}.` `${exposedOriginDomains[0]} oraz ${exposedOriginDomains[1]}.`
); );
case 3: case 3:
return setExposedOriginDomainCopy( return setExposedOriginDomainCopy(
first_sentence +
`${exposedOriginDomains[0]}, ${exposedOriginDomains[1]} oraz ${exposedOriginDomains[2]}.` `${exposedOriginDomains[0]}, ${exposedOriginDomains[1]} oraz ${exposedOriginDomains[2]}.`
); );
default: default:
return setExposedOriginDomainCopy( return setExposedOriginDomainCopy(
first_sentence +
`${exposedOriginDomains[0]}, ${exposedOriginDomains[1]} (i ${ `${exposedOriginDomains[0]}, ${exposedOriginDomains[1]} (i ${
exposedOriginDomains.length - 2 < 2 exposedOriginDomains.length - 2 < 2 ? 2 : exposedOriginDomains.length - 2
? 2
: exposedOriginDomains.length - 2
} innych).` } innych).`
); );
} }
@ -84,25 +83,20 @@ const Toolbar = () => {
.filter((cluster) => cluster.hasCookies()) .filter((cluster) => cluster.hasCookies())
.map((cluster) => cluster.id); .map((cluster) => cluster.id);
setCookieDomainCopy(''); setCookieDomainCopy('');
const first_sentence = `Strona ${origin} dokonała zapisu i odczytu plików Cookie dla domen `;
switch (cookieDomains.length) { switch (cookieDomains.length) {
case 0: case 0:
return null; return null;
case 1: case 1:
return setCookieDomainCopy(first_sentence + `${cookieDomains[0]}.`); return setCookieDomainCopy(`${cookieDomains[0]}.`);
case 2: case 2:
return setCookieDomainCopy( return setCookieDomainCopy(`${cookieDomains[0]} oraz ${cookieDomains[1]}.`);
first_sentence + `${cookieDomains[0]} oraz ${cookieDomains[1]}.`
);
case 3: case 3:
return setCookieDomainCopy( return setCookieDomainCopy(
first_sentence +
`${cookieDomains[0]}, ${cookieDomains[1]} oraz ${cookieDomains[2]}.` `${cookieDomains[0]}, ${cookieDomains[1]} oraz ${cookieDomains[2]}.`
); );
default: default:
return setCookieDomainCopy( return setCookieDomainCopy(
first_sentence +
`${cookieDomains[0]}, ${cookieDomains[1]} (i ${ `${cookieDomains[0]}, ${cookieDomains[1]} (i ${
cookieDomains.length - 2 < 2 ? 2 : cookieDomains.length - 2 cookieDomains.length - 2 < 2 ? 2 : cookieDomains.length - 2
} innych).` } innych).`
@ -184,6 +178,7 @@ const Toolbar = () => {
</section> </section>
<section className="details"> <section className="details">
{exposedOriginDomainCopy ? (
<p <p
data-event={`${eventCounts['*']}`} data-event={`${eventCounts['*']}`}
title={Object.values(getMemory().getClustersForOrigin(origin)) title={Object.values(getMemory().getClustersForOrigin(origin))
@ -191,8 +186,11 @@ const Toolbar = () => {
.map((domain) => domain.id) .map((domain) => domain.id)
.join(', ')} .join(', ')}
> >
{exposedOriginDomainCopy} {first_sentence_cookie}
<strong>{exposedOriginDomainCopy}</strong>
</p> </p>
) : null}
{cookieDomainCopy ? (
<p <p
data-event={`${eventCounts['*']}`} data-event={`${eventCounts['*']}`}
title={Object.values(getMemory().getClustersForOrigin(origin)) title={Object.values(getMemory().getClustersForOrigin(origin))
@ -200,11 +198,13 @@ const Toolbar = () => {
.map((domain) => domain.id) .map((domain) => domain.id)
.join(', ')} .join(', ')}
> >
{cookieDomainCopy} {first_sentence_history}
<strong>{cookieDomainCopy}</strong>
</p> </p>
) : null}
</section> </section>
{exposedOriginDomainCopy !== null || cookieDomainCopy !== null ? ( {exposedOriginDomainCopy || cookieDomainCopy ? (
<Fragment> <Fragment>
<section className="about"> <section className="about">
<p> <p>
@ -229,7 +229,13 @@ const Toolbar = () => {
</button> </button>
</section> </section>
</Fragment> </Fragment>
) : null} ) : (
<Fragment>
<section className="about about__no-errors">
<p>Nie znaleziono problemów na tej stronie.</p>
</section>
</Fragment>
)}
</div> </div>
); );
}; };