Ghost/ghost/admin/app/templates/editor.hbs
Chris Raible a5d3101ec9
🐛 Fixed broken editor breadcrumbs when opening a new post from analytics (#16463)
refs TryGhost/Team#2401

- Previously, if you opened a new post using the plus button on the sidebar while on a different post's analytics page, the breadcrumbs would point back to Analytics instead of the Posts list view. Going back to Analytics brought you back to the analytics page for the post you just created, which wasn't populating since it likely hadn't been published yet.
- This commit fixes the issue by setting fromAnalytics = false if transitioning to a new Post, even if the previous route was the analytics page.
2023-03-22 00:12:15 -07:00

127 lines
6.2 KiB
Handlebars

{{#if this.post}}
<div class="flex flex-row">
<GhEditor
@tagName="section"
@class="gh-editor gh-view relative"
as |editor|
>
<header class="gh-editor-header br2 pe-none">
<Editor::PublishManagement
@post={{this.post}}
@hasUnsavedChanges={{this.hasDirtyAttributes}}
@beforePublish={{perform this.beforeSaveTask}}
@afterPublish={{this.afterSave}}
@saveTask={{this.saveTask}}
@savePostTask={{this.savePostTask}}
as |publishManagement|
>
<div class="flex items-center pe-auto h-100">
{{#if this.ui.isFullScreen}}
{{#if this.fromAnalytics }}
<LinkTo @route="posts.analytics" @model={{this.post.id}} class="gh-btn-editor gh-editor-back-button" data-test-breadcrumb>
<span>
{{svg-jar "arrow-left"}}
Analytics
</span>
</LinkTo>
{{else}}
<LinkTo @route={{pluralize this.post.displayName }} class="gh-btn-editor gh-editor-back-button" data-test-link={{pluralize this.post.displayName}} data-test-breadcrumb>
<span>
{{svg-jar "arrow-left"}}
{{capitalize (pluralize this.post.displayName)}}
</span>
</LinkTo>
{{/if}}
{{/if}}
{{#if (or (not this.ui.isFullScreen) (not this.fromAnalytics) this.post.didEmailFail) }}
<div class="gh-editor-post-status">
<span>
<GhEditorPostStatus
@post={{this.post}}
@publishManagement={{publishManagement}}
@hasDirtyAttributes={{this.hasDirtyAttributes}}
@isSaving={{or this.autosaveTask.isRunning this.saveTasks.isRunning}}
@openUpdateFlow={{publishManagement.openUpdateFlow}}
/>
</span>
</div>
{{/if}}
</div>
<section class="flex items-center pe-auto h-100">
{{#unless this.post.isNew}}
<Editor::PublishButtons @publishManagement={{publishManagement}} />
{{#unless this.showSettingsMenu}}
<div class="settings-menu-toggle-spacer"></div>
{{/unless}}
{{/unless}}
</section>
</Editor::PublishManagement>
</header>
{{!--
gh-koenig-editor acts as a wrapper around the title input and
koenig editor canvas to support Ghost-specific editor behaviour
--}}
<GhKoenigEditor
@title={{readonly this.post.titleScratch}}
@titleAutofocus={{this.shouldFocusTitle}}
@titlePlaceholder={{concat (capitalize this.post.displayName) " title"}}
@onTitleChange={{this.updateTitleScratch}}
@onTitleBlur={{perform this.saveTitleTask}}
@body={{readonly this.post.scratch}}
@bodyPlaceholder={{concat "Begin writing your " this.post.displayName "..."}}
@onBodyChange={{this.updateScratch}}
@headerOffset={{editor.headerHeight}}
@scrollContainerSelector=".gh-koenig-editor"
@scrollOffsetBottomSelector=".gh-mobile-nav-bar"
@onEditorCreated={{this.setKoenigEditor}}
@onWordCountChange={{this.updateWordCount}}
@snippets={{this.snippets}}
@saveSnippet={{if this.canManageSnippets this.saveSnippet}}
@updateSnippet={{if this.canManageSnippets this.confirmUpdateSnippet}}
@deleteSnippet={{if this.canManageSnippets this.confirmDeleteSnippet}}
@featureImage={{this.post.featureImage}}
@featureImageAlt={{this.post.featureImageAlt}}
@featureImageCaption={{this.post.featureImageCaption}}
@setFeatureImage={{this.setFeatureImage}}
@setFeatureImageAlt={{this.setFeatureImageAlt}}
@setFeatureImageCaption={{this.setFeatureImageCaption}}
@clearFeatureImage={{this.clearFeatureImage}}
@cardOptions={{hash
post=this.post
}}
@postType={{this.post.displayName}}
/>
<div class="gh-editor-wordcount-container">
<div class="gh-editor-wordcount">
{{gh-pluralize this.wordCount.wordCount "word"}}
</div>
<a href="https://ghost.org/help/using-the-editor/" class="flex" target="_blank" rel="noopener noreferrer">{{svg-jar "help"}}</a>
</div>
</GhEditor>
{{#if this.showSettingsMenu}}
<GhPostSettingsMenu
@post={{this.post}}
@deletePost={{this.openDeletePostModal}}
@updateSlugTask={{this.updateSlugTask}}
@savePostTask={{this.savePostTask}}
/>
{{/if}}
</div>
<button type="button" class="settings-menu-toggle gh-btn gh-btn-editor gh-btn-icon icon-only gh-btn-action-icon" title="Settings" {{on "click" this.toggleSettingsMenu}} data-test-psm-trigger>
{{#if this.showSettingsMenu}}
<span class="settings-menu-open">{{svg-jar "sidemenu-open"}}</span>
{{else}}
<span>{{svg-jar "sidemenu"}}</span>
{{/if}}
</button>
{{/if}}
{{outlet}}