Skip to content

Commit

Permalink
Merge pull request #13329 from mozilla/fxa-5290-update-flow-for-confi…
Browse files Browse the repository at this point in the history
…rming-pairing

refactor(content-server): update copy and add asset on "/pair" page
  • Loading branch information
millsoper authored Jun 22, 2022
2 parents b75efd2 + ebc6e58 commit 587aa6b
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 25 deletions.
15 changes: 15 additions & 0 deletions packages/fxa-content-server/app/images/confirm-pairing.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
<div id="main-content" class="card pair-auth">
<header>
<h1 id="fxa-pair-auth-allow-header">
{{#unsafeTranslate}}Approve new device <small>for %(email)s</small>{{/unsafeTranslate}}
{{#t}}Did you just sign in to Firefox?{{/t}}
</h1>
<p>{{#unsafeTranslate}} %(email)s {{/unsafeTranslate}}</p>
</header>

<section>
<div class="error"></div>
<div class="success"></div>
<div class="graphic graphic-confirm-pairing" role="img" aria-label="{{#t}}location balloon{{/t}}"></div>

<form novalidate>
{{{ unsafeDeviceBeingPairedHTML }}}

<div class="button-row">
<button type="submit" id="auth-approve-btn">{{#t}}Approve device{{/t}}</button>
</div>

<div class="links">
<a href="#" id="cancel">{{#t}}Cancel{{/t}}</a>
<button type="submit" id="auth-approve-btn">{{#t}}Yes, approve device{{/t}}</button>
</div>
<p>{{#unsafeTranslate}}If this wasn’t you, <a href="/settings/change_password" id="change-password">change your passsword</a> {{/unsafeTranslate}}</p>
</form>
</section>
</div>
11 changes: 0 additions & 11 deletions packages/fxa-content-server/app/scripts/views/pair/auth_allow.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,15 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import { assign } from 'underscore';
import Cocktail from 'cocktail';
import DeviceBeingPairedMixin from './device-being-paired-mixin';
import PairingTotpMixin from './pairing-totp-mixin';
import FormView from '../form';
import preventDefaultThen from '../decorators/prevent_default_then';
import Template from '../../templates/pair/auth_allow.mustache';

class PairAuthAllowView extends FormView {
template = Template;

events = assign(this.events, {
'click #cancel': preventDefaultThen('cancel'),
});

setInitialContext(context) {
context.set({
email: this.broker.get('browserSignedInAccount').email,
Expand All @@ -32,11 +26,6 @@ class PairAuthAllowView extends FormView {
submit() {
return this.invokeBrokerMethod('afterPairAuthAllow');
}

cancel() {
this.replaceCurrentPage('pair/failure');
return this.invokeBrokerMethod('afterPairAuthDecline');
}
}

Cocktail.mixin(PairAuthAllowView, PairingTotpMixin(), DeviceBeingPairedMixin());
Expand Down
8 changes: 8 additions & 0 deletions packages/fxa-content-server/app/styles/modules/_graphic.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@
margin: 0 auto 20px auto;
}

.graphic-confirm-pairing {
background-image: image-url('confirm-pairing.svg');

@include respond-to('small') {
height: 100px;
}
}

.graphic-laptop-mobile {
background-image: image-url('graphic_laptop_mobile.svg');
height: 138px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ describe('views/pair/auth_allow', () => {
}

describe('render', () => {
it('renders, can submit and cancel', () => {
const HEADER_TEXT = 'Did you just sign in to Firefox?';
it('renders, can submit and navigate to change password', () => {
sinon.stub(view, 'invokeBrokerMethod').callsFake(() => {});
sinon.spy(view, 'replaceCurrentPage');
return view.render().then(() => {
Expand All @@ -101,8 +102,9 @@ describe('views/pair/auth_allow', () => {
view.$el
.find('#fxa-pair-auth-allow-header')
.text()
.includes(MOCK_EMAIL)
.includes(HEADER_TEXT)
);
assert.isTrue(view.$el.find('header p').text().includes(MOCK_EMAIL));
assert.equal(view.$el.find('.family-os').text(), 'Firefox on Windows');
assert.equal(
view.$el.find('.location').text().trim(),
Expand All @@ -119,11 +121,7 @@ describe('views/pair/auth_allow', () => {
assert.isFalse(
view.invokeBrokerMethod.calledOnceWith('afterPairAuthDecline')
);
$('#container').find('#cancel').click();
assert.isTrue(
view.invokeBrokerMethod.secondCall.calledWith('afterPairAuthDecline')
);
assert.isTrue(view.replaceCurrentPage.calledOnceWith('pair/failure'));
assert.lengthOf(view.$('#change-password'), 1);
});
});

Expand Down Expand Up @@ -175,7 +173,7 @@ describe('views/pair/auth_allow', () => {
view.$el
.find('#fxa-pair-auth-allow-header')
.text()
.includes(MOCK_EMAIL)
.includes(HEADER_TEXT)
);
assert.equal(view.$el.find('.family-os').text(), 'Firefox on Windows');
assert.equal(
Expand Down

0 comments on commit 587aa6b

Please sign in to comment.