-
Notifications
You must be signed in to change notification settings - Fork 140
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Account migrate/merge (experimental only) #1524
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f2c274b
State flow for proposing migration
outoftime 53fd518
UI for proposed account migration
outoftime 3bca38c
Connect buttons in account migration UI
outoftime cf4d290
Second stage of account migration
outoftime ef2c850
Account migration
outoftime a4b2930
Cancelling account migration during undo period actually stops the pr…
outoftime 13419d4
Log account migration information to Bugsnag
outoftime e8fcf40
Only do account merge in experimental mode; otherwise just show error…
outoftime f1050a6
Handle errors during account migration
outoftime File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest adding a countdown timer here.