-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1524 from outoftime/account-migrate-merge
Account migrate/merge (experimental only)
- Loading branch information
Showing
28 changed files
with
913 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
import isNull from 'lodash-es/isNull'; | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import {t} from 'i18next'; | ||
|
||
import { | ||
AccountMigration as AccountMigrationRecord, | ||
UserAccount as UserAccountRecord, | ||
} from '../records'; | ||
import {AccountMigrationState} from '../enums'; | ||
|
||
import AccountMigrationComplete from './AccountMigrationComplete'; | ||
import AccountMigrationInProgress from './AccountMigrationInProgress'; | ||
import AccountMigrationUndoGracePeriod | ||
from './AccountMigrationUndoGracePeriod'; | ||
import Modal from './Modal'; | ||
import ProposedAccountMigration from './ProposedAccountMigration'; | ||
import AccountMigrationError from './AccountMigrationError'; | ||
|
||
export default function AccountMigration({ | ||
currentUserAccount, | ||
migration, | ||
onDismiss, | ||
onMigrate, | ||
}) { | ||
if (isNull(currentUserAccount) || isNull(migration)) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<Modal> | ||
<div className="account-migration"> | ||
<h1 className="account-migration__header"> | ||
{t(`account-migration.header.${ | ||
migration.state.key.toLowerCase().replace(/_/g, '-') | ||
}`)} | ||
</h1> | ||
<div className="account-migration__accounts"> | ||
<div className="account-migration__account"> | ||
<p className="account-migration__account-label"> | ||
{t('account-migration.your-account')} | ||
</p> | ||
<img | ||
className="account-migration__avatar" | ||
src={currentUserAccount.avatarUrl} | ||
/> | ||
<div className="account-migration__user-name"> | ||
{currentUserAccount.displayName} | ||
</div> | ||
</div> | ||
<div | ||
className="account-migration__merge-icon u__icon u__icon_disabled" | ||
> | ||
 | ||
</div> | ||
<div className="account-migration__account"> | ||
<p className="account-migration__account-label"> | ||
{t('account-migration.account-to-merge')} | ||
</p> | ||
<img | ||
className="account-migration__avatar" | ||
src={migration.userAccountToMerge.avatarUrl} | ||
/> | ||
<div className="account-migration__user-name"> | ||
{migration.userAccountToMerge.displayName} | ||
</div> | ||
</div> | ||
</div> | ||
{(() => { | ||
switch (migration.state) { | ||
case AccountMigrationState.PROPOSED: | ||
return ( | ||
<ProposedAccountMigration | ||
onDismiss={onDismiss} | ||
onMigrate={onMigrate} | ||
/> | ||
); | ||
case AccountMigrationState.UNDO_GRACE_PERIOD: | ||
return <AccountMigrationUndoGracePeriod onDismiss={onDismiss} />; | ||
case AccountMigrationState.IN_PROGRESS: | ||
return <AccountMigrationInProgress />; | ||
case AccountMigrationState.COMPLETE: | ||
return <AccountMigrationComplete onDismiss={onDismiss} />; | ||
case AccountMigrationState.ERROR: | ||
return <AccountMigrationError onDismiss={onDismiss} />; | ||
} | ||
return null; | ||
})()} | ||
</div> | ||
</Modal> | ||
); | ||
} | ||
|
||
AccountMigration.propTypes = { | ||
currentUserAccount: PropTypes.instanceOf(UserAccountRecord), | ||
migration: PropTypes.instanceOf(AccountMigrationRecord), | ||
onDismiss: PropTypes.func.isRequired, | ||
onMigrate: PropTypes.func.isRequired, | ||
}; | ||
|
||
AccountMigration.defaultProps = { | ||
currentUserAccount: null, | ||
migration: null, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import classnames from 'classnames'; | ||
import {t} from 'i18next'; | ||
import React, {Fragment} from 'react'; | ||
import PropTypes from 'prop-types'; | ||
|
||
export default function AccountMigrationComplete({onDismiss}) { | ||
return ( | ||
<Fragment> | ||
<p> | ||
{t('account-migration.complete')} | ||
</p> | ||
<div className="account-migration__buttons"> | ||
<button | ||
className={classnames( | ||
'account-migration__button', | ||
)} | ||
onClick={onDismiss} | ||
> | ||
{t('account-migration.buttons.dismiss')} | ||
</button> | ||
</div> | ||
</Fragment> | ||
); | ||
} | ||
|
||
AccountMigrationComplete.propTypes = { | ||
onDismiss: PropTypes.func.isRequired, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import classnames from 'classnames'; | ||
import PropTypes from 'prop-types'; | ||
import React, {Fragment} from 'react'; | ||
import {t} from 'i18next'; | ||
|
||
|
||
export default function AccountMigrationError({onDismiss}) { | ||
return ( | ||
<Fragment> | ||
<p> | ||
{t('account-migration.error')} | ||
</p> | ||
<div className="account-migration__buttons"> | ||
<button | ||
className={classnames( | ||
'account-migration__button', | ||
)} | ||
onClick={onDismiss} | ||
> | ||
{t('account-migration.buttons.dismiss')} | ||
</button> | ||
</div> | ||
</Fragment> | ||
); | ||
} | ||
|
||
AccountMigrationError.propTypes = { | ||
onDismiss: PropTypes.func.isRequired, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import {t} from 'i18next'; | ||
|
||
export default function AccountMigrationInProgress() { | ||
return ( | ||
<p> | ||
{t('account-migration.in-progress')} | ||
</p> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import classnames from 'classnames'; | ||
import PropTypes from 'prop-types'; | ||
import React, {Fragment} from 'react'; | ||
import {t} from 'i18next'; | ||
|
||
export default function AccountMigrationUndoGracePeriod({onDismiss}) { | ||
return ( | ||
<Fragment> | ||
<p> | ||
{t('account-migration.preparing')} | ||
</p> | ||
<div className="account-migration__buttons"> | ||
<button | ||
className={classnames( | ||
'account-migration__button', | ||
)} | ||
onClick={onDismiss} | ||
> | ||
{t('account-migration.buttons.stop')} | ||
</button> | ||
</div> | ||
</Fragment> | ||
); | ||
} | ||
|
||
AccountMigrationUndoGracePeriod.propTypes = { | ||
onDismiss: PropTypes.func.isRequired, | ||
}; |
Oops, something went wrong.