Skip to content

fix: Move padding inside unverified user component #4404

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

Merged
merged 3 commits into from
May 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions app/components/unverified-user-message.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{#if this.shouldShowMessage}}
<div class="{{unless @padless 'mb-8'}}">
<div class="ui icon {{if this.isMailSent 'info' 'error'}} message eight wide column center aligned">
<i class="close icon" onclick={{action (mut this.isMessageVisible) false}} role="button"></i>
<i class="info icon"></i>
<div class="content">
{{#if this.isMailSent}}
<div class="header">
{{t 'Confirmation mail has been sent again successfully!'}}
</div>
{{else}}
<div class="header">
{{#if (eq this.session.currentRouteName 'events.view.index')}}
{{t 'To make your event live, please verify your account by clicking on the confirmation link that has been emailed to you.'}}
{{else}}
{{t 'Your account is unverified. Please verify by clicking on the confirmation link that has been emailed to you.'}}
{{/if}}
</div>
<p>{{t 'Did not get the email?'}} <a href="#" onclick={{action 'sendConfirmationMail'}}>{{t 'Please click here to resend the confirmation mail.'}}</a></p>
{{/if}}
</div>
</div>
</div>
{{/if}}
9 changes: 1 addition & 8 deletions app/components/unverified-user-message.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
import { tracked } from '@glimmer/tracking';
import classic from 'ember-classic-decorator';
import { action, computed } from '@ember/object';
import { action } from '@ember/object';
import Component from '@ember/component';

@classic
export default class UnverifiedUserMessage extends Component {
@tracked isMessageVisible = true;
isMailSent = false;

@computed(
'session.isAuthenticated',
'authManager.currentUser.isVerified',
'isMessageVisible'
)
get shouldShowMessage() {
return this.session.isAuthenticated
&& this.isMessageVisible
Expand Down
4 changes: 4 additions & 0 deletions app/styles/partials/utils.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@
border-bottom-left-radius: 0 !important;
border-top-left-radius: 0 !important;
}

.mb-8 {
margin-bottom: 2rem;
}
6 changes: 1 addition & 5 deletions app/templates/account.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<div class="ui stackable grid">
<div class="sixteen wide column">
<UnverifiedUserMessage />
</div>
</div>
<UnverifiedUserMessage @padless="true" />
<div class="row">
<div class="sixteen wide column">
<TabbedNavigation>
Expand Down
22 changes: 0 additions & 22 deletions app/templates/components/unverified-user-message.hbs

This file was deleted.

6 changes: 1 addition & 5 deletions app/templates/create.hbs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<div class="ui container">
<div class="ui stackable grid">
<div class="sixteen wide column">
<UnverifiedUserMessage />
</div>
</div>
<UnverifiedUserMessage />
{{#if this.model.event.name}}
<h2 class="weight-300">{{t 'Creating'}} <span class="weight-500">{{this.model.event.name}}</span></h2>
{{else}}
Expand Down
8 changes: 1 addition & 7 deletions app/templates/events/view.hbs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
{{#if (and (or (eq this.session.currentRouteName 'events.view.index') (eq this.session.currentRouteName 'events.view.export')) (gt this.unverified-user-message.length 0))}}
{{#if (eq this.model.state 'draft')}}
<div class="ui grid stackable">
<div class="row">
<div class="sixteen wide column">
<UnverifiedUserMessage />
</div>
</div>
</div>
<UnverifiedUserMessage />
{{/if}}
{{/if}}
{{#if (not-includes this.session.currentRouteName 'events.view.edit')}}
Expand Down
6 changes: 1 addition & 5 deletions app/templates/public.hbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
<div class="ui stackable grid">
<div class="sixteen wide column">
<UnverifiedUserMessage />
</div>
</div>
<UnverifiedUserMessage />
<div class="public-event ui relaxed grid">
<div class="sixteen wide column lead {{if this.smallLead 'small'}}">
<Widgets::SafeImage @src={{if this.model.largeImageUrl this.model.largeImageUrl this.model.originalImageUrl}} />
Expand Down
39 changes: 21 additions & 18 deletions tests/integration/components/unverified-user-message-test.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,45 @@
import { hbs } from 'ember-cli-htmlbars';
import { module, test } from 'qunit';
import EmberObject from '@ember/object';
import { setupIntegrationTest } from 'open-event-frontend/tests/helpers/setup-integration-test';
import { render } from '@ember/test-helpers';

module('Integration | Component | unverified user message', function(hooks) {
setupIntegrationTest(hooks);

test('it renders', async function(assert) {
this.set('shouldShowMessage', true);
function setShouldShowMessage(sessionExtra = {}) {
this.set('session', {
isAuthenticated: true,
...sessionExtra
});
this.set('authManager', {
currentUser: {
isVerified: false
}
});
}

test('confirmation mail sent', async function(assert) {
setShouldShowMessage.call(this);
this.set('isMailSent', true);
await render(hbs`{{unverified-user-message shouldShowMessage=shouldShowMessage isMailSent=isMailSent}}`);
await render(hbs`{{unverified-user-message isMailSent=isMailSent authManager=authManager session=session}}`);
assert.ok(this.element.innerHTML.trim().includes('Confirmation mail has been sent again successfully'));
});

test('it renders', async function(assert) {

let session = EmberObject.create({
test('event live message', async function(assert) {
setShouldShowMessage.call(this, {
currentRouteName: 'events.view.index'
});

this.set('shouldShowMessage', true);
this.set('isMailSent', false);
this.set('session', session);
await render(hbs`{{unverified-user-message shouldShowMessage=shouldShowMessage session=session isMailSent=isMailSent}}`);
await render(hbs`{{unverified-user-message session=session authManager=authManager isMailSent=isMailSent}}`);
assert.ok(this.element.innerHTML.trim().includes('To make your event live, please verify your account by clicking on the confirmation link that has been emailed to you.'));
});

test('it renders', async function(assert) {

let session = EmberObject.create({
test('unverified message', async function(assert) {
setShouldShowMessage.call(this, {
currentRouteName: 'else'
});

this.set('shouldShowMessage', true);
this.set('isMailSent', false);
this.set('session', session);
await render(hbs`{{unverified-user-message shouldShowMessage=shouldShowMessage session=session isMailSent=isMailSent}}`);
await render(hbs`{{unverified-user-message session=session authManager=authManager isMailSent=isMailSent}}`);
assert.ok(this.element.innerHTML.trim().includes('Your account is unverified. Please verify by clicking on the confirmation link that has been emailed to you.'));
});
});