0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Added announcement fields to settings table (#16654)

refs https://github.com/TryGhost/Team/issues/3011

- This is a data structure needed to support Announcement Bar feature -
allows to create custom site-wide announcements tailored to the
audience.
- The `announcement_content` is meant to hold displayed HTML content of
the announcement and will be exposed through unauthenticated Content
Site API

- The `announcement_visibility` sets the target audience to display the
Announcement Bart to:
  - `public` - Everyone
  - `visitors` - Logged out visitors only
  - `members` - Members only
  - `paid` - Paid members only

- The `announcement_background` sets the CSS class that should be
applied to the Announcement Bar. and will be exposed through
unauthenticated Content Site API. Three styles are available:
  - `accent` - matches the color of the site accent
  - `dark` - dark style
  - `light` - light style
This commit is contained in:
naz 2023-04-19 14:25:25 +02:00 committed by GitHub
parent 6e20d7704e
commit 865df1e143
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 167 additions and 5 deletions

View file

@ -0,0 +1,24 @@
const {combineTransactionalMigrations, addSetting} = require('../../utils');
module.exports = combineTransactionalMigrations(
addSetting({
key: 'announcement_content',
value: null,
type: 'string',
flags: 'PUBLIC',
group: 'announcement'
}),
addSetting({
key: 'announcement_visibility',
value: 'public',
type: 'string',
group: 'announcement'
}),
addSetting({
key: 'announcement_background',
value: 'dark',
type: 'string',
flags: 'PUBLIC',
group: 'announcement'
})
);

View file

@ -483,6 +483,33 @@
"type": "string"
}
},
"announcement": {
"announcement_content": {
"defaultValue": null,
"type": "string",
"flags": "PUBLIC"
},
"announcement_visibility": {
"defaultValue": "public",
"type": "string",
"isIn": [[
"public",
"visitors",
"members",
"paid"
]]
},
"announcement_background": {
"defaultValue": "dark",
"type": "string",
"isIn": [[
"accent",
"dark",
"light"
]],
"flags": "PUBLIC"
}
},
"comments": {
"comments_enabled": {
"type": "string",

View file

@ -272,6 +272,18 @@ Object {
"key": "editor_default_email_recipients_filter",
"value": "all",
},
Object {
"key": "announcement_content",
"value": null,
},
Object {
"key": "announcement_visibility",
"value": "public",
},
Object {
"key": "announcement_background",
"value": "dark",
},
Object {
"key": "comments_enabled",
"value": "off",
@ -638,6 +650,18 @@ Object {
"key": "editor_default_email_recipients_filter",
"value": "all",
},
Object {
"key": "announcement_content",
"value": null,
},
Object {
"key": "announcement_visibility",
"value": "public",
},
Object {
"key": "announcement_background",
"value": "dark",
},
Object {
"key": "comments_enabled",
"value": "off",
@ -670,7 +694,7 @@ exports[`Settings API Edit Can edit a setting 2: [headers] 1`] = `
Object {
"access-control-allow-origin": "http://127.0.0.1:2369",
"cache-control": "no-cache, private, no-store, must-revalidate, max-stale=0, post-check=0, pre-check=0",
"content-length": "3762",
"content-length": "3906",
"content-type": "application/json; charset=utf-8",
"content-version": StringMatching /v\\\\d\\+\\\\\\.\\\\d\\+/,
"etag": StringMatching /\\(\\?:W\\\\/\\)\\?"\\(\\?:\\[ !#-\\\\x7E\\\\x80-\\\\xFF\\]\\*\\|\\\\r\\\\n\\[\\\\t \\]\\|\\\\\\\\\\.\\)\\*"/,
@ -952,6 +976,18 @@ Object {
"key": "editor_default_email_recipients_filter",
"value": "all",
},
Object {
"key": "announcement_content",
"value": null,
},
Object {
"key": "announcement_visibility",
"value": "public",
},
Object {
"key": "announcement_background",
"value": "dark",
},
Object {
"key": "comments_enabled",
"value": "off",
@ -1265,6 +1301,18 @@ Object {
"key": "editor_default_email_recipients_filter",
"value": "all",
},
Object {
"key": "announcement_content",
"value": null,
},
Object {
"key": "announcement_visibility",
"value": "public",
},
Object {
"key": "announcement_background",
"value": "dark",
},
Object {
"key": "comments_enabled",
"value": "off",
@ -1583,6 +1631,18 @@ Object {
"key": "editor_default_email_recipients_filter",
"value": "all",
},
Object {
"key": "announcement_content",
"value": null,
},
Object {
"key": "announcement_visibility",
"value": "public",
},
Object {
"key": "announcement_background",
"value": "dark",
},
Object {
"key": "comments_enabled",
"value": "off",
@ -1896,6 +1956,18 @@ Object {
"key": "editor_default_email_recipients_filter",
"value": "all",
},
Object {
"key": "announcement_content",
"value": null,
},
Object {
"key": "announcement_visibility",
"value": "public",
},
Object {
"key": "announcement_background",
"value": "dark",
},
Object {
"key": "comments_enabled",
"value": "off",
@ -2274,6 +2346,18 @@ Object {
"key": "editor_default_email_recipients_filter",
"value": "all",
},
Object {
"key": "announcement_content",
"value": null,
},
Object {
"key": "announcement_visibility",
"value": "public",
},
Object {
"key": "announcement_background",
"value": "dark",
},
Object {
"key": "comments_enabled",
"value": "off",

View file

@ -6,7 +6,7 @@ const {stringMatching, anyEtag, anyUuid, anyContentLength, anyContentVersion} =
const models = require('../../../core/server/models');
const {anyErrorId} = matchers;
const CURRENT_SETTINGS_COUNT = 73;
const CURRENT_SETTINGS_COUNT = 76;
const settingsMatcher = {};

View file

@ -5,7 +5,7 @@ const db = require('../../../core/server/data/db');
// Stuff we are testing
const models = require('../../../core/server/models');
const SETTINGS_LENGTH = 84;
const SETTINGS_LENGTH = 87;
describe('Settings Model', function () {
before(models.init);

View file

@ -236,7 +236,7 @@ describe('Exporter', function () {
// NOTE: if default settings changed either modify the settings keys blocklist or increase allowedKeysLength
// This is a reminder to think about the importer/exporter scenarios ;)
const allowedKeysLength = 76;
const allowedKeysLength = 79;
totalKeysLength.should.eql(SETTING_KEYS_BLOCKLIST.length + allowedKeysLength);
});
});

View file

@ -37,7 +37,7 @@ describe('DB version integrity', function () {
// Only these variables should need updating
const currentSchemaHash = '00c8616470de50a6716369511a39eca9';
const currentFixturesHash = '869ceb3302303494c645f4201540ead3';
const currentSettingsHash = 'e2fc04c37fe89e972b063ee8fd1d4bec';
const currentSettingsHash = '7b80d26ccced791da70ca5c753959689';
const currentRoutesHash = '3d180d52c663d173a6be791ef411ed01';
// If this test is failing, then it is likely a change has been made that requires a DB version bump,

View file

@ -491,6 +491,33 @@
"type": "string"
}
},
"announcement": {
"announcement_content": {
"defaultValue": null,
"type": "string",
"flags": "PUBLIC"
},
"announcement_visibility": {
"defaultValue": "public",
"type": "string",
"isIn": [[
"public",
"visitors",
"members",
"paid"
]]
},
"announcement_background": {
"defaultValue": "dark",
"type": "string",
"isIn": [[
"accent",
"dark",
"light"
]],
"flags": "PUBLIC"
}
},
"comments": {
"comments_enabled": {
"type": "string",