mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-07 03:22:21 +03:00
63df5ffb9b
Closes https://github.com/TryGhost/Ghost/issues/8731, closes https://github.com/TryGhost/Ghost/issues/8742 - Visual bugs resolved - Slack test message converted from alert to notiftication - Slack test message notification copy update - Increased size for notifications
64 lines
1.8 KiB
JavaScript
64 lines
1.8 KiB
JavaScript
import Controller from 'ember-controller';
|
|
import injectService from 'ember-service/inject';
|
|
import {alias} from 'ember-computed';
|
|
import {empty} from 'ember-computed';
|
|
import {isInvalidError} from 'ember-ajax/errors';
|
|
import {task} from 'ember-concurrency';
|
|
|
|
export default Controller.extend({
|
|
ghostPaths: injectService(),
|
|
ajax: injectService(),
|
|
notifications: injectService(),
|
|
settings: injectService(),
|
|
|
|
model: alias('settings.slack.firstObject'),
|
|
testNotificationDisabled: empty('model.url'),
|
|
|
|
save: task(function* () {
|
|
let slack = this.get('model');
|
|
let settings = this.get('settings');
|
|
|
|
try {
|
|
yield slack.validate();
|
|
settings.get('slack').clear().pushObject(slack);
|
|
return yield settings.save();
|
|
|
|
} catch (error) {
|
|
if (error) {
|
|
this.get('notifications').showAPIError(error);
|
|
throw error;
|
|
}
|
|
}
|
|
}).drop(),
|
|
|
|
sendTestNotification: task(function* () {
|
|
let notifications = this.get('notifications');
|
|
let slackApi = this.get('ghostPaths.url').api('slack', 'test');
|
|
|
|
try {
|
|
yield this.get('save').perform();
|
|
yield this.get('ajax').post(slackApi);
|
|
notifications.showNotification('Check your Slack channel for the test message!', {type: 'info', key: 'slack-test.send.success'});
|
|
return true;
|
|
|
|
} catch (error) {
|
|
notifications.showAPIError(error, {key: 'slack-test:send'});
|
|
|
|
if (!isInvalidError(error)) {
|
|
throw error;
|
|
}
|
|
}
|
|
}).drop(),
|
|
|
|
actions: {
|
|
save() {
|
|
this.get('save').perform();
|
|
},
|
|
|
|
updateURL(value) {
|
|
this.set('model.url', value);
|
|
this.get('model.errors').clear();
|
|
}
|
|
}
|
|
});
|