mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-30 01:42:29 +03:00
2453f6afbd
closes https://github.com/TryGhost/Ghost/issues/12461 Design changes: - added activity feed to member details page - rearranged Stripe info to display on the right - added toggle buttons for Stripe subscription and customer info - added box to display activity feed for received and opened emails Functionality changes: - added `queryRecord()` to member adapter so `queryRecord('member', {id: x})` will hit `/members/:id/?query` instead of `/members/?id=x&query` - updated member route to query member with `?include=email_recipients` - added `EmailRecipient` model for access to event timestamps and email relationship setup - added `<GhMemberActivityFeed>` component that accepts an `EmailRecipient` array and converts that into an activity list - added support for `@model=emailInstance` to the email preview modal - fixed a timing issue with email preview that could result in it showing blank content until the mobile/desktop toggle is used - fixed sometimes blank member location Co-authored-by: Kevin Ansfield <kevin@lookingsideways.co.uk>
83 lines
2.4 KiB
JavaScript
83 lines
2.4 KiB
JavaScript
import ModalComponent from 'ghost-admin/components/modal-base';
|
|
import {action} from '@ember/object';
|
|
import {alias} from '@ember/object/computed';
|
|
import {inject as service} from '@ember/service';
|
|
import {timeout} from 'ember-concurrency';
|
|
|
|
const INJECTED_CSS = `
|
|
html::-webkit-scrollbar {
|
|
display: none;
|
|
width: 0;
|
|
background: transparent
|
|
}
|
|
html {
|
|
scrollbar-width: none;
|
|
}
|
|
`;
|
|
|
|
export default ModalComponent.extend({
|
|
ghostPaths: service(),
|
|
ajax: service(),
|
|
settings: service(),
|
|
config: service(),
|
|
|
|
type: 'desktop',
|
|
html: '',
|
|
subject: '',
|
|
|
|
post: alias('model'),
|
|
|
|
actions: {
|
|
changeType(type) {
|
|
this.set('type', type);
|
|
}
|
|
},
|
|
|
|
renderEmailPreview: action(async function renderEmailPreview(iframe) {
|
|
await this._fetchEmailData();
|
|
// avoid timing issues when _fetchEmailData didn't perform any async ops
|
|
await timeout(100);
|
|
|
|
if (iframe) {
|
|
iframe.contentWindow.document.open();
|
|
iframe.contentWindow.document.write(this.html);
|
|
iframe.contentWindow.document.close();
|
|
}
|
|
}),
|
|
|
|
async _fetchEmailData() {
|
|
let {html, subject} = this;
|
|
|
|
if (html && subject) {
|
|
return {html, subject};
|
|
}
|
|
|
|
// model is an email
|
|
if (this.model.html && this.model.subject) {
|
|
html = this.model.html;
|
|
subject = this.model.subject;
|
|
// model is a post with an existing email
|
|
} else if (this.post.email) {
|
|
html = this.post.email.html;
|
|
subject = this.post.email.subject;
|
|
// model is a post, fetch email preview
|
|
} else {
|
|
let url = this.get('ghostPaths.url').api('/email_preview/posts', this.post.id);
|
|
let response = await this.ajax.request(url);
|
|
let [emailPreview] = response.email_previews;
|
|
html = emailPreview.html;
|
|
subject = emailPreview.subject;
|
|
}
|
|
|
|
// inject extra CSS into the html for disabling links and scrollbars etc
|
|
let domParser = new DOMParser();
|
|
let htmlDoc = domParser.parseFromString(html, 'text/html');
|
|
let stylesheet = htmlDoc.querySelector('style');
|
|
let originalCss = stylesheet.innerHTML;
|
|
stylesheet.innerHTML = `${originalCss}\n\n${INJECTED_CSS}`;
|
|
html = htmlDoc.documentElement.innerHTML;
|
|
|
|
this.setProperties({html, subject});
|
|
}
|
|
});
|