From 5c32b6ccbf1376c3f0f92ab1c03360a87f09fe95 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Wed, 22 Nov 2023 17:19:19 +0000 Subject: [PATCH] Wired up TK reminder step in publish flow (#19104) refs https://github.com/TryGhost/Product/issues/4184 - set up property on the editor controller for tracking number of TKs, action for updating it, and reset mechanism to ensure we go back to 0 when switching post - uses random number for now pending `` being updated to expose the TK count - passed TK count data to the publish flow modal so it can show a reminder step before the publish options step when there are still TKs in the post content - added `onCountChange` prop to `` ready for the count feature to be implemented --- .../components/editor/modals/publish-flow.hbs | 6 ++++++ .../components/editor/modals/publish-flow.js | 11 ++++++++++ .../modals/publish-flow/tk-reminder.hbs | 21 +++++++++++++------ .../components/editor/publish-management.js | 3 ++- .../components/gh-koenig-editor-lexical.hbs | 1 + .../app/components/koenig-lexical-editor.js | 2 +- ghost/admin/app/controllers/lexical-editor.js | 17 ++++++++++++++- ghost/admin/app/templates/lexical-editor.hbs | 2 ++ 8 files changed, 54 insertions(+), 9 deletions(-) diff --git a/ghost/admin/app/components/editor/modals/publish-flow.hbs b/ghost/admin/app/components/editor/modals/publish-flow.hbs index e8264e4746..994453a8da 100644 --- a/ghost/admin/app/components/editor/modals/publish-flow.hbs +++ b/ghost/admin/app/components/editor/modals/publish-flow.hbs @@ -51,6 +51,12 @@ @postCount={{this.postCount}} @close={{@close}} /> + {{else if this.isConfirmingTks}} + {{else}} 0 && !this.hasConfirmedTks; + } + get recipientType() { const filter = this.args.data.publishOptions.recipientFilter; @@ -40,6 +46,11 @@ export default class PublishModalComponent extends Component { return 'specific'; } + @action + confirmTks() { + this.hasConfirmedTks = true; + } + @action toggleConfirm() { this.isConfirming = !this.isConfirming; diff --git a/ghost/admin/app/components/editor/modals/publish-flow/tk-reminder.hbs b/ghost/admin/app/components/editor/modals/publish-flow/tk-reminder.hbs index 4288b4bf27..d1df224b19 100644 --- a/ghost/admin/app/components/editor/modals/publish-flow/tk-reminder.hbs +++ b/ghost/admin/app/components/editor/modals/publish-flow/tk-reminder.hbs @@ -2,13 +2,22 @@
Forget something?

- Looks like you've got some unfinished business. There are 5 TK reminders left in your post. + Looks like you've got some unfinished business. There are {{@tkCount}} TK reminders left in your post.

- - + +
\ No newline at end of file diff --git a/ghost/admin/app/components/editor/publish-management.js b/ghost/admin/app/components/editor/publish-management.js index ce156a0e73..ffc754bdc5 100644 --- a/ghost/admin/app/components/editor/publish-management.js +++ b/ghost/admin/app/components/editor/publish-management.js @@ -52,7 +52,8 @@ export default class PublishManagement extends Component { publishOptions: this.publishOptions, saveTask: this.publishTask, togglePreviewPublish: this.togglePreviewPublish, - skipAnimation + skipAnimation, + tkCount: this.args.tkCount }); const result = await this.publishFlowModal; diff --git a/ghost/admin/app/components/gh-koenig-editor-lexical.hbs b/ghost/admin/app/components/gh-koenig-editor-lexical.hbs index b1e5aab9b6..10d823d358 100644 --- a/ghost/admin/app/components/gh-koenig-editor-lexical.hbs +++ b/ghost/admin/app/components/gh-koenig-editor-lexical.hbs @@ -56,6 +56,7 @@ @registerAPI={{this.registerEditorAPI}} @cursorDidExitAtTop={{this.focusTitle}} @updateWordCount={{@updateWordCount}} + @updateTkCount={{@updateTkCount}} /> diff --git a/ghost/admin/app/components/koenig-lexical-editor.js b/ghost/admin/app/components/koenig-lexical-editor.js index 9ebeb80911..5f6238ef6a 100644 --- a/ghost/admin/app/components/koenig-lexical-editor.js +++ b/ghost/admin/app/components/koenig-lexical-editor.js @@ -536,7 +536,7 @@ export default class KoenigLexicalEditor extends Component { registerAPI={this.args.registerAPI} /> - {this.feature.tkReminders && } + {this.feature.tkReminders && } diff --git a/ghost/admin/app/controllers/lexical-editor.js b/ghost/admin/app/controllers/lexical-editor.js index f8f4188e9c..44684f6903 100644 --- a/ghost/admin/app/controllers/lexical-editor.js +++ b/ghost/admin/app/controllers/lexical-editor.js @@ -127,6 +127,7 @@ export default class LexicalEditorController extends Controller { // koenig related properties wordCount = 0; + tkCount = this.getRandomTkCount(); // TODO: set to 0 once onCountChange is wired up /* private properties ----------------------------------------------------*/ @@ -134,6 +135,14 @@ export default class LexicalEditorController extends Controller { _saveOnLeavePerformed = false; _previousTagNames = null; // set by setPost and _postSaved, used in hasDirtyAttributes + // TODO: remove once onCountChange is wired up + getRandomTkCount() { + if (!this.feature.tkReminders) { + return 0; + } + return Math.ceil(Math.random() * 10); + } + /* computed properties ---------------------------------------------------*/ @alias('model') @@ -310,6 +319,11 @@ export default class LexicalEditorController extends Controller { this.set('wordCount', count); } + @action + updateTkCount(count) { + this.set('tkCount', count); + } + @action setFeatureImage(url) { this.post.set('featureImage', url); @@ -1075,7 +1089,8 @@ export default class LexicalEditorController extends Controller { this.set('hasDirtyAttributes', false); this.set('shouldFocusTitle', false); this.set('showSettingsMenu', false); - this.set('wordCount', null); + this.set('wordCount', 0); + this.set('tkCount', this.getRandomTkCount()); // TODO: set to 0 once onCountChange is wired up // remove the onbeforeunload handler as it's only relevant whilst on // the editor route diff --git a/ghost/admin/app/templates/lexical-editor.hbs b/ghost/admin/app/templates/lexical-editor.hbs index b3db4490e5..298262e07f 100644 --- a/ghost/admin/app/templates/lexical-editor.hbs +++ b/ghost/admin/app/templates/lexical-editor.hbs @@ -9,6 +9,7 @@