mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-18 02:21:47 -05:00
Switched from url param to local storage
This commit is contained in:
parent
a5ff2b7822
commit
f2454c5d13
7 changed files with 50 additions and 71 deletions
|
@ -92,9 +92,11 @@ export default class PublishFlowOptions extends Component {
|
|||
try {
|
||||
yield this.args.saveTask.perform();
|
||||
if (this.args.publishOptions.isScheduled) {
|
||||
window.location.href = '/ghost/#/posts/?success=true';
|
||||
localStorage.setItem('ghost-last-scheduled-post', this.args.publishOptions.post.id);
|
||||
window.location.href = '/ghost/#/posts?type=scheduled';
|
||||
} else {
|
||||
window.location.href = `/ghost/#/posts/analytics/${this.args.publishOptions.post.id}/?success=true`;
|
||||
localStorage.setItem('ghost-last-published-post', this.args.publishOptions.post.id);
|
||||
window.location.href = `/ghost/#/posts/analytics/${this.args.publishOptions.post.id}`;
|
||||
}
|
||||
} catch (e) {
|
||||
if (e === undefined && this.args.publishOptions.post.errors.length !== 0) {
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
{{/if}}
|
||||
|
||||
<header class="modal-header">
|
||||
<h1>
|
||||
<h1>{{this.post.title}}
|
||||
{{#unless this.post.isScheduled}}
|
||||
<span>Boom! It's out there.</span>
|
||||
<span>
|
||||
|
|
|
@ -43,3 +43,11 @@
|
|||
>
|
||||
<PostsList::ContextMenu @menu={{menu}} />
|
||||
</GhContextMenu>
|
||||
|
||||
{{#if this.showPublishFlowModal}}
|
||||
<GhFullscreenModal
|
||||
@modal="publish-flow"
|
||||
@model={{this.latestScheduledPost}}
|
||||
@close={{this.togglePublishFlowModal}}
|
||||
@modifier="action wide" />
|
||||
{{/if}}
|
|
@ -1,7 +1,40 @@
|
|||
import Component from '@glimmer/component';
|
||||
import {action} from '@ember/object';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {task} from 'ember-concurrency';
|
||||
import {tracked} from '@glimmer/tracking';
|
||||
|
||||
export default class PostsList extends Component {
|
||||
@service store;
|
||||
|
||||
@tracked showPublishFlowModal = false;
|
||||
@tracked latestScheduledPost = null;
|
||||
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.checkPublishFlowModal();
|
||||
}
|
||||
|
||||
checkPublishFlowModal() {
|
||||
if (localStorage.getItem('ghost-last-scheduled-post')) {
|
||||
this.getLatestScheduledPost.perform();
|
||||
this.showPublishFlowModal = true;
|
||||
localStorage.removeItem('ghost-last-scheduled-post');
|
||||
}
|
||||
}
|
||||
|
||||
get list() {
|
||||
return this.args.list;
|
||||
}
|
||||
|
||||
@action
|
||||
togglePublishFlowModal() {
|
||||
this.showPublishFlowModal = !this.showPublishFlowModal;
|
||||
}
|
||||
|
||||
@task
|
||||
*getLatestScheduledPost() {
|
||||
const result = yield this.store.query('post', {filter: 'status:scheduled', limit: 1});
|
||||
this.latestScheduledPost = result.toArray()[0];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -211,7 +211,6 @@
|
|||
<GhFullscreenModal
|
||||
@modal="publish-flow"
|
||||
@model={{this.post}}
|
||||
@publishOptions={{this.publishOptions}}
|
||||
@close={{this.togglePublishFlowModal}}
|
||||
@modifier="action wide" />
|
||||
{{/if}}
|
|
@ -1,10 +1,8 @@
|
|||
import Component from '@glimmer/component';
|
||||
import PublishOptionsResource from 'ghost-admin/helpers/publish-options';
|
||||
import {action} from '@ember/object';
|
||||
import {didCancel, task} from 'ember-concurrency';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {tracked} from '@glimmer/tracking';
|
||||
import {use} from 'ember-could-get-used-to-this';
|
||||
|
||||
/**
|
||||
* @typedef {import('../../services/dashboard-stats').SourceAttributionCount} SourceAttributionCount
|
||||
|
@ -37,19 +35,15 @@ export default class Analytics extends Component {
|
|||
@tracked showPublishFlowModal = false;
|
||||
displayOptions = DISPLAY_OPTIONS;
|
||||
|
||||
@use publishOptions = new PublishOptionsResource(() => [this.args.post]);
|
||||
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.checkUrlParameter();
|
||||
this.checkPublishFlowModal();
|
||||
}
|
||||
|
||||
checkUrlParameter() {
|
||||
const currentURL = this.router.currentURL;
|
||||
const url = new URL(window.location.origin + currentURL);
|
||||
const successParam = url.searchParams.get('success');
|
||||
if (successParam === 'true') {
|
||||
checkPublishFlowModal() {
|
||||
if (localStorage.getItem('ghost-last-published-post')) {
|
||||
this.showPublishFlowModal = true;
|
||||
localStorage.removeItem('ghost-last-published-post');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -164,28 +158,6 @@ export default class Analytics extends Component {
|
|||
|
||||
@action
|
||||
togglePublishFlowModal() {
|
||||
if (this.showPublishFlowModal) {
|
||||
const hash = window.location.hash;
|
||||
|
||||
// Extract the part before '?' and the query parameters
|
||||
const [path, queryParamsString] = hash.split('?');
|
||||
|
||||
// If there are query parameters, proceed to modify them
|
||||
if (queryParamsString) {
|
||||
const searchParams = new URLSearchParams(queryParamsString);
|
||||
|
||||
// Remove the 'success' parameter
|
||||
searchParams.delete('success');
|
||||
|
||||
// Construct the new hash fragment
|
||||
const newQueryParamsString = searchParams.toString();
|
||||
const newHash = newQueryParamsString ? `${path}?${newQueryParamsString}` : path;
|
||||
|
||||
// Update the URL without reloading the page
|
||||
window.history.replaceState(null, '', `${window.location.pathname}${window.location.search}${newHash}`);
|
||||
}
|
||||
}
|
||||
|
||||
this.showPublishFlowModal = !this.showPublishFlowModal;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import {DEFAULT_QUERY_PARAMS} from 'ghost-admin/helpers/reset-query-params';
|
|||
import {action} from '@ember/object';
|
||||
import {inject} from 'ghost-admin/decorators/inject';
|
||||
import {inject as service} from '@ember/service';
|
||||
import {task} from 'ember-concurrency';
|
||||
import {tracked} from '@glimmer/tracking';
|
||||
|
||||
const TYPES = [{
|
||||
|
@ -69,8 +68,6 @@ export default class PostsController extends Controller {
|
|||
@tracked tag = null;
|
||||
@tracked order = null;
|
||||
@tracked selectionList = new SelectionList(this.postsInfinityModel);
|
||||
@tracked showPublishFlowModal = false;
|
||||
@tracked latestScheduledPost = null;
|
||||
|
||||
availableTypes = TYPES;
|
||||
availableVisibilities = VISIBILITIES;
|
||||
|
@ -84,31 +81,10 @@ export default class PostsController extends Controller {
|
|||
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.checkUrlParameter();
|
||||
|
||||
this.router.on('routeDidChange', () => {
|
||||
this.checkUrlParameter();
|
||||
});
|
||||
|
||||
this.getLatestScheduledPost.perform();
|
||||
|
||||
Object.assign(this, DEFAULT_QUERY_PARAMS.posts);
|
||||
}
|
||||
|
||||
checkUrlParameter() {
|
||||
const hash = window.location.hash; // Get the full hash fragment
|
||||
const queryParamsString = hash.split('?')[1]; // Get the part after '?'
|
||||
|
||||
if (queryParamsString) {
|
||||
const searchParams = new URLSearchParams(queryParamsString);
|
||||
const successParam = searchParams.get('success');
|
||||
|
||||
if (successParam === 'true') {
|
||||
this.showPublishFlowModal = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
get showingAll() {
|
||||
const {type, author, tag, visibility} = this;
|
||||
|
||||
|
@ -190,15 +166,4 @@ export default class PostsController extends Controller {
|
|||
openEditor(post) {
|
||||
this.router.transitionTo('lexical-editor.edit', 'post', post.id);
|
||||
}
|
||||
|
||||
@action
|
||||
togglePublishFlowModal() {
|
||||
this.showPublishFlowModal = !this.showPublishFlowModal;
|
||||
}
|
||||
|
||||
@task
|
||||
*getLatestScheduledPost() {
|
||||
const result = yield this.store.query('post', {filter: 'status:scheduled', limit: 1});
|
||||
this.latestScheduledPost = result.toArray()[0];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue