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 });
if (features.mastodonAdminApi) {
if (features.mastodonAdmi) {
return dispatch(fetchMastodonReports(params));
} else {
const { resolved } = params;
@ -191,7 +191,7 @@ function patchReports(ids, reportState) {
dispatch({ type: ADMIN_REPORTS_PATCH_REQUEST, reports });
if (features.mastodonAdminApi) {
if (features.mastodonAdmin) {
return dispatch(patchMastodonReports(reports));
} else {
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 });
if (features.mastodonAdminApi) {
if (features.mastodonAdmi) {
return dispatch(fetchMastodonUsers(filters, page, query, pageSize, next));
} else {
return dispatch(fetchPleromaUsers(filters, page, query, pageSize));
@ -305,7 +305,7 @@ export function deactivateUsers(accountIds, reportId) {
dispatch({ type: ADMIN_USERS_DEACTIVATE_REQUEST, accountIds });
if (features.mastodonAdminApi) {
if (features.mastodonAdmi) {
return dispatch(deactivateMastodonUsers(accountIds, reportId));
} else {
return dispatch(deactivatePleromaUsers(accountIds));
@ -363,7 +363,7 @@ export function approveUsers(accountIds) {
dispatch({ type: ADMIN_USERS_APPROVE_REQUEST, accountIds });
if (features.mastodonAdminApi) {
if (features.mastodonAdmi) {
return dispatch(approveMastodonUsers(accountIds));
} else {
return dispatch(approvePleromaUsers(accountIds));

View file

@ -311,7 +311,7 @@ const SidebarMenu: React.FC = (): JSX.Element | null => {
/>
)}
{features.importAPI && (
{features.import && (
<SidebarLink
to='/settings/import'
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 />
<SidebarLink

View file

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

View file

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

View file

@ -56,12 +56,9 @@ const LinkFooter: React.FC = (): JSX.Element => {
{account.locked && (
<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>
)}
{(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>
</>}
</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();
}

View file

@ -288,7 +288,7 @@ const SwitchingColumnsArea: React.FC = ({ children }) => {
{/* FIXME: this could DDoS our API? :\ */}
{/* <WrappedRoute path='/settings/export' page={DefaultPage} component={ExportData} 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} />}
<WrappedRoute path='/settings/email' page={DefaultPage} component={EditEmail} 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 PATCH /api/v1/accounts/update_credentials
*/
accountAliasesAPI: v.software === PLEROMA,
accountAliases: v.software === PLEROMA,
/**
* 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/mutes_import
*/
importAPI: v.software === PLEROMA,
import: v.software === PLEROMA,
/**
* 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/approve
*/
mastodonAdminApi: any([
mastodonAdmin: any([
v.software === MASTODON && gte(v.compatVersion, '2.9.1'),
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.
* @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.
@ -462,7 +462,7 @@ const getInstanceFeatures = (instance: Instance) => {
* Can request a password reset email through the API.
* @see POST /auth/password
*/
resetPasswordAPI: v.software === PLEROMA,
resetPassword: v.software === PLEROMA,
/**
* 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/delete_account
*/
securityAPI: any([
security: any([
v.software === PLEROMA,
v.software === TRUTHSOCIAL,
]),
@ -506,7 +506,7 @@ const getInstanceFeatures = (instance: Instance) => {
* @see GET /api/oauth_tokens.json
* @see DELETE /api/oauth_tokens/:id
*/
sessionsAPI: v.software === PLEROMA,
sessions: v.software === PLEROMA,
/**
* Can store client settings in the database.