Show automigration message on the Top Site section, fix #2616 #2650
Conversation
|
The code looks great in general, awesome work so far! What is the best way to manually test this? |
| function AutoMigrate(prevState = INITIAL_STATE.AutoMigrate, action) { | ||
| switch (action.type) { | ||
| case at.AUTOMIGRATE_HIDE: { | ||
| return Object.assign({}, prevState, { |
k88hudson
May 31, 2017
Member
This doesn't need to Object.assign if you are replacing every value, right?
This doesn't need to Object.assign if you are replacing every value, right?
| const {FormattedMessage, injectIntl} = require("react-intl"); | ||
| const {actionTypes: at, actionCreators: ac} = require("common/Actions.jsm"); | ||
|
|
||
| class AutoMigratePrompt extends React.Component { |
k88hudson
May 31, 2017
Member
You can just use a pure function here, i.e.
const AutoMigratePrompt = props => {
// render stuff here
};
You can just use a pure function here, i.e.
const AutoMigratePrompt = props => {
// render stuff here
};| (<div className="migrate-prompt"> | ||
| <span>{this.props.AutoMigrate.msg}</span> | ||
| <div className="confirm"> | ||
| <button onClick={this.props.onUndoClick.bind(this)}><FormattedMessage id="migrate_undo_button" /></button> |
k88hudson
May 31, 2017
Member
If you use a pure function, you might have to do onClick={() => props.onUndoClick()}
If you use a pure function, you might have to do onClick={() => props.onUndoClick()}
Mardak
May 31, 2017
•
Member
We should probably not do the pure function and bind the function in constructor as binding from render will cause render optimizations to fail:
https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
We should probably not do the pure function and bind the function in constructor as binding from render will cause render optimizations to fail:
https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-no-bind.md
Mardak
May 31, 2017
•
Member
Actually, if onUndoClick is a prop, this probably shouldn't be AutoMigratePrompt anyway? So instead just do onClick={this.props.onUndoClick}
Actually, if onUndoClick is a prop, this probably shouldn't be AutoMigratePrompt anyway? So instead just do onClick={this.props.onUndoClick}
k88hudson
May 31, 2017
Member
actually yeah, the this isn't needed at all
actually yeah, the this isn't needed at all
| cursor: pointer; | ||
|
|
||
| &:hover { | ||
| box-shadow: 0 0 0 5px $faintest-black; |
k88hudson
May 31, 2017
Member
indentation is wrong here
indentation is wrong here
| } else { | ||
| this.store.dispatch(ac.BroadcastToContent({type: at.AUTOMIGRATE_HIDE})); | ||
| } | ||
| }).catch(() => {}); |
k88hudson
May 31, 2017
Member
Maybe Cu.reportError here
Maybe Cu.reportError here
| } | ||
| }).catch(() => {}); | ||
| break; | ||
| default: |
k88hudson
May 31, 2017
Member
This default block is not necessary
This default block is not necessary
| this.store.dispatch(ac.BroadcastToContent({type: at.AUTOMIGRATE_HIDE})); | ||
| break; | ||
| case at.AUTOMIGRATE_UNDO_MIGRATION: | ||
| AutoMigrate.undoAutoMigration(this.window); |
k88hudson
May 31, 2017
Member
I think it might be better to use action._target.browser (that is, from the AUTOMIGRATE_UNDO_MIGRATION action), since there could be multiple windows open at once
I think it might be better to use action._target.browser (that is, from the AUTOMIGRATE_UNDO_MIGRATION action), since there could be multiple windows open at once
gasolin
Jun 1, 2017
Author
Contributor
👍
| case at.NEW_TAB_VISIBLE: | ||
| AutoMigrate.shouldShowMigratePrompt(action._target.browser).then(prompt => { | ||
| if (prompt) { | ||
| this.window = action._target.browser.ownerGlobal; |
k88hudson
May 31, 2017
Member
See above comment on line 23, this might cause problems since there could be multiple windows open at once
See above comment on line 23, this might cause problems since there could be multiple windows open at once
gasolin
Jun 1, 2017
Author
Contributor
✅
| })); | ||
| } | ||
| } else { | ||
| this.store.dispatch(ac.BroadcastToContent({type: at.AUTOMIGRATE_HIDE})); |
k88hudson
May 31, 2017
Member
Could you perhaps do
else if (this.store.getState().Automigrate.display) { ... }
to prevent unnecessary messages/updates?
Could you perhaps do
else if (this.store.getState().Automigrate.display) { ... }
to prevent unnecessary messages/updates?
gasolin
Jun 1, 2017
Author
Contributor
👍
|
Here's how to do the manual testing:
|
3239322
to
914669e
|
tests added, ready for review again |
21b5e0b
to
41927a3
| </div> | ||
| </div>) : (<div className="migrate-prompt"> | ||
| <FormattedMessage id="migrate_manual_import_msg" /> | ||
| <FormattedMessage id="migrate_manual_import_link_msg" /> |
gasolin
Jun 5, 2017
Author
Contributor
this message would be a link to trigger the manual import wizard, which will be implemented in bug 1361294
For l10n team friendly I think its better to split strings early before we actually implement that function.
this message would be a link to trigger the manual import wizard, which will be implemented in bug 1361294
For l10n team friendly I think its better to split strings early before we actually implement that function.
Mardak
Jun 8, 2017
Member
I see that AutoMigrate will be passing over at least one of the messages. Any reason why it shouldn't pass over the manual import messages too? I do see that parts of it will be linked, but multiple message parts could be passed over too.
I see that AutoMigrate will be passing over at least one of the messages. Any reason why it shouldn't pass over the manual import messages too? I do see that parts of it will be linked, but multiple message parts could be passed over too.
|
@k88hudson or @Mardak could you help review this patch? |
|
Looks like there's some untested code causing coverage failures that would have resulted in runtime failures if it were executed. There's also some string issues with implicit concatenation although I seem to recall running into some issues with needing dangerously setting html for nesting links? @k88hudson ? |
| globals = new GlobalOverrider(); | ||
| globals.set("AutoMigrate", { | ||
| keepAutoMigration: globals.sandbox.stub(), | ||
| shouldShowMigratePrompt: globals.sandbox.stub().resolves(true), |
Mardak
Jun 8, 2017
Member
To get (100%) coverage tests passing, you'll need to test the false case of shouldShowMigratePrompt
To get (100%) coverage tests passing, you'll need to test the false case of shouldShowMigratePrompt
| }); | ||
|
|
||
| assert.calledOnce(global.AutoMigrate.shouldShowMigratePrompt); | ||
| }); |
Mardak
Jun 8, 2017
Member
Similarly for coverage, there should be additional tests for the various code paths handling NEW_TAB_VISIBLE
Similarly for coverage, there should be additional tests for the various code paths handling NEW_TAB_VISIBLE
| migrate_manual_import_msg=No problem. We can start you off with a few popular sites instead. You can always | ||
| # LOCALIZATION NOTE (migrate_manual_import_link_msg): This is shown as the link in message | ||
| migrate_manual_import_link_msg=import your information | ||
| migrate_manual_import_msg_trail=later. |
Mardak
Jun 8, 2017
Member
These strings need to be composed without implicit space-concatenation. If the message structure can't be changed, it'll probably look like "No problem. … You can always {import_link} later." Although even that seems odd to localize given the fragment within a sentence. Perhaps if it can be just two separate but adjacent messages, e.g., "No problem. … popular sites instead." and "Import your information when you're ready." with the latter sentence being the clickable link.
I do see that you're just using the strings from https://mozilla.invisionapp.com/share/Y3BGDY88H#/screens/234912781 via https://bugzilla.mozilla.org/show_bug.cgi?id=1360109 so I've relayed these comments in a ni? there.
These strings need to be composed without implicit space-concatenation. If the message structure can't be changed, it'll probably look like "No problem. … You can always {import_link} later." Although even that seems odd to localize given the fragment within a sentence. Perhaps if it can be just two separate but adjacent messages, e.g., "No problem. … popular sites instead." and "Import your information when you're ready." with the latter sentence being the clickable link.
I do see that you're just using the strings from https://mozilla.invisionapp.com/share/Y3BGDY88H#/screens/234912781 via https://bugzilla.mozilla.org/show_bug.cgi?id=1360109 so I've relayed these comments in a ni? there.
Mardak
Jun 8, 2017
Member
I see that flod says it won't be difficult to localize, so maybe we just need to fix the implicit concatenation issue with {replacement}. Although actually given that we have a before-link and after-link text, that should provide localizers with enough flexibility to work with? @flodolo
I see that flod says it won't be difficult to localize, so maybe we just need to fix the implicit concatenation issue with {replacement}. Although actually given that we have a before-link and after-link text, that should provide localizers with enough flexibility to work with? @flodolo
Mardak
Jun 8, 2017
Member
Ehh. I could see some locales wanting to just put "." in the trailing text, so if there's an implicit space to join, it would appear as "Stuff stuff later [link] ."
Ehh. I could see some locales wanting to just put "." in the trailing text, so if there's an implicit space to join, it would appear as "Stuff stuff later [link] ."
flodolo
Jun 8, 2017
Collaborator
Empty spaces in .properties files are a pain. I would go with:
# LOCALIZATION NOTE (migrate_manual_import_link_msg): do not translate {link},
# it's replaced by an active link using migrate_manual_import_link as text
migrate_manual_import_msg=No problem. We can start you off with a few popular sites instead. You can always {link} later.
migrate_manual_import_link=import your information
Empty spaces in .properties files are a pain. I would go with:
# LOCALIZATION NOTE (migrate_manual_import_link_msg): do not translate {link},
# it's replaced by an active link using migrate_manual_import_link as text
migrate_manual_import_msg=No problem. We can start you off with a few popular sites instead. You can always {link} later.
migrate_manual_import_link=import your information
| migrate_manual_import_link_msg=import your information | ||
| migrate_manual_import_msg_trail=later. | ||
| migrate_import_button=Import It | ||
| migrate_undo_button=Don't Import |
Mardak
Jun 8, 2017
Member
Behind the scenes, we're doing an undo; but that might be confusing to expose it that way to translators. Probably best to just call this migrate_dont_import_button
Behind the scenes, we're doing an undo; but that might be confusing to expose it that way to translators. Probably best to just call this migrate_dont_import_button
|
|
||
| return props.AutoMigrate.stage === 0 ? | ||
| (<div className="migrate-prompt"> | ||
| <span>{props.AutoMigrate.msg}</span> |
Mardak
Jun 8, 2017
Member
Just making sure, this msg should be the success message, e.g., "Dive right into Firefox! Import your favorite sites, bookmarks, history and passwords from Chrome" ? Maybe a more descriptive name will help -- migratedMessage ?
Just making sure, this msg should be the success message, e.g., "Dive right into Firefox! Import your favorite sites, bookmarks, history and passwords from Chrome" ? Maybe a more descriptive name will help -- migratedMessage ?
| case at.AUTOMIGRATE_IS_REVERTED: { | ||
| return { | ||
| display: true, | ||
| stage: 1, |
Mardak
Jun 8, 2017
Member
@k88hudson not sure if you have preferences on how this stage / state should be handled. With just numbers as here? Or strings or enum-ish? Or I suppose completely different is just deriving both display and stage from the component and storing the state as "HIDDEN" "MIGRATED" "REVERTED" ?
@k88hudson not sure if you have preferences on how this stage / state should be handled. With just numbers as here? Or strings or enum-ish? Or I suppose completely different is just deriving both display and stage from the component and storing the state as "HIDDEN" "MIGRATED" "REVERTED" ?
| state => ({AutoMigrate: state.AutoMigrate}), | ||
| dispatch => ({ | ||
| onImportClick: () => dispatch(ac.SendToMain({type: at.AUTOMIGRATE_MIGRATE_DONE})), | ||
| onUndoClick: () => dispatch(ac.SendToMain({type: at.AUTOMIGRATE_UNDO_MIGRATION})) |
Mardak
Jun 8, 2017
Member
I suppose following this pattern, we would want to add a onManualImportClick ?
I suppose following this pattern, we would want to add a onManualImportClick ?
gasolin
Jun 9, 2017
Author
Contributor
yes, it will be in the followup patch
yes, it will be in the followup patch
| case at.NEW_TAB_VISIBLE: | ||
| AutoMigrate.shouldShowMigratePrompt(action._target.browser).then(prompt => { | ||
| if (prompt) { | ||
| let browserName = Services.prefs.getStringPref("browser.migrate.automigrate.browser", ""); |
Mardak
Jun 8, 2017
Member
Why is there this pref logic when home/newtab usage doesn't check? https://dxr.mozilla.org/mozilla-central/search?q=%2Bref%3A%22AutoMigrate%23shouldShowMigratePrompt%22
The logic seems a bit odd in having Activity Stream seemingly randomly check a pref to do something different and somewhat overriding the just called shouldShowMigratePrompt. Is it possible to have that should method indicate what type of prompt should be shown instead of that a prompt should be shown?
Why is there this pref logic when home/newtab usage doesn't check? https://dxr.mozilla.org/mozilla-central/search?q=%2Bref%3A%22AutoMigrate%23shouldShowMigratePrompt%22
The logic seems a bit odd in having Activity Stream seemingly randomly check a pref to do something different and somewhat overriding the just called shouldShowMigratePrompt. Is it possible to have that should method indicate what type of prompt should be shown instead of that a prompt should be shown?
| data: {msg} | ||
| })); | ||
| } | ||
| } else if (this.store.getState().Automigrate.display) { |
Mardak
Jun 8, 2017
Member
This looks like a typo? Uncapitalized "M" in AutoMigrate ?
This looks like a typo? Uncapitalized "M" in AutoMigrate ?
| AutoMigrate.undoAutoMigration(action._target.browser.ownerGlobal); | ||
| this.store.dispatch(ac.BroadcastToContent({type: at.AUTOMIGRATE_IS_REVERTED})); | ||
| break; | ||
| case at.NEW_TAB_VISIBLE: |
Mardak
Jun 8, 2017
Member
Overall this logic seems a bit strange in that on visibility of a single new tab, there's broadcasts to all tabs?
Overall this logic seems a bit strange in that on visibility of a single new tab, there's broadcasts to all tabs?
|
Rebased and added manual import wizard link PR. @Mardak @k88hudson Due to priority shift I have been asked to help on other photon things. So I will not continue to finish these patch. Still thanks for your help! |
|
Closing this as automigration is no longer being impelmented as such. |
UI works, unit test is on the way, I think its ready for the first round review
You can enable this in about:config
browser.migrate.automigrate.inpage.ui.enabledonceBug 1361286is landed