mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Remember post preview tab when switching between preview/publish
refs https://github.com/TryGhost/Team/issues/1621 - added `currentTab` and `changeTab()` data arguments to preview modal allowing for the current tab to be remembered across opens in the `<PublishManagement>` component that controls open/close of the preview modal
This commit is contained in:
parent
dbcf51ee6b
commit
150f4fda2d
2 changed files with 13 additions and 2 deletions
|
@ -14,7 +14,7 @@ export default class EditorPostPreviewModal extends Component {
|
|||
ignoreBackdropClick: true
|
||||
};
|
||||
|
||||
@tracked tab = 'browser';
|
||||
@tracked tab = this.args.data.currentTab || 'browser';
|
||||
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
|
@ -24,6 +24,7 @@ export default class EditorPostPreviewModal extends Component {
|
|||
@action
|
||||
changeTab(tab) {
|
||||
this.tab = tab;
|
||||
this.args.data.changeTab?.(tab);
|
||||
}
|
||||
|
||||
@task
|
||||
|
|
|
@ -9,6 +9,7 @@ import {action} from '@ember/object';
|
|||
import {capitalize} from '@ember/string';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {task, taskGroup, timeout} from 'ember-concurrency';
|
||||
import {tracked} from '@glimmer/tracking';
|
||||
import {use} from 'ember-could-get-used-to-this';
|
||||
|
||||
const SHOW_SAVE_STATUS_DURATION = 3000;
|
||||
|
@ -26,6 +27,8 @@ export default class PublishManagement extends Component {
|
|||
// ensure we get a new PublishOptions instance when @post is replaced
|
||||
@use publishOptions = new PublishOptionsResource(() => [this.args.post]);
|
||||
|
||||
@tracked previewTab = 'browser';
|
||||
|
||||
publishFlowModal = null;
|
||||
updateFlowModal = null;
|
||||
|
||||
|
@ -88,11 +91,18 @@ export default class PublishManagement extends Component {
|
|||
post: this.publishOptions.post,
|
||||
hasDirtyAttributes: this.args.hasUnsavedChanges,
|
||||
saveTask: this.saveTask,
|
||||
togglePreviewPublish: this.togglePreviewPublish
|
||||
togglePreviewPublish: this.togglePreviewPublish,
|
||||
currentTab: this.previewTab,
|
||||
changeTab: this.changePreviewTab
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
changePreviewTab(tab) {
|
||||
this.previewTab = tab;
|
||||
}
|
||||
|
||||
@action
|
||||
async togglePreviewPublish(event) {
|
||||
event?.preventDefault();
|
||||
|
|
Loading…
Add table
Reference in a new issue