mirror of
https://github.com/XFox111/TabsAsideExtension.git
synced 2026-04-22 07:58:01 +03:00
e21022d985
* Some features are now optional (#148) * fix(dev): yarn.lock tree fix * feat: bookmarks moved to optional permissions * fix: analytics not working in firefox * feat!: ability to turn off analytics (uses permissions on firefox) * feat: analytics tracker for bookmark export * feat: add privacy policy link in about section * docs: privacy policy update * feat: ability to chain multiple dialogs * fix(loc): analytics option translation * feat: settings review dialog * fix: background script fails to load because of frontend code * chore: use analytics permission as storage value * fix: inverted analytics value * feat!: option to disable thumbnail capture * fix(ci): sed typo * fix: minor fixes * fix(firefox): web-ext lint error fix * chore(ci): switch web-ext action * chore(lint): fix eslint warnings * chore(deps): monthly dependency bump (September 2025) (#149) * chore: 3.1.0 version bump * chore: minor cleanup * fix: allow analytics checkbox stays inactive after denying permission on firefox * fix(deps): yarn.lock rebuild * fix: type assertion for userId * fix: settings review dialog not showing if welcome dialog is not required * fix: analytics and thumbnail capture toggles react incorrectly if permission is denied
133 lines
4.3 KiB
TypeScript
133 lines
4.3 KiB
TypeScript
import { githubLinks } from "@/data/links";
|
|
import { analyticsPermission } from "@/features/analytics";
|
|
import extLink from "@/utils/extLink";
|
|
import * as fui from "@fluentui/react-components";
|
|
import { settingsForReview } from "../utils/showSettingsReviewDialog";
|
|
import { reviewSettings } from "../utils/setSettingsReviewNeeded";
|
|
import { Unwatch } from "wxt/storage";
|
|
import { thumbnailCaptureEnabled } from "@/features/collectionStorage";
|
|
|
|
export default function SettingsReviewDialog(): React.ReactElement
|
|
{
|
|
const [allowAnalytics, setAllowAnalytics] = useState<boolean | null>(null);
|
|
const [captureThumbnails, setCaptureThumbnails] = useState<boolean | null>(null);
|
|
const [needsReview, setNeedsReview] = useState<string[]>([]);
|
|
const cls = useStyles();
|
|
|
|
useEffect(() =>
|
|
{
|
|
analyticsPermission.getValue().then(setAllowAnalytics);
|
|
thumbnailCaptureEnabled.getValue().then(setCaptureThumbnails);
|
|
settingsForReview.getValue().then(setNeedsReview);
|
|
|
|
const unwatchAnalytics: Unwatch = analyticsPermission.watch(setAllowAnalytics);
|
|
const unwatchThumbnails: Unwatch = thumbnailCaptureEnabled.watch(setCaptureThumbnails);
|
|
|
|
return () =>
|
|
{
|
|
unwatchAnalytics();
|
|
unwatchThumbnails();
|
|
};
|
|
}, []);
|
|
|
|
const updateAnalytics = (enabled: boolean): void =>
|
|
{
|
|
setAllowAnalytics(null);
|
|
analyticsPermission.setValue(enabled)
|
|
.catch(() => setAllowAnalytics(!enabled));
|
|
};
|
|
|
|
const updateThumbnails = (enabled: boolean): void =>
|
|
{
|
|
setCaptureThumbnails(null);
|
|
thumbnailCaptureEnabled.setValue(enabled)
|
|
.catch(() => setCaptureThumbnails(!enabled));
|
|
};
|
|
|
|
return (
|
|
<fui.DialogSurface>
|
|
<fui.DialogBody>
|
|
<fui.DialogTitle>{ i18n.t("features.settingsReview.title") }</fui.DialogTitle>
|
|
<fui.DialogContent className={ cls.content }>
|
|
{ needsReview.includes(reviewSettings.THUMBNAILS) &&
|
|
<div className={ cls.section }>
|
|
<fui.Switch
|
|
label={ i18n.t("options_page.storage.thumbnail_capture") }
|
|
checked={ captureThumbnails ?? true }
|
|
disabled={ captureThumbnails === null }
|
|
onChange={ (_, e) => updateThumbnails(e.checked as boolean) } />
|
|
|
|
<fui.MessageBar layout="multiline">
|
|
<fui.MessageBarBody className={ cls.msgBarBody }>
|
|
<fui.MessageBarTitle>
|
|
{ i18n.t("options_page.storage.thumbnail_capture_notice1") }
|
|
</fui.MessageBarTitle>
|
|
<fui.Text as="p">
|
|
{ i18n.t("options_page.storage.thumbnail_capture_notice2") }
|
|
</fui.Text>
|
|
</fui.MessageBarBody>
|
|
</fui.MessageBar>
|
|
</div>
|
|
}
|
|
{ needsReview.includes(reviewSettings.ANALYTICS) &&
|
|
<div className={ cls.section }>
|
|
<fui.Switch
|
|
label={ i18n.t("options_page.general.options.allow_analytics") }
|
|
checked={ allowAnalytics ?? true }
|
|
disabled={ allowAnalytics === null }
|
|
onChange={ (_, e) => updateAnalytics(e.checked as boolean) } />
|
|
|
|
<fui.MessageBar layout="multiline">
|
|
<fui.MessageBarBody className={ cls.msgBarBody }>
|
|
<fui.MessageBarTitle>
|
|
{ i18n.t("features.settingsReview.analytics.title") }
|
|
</fui.MessageBarTitle>
|
|
<fui.Text as="p">
|
|
{ i18n.t("features.settingsReview.analytics.p1") }
|
|
</fui.Text>
|
|
<fui.Text as="p" weight="semibold">
|
|
{ i18n.t("features.settingsReview.analytics.p2") }
|
|
</fui.Text>
|
|
<fui.Text as="p">
|
|
{ i18n.t("features.settingsReview.analytics.p3_text") } <fui.Link { ...extLink(githubLinks.privacy) }>{ i18n.t("features.settingsReview.analytics.p3_link") }</fui.Link>.
|
|
</fui.Text>
|
|
</fui.MessageBarBody>
|
|
</fui.MessageBar>
|
|
</div>
|
|
}
|
|
</fui.DialogContent>
|
|
<fui.DialogActions>
|
|
<fui.Button onClick={ () => browser.runtime.openOptionsPage() }>
|
|
{ i18n.t("features.settingsReview.action") }
|
|
</fui.Button>
|
|
<fui.DialogTrigger>
|
|
<fui.Button appearance="primary">{ i18n.t("common.actions.save") }</fui.Button>
|
|
</fui.DialogTrigger>
|
|
</fui.DialogActions>
|
|
</fui.DialogBody>
|
|
</fui.DialogSurface>
|
|
);
|
|
}
|
|
|
|
const useStyles = fui.makeStyles({
|
|
content:
|
|
{
|
|
display: "flex",
|
|
flexFlow: "column",
|
|
gap: fui.tokens.spacingVerticalL
|
|
},
|
|
section:
|
|
{
|
|
display: "flex",
|
|
flexFlow: "column",
|
|
gap: fui.tokens.spacingVerticalXS
|
|
},
|
|
msgBarBody:
|
|
{
|
|
display: "flex",
|
|
flexFlow: "column",
|
|
gap: fui.tokens.spacingVerticalXS,
|
|
marginBottom: fui.tokens.spacingVerticalXS
|
|
}
|
|
});
|