diff --git a/app/components/notifier/modal-new-edit/component.js b/app/components/notifier/modal-new-edit/component.js index 603b3034c..0b7cfbc55 100644 --- a/app/components/notifier/modal-new-edit/component.js +++ b/app/components/notifier/modal-new-edit/component.js @@ -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); diff --git a/app/models/notifier.js b/app/models/notifier.js index a413f5dec..b1e581f4f 100644 --- a/app/models/notifier.js +++ b/app/models/notifier.js @@ -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() { diff --git a/lib/shared/addon/utils/constants.js b/lib/shared/addon/utils/constants.js index 4b239d701..121cfffc9 100644 --- a/lib/shared/addon/utils/constants.js +++ b/lib/shared/addon/utils/constants.js @@ -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;