From 98f311873c672cb34aac8a80ee0b1abb19a026d1 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 11 Jan 2023 17:25:25 -0600 Subject: [PATCH 1/4] Expose backups again --- CHANGELOG.md | 1 + app/soapbox/features/backups/index.tsx | 35 +++++++++++-------------- app/soapbox/features/settings/index.tsx | 6 +++++ app/soapbox/features/ui/index.tsx | 4 +-- app/soapbox/utils/features.ts | 7 +++++ app/styles/application.scss | 1 - app/styles/components/backups.scss | 12 --------- 7 files changed, 31 insertions(+), 35 deletions(-) delete mode 100644 app/styles/components/backups.scss diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b2a108d5..7a76c58a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - UI: added backdrop blur behind modals. - Admin: let admins configure media preview for attachment thumbnails. - Login: accept `?server` param in external login, eg `fe.soapbox.pub/login/external?server=gleasonator.com`. +- Backups: restored Pleroma backups functionality. ### Changed - Posts: letterbox images to 19:6 again. diff --git a/app/soapbox/features/backups/index.tsx b/app/soapbox/features/backups/index.tsx index b47f10766..5e1dd705f 100644 --- a/app/soapbox/features/backups/index.tsx +++ b/app/soapbox/features/backups/index.tsx @@ -1,10 +1,9 @@ -import classNames from 'clsx'; import React, { useEffect, useState } from 'react'; import { defineMessages, useIntl } from 'react-intl'; import { fetchBackups, createBackup } from 'soapbox/actions/backups'; import ScrollableList from 'soapbox/components/scrollable-list'; -import { Column } from 'soapbox/components/ui'; +import { Button, Column, FormActions, Text } from 'soapbox/components/ui'; import { useAppDispatch, useAppSelector } from 'soapbox/hooks'; const messages = defineMessages({ @@ -23,22 +22,14 @@ const Backups = () => { const [isLoading, setIsLoading] = useState(true); - const handleCreateBackup: React.MouseEventHandler = e => { + const handleCreateBackup: React.MouseEventHandler = e => { dispatch(createBackup()); e.preventDefault(); }; - const makeColumnMenu = () => { - return [{ - text: intl.formatMessage(messages.create), - action: handleCreateBackup, - icon: require('@tabler/icons/plus.svg'), - }]; - }; - useEffect(() => { dispatch(fetchBackups()).then(() => { - setIsLoading(true); + setIsLoading(false); }).catch(() => {}); }, []); @@ -46,16 +37,14 @@ const Backups = () => { const emptyMessageAction = ( - {intl.formatMessage(messages.emptyMessageAction)} + + {intl.formatMessage(messages.emptyMessageAction)} + ); return ( - + { > {backups.map((backup) => (
{backup.processed ? {backup.inserted_at} - :
{intl.formatMessage(messages.pending)}: {backup.inserted_at}
+ : {intl.formatMessage(messages.pending)}: {backup.inserted_at} }
))}
+ + + +
); }; diff --git a/app/soapbox/features/settings/index.tsx b/app/soapbox/features/settings/index.tsx index a0842984a..fce0ec814 100644 --- a/app/soapbox/features/settings/index.tsx +++ b/app/soapbox/features/settings/index.tsx @@ -27,6 +27,7 @@ const messages = defineMessages({ other: { id: 'settings.other', defaultMessage: 'Other options' }, mfaEnabled: { id: 'mfa.enabled', defaultMessage: 'Enabled' }, mfaDisabled: { id: 'mfa.disabled', defaultMessage: 'Disabled' }, + backups: { id: 'column.backups', defaultMessage: 'Backups' }, }); /** User settings page. */ @@ -47,6 +48,7 @@ const Settings = () => { const navigateToDeleteAccount = () => history.push('/settings/account'); const navigateToMoveAccount = () => history.push('/settings/migration'); const navigateToAliases = () => history.push('/settings/aliases'); + const navigateToBackups = () => history.push('/settings/backups'); const isMfaEnabled = mfa.getIn(['settings', 'totp']); @@ -136,6 +138,10 @@ const Settings = () => { ))} + {features.backups && ( + + )} + {features.security && ( )} diff --git a/app/soapbox/features/ui/index.tsx b/app/soapbox/features/ui/index.tsx index 319ae539f..211fefc46 100644 --- a/app/soapbox/features/ui/index.tsx +++ b/app/soapbox/features/ui/index.tsx @@ -78,7 +78,7 @@ import { SoapboxConfig, // ExportData, ImportData, - // Backups, + Backups, MfaForm, ChatIndex, ChatWidget, @@ -278,6 +278,7 @@ const SwitchingColumnsArea: React.FC = ({ children }) => { {features.importData && } {features.accountAliases && } {features.accountMoving && } + {features.backups && } @@ -285,7 +286,6 @@ const SwitchingColumnsArea: React.FC = ({ children }) => { - {/* */} diff --git a/app/soapbox/utils/features.ts b/app/soapbox/utils/features.ts index d224502ff..f625c4f37 100644 --- a/app/soapbox/utils/features.ts +++ b/app/soapbox/utils/features.ts @@ -178,6 +178,13 @@ const getInstanceFeatures = (instance: Instance) => { */ announcementsReactions: v.software === MASTODON && gte(v.compatVersion, '3.1.0'), + /** + * Pleroma backups. + * @see GET /api/v1/pleroma/backups + * @see POST /api/v1/pleroma/backups + */ + backups: v.software === PLEROMA, + /** * Set your birthday and view upcoming birthdays. * @see GET /api/v1/pleroma/birthdays diff --git a/app/styles/application.scss b/app/styles/application.scss index 828c678d1..d8a9cbe3d 100644 --- a/app/styles/application.scss +++ b/app/styles/application.scss @@ -43,7 +43,6 @@ @import 'components/video-player'; @import 'components/audio-player'; @import 'components/filters'; -@import 'components/backups'; @import 'components/crypto-donate'; @import 'components/aliases'; @import 'components/icon'; diff --git a/app/styles/components/backups.scss b/app/styles/components/backups.scss deleted file mode 100644 index 728d9375e..000000000 --- a/app/styles/components/backups.scss +++ /dev/null @@ -1,12 +0,0 @@ -.backup { - padding: 15px; - border-bottom: 1px solid var(--brand-color--faint); - - a { - color: var(--brand-color--hicontrast); - } - - &--pending { - @apply text-gray-400 italic; - } -} From ebfd7bdc94b46fe95562c713952bccd3a11844fe Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 11 Jan 2023 17:30:32 -0600 Subject: [PATCH 2/4] Move "Import data" under settings --- CHANGELOG.md | 1 + app/soapbox/components/sidebar-menu.tsx | 10 ---------- app/soapbox/features/settings/index.tsx | 6 ++++++ app/soapbox/features/ui/components/link-footer.tsx | 3 --- 4 files changed, 7 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a76c58a6..1a2837a3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Posts: letterbox images to 19:6 again. - Status Info: moved context (repost, pinned) to improve UX. - Posts: remove file icon from empty link previews. +- Settings: moved "Import data" under settings. ### Fixed - Layout: use accent color for "floating action button" (mobile compose button). diff --git a/app/soapbox/components/sidebar-menu.tsx b/app/soapbox/components/sidebar-menu.tsx index 766d3dc87..7f3397bb2 100644 --- a/app/soapbox/components/sidebar-menu.tsx +++ b/app/soapbox/components/sidebar-menu.tsx @@ -28,7 +28,6 @@ const messages = defineMessages({ mutes: { id: 'navigation_bar.mutes', defaultMessage: 'Muted users' }, filters: { id: 'navigation_bar.filters', defaultMessage: 'Muted words' }, soapboxConfig: { id: 'navigation_bar.soapbox_config', defaultMessage: 'Soapbox config' }, - importData: { id: 'navigation_bar.import_data', defaultMessage: 'Import data' }, accountMigration: { id: 'navigation_bar.account_migration', defaultMessage: 'Move account' }, accountAliases: { id: 'navigation_bar.account_aliases', defaultMessage: 'Account aliases' }, logout: { id: 'navigation_bar.logout', defaultMessage: 'Logout' }, @@ -305,15 +304,6 @@ const SidebarMenu: React.FC = (): JSX.Element | null => { /> )} - {features.import && ( - - )} - { const navigateToMoveAccount = () => history.push('/settings/migration'); const navigateToAliases = () => history.push('/settings/aliases'); const navigateToBackups = () => history.push('/settings/backups'); + const navigateToImportData = () => history.push('/settings/import'); const isMfaEnabled = mfa.getIn(['settings', 'totp']); @@ -142,6 +144,10 @@ const Settings = () => { )} + {features.importData && ( + + )} + {features.security && ( )} diff --git a/app/soapbox/features/ui/components/link-footer.tsx b/app/soapbox/features/ui/components/link-footer.tsx index 333a01a21..14c19ed17 100644 --- a/app/soapbox/features/ui/components/link-footer.tsx +++ b/app/soapbox/features/ui/components/link-footer.tsx @@ -56,9 +56,6 @@ const LinkFooter: React.FC = (): JSX.Element => { {account.locked && ( )} - {features.import && ( - - )} } From e50e4b8e608de927bb64405aec4d50d1104e7c25 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 11 Jan 2023 17:59:50 -0600 Subject: [PATCH 3/4] Restore export data CSV (behind a feature flag) --- CHANGELOG.md | 1 + app/soapbox/features/settings/index.tsx | 22 ++++++++++++++-------- app/soapbox/features/ui/index.tsx | 5 ++--- app/soapbox/utils/features.ts | 3 +++ 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a2837a3a..709b0c70c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Admin: let admins configure media preview for attachment thumbnails. - Login: accept `?server` param in external login, eg `fe.soapbox.pub/login/external?server=gleasonator.com`. - Backups: restored Pleroma backups functionality. +- Export: restored "Export data" to CSV. ### Changed - Posts: letterbox images to 19:6 again. diff --git a/app/soapbox/features/settings/index.tsx b/app/soapbox/features/settings/index.tsx index c3c8cea10..f199170d1 100644 --- a/app/soapbox/features/settings/index.tsx +++ b/app/soapbox/features/settings/index.tsx @@ -29,6 +29,7 @@ const messages = defineMessages({ mfaDisabled: { id: 'mfa.disabled', defaultMessage: 'Disabled' }, backups: { id: 'column.backups', defaultMessage: 'Backups' }, importData: { id: 'navigation_bar.import_data', defaultMessage: 'Import data' }, + exportData: { id: 'settings.export_data', defaultMessage: 'Export data' }, }); /** User settings page. */ @@ -51,6 +52,7 @@ const Settings = () => { const navigateToAliases = () => history.push('/settings/aliases'); const navigateToBackups = () => history.push('/settings/backups'); const navigateToImportData = () => history.push('/settings/import'); + const navigateToExportData = () => history.push('/settings/export'); const isMfaEnabled = mfa.getIn(['settings', 'totp']); @@ -134,19 +136,23 @@ const Settings = () => { - {features.federating && (features.accountMoving ? ( - - ) : features.accountAliases && ( - - ))} + {features.importData && ( + + )} + + {features.exportData && ( + + )} {features.backups && ( )} - {features.importData && ( - - )} + {features.federating && (features.accountMoving ? ( + + ) : features.accountAliases && ( + + ))} {features.security && ( diff --git a/app/soapbox/features/ui/index.tsx b/app/soapbox/features/ui/index.tsx index 211fefc46..2fdfda3c9 100644 --- a/app/soapbox/features/ui/index.tsx +++ b/app/soapbox/features/ui/index.tsx @@ -76,7 +76,7 @@ import { EmailConfirmation, DeleteAccount, SoapboxConfig, - // ExportData, + ExportData, ImportData, Backups, MfaForm, @@ -273,8 +273,7 @@ const SwitchingColumnsArea: React.FC = ({ children }) => { {features.scheduledStatuses && } - {/* FIXME: this could DDoS our API? :\ */} - {/* */} + {features.exportData && } {features.importData && } {features.accountAliases && } {features.accountMoving && } diff --git a/app/soapbox/utils/features.ts b/app/soapbox/utils/features.ts index f625c4f37..e59cdfff3 100644 --- a/app/soapbox/utils/features.ts +++ b/app/soapbox/utils/features.ts @@ -388,6 +388,9 @@ const getInstanceFeatures = (instance: Instance) => { v.software === TRUTHSOCIAL, ]), + /** Whether to allow exporting follows/blocks/mutes to CSV by paginating the API. */ + exportData: true, + /** Whether the accounts who favourited or emoji-reacted to a status can be viewed through the API. */ exposableReactions: any([ v.software === MASTODON, From 658e336e5c2ff371eced8bc131f044831c158912 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 11 Jan 2023 18:06:20 -0600 Subject: [PATCH 4/4] Fix export_data locale --- app/soapbox/features/settings/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/soapbox/features/settings/index.tsx b/app/soapbox/features/settings/index.tsx index f199170d1..e01ed848c 100644 --- a/app/soapbox/features/settings/index.tsx +++ b/app/soapbox/features/settings/index.tsx @@ -29,7 +29,7 @@ const messages = defineMessages({ mfaDisabled: { id: 'mfa.disabled', defaultMessage: 'Disabled' }, backups: { id: 'column.backups', defaultMessage: 'Backups' }, importData: { id: 'navigation_bar.import_data', defaultMessage: 'Import data' }, - exportData: { id: 'settings.export_data', defaultMessage: 'Export data' }, + exportData: { id: 'column.export_data', defaultMessage: 'Export data' }, }); /** User settings page. */