Update for review

This commit is contained in:
n313893254 2018-09-19 17:59:43 +08:00
parent 912669bc50
commit d138ffd8f5
3 changed files with 24 additions and 13 deletions

View File

@ -6,6 +6,7 @@ import layout from './template';
import { get, set } from '@ember/object'
import { inject as service } from '@ember/service';
import NewOrEdit from 'ui/mixins/new-or-edit';
import C from 'ui/utils/constants';
const TYPES = [
{
@ -162,7 +163,7 @@ export default Component.extend(ModalBase, NewOrEdit, {
},
validate() {
this._super();
this._super(...arguments);
const errors = get(this, 'errors') || [];
const intl = get(this, 'intl')
const preError = '"Default Recipient" is required'
@ -172,12 +173,13 @@ export default Component.extend(ModalBase, NewOrEdit, {
let afterError = ''
if (notifierType === 'slack') {
afterError = 'Default Channel'
afterError = C.NOTIFIER_TABLE_LABEL.SLACK
errors.splice(errors.findIndex((e) => e === preError), 1, intl.t('validation.required', { key: afterError }))
}
if (notifierType === 'email') {
afterError = 'Default Recipient Address'
afterError = C.NOTIFIER_TABLE_LABEL.SMTP
errors.splice(errors.findIndex((e) => e === preError), 1, intl.t('validation.required', { key: afterError }))
}
errors.splice(errors.findIndex((e) => e === preError), 1, intl.t('validation.required', { key: afterError }))
}
set(this, 'errors', errors);

View File

@ -2,6 +2,7 @@ import Resource from 'ember-api-store/models/resource';
import { inject as service } from '@ember/service';
import { get, computed } from '@ember/object';
import { hash } from 'rsvp';
import C from 'ui/utils/constants';
export default Resource.extend({
growl: service(),
@ -24,25 +25,25 @@ export default Resource.extend({
}),
notifierTableLabel: computed('slackConfig', 'pagerdutyConfig', 'emailConfig', 'webhookConfig', function() {
const sc = this.get('slackConfig');
const pc = this.get('pagerdutyConfig');
const ec = this.get('smtpConfig');
const wc = this.get('webhookConfig');
const sc = get(this, 'slackConfig');
const pc = get(this, 'pagerdutyConfig');
const ec = get(this, 'smtpConfig');
const wc = get(this, 'webhookConfig');
if (sc) {
return 'Default Channel';
return C.NOTIFIER_TABLE_LABEL.SLACK;
}
if (pc) {
return 'Service Key';
return C.NOTIFIER_TABLE_LABEL.PAGERDUTY;
}
if (ec) {
return 'Default Recipient Address';
return C.NOTIFIER_TABLE_LABEL.SMTP;
}
if (wc) {
return 'URL';
return C.NOTIFIER_TABLE_LABEL.WEBHOOK;
}
return 'Notifier';
return C.NOTIFIER_TABLE_LABEL.DEFAULT;
}),
notifierType: function() {

View File

@ -682,4 +682,12 @@ C.VOLUME_TYPES = {
CUSTOM_LOG_PATH: 'customLogPath'
}
C.NOTIFIER_TABLE_LABEL = {
SLACK: 'Default Channel',
PAGERDUTY: 'Service Key',
SMTP: 'Default Recipient Address',
WEBHOOK: 'URL',
DEFAULT: 'Notifier',
}
export default C;