From a0a0c50ff52c2be22d106c414cfb1c8aeb441517 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Mon, 25 Feb 2019 21:55:55 +0700 Subject: [PATCH] Removed use of `?include=tags,authors,authors.roles` query param on post/page requests no issue - Admin API v2 now includes tags and authors by default --- ghost/admin/app/adapters/page.js | 12 ++++++++++++ ghost/admin/app/adapters/post.js | 12 ++++++++++++ ghost/admin/app/routes/editor/edit.js | 3 +-- ghost/admin/app/routes/posts.js | 2 -- ghost/admin/mirage/serializers/page.js | 3 +++ ghost/admin/mirage/serializers/post.js | 11 +++-------- 6 files changed, 31 insertions(+), 12 deletions(-) create mode 100644 ghost/admin/app/adapters/page.js create mode 100644 ghost/admin/app/adapters/post.js create mode 100644 ghost/admin/mirage/serializers/page.js diff --git a/ghost/admin/app/adapters/page.js b/ghost/admin/app/adapters/page.js new file mode 100644 index 0000000000..5375028b47 --- /dev/null +++ b/ghost/admin/app/adapters/page.js @@ -0,0 +1,12 @@ +import ApplicationAdapter from 'ghost-admin/adapters/application'; + +export default ApplicationAdapter.extend({ + // posts and pages now include everything by default + buildIncludeURL(store, modelName, id, snapshot, requestType, query) { + return this.buildURL(modelName, id, snapshot, requestType, query); + }, + + buildQuery(store, modelName, options) { + return options; + } +}); diff --git a/ghost/admin/app/adapters/post.js b/ghost/admin/app/adapters/post.js new file mode 100644 index 0000000000..5375028b47 --- /dev/null +++ b/ghost/admin/app/adapters/post.js @@ -0,0 +1,12 @@ +import ApplicationAdapter from 'ghost-admin/adapters/application'; + +export default ApplicationAdapter.extend({ + // posts and pages now include everything by default + buildIncludeURL(store, modelName, id, snapshot, requestType, query) { + return this.buildURL(modelName, id, snapshot, requestType, query); + }, + + buildQuery(store, modelName, options) { + return options; + } +}); diff --git a/ghost/admin/app/routes/editor/edit.js b/ghost/admin/app/routes/editor/edit.js index 67548aecc1..fd92413ec6 100644 --- a/ghost/admin/app/routes/editor/edit.js +++ b/ghost/admin/app/routes/editor/edit.js @@ -17,8 +17,7 @@ export default AuthenticatedRoute.extend({ model(params) { let query = { id: params.post_id, - status: 'all', - formats: 'mobiledoc,plaintext' + status: 'all' }; return this.store.query(params.type, query) diff --git a/ghost/admin/app/routes/posts.js b/ghost/admin/app/routes/posts.js index 024dbc448f..5dd2cf10ff 100644 --- a/ghost/admin/app/routes/posts.js +++ b/ghost/admin/app/routes/posts.js @@ -67,8 +67,6 @@ export default AuthenticatedRoute.extend({ queryParams.order = params.order; } - queryParams.formats = 'mobiledoc,plaintext'; - let perPage = this.perPage; let paginationSettings = assign({perPage, startingPage: 1}, paginationParams, queryParams); diff --git a/ghost/admin/mirage/serializers/page.js b/ghost/admin/mirage/serializers/page.js new file mode 100644 index 0000000000..5e82bbd95e --- /dev/null +++ b/ghost/admin/mirage/serializers/page.js @@ -0,0 +1,3 @@ +import PostSerializer from './post'; + +export default PostSerializer.extend({}); diff --git a/ghost/admin/mirage/serializers/post.js b/ghost/admin/mirage/serializers/post.js index ae05e556b7..1c9d7f5a13 100644 --- a/ghost/admin/mirage/serializers/post.js +++ b/ghost/admin/mirage/serializers/post.js @@ -3,16 +3,11 @@ import BaseSerializer from './application'; export default BaseSerializer.extend({ embed: true, - include(request) { + include(/*request*/) { let includes = []; - if (request.queryParams.include && request.queryParams.include.indexOf('tags') >= 0) { - includes.push('tags'); - } - - if (request.queryParams.include && request.queryParams.include.indexOf('authors') >= 0) { - includes.push('authors'); - } + includes.push('tags'); + includes.push('authors'); return includes; }