Merge branch 'settings' into 'develop'

Move account migration to settings

See merge request soapbox-pub/soapbox-fe!1497
This commit is contained in:
marcin mikołajczak 2022-06-05 13:58:51 +00:00
commit 9dcbdf0553
8 changed files with 65 additions and 61 deletions

View file

@ -143,7 +143,7 @@ export function fetchReports(params = {}) {
dispatch({ type: ADMIN_REPORTS_FETCH_REQUEST, params }); dispatch({ type: ADMIN_REPORTS_FETCH_REQUEST, params });
if (features.mastodonAdminApi) { if (features.mastodonAdmi) {
return dispatch(fetchMastodonReports(params)); return dispatch(fetchMastodonReports(params));
} else { } else {
const { resolved } = params; const { resolved } = params;
@ -191,7 +191,7 @@ function patchReports(ids, reportState) {
dispatch({ type: ADMIN_REPORTS_PATCH_REQUEST, reports }); dispatch({ type: ADMIN_REPORTS_PATCH_REQUEST, reports });
if (features.mastodonAdminApi) { if (features.mastodonAdmin) {
return dispatch(patchMastodonReports(reports)); return dispatch(patchMastodonReports(reports));
} else { } else {
return dispatch(patchPleromaReports(reports)); return dispatch(patchPleromaReports(reports));
@ -258,7 +258,7 @@ export function fetchUsers(filters = [], page = 1, query, pageSize = 50, next) {
dispatch({ type: ADMIN_USERS_FETCH_REQUEST, filters, page, pageSize }); dispatch({ type: ADMIN_USERS_FETCH_REQUEST, filters, page, pageSize });
if (features.mastodonAdminApi) { if (features.mastodonAdmi) {
return dispatch(fetchMastodonUsers(filters, page, query, pageSize, next)); return dispatch(fetchMastodonUsers(filters, page, query, pageSize, next));
} else { } else {
return dispatch(fetchPleromaUsers(filters, page, query, pageSize)); return dispatch(fetchPleromaUsers(filters, page, query, pageSize));
@ -305,7 +305,7 @@ export function deactivateUsers(accountIds, reportId) {
dispatch({ type: ADMIN_USERS_DEACTIVATE_REQUEST, accountIds }); dispatch({ type: ADMIN_USERS_DEACTIVATE_REQUEST, accountIds });
if (features.mastodonAdminApi) { if (features.mastodonAdmi) {
return dispatch(deactivateMastodonUsers(accountIds, reportId)); return dispatch(deactivateMastodonUsers(accountIds, reportId));
} else { } else {
return dispatch(deactivatePleromaUsers(accountIds)); return dispatch(deactivatePleromaUsers(accountIds));
@ -363,7 +363,7 @@ export function approveUsers(accountIds) {
dispatch({ type: ADMIN_USERS_APPROVE_REQUEST, accountIds }); dispatch({ type: ADMIN_USERS_APPROVE_REQUEST, accountIds });
if (features.mastodonAdminApi) { if (features.mastodonAdmi) {
return dispatch(approveMastodonUsers(accountIds)); return dispatch(approveMastodonUsers(accountIds));
} else { } else {
return dispatch(approvePleromaUsers(accountIds)); return dispatch(approvePleromaUsers(accountIds));

View file

@ -311,7 +311,7 @@ const SidebarMenu: React.FC = (): JSX.Element | null => {
/> />
)} )}
{features.importAPI && ( {features.import && (
<SidebarLink <SidebarLink
to='/settings/import' to='/settings/import'
icon={require('@tabler/icons/icons/cloud-upload.svg')} icon={require('@tabler/icons/icons/cloud-upload.svg')}
@ -320,22 +320,6 @@ const SidebarMenu: React.FC = (): JSX.Element | null => {
/> />
)} )}
{features.federating && (features.accountMoving ? (
<SidebarLink
to='/settings/migration'
icon={require('@tabler/icons/icons/briefcase.svg')}
text={intl.formatMessage(messages.accountMigration)}
onClick={onClose}
/>
) : features.accountAliasesAPI && (
<SidebarLink
to='/settings/aliases'
icon={require('@tabler/icons/icons/briefcase.svg')}
text={intl.formatMessage(messages.accountAliases)}
onClick={onClose}
/>
))}
<hr /> <hr />
<SidebarLink <SidebarLink

View file

@ -22,6 +22,8 @@ const messages = defineMessages({
configureMfa: { id: 'settings.configure_mfa', defaultMessage: 'Configure MFA' }, configureMfa: { id: 'settings.configure_mfa', defaultMessage: 'Configure MFA' },
sessions: { id: 'settings.sessions', defaultMessage: 'Active sessions' }, sessions: { id: 'settings.sessions', defaultMessage: 'Active sessions' },
deleteAccount: { id: 'settings.delete_account', defaultMessage: 'Delete Account' }, deleteAccount: { id: 'settings.delete_account', defaultMessage: 'Delete Account' },
accountMigration: { id: 'settings.account_migration', defaultMessage: 'Move Account' },
accountAliases: { id: 'navigation_bar.account_aliases', defaultMessage: 'Account aliases' },
other: { id: 'settings.other', defaultMessage: 'Other options' }, other: { id: 'settings.other', defaultMessage: 'Other options' },
mfaEnabled: { id: 'mfa.enabled', defaultMessage: 'Enabled' }, mfaEnabled: { id: 'mfa.enabled', defaultMessage: 'Enabled' },
mfaDisabled: { id: 'mfa.disabled', defaultMessage: 'Disabled' }, mfaDisabled: { id: 'mfa.disabled', defaultMessage: 'Disabled' },
@ -43,6 +45,8 @@ const Settings = () => {
const navigateToSessions = () => history.push('/settings/tokens'); const navigateToSessions = () => history.push('/settings/tokens');
const navigateToEditProfile = () => history.push('/settings/profile'); const navigateToEditProfile = () => history.push('/settings/profile');
const navigateToDeleteAccount = () => history.push('/settings/account'); const navigateToDeleteAccount = () => history.push('/settings/account');
const navigateToMoveAccount = () => history.push('/settings/migration');
const navigateToAliases = () => history.push('/settings/aliases');
const isMfaEnabled = mfa.getIn(['settings', 'totp']); const isMfaEnabled = mfa.getIn(['settings', 'totp']);
@ -69,24 +73,32 @@ const Settings = () => {
</List> </List>
</CardBody> </CardBody>
<CardHeader> {features.security || features.sessions && (
<CardTitle title={intl.formatMessage(messages.security)} /> <>
</CardHeader> <CardHeader>
<CardTitle title={intl.formatMessage(messages.security)} />
</CardHeader>
<CardBody> <CardBody>
<List> <List>
<ListItem label={intl.formatMessage(messages.changeEmail)} onClick={navigateToChangeEmail} /> {features.security && (
<ListItem label={intl.formatMessage(messages.changePassword)} onClick={navigateToChangePassword} /> <>
<ListItem label={intl.formatMessage(messages.configureMfa)} onClick={navigateToMfa}> <ListItem label={intl.formatMessage(messages.changeEmail)} onClick={navigateToChangeEmail} />
{isMfaEnabled ? <ListItem label={intl.formatMessage(messages.changePassword)} onClick={navigateToChangePassword} />
intl.formatMessage(messages.mfaEnabled) : <ListItem label={intl.formatMessage(messages.configureMfa)} onClick={navigateToMfa}>
intl.formatMessage(messages.mfaDisabled)} {isMfaEnabled ?
</ListItem> intl.formatMessage(messages.mfaEnabled) :
{features.sessionsAPI && ( intl.formatMessage(messages.mfaDisabled)}
<ListItem label={intl.formatMessage(messages.sessions)} onClick={navigateToSessions} /> </ListItem>
)} </>
</List> )}
</CardBody> {features.sessions && (
<ListItem label={intl.formatMessage(messages.sessions)} onClick={navigateToSessions} />
)}
</List>
</CardBody>
</>
)}
<CardHeader> <CardHeader>
<CardTitle title={intl.formatMessage(messages.preferences)} /> <CardTitle title={intl.formatMessage(messages.preferences)} />
@ -96,15 +108,26 @@ const Settings = () => {
<Preferences /> <Preferences />
</CardBody> </CardBody>
<CardHeader> {features.security || features.accountAliases && (
<CardTitle title={intl.formatMessage(messages.other)} /> <>
</CardHeader> <CardHeader>
<CardTitle title={intl.formatMessage(messages.other)} />
</CardHeader>
<CardBody> <CardBody>
<List> <List>
<ListItem label={intl.formatMessage(messages.deleteAccount)} onClick={navigateToDeleteAccount} /> {features.security && (
</List> <ListItem label={intl.formatMessage(messages.deleteAccount)} onClick={navigateToDeleteAccount} />
</CardBody> )}
{features.federating && (features.accountMoving ? (
<ListItem label={intl.formatMessage(messages.accountMigration)} onClick={navigateToMoveAccount} />
) : features.accountAliases && (
<ListItem label={intl.formatMessage(messages.accountAliases)} onClick={navigateToAliases} />
))}
</List>
</CardBody>
</>
)}
</Card> </Card>
</Column> </Column>
); );

View file

@ -118,7 +118,7 @@ const ActionButton: React.FC<IActionButton> = ({ account, actionType, small }) =
/** Render a remote follow button, depending on features. */ /** Render a remote follow button, depending on features. */
const renderRemoteFollow = () => { const renderRemoteFollow = () => {
// Remote follow through the API. // Remote follow through the API.
if (features.remoteInteractionsAPI) { if (features.remoteInteractions) {
return ( return (
<Button <Button
onClick={handleRemoteFollow} onClick={handleRemoteFollow}

View file

@ -56,12 +56,9 @@ const LinkFooter: React.FC = (): JSX.Element => {
{account.locked && ( {account.locked && (
<FooterLink to='/follow_requests'><FormattedMessage id='navigation_bar.follow_requests' defaultMessage='Follow requests' /></FooterLink> <FooterLink to='/follow_requests'><FormattedMessage id='navigation_bar.follow_requests' defaultMessage='Follow requests' /></FooterLink>
)} )}
{features.importAPI && ( {features.import && (
<FooterLink to='/settings/import'><FormattedMessage id='navigation_bar.import_data' defaultMessage='Import data' /></FooterLink> <FooterLink to='/settings/import'><FormattedMessage id='navigation_bar.import_data' defaultMessage='Import data' /></FooterLink>
)} )}
{(features.federating && features.accountMoving) && (
<FooterLink to='/settings/migration'><FormattedMessage id='navigation_bar.account_migration' defaultMessage='Move account' /></FooterLink>
)}
<FooterLink to='/logout' onClick={onClickLogOut}><FormattedMessage id='navigation_bar.logout' defaultMessage='Logout' /></FooterLink> <FooterLink to='/logout' onClick={onClickLogOut}><FormattedMessage id='navigation_bar.logout' defaultMessage='Logout' /></FooterLink>
</>} </>}
</div> </div>

View file

@ -129,7 +129,7 @@ const UnauthorizedModal: React.FC<IUnauthorizedModal> = ({ action, onClose, acco
); );
}; };
if (action && features.remoteInteractionsAPI && features.federating) { if (action && features.remoteInteractions && features.federating) {
return renderRemoteInteractions(); return renderRemoteInteractions();
} }

View file

@ -288,7 +288,7 @@ const SwitchingColumnsArea: React.FC = ({ children }) => {
{/* FIXME: this could DDoS our API? :\ */} {/* FIXME: this could DDoS our API? :\ */}
{/* <WrappedRoute path='/settings/export' page={DefaultPage} component={ExportData} content={children} /> */} {/* <WrappedRoute path='/settings/export' page={DefaultPage} component={ExportData} content={children} /> */}
{features.importData && <WrappedRoute path='/settings/import' page={DefaultPage} component={ImportData} content={children} />} {features.importData && <WrappedRoute path='/settings/import' page={DefaultPage} component={ImportData} content={children} />}
{features.accountAliasesAPI && <WrappedRoute path='/settings/aliases' page={DefaultPage} component={Aliases} content={children} />} {features.accountAliases && <WrappedRoute path='/settings/aliases' page={DefaultPage} component={Aliases} content={children} />}
{features.accountMoving && <WrappedRoute path='/settings/migration' page={DefaultPage} component={Migration} content={children} />} {features.accountMoving && <WrappedRoute path='/settings/migration' page={DefaultPage} component={Migration} content={children} />}
<WrappedRoute path='/settings/email' page={DefaultPage} component={EditEmail} content={children} /> <WrappedRoute path='/settings/email' page={DefaultPage} component={EditEmail} content={children} />
<WrappedRoute path='/settings/password' page={DefaultPage} component={EditPassword} content={children} /> <WrappedRoute path='/settings/password' page={DefaultPage} component={EditPassword} content={children} />

View file

@ -69,7 +69,7 @@ const getInstanceFeatures = (instance: Instance) => {
* @see GET /api/pleroma/aliases * @see GET /api/pleroma/aliases
* @see PATCH /api/v1/accounts/update_credentials * @see PATCH /api/v1/accounts/update_credentials
*/ */
accountAliasesAPI: v.software === PLEROMA, accountAliases: v.software === PLEROMA,
/** /**
* The accounts API allows an acct instead of an ID. * The accounts API allows an acct instead of an ID.
@ -306,7 +306,7 @@ const getInstanceFeatures = (instance: Instance) => {
* @see POST /api/pleroma/blocks_import * @see POST /api/pleroma/blocks_import
* @see POST /api/pleroma/mutes_import * @see POST /api/pleroma/mutes_import
*/ */
importAPI: v.software === PLEROMA, import: v.software === PLEROMA,
/** /**
* Pleroma import endpoints. * Pleroma import endpoints.
@ -335,7 +335,7 @@ const getInstanceFeatures = (instance: Instance) => {
* @see POST /api/v1/admin/accounts/:account_id/action * @see POST /api/v1/admin/accounts/:account_id/action
* @see POST /api/v1/admin/accounts/:account_id/approve * @see POST /api/v1/admin/accounts/:account_id/approve
*/ */
mastodonAdminApi: any([ mastodonAdmin: any([
v.software === MASTODON && gte(v.compatVersion, '2.9.1'), v.software === MASTODON && gte(v.compatVersion, '2.9.1'),
v.software === PLEROMA && v.build === SOAPBOX && gte(v.version, '2.4.50'), v.software === PLEROMA && v.build === SOAPBOX && gte(v.version, '2.4.50'),
]), ]),
@ -442,7 +442,7 @@ const getInstanceFeatures = (instance: Instance) => {
* Interact with statuses from another instance while logged-out. * Interact with statuses from another instance while logged-out.
* @see POST /api/v1/pleroma/remote_interaction * @see POST /api/v1/pleroma/remote_interaction
*/ */
remoteInteractionsAPI: v.software === PLEROMA && gte(v.version, '2.4.50'), remoteInteractions: v.software === PLEROMA && gte(v.version, '2.4.50'),
/** /**
* Ability to remove an account from your followers. * Ability to remove an account from your followers.
@ -462,7 +462,7 @@ const getInstanceFeatures = (instance: Instance) => {
* Can request a password reset email through the API. * Can request a password reset email through the API.
* @see POST /auth/password * @see POST /auth/password
*/ */
resetPasswordAPI: v.software === PLEROMA, resetPassword: v.software === PLEROMA,
/** /**
* Ability to post statuses in Markdown, BBCode, and HTML. * Ability to post statuses in Markdown, BBCode, and HTML.
@ -496,7 +496,7 @@ const getInstanceFeatures = (instance: Instance) => {
* @see POST /api/pleroma/change_email * @see POST /api/pleroma/change_email
* @see POST /api/pleroma/delete_account * @see POST /api/pleroma/delete_account
*/ */
securityAPI: any([ security: any([
v.software === PLEROMA, v.software === PLEROMA,
v.software === TRUTHSOCIAL, v.software === TRUTHSOCIAL,
]), ]),
@ -506,7 +506,7 @@ const getInstanceFeatures = (instance: Instance) => {
* @see GET /api/oauth_tokens.json * @see GET /api/oauth_tokens.json
* @see DELETE /api/oauth_tokens/:id * @see DELETE /api/oauth_tokens/:id
*/ */
sessionsAPI: v.software === PLEROMA, sessions: v.software === PLEROMA,
/** /**
* Can store client settings in the database. * Can store client settings in the database.