From c9048198d9739689f7c0ecb11130263665bf30ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Sat, 18 Oct 2025 17:08:59 +0200 Subject: [PATCH] pl-fe: Rename Privacy page before adding non-URL related stuff MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- packages/pl-fe/src/features/ui/index.tsx | 5 +- .../src/features/ui/util/async-components.ts | 2 +- packages/pl-fe/src/locales/en.json | 1 + .../pl-fe/src/pages/settings/settings.tsx | 4 +- .../pl-fe/src/pages/settings/url-privacy.tsx | 213 ------------------ 5 files changed, 7 insertions(+), 218 deletions(-) delete mode 100644 packages/pl-fe/src/pages/settings/url-privacy.tsx diff --git a/packages/pl-fe/src/features/ui/index.tsx b/packages/pl-fe/src/features/ui/index.tsx index 4c0d25778..dcaff44a8 100644 --- a/packages/pl-fe/src/features/ui/index.tsx +++ b/packages/pl-fe/src/features/ui/index.tsx @@ -148,7 +148,7 @@ import { StatusHoverCard, TestTimeline, ThemeEditor, - UrlPrivacy, + Privacy, UserIndex, WrenchedTimeline, } from './util/async-components'; @@ -325,7 +325,8 @@ const SwitchingColumnsArea: React.FC = React.memo(({ chil {features.interactionRequests && } - + + diff --git a/packages/pl-fe/src/features/ui/util/async-components.ts b/packages/pl-fe/src/features/ui/util/async-components.ts index 53bb02243..7152fd161 100644 --- a/packages/pl-fe/src/features/ui/util/async-components.ts +++ b/packages/pl-fe/src/features/ui/util/async-components.ts @@ -95,7 +95,7 @@ export const Share = lazy(() => import('pl-fe/pages/utils/share')); export const Status = lazy(() => import('pl-fe/pages/statuses/status')); export const TestTimeline = lazy(() => import('pl-fe/pages/timelines/test-timeline')); export const ThemeEditor = lazy(() => import('pl-fe/pages/dashboard/theme-editor')); -export const UrlPrivacy = lazy(() => import('pl-fe/pages/settings/url-privacy')); +export const Privacy = lazy(() => import('pl-fe/pages/settings/privacy')); export const UserIndex = lazy(() => import('pl-fe/pages/dashboard/user-index')); export const WrenchedTimeline = lazy(() => import('pl-fe/pages/timelines/wrenched-timeline')); diff --git a/packages/pl-fe/src/locales/en.json b/packages/pl-fe/src/locales/en.json index 903d2fe34..547bf13ee 100644 --- a/packages/pl-fe/src/locales/en.json +++ b/packages/pl-fe/src/locales/en.json @@ -1596,6 +1596,7 @@ "settings.mutes_blocks": "Mutes and blocks", "settings.other": "Other options", "settings.preferences": "Preferences", + "settings.privacy": "Privacy", "settings.profile": "Profile", "settings.save.success": "Your preferences have been saved!", "settings.security": "Security", diff --git a/packages/pl-fe/src/pages/settings/settings.tsx b/packages/pl-fe/src/pages/settings/settings.tsx index b0056214f..2a1398727 100644 --- a/packages/pl-fe/src/pages/settings/settings.tsx +++ b/packages/pl-fe/src/pages/settings/settings.tsx @@ -37,7 +37,7 @@ const messages = defineMessages({ security: { id: 'settings.security', defaultMessage: 'Security' }, sessions: { id: 'settings.sessions', defaultMessage: 'Active sessions' }, settings: { id: 'settings.settings', defaultMessage: 'Settings' }, - urlPrivacy: { id: 'settings.url_privacy', defaultMessage: 'URL privacy' }, + privacy: { id: 'settings.privacy', defaultMessage: 'Privacy' }, }); /** User settings page. */ @@ -105,7 +105,7 @@ const SettingsPage = () => { {features.sessions && ( )} - + } to='/settings/url_privacy' /> diff --git a/packages/pl-fe/src/pages/settings/url-privacy.tsx b/packages/pl-fe/src/pages/settings/url-privacy.tsx deleted file mode 100644 index aa4072ae9..000000000 --- a/packages/pl-fe/src/pages/settings/url-privacy.tsx +++ /dev/null @@ -1,213 +0,0 @@ -import { mappings } from '@mkljczk/url-purify'; -import React, { useEffect, useState } from 'react'; -import { defineMessages, FormattedList, FormattedMessage, useIntl } from 'react-intl'; -import { useMutative } from 'use-mutative'; - -import { changeSetting } from 'pl-fe/actions/settings'; -import List, { ListItem } from 'pl-fe/components/list'; -import Button from 'pl-fe/components/ui/button'; -import Card, { CardBody, CardHeader, CardTitle } from 'pl-fe/components/ui/card'; -import Column from 'pl-fe/components/ui/column'; -import Form from 'pl-fe/components/ui/form'; -import FormActions from 'pl-fe/components/ui/form-actions'; -import FormGroup from 'pl-fe/components/ui/form-group'; -import Input from 'pl-fe/components/ui/input'; -import Toggle from 'pl-fe/components/ui/toggle'; -import { SelectDropdown } from 'pl-fe/features/forms'; -import { useAppDispatch } from 'pl-fe/hooks/use-app-dispatch'; -import { useAppSelector } from 'pl-fe/hooks/use-app-selector'; -import { useSettings } from 'pl-fe/hooks/use-settings'; -import KVStore from 'pl-fe/storage/kv-store'; -import { KVStoreRedirectServicesItem } from 'pl-fe/utils/url-purify'; - -const messages = defineMessages({ - urlPrivacy: { id: 'settings.url_privacy', defaultMessage: 'URL privacy' }, - rulesUrlPlaceholder: { id: 'url_privacy.rules_url.placeholder', defaultMessage: 'Rules URL' }, - hashUrlPlaceholder: { id: 'url_privacy.hash_url.placeholder', defaultMessage: 'Hash URL' }, - redirectLinksModeOff: { id: 'url_privacy.redirect_links_mode.off', defaultMessage: 'Disabled' }, - redirectLinksModeAuto: { id: 'url_privacy.redirect_links_mode.auto', defaultMessage: 'From URL' }, - redirectLinksModeManual: { id: 'url_privacy.redirect_links_mode.manual', defaultMessage: 'Specify manually' }, - redirectServicesUrlPlaceholder: { id: 'url_privacy.redirect_services_url.placeholder', defaultMessage: 'Rules URL' }, - redirectServicePlaceholder: { id: 'url_privacy.redirect_services_url.placeholder', defaultMessage: 'eg. https://proxy.example.org' }, -}); - -const UrlPrivacy = () => { - const dispatch = useAppDispatch(); - const me = useAppSelector((state) => state.me); - const intl = useIntl(); - - const { urlPrivacy } = useSettings(); - - const [displayTargetHost, setDisplayTargetHost] = useState(urlPrivacy.displayTargetHost); - const [clearLinksInCompose, setClearLinksInCompose] = useState(urlPrivacy.clearLinksInCompose); - const [clearLinksInContent, setClearLinksInContent] = useState(urlPrivacy.clearLinksInContent); - const [hashUrl, setHashUrl] = useState(urlPrivacy.hashUrl); - const [rulesUrl, setRulesUrl] = useState(urlPrivacy.rulesUrl); - const [redirectLinksMode, setRedirectLinksMode] = useState(urlPrivacy.redirectLinksMode); - const [redirectServicesUrl, setRedirectServicesUrl] = useState(urlPrivacy.redirectServicesUrl); - const [redirectServices, setRedirectServices] = useMutative(urlPrivacy.redirectServices); - - const onSubmit = () => { - const value = { - ...urlPrivacy, - displayTargetHost, - clearLinksInCompose, - clearLinksInContent, - hashUrl, - rulesUrl, - redirectLinksMode, - redirectServicesUrl, - redirectServices, - }; - - switch (redirectLinksMode) { - case 'off': - value.redirectServicesUrl = ''; - value.redirectServices = {}; - break; - case 'manual': - value.redirectServicesUrl = ''; - break; - case 'auto': - value.redirectServices = {}; - break; - } - - dispatch(changeSetting(['urlPrivacy'], value, { - save: true, - showAlert: true, - })); - }; - - const handleChangeRedirectLinksMode = (event: React.ChangeEvent) => { - if (redirectLinksMode === 'auto' && event.target.value === 'manual') { - KVStore.getItem(`url-purify-redirect-services:${me}`).then((services) => { - if (!services?.redirectServices) return; - - setRedirectServices( - Object.fromEntries( - mappings.map(({ name, targets }) => ([ - name, - services.redirectServices.find((service) => targets.includes(service.type) && service.instances.length)?.instances[0].split('|')[0] || '', - ])), - ), - ); - }).catch(() => { }); - } - return setRedirectLinksMode(event.target.value as 'off'); - }; - - useEffect(() => { - }, [dispatch]); - - return ( - - - - - - - -
- - }> - setDisplayTargetHost(target.checked)} /> - - - - - }> - setClearLinksInCompose(target.checked)} /> - - - }> - setClearLinksInContent(target.checked)} /> - - - - } - hintText={} - > - setRulesUrl(target.value)} - /> - - - } - hintText={} - > - setHashUrl(target.value)} - /> - - - - }> - - - - - {redirectLinksMode === 'auto' && ( - } - hintText={} - > - setRedirectServicesUrl(target.value)} - /> - - )} - - {redirectLinksMode === 'manual' && ( - mappings.map((service) => ( - } - hintText={ }} />} - > - setRedirectServices((services) => { - services[service.name] = e.target.value; - })} - placeholder={intl.formatMessage(messages.redirectServicePlaceholder)} - /> - - )) - )} - - - - -
-
-
-
- ); -}; - -export { UrlPrivacy as default };