From 8984c0ae32c60744d8de40a240bf21921ef3fda8 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Wed, 24 Jun 2020 14:23:51 +0100 Subject: [PATCH] Updated to fetch settings using `/settings/?group=` instead of `?type=` refs https://github.com/TryGhost/Ghost/issues/10318 - primary change is in the settings service which is the only place we fetch the settings endpoint - mocked APIs and fixture data updated to expect and to filter on `?group` rather than `?type` --- ghost/admin/app/services/settings.js | 2 +- ghost/admin/mirage/config/settings.js | 12 +++--- ghost/admin/mirage/fixtures/settings.js | 40 ++++++++++---------- ghost/admin/tests/acceptance/content-test.js | 2 +- 4 files changed, 28 insertions(+), 28 deletions(-) diff --git a/ghost/admin/app/services/settings.js b/ghost/admin/app/services/settings.js index bb5422cc28..67b7cd6549 100644 --- a/ghost/admin/app/services/settings.js +++ b/ghost/admin/app/services/settings.js @@ -27,7 +27,7 @@ export default Service.extend(_ProxyMixin, ValidationEngine, { _loadSettings() { if (!this._loadingPromise) { this._loadingPromise = this.store - .queryRecord('setting', {type: 'site,theme,private,members,portal,email,amp,labs,slack,unsplash,views'}) + .queryRecord('setting', {group: 'site,theme,private,members,portal,email,amp,labs,slack,unsplash,views'}) .then((settings) => { this._loadingPromise = null; return settings; diff --git a/ghost/admin/mirage/config/settings.js b/ghost/admin/mirage/config/settings.js index 93d0d04f66..3a81e2ce20 100644 --- a/ghost/admin/mirage/config/settings.js +++ b/ghost/admin/mirage/config/settings.js @@ -1,20 +1,20 @@ export default function mockSettings(server) { server.get('/settings/', function ({db}, {queryParams}) { - let {type} = queryParams; - let filters = type.split(','); + let {group} = queryParams; + let filters = group.split(','); let settings = []; if (!db.settings.length) { server.loadFixtures('settings'); } - filters.forEach((type) => { - settings.pushObjects(db.settings.where({type})); + filters.forEach((groupFilter) => { + settings.pushObjects(db.settings.where({group: groupFilter})); }); return { settings, - meta: {filters: {type}} + meta: {filters: {group}} }; }); @@ -27,7 +27,7 @@ export default function mockSettings(server) { if (db.settings.where({key}).length > 0) { db.settings.update({key}, newSetting); } else { - newSetting.type = newSetting.type || 'site'; + newSetting.group = newSetting.group || 'site'; db.settings.insert(newSetting); } }); diff --git a/ghost/admin/mirage/fixtures/settings.js b/ghost/admin/mirage/fixtures/settings.js index 73ac20c300..fb347f1343 100644 --- a/ghost/admin/mirage/fixtures/settings.js +++ b/ghost/admin/mirage/fixtures/settings.js @@ -5,7 +5,7 @@ export default [ created_at: '2015-09-11T09:44:30.805Z', created_by: 1, key: 'title', - type: 'site', + group: 'site', updated_at: '2015-10-04T16:26:05.195Z', updated_by: 1, value: 'Test Blog' @@ -15,7 +15,7 @@ export default [ created_at: '2015-09-11T09:44:30.806Z', created_by: 1, key: 'description', - type: 'site', + group: 'site', updated_at: '2015-10-04T16:26:05.198Z', updated_by: 1, value: 'Thoughts, stories and ideas.' @@ -24,7 +24,7 @@ export default [ id: 3, key: 'logo', value: '/content/images/2013/Nov/logo.png', - type: 'site', + group: 'site', created_at: '2013-11-25T14:48:11.000Z', created_by: 1, updated_at: '2015-10-27T17:39:58.273Z', @@ -34,7 +34,7 @@ export default [ id: 4, key: 'cover_image', value: '/content/images/2014/Feb/cover.jpg', - type: 'site', + group: 'site', created_at: '2013-11-25T14:48:11.000Z', created_by: 1, updated_at: '2015-10-27T17:39:58.276Z', @@ -44,7 +44,7 @@ export default [ id: 5, key: 'default_locale', value: 'en', - type: 'site', + group: 'site', created_at: '2013-11-25T14:48:11.000Z', created_by: 1, updated_at: '2015-10-27T17:39:58.278Z', @@ -55,7 +55,7 @@ export default [ created_at: '2015-09-11T09:44:30.809Z', created_by: 1, key: 'codeinjection_head', - type: 'site', + group: 'site', updated_at: '2015-09-23T13:32:49.858Z', updated_by: 1, value: '' @@ -65,7 +65,7 @@ export default [ created_at: '2015-09-11T09:44:30.809Z', created_by: 1, key: 'codeinjection_foot', - type: 'site', + group: 'site', updated_at: '2015-09-23T13:32:49.858Z', updated_by: 1, value: '' @@ -74,7 +74,7 @@ export default [ id: 12, key: 'labs', value: '{}', - type: 'labs', + group: 'labs', created_at: '2015-01-12T18:29:01.000Z', created_by: 1, updated_at: '2015-10-27T17:39:58.288Z', @@ -85,7 +85,7 @@ export default [ created_at: '2015-09-11T09:44:30.810Z', created_by: 1, key: 'navigation', - type: 'site', + group: 'site', updated_at: '2015-09-23T13:32:49.868Z', updated_by: 1, value: JSON.stringify([ @@ -98,7 +98,7 @@ export default [ created_at: '2015-09-11T09:44:30.810Z', created_by: 1, key: 'is_private', - type: 'private', + group: 'private', updated_at: '2015-09-23T13:32:49.868Z', updated_by: 1, value: false @@ -108,7 +108,7 @@ export default [ created_at: '2015-09-11T09:44:30.810Z', created_by: 1, key: 'password', - type: 'private', + group: 'private', updated_at: '2015-09-23T13:32:49.868Z', updated_by: 1, value: '' @@ -118,7 +118,7 @@ export default [ created_at: '2016-05-05T15:04:03.115Z', created_by: 1, key: 'slack', - type: 'slack', + group: 'slack', updated_at: '2016-05-05T18:33:09.168Z', updated_by: 1, value: '[{"url":"", "username":"Ghost"}]' @@ -128,7 +128,7 @@ export default [ created_at: '2016-05-05T15:40:12.133Z', created_by: 1, key: 'facebook', - type: 'site', + group: 'site', updated_at: '2016-05-08T15:20:25.953Z', updated_by: 1, value: 'test' @@ -138,7 +138,7 @@ export default [ created_at: '2016-05-05T15:40:12.134Z', created_by: 1, key: 'twitter', - type: 'site', + group: 'site', updated_at: '2016-05-08T15:20:25.954Z', updated_by: 1, value: '@test' @@ -148,7 +148,7 @@ export default [ created_at: '2015-09-11T09:44:30.810Z', created_by: 1, key: 'active_timezone', - type: 'site', + group: 'site', updated_at: '2015-09-23T13:32:49.868Z', updated_by: 1, value: 'Etc/UTC' @@ -158,7 +158,7 @@ export default [ created_at: '2017-01-09T08:40:59.000Z', created_by: 1, key: 'amp', - type: 'amp', + group: 'amp', updated_at: '2017-01-09T08:49:42.991Z', updated_by: 1, value: 'true' @@ -167,7 +167,7 @@ export default [ id: 22, key: 'icon', value: '/content/images/2014/Feb/favicon.ico', - type: 'site', + group: 'site', created_at: '2013-11-25T14:48:11.000Z', created_by: 1, updated_at: '2015-10-27T17:39:58.276Z', @@ -175,7 +175,7 @@ export default [ }, { id: 23, - type: 'members', + group: 'members', key: 'members_subscription_settings', value: '{"allowSelfSignup":true,"fromAddress":"noreply","paymentProcessors":[{"adapter":"stripe","config":{"secret_token":"","public_token":"","product":{"name":"Ghost Subscription"},"plans":[{"name":"Monthly","currency":"usd","interval":"month","amount":""},{"name":"Yearly","currency":"usd","interval":"year","amount":""}]}}]}', created_at: '2019-10-09T09:49:00.000Z', @@ -185,7 +185,7 @@ export default [ }, { id: 24, - type: 'email', + group: 'email', key: 'bulk_email_settings', value: '{"provider":"mailgun","apiKey":"","domain":"","baseUrl":""}', created_at: '2019-10-09T09:49:00.000Z', @@ -196,7 +196,7 @@ export default [ { id: 25, key: 'secondary_navigation', - type: 'site', + group: 'site', created_at: '2019-11-20T09:44:30.810Z', created_by: 1, updated_at: '2019-11-20T13:32:49.868Z', diff --git a/ghost/admin/tests/acceptance/content-test.js b/ghost/admin/tests/acceptance/content-test.js index 7114408f2e..402306bbcb 100644 --- a/ghost/admin/tests/acceptance/content-test.js +++ b/ghost/admin/tests/acceptance/content-test.js @@ -171,7 +171,7 @@ describe('Acceptance: Content', function () { it('can navigate to custom views', async function () { this.server.create('setting', { - type: 'site', + group: 'site', key: 'shared_views', value: JSON.stringify([{ route: 'posts',