mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-02 07:43:11 +03:00
fb9b4b7957
refs e9911d5e20
- unused import was left over from earlier experiment
57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
import Controller from '@ember/controller';
|
|
import {action} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
import {task} from 'ember-concurrency-decorators';
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
export default class SettingsDesignIndexController extends Controller {
|
|
@service config;
|
|
@service customThemeSettings;
|
|
@service notifications;
|
|
@service settings;
|
|
@service themeManagement;
|
|
|
|
@tracked previewSize = 'desktop';
|
|
|
|
get isDesktopPreview() {
|
|
return this.previewSize === 'desktop';
|
|
}
|
|
|
|
get isMobilePreview() {
|
|
return this.previewSize === 'mobile';
|
|
}
|
|
|
|
@action
|
|
setPreviewSize(size) {
|
|
this.previewSize = size;
|
|
}
|
|
|
|
@action
|
|
saveFromKeyboard() {
|
|
document.activeElement.blur?.();
|
|
return this.saveTask.perform();
|
|
}
|
|
|
|
@task
|
|
*saveTask() {
|
|
try {
|
|
if (this.settings.get('errors').length !== 0) {
|
|
return;
|
|
}
|
|
|
|
yield Promise.all([
|
|
this.settings.save(),
|
|
this.customThemeSettings.save()
|
|
]);
|
|
|
|
// ensure task button switches to success state
|
|
return true;
|
|
} catch (error) {
|
|
if (error) {
|
|
this.notifications.showAPIError(error);
|
|
throw error;
|
|
}
|
|
}
|
|
}
|
|
}
|