mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-02 08:13:34 +03:00
3cd1eb5826
closes https://github.com/TryGhost/Team/issues/506 - launch wizard and brand settings both shared the same design and behaviour for customising brand settings but used duplicated code that had diverged - extracted the more up-to-date behaviour from the launch wizard into a component - updated brand settings and launch wizard to use the new component changes to brand settings modal behaviour: - preview is no longer interactive - switches to using iframe contents replacement instead of `postMessage`
41 lines
1.1 KiB
JavaScript
41 lines
1.1 KiB
JavaScript
import ModalComponent from 'ghost-admin/components/modal-base';
|
|
import {action} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
import {task} from 'ember-concurrency';
|
|
|
|
export default ModalComponent.extend({
|
|
config: service(),
|
|
notifications: service(),
|
|
settings: service(),
|
|
|
|
willDestroyElement() {
|
|
// reset any unsaved changes when closing
|
|
this.settings.rollbackAttributes();
|
|
},
|
|
|
|
registerPreviewIframe: action(function (element) {
|
|
this.previewIframe = element;
|
|
}),
|
|
|
|
replacePreviewContents: action(function (html) {
|
|
if (this.previewIframe) {
|
|
this.previewIframe.contentWindow.document.open();
|
|
this.previewIframe.contentWindow.document.write(html);
|
|
this.previewIframe.contentWindow.document.close();
|
|
}
|
|
}),
|
|
|
|
saveTask: task(function* () {
|
|
try {
|
|
yield this.settings.save();
|
|
this.closeModal();
|
|
return true;
|
|
} catch (error) {
|
|
if (error) {
|
|
this.notifications.showAPIError(error);
|
|
throw error;
|
|
}
|
|
}
|
|
})
|
|
});
|