From 3d49e01e6a492e4252f0861499dd3c9b946e6f94 Mon Sep 17 00:00:00 2001 From: Sodbileg Gansukh Date: Tue, 6 Aug 2024 17:36:00 +0800 Subject: [PATCH] Wired up the social and copy link buttons --- .../app/components/modal-publish-flow.hbs | 23 +++++++------- .../app/components/modal-publish-flow.js | 30 +++++++++++++++++++ ghost/admin/app/components/posts-list/list.js | 7 ++--- ghost/admin/app/components/posts/analytics.js | 7 ++--- 4 files changed, 46 insertions(+), 21 deletions(-) diff --git a/ghost/admin/app/components/modal-publish-flow.hbs b/ghost/admin/app/components/modal-publish-flow.hbs index 8a83f31b75..34a28a146b 100644 --- a/ghost/admin/app/components/modal-publish-flow.hbs +++ b/ghost/admin/app/components/modal-publish-flow.hbs @@ -1,4 +1,4 @@ -{{#if this.post.featureImage}} +{{#if (and this.post.featureImage (not this.post.emailOnly))}} @@ -75,7 +75,7 @@ - + {{else}} {{#if this.post.emailOnly}} {{#if this.post.isScheduled}} diff --git a/ghost/admin/app/components/modal-publish-flow.js b/ghost/admin/app/components/modal-publish-flow.js index c11e69ea16..3f8a758c54 100644 --- a/ghost/admin/app/components/modal-publish-flow.js +++ b/ghost/admin/app/components/modal-publish-flow.js @@ -1,5 +1,8 @@ import ModalComponent from 'ghost-admin/components/modal-base'; +import copyTextToClipboard from 'ghost-admin/utils/copy-text-to-clipboard'; +import {action} from '@ember/object'; import {inject as service} from '@ember/service'; +import {task, timeout} from 'ember-concurrency'; export default class ModalPublishFlow extends ModalComponent { @service store; @@ -13,4 +16,31 @@ export default class ModalPublishFlow extends ModalComponent { get postCount() { return this.model.postCount; } + + @action + handleTwitter() { + window.open(`https://twitter.com/intent/tweet?url=${encodeURI(this.post.url)}`, '_blank'); + } + + @action + handleThreads() { + window.open(`https://threads.net/intent/post?text=${encodeURI(this.post.url)}`, '_blank'); + } + + @action + handleFacebook() { + window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURI(this.post.url)}`, '_blank'); + } + + @action + handleLinkedIn() { + window.open(`http://www.linkedin.com/shareArticle?mini=true&url=${encodeURI(this.post.url)}`, '_blank'); + } + + @task + *handleCopyClick() { + copyTextToClipboard(this.post.url); + yield timeout(1000); + return true; + } } diff --git a/ghost/admin/app/components/posts-list/list.js b/ghost/admin/app/components/posts-list/list.js index 900b662620..22913a7f86 100644 --- a/ghost/admin/app/components/posts-list/list.js +++ b/ghost/admin/app/components/posts-list/list.js @@ -15,10 +15,10 @@ export default class PostsList extends Component { this.checkPublishFlowModal(); } - checkPublishFlowModal() { + async checkPublishFlowModal() { if (localStorage.getItem('ghost-last-scheduled-post')) { - this.getLatestScheduledPost.perform(); - // this.showPublishFlowModal = true; + await this.getLatestScheduledPost.perform(); + this.showPublishFlowModal = true; localStorage.removeItem('ghost-last-scheduled-post'); } } @@ -36,6 +36,5 @@ export default class PostsList extends Component { *getLatestScheduledPost() { const result = yield this.store.query('post', {filter: `id:${localStorage.getItem('ghost-last-scheduled-post')}`, limit: 1}); this.latestScheduledPost = result.toArray()[0]; - this.showPublishFlowModal = true; } } diff --git a/ghost/admin/app/components/posts/analytics.js b/ghost/admin/app/components/posts/analytics.js index 7ad29362f5..d768e34174 100644 --- a/ghost/admin/app/components/posts/analytics.js +++ b/ghost/admin/app/components/posts/analytics.js @@ -41,10 +41,10 @@ export default class Analytics extends Component { this.checkPublishFlowModal(); } - checkPublishFlowModal() { + async checkPublishFlowModal() { if (localStorage.getItem('ghost-last-published-post')) { - this.fetchPostCountTask.perform(); - // this.showPublishFlowModal = true; + await this.fetchPostCountTask.perform(); + this.showPublishFlowModal = true; localStorage.removeItem('ghost-last-published-post'); } } @@ -333,7 +333,6 @@ export default class Analytics extends Component { this.postCount = count; } - this.showPublishFlowModal = true; } get showLinks() {