Skip to content

Commit 93029f3

Browse files
authored
feat: Add test mails functionality in admin settings (#3135)
1 parent b32c89f commit 93029f3

File tree

4 files changed

+80
-0
lines changed

4 files changed

+80
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import Component from '@ember/component';
2+
import FormMixin from 'open-event-frontend/mixins/form';
3+
4+
export default Component.extend(FormMixin, {
5+
getValidationRules() {
6+
return {
7+
inline : true,
8+
delay : false,
9+
on : 'blur',
10+
fields : {
11+
testEmail: {
12+
identifier : 'test_email',
13+
rules : [
14+
{
15+
type : 'empty',
16+
prompt : this.l10n.t('Please enter the recepient E-mail')
17+
},
18+
{
19+
type : 'email',
20+
prompt : this.l10n.t('Please enter a valid email address')
21+
}
22+
]
23+
}
24+
}
25+
};
26+
},
27+
actions: {
28+
sendTestMail() {
29+
this.onValid(() => {
30+
let payload = {
31+
recipient: this.recipientEmail
32+
};
33+
let config = {
34+
skipDataTransform: true
35+
};
36+
this.loader.post('/test-mail', JSON.stringify(payload), config)
37+
.then(response => {
38+
this.notify.success(response.message);
39+
})
40+
.catch(e => {
41+
console.warn(e);
42+
this.notify.error(this.l10n.t('An unexpected error has occurred'));
43+
});
44+
});
45+
}
46+
}
47+
});

app/templates/components/forms/admin/settings/system/mail-settings.hbs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,3 +95,4 @@
9595
{{input type='text' name='sendgrid_token' value=settings.sendgridKey}}
9696
</div>
9797
{{/if}}
98+
{{forms/admin/settings/system/mail-settings/test-email-form}}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<div class="ui form">
2+
{{#ui-accordion class='field'}}
3+
<div class="title">
4+
<i class="icon dropdown"></i>
5+
{{t 'Send Test Email'}}
6+
</div>
7+
<div class="content four wide field">
8+
<div class="ui action input">
9+
{{input type="text" placeholder=(t 'Recipient E-mail') name='test_email' value=recipientEmail }}
10+
<div class="ui secondary button" role="button" {{action 'sendTestMail'}}>
11+
{{t 'Test'}}
12+
</div>
13+
</div>
14+
</div>
15+
{{/ui-accordion}}
16+
</div>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { module, test } from 'qunit';
2+
import { setupRenderingTest } from 'ember-qunit';
3+
import { render } from '@ember/test-helpers';
4+
import hbs from 'htmlbars-inline-precompile';
5+
6+
module('Integration | Component | forms/admin/settings/system/mail-settings/test-email-form', function(hooks) {
7+
setupRenderingTest(hooks);
8+
9+
test('it renders', async function(assert) {
10+
11+
await render(hbs`{{forms/admin/settings/system/mail-settings/test-email-form}}`);
12+
13+
assert.ok(this.element.innerHTML.trim().includes('Send Test Email'));
14+
15+
});
16+
});

0 commit comments

Comments
 (0)