From 7f7d2cafc6a62ef5e1a95496e703828ebd9b72a8 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Tue, 26 Jan 2021 22:49:05 +0000 Subject: [PATCH] Added share/send preview footers to post preview modal refs https://github.com/TryGhost/Team/issues/451 - disabled email tab when previewing a page (pages can't be emailed) - added share preview url footer to browser tab - added send preview footer to email tab - added first pass at social tab contents --- .../app/components/modal-post-preview.hbs | 12 ++-- .../app/components/modal-post-preview.js | 13 +++- .../components/modal-post-preview/browser.hbs | 20 ++++++ .../components/modal-post-preview/browser.js | 12 ++++ .../components/modal-post-preview/desktop.hbs | 5 -- .../components/modal-post-preview/email.hbs | 24 ++++++- .../components/modal-post-preview/email.js | 52 +++++++++++++++ .../components/modal-post-preview/social.hbs | 42 ++++++++++++ .../components/modal-post-preview/social.js | 65 +++++++++++++++++++ .../app/styles/layouts/preview-email.css | 3 +- ghost/admin/config/environment.js | 4 ++ ghost/admin/package.json | 1 + ghost/admin/yarn.lock | 10 +++ 13 files changed, 250 insertions(+), 13 deletions(-) create mode 100644 ghost/admin/app/components/modal-post-preview/browser.hbs create mode 100644 ghost/admin/app/components/modal-post-preview/browser.js delete mode 100644 ghost/admin/app/components/modal-post-preview/desktop.hbs create mode 100644 ghost/admin/app/components/modal-post-preview/social.js diff --git a/ghost/admin/app/components/modal-post-preview.hbs b/ghost/admin/app/components/modal-post-preview.hbs index b748a25a9e..4115587c64 100644 --- a/ghost/admin/app/components/modal-post-preview.hbs +++ b/ghost/admin/app/components/modal-post-preview.hbs @@ -2,8 +2,10 @@ - {{#if (eq this.tab "desktop")}} - + {{#if (eq this.tab "browser")}} + {{/if}} - {{#if (eq this.tab "email")}} + {{#if (and (eq this.tab "email") this.model.isPost)}} {{/if}} diff --git a/ghost/admin/app/components/modal-post-preview.js b/ghost/admin/app/components/modal-post-preview.js index 854296e41a..7c886d6871 100644 --- a/ghost/admin/app/components/modal-post-preview.js +++ b/ghost/admin/app/components/modal-post-preview.js @@ -6,7 +6,7 @@ import {tracked} from '@glimmer/tracking'; // TODO: update modals to work fully with Glimmer components @classic export default class ModalPostPreviewComponent extends ModalBase { - @tracked tab = 'desktop'; + @tracked tab = 'browser'; @action changeTab(tab) { @@ -17,4 +17,15 @@ export default class ModalPostPreviewComponent extends ModalBase { close() { this.closeModal(); } + + actions = { + confirm() { + // noop - needed to override ModalBase.actions.confirm + }, + + // needed because ModalBase uses .send() for keyboard events + closeModal() { + this.closeModal(); + } + } } diff --git a/ghost/admin/app/components/modal-post-preview/browser.hbs b/ghost/admin/app/components/modal-post-preview/browser.hbs new file mode 100644 index 0000000000..16c95e92dc --- /dev/null +++ b/ghost/admin/app/components/modal-post-preview/browser.hbs @@ -0,0 +1,20 @@ + +
+ Share this preview privately +
+ {{@post.previewUrl}} +
+ +
\ No newline at end of file diff --git a/ghost/admin/app/components/modal-post-preview/browser.js b/ghost/admin/app/components/modal-post-preview/browser.js new file mode 100644 index 0000000000..c19a5f3c52 --- /dev/null +++ b/ghost/admin/app/components/modal-post-preview/browser.js @@ -0,0 +1,12 @@ +import Component from '@glimmer/component'; +import copyTextToClipboard from 'ghost-admin/utils/copy-text-to-clipboard'; +import {task} from 'ember-concurrency-decorators'; +import {timeout} from 'ember-concurrency'; + +export default class ModalPostPreviewBrowserComponent extends Component { + @task + *copyPreviewUrl() { + copyTextToClipboard(this.args.post.previewUrl); + yield timeout(this.isTesting ? 50 : 3000); + } +} diff --git a/ghost/admin/app/components/modal-post-preview/desktop.hbs b/ghost/admin/app/components/modal-post-preview/desktop.hbs deleted file mode 100644 index 9e6e183b0e..0000000000 --- a/ghost/admin/app/components/modal-post-preview/desktop.hbs +++ /dev/null @@ -1,5 +0,0 @@ - \ No newline at end of file diff --git a/ghost/admin/app/components/modal-post-preview/email.hbs b/ghost/admin/app/components/modal-post-preview/email.hbs index 363cb50033..124c3a1be1 100644 --- a/ghost/admin/app/components/modal-post-preview/email.hbs +++ b/ghost/admin/app/components/modal-post-preview/email.hbs @@ -1,4 +1,4 @@ -