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,30 +55,25 @@ 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 ? 2 : exposedOriginDomains.length - 2
exposedOriginDomains.length - 2 < 2 } innych).`
? 2
: exposedOriginDomains.length - 2
} innych).`
); );
} }
}, [eventCounts['*'], origin]); }, [eventCounts['*'], origin]);
@ -84,28 +83,23 @@ 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).`
); );
} }
}, [eventCounts['*'], origin]); }, [eventCounts['*'], origin]);
@ -184,27 +178,33 @@ const Toolbar = () => {
</section> </section>
<section className="details"> <section className="details">
<p {exposedOriginDomainCopy ? (
data-event={`${eventCounts['*']}`} <p
title={Object.values(getMemory().getClustersForOrigin(origin)) data-event={`${eventCounts['*']}`}
.filter((cluster) => cluster.exposesOrigin()) title={Object.values(getMemory().getClustersForOrigin(origin))
.map((domain) => domain.id) .filter((cluster) => cluster.exposesOrigin())
.join(', ')} .map((domain) => domain.id)
> .join(', ')}
{exposedOriginDomainCopy} >
</p> {first_sentence_cookie}
<p <strong>{exposedOriginDomainCopy}</strong>
data-event={`${eventCounts['*']}`} </p>
title={Object.values(getMemory().getClustersForOrigin(origin)) ) : null}
.filter((cluster) => cluster.hasCookies()) {cookieDomainCopy ? (
.map((domain) => domain.id) <p
.join(', ')} data-event={`${eventCounts['*']}`}
> title={Object.values(getMemory().getClustersForOrigin(origin))
{cookieDomainCopy} .filter((cluster) => cluster.hasCookies())
</p> .map((domain) => domain.id)
.join(', ')}
>
{first_sentence_history}
<strong>{cookieDomainCopy}</strong>
</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>
); );
}; };