mirror of https://github.com/rancher/ui.git
Update for review
This commit is contained in:
parent
912669bc50
commit
d138ffd8f5
|
|
@ -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,13 +173,14 @@ 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 }))
|
||||
}
|
||||
}
|
||||
|
||||
set(this, 'errors', errors);
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue