1
0
mirror of synced 2025-12-19 18:10:59 -05:00

Merge pull request #28370 from github/imjohnbo-content-plan-6764

Add dismiss option to Enterprise announcement banner
This commit is contained in:
Sophie
2022-07-11 15:38:01 +02:00
committed by GitHub
7 changed files with 35 additions and 12 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

View File

@@ -23,10 +23,6 @@ You can execute these commands from anywhere on the VM after signing in as an SS
This utility sets a banner at the top of every {% data variables.product.prodname_enterprise %} page. You can use it to broadcast a message to your users.
{% ifversion ghes %}
You can also set an announcement banner using the enterprise settings on {% data variables.product.product_name %}. For more information, see "[Customizing user messages on your instance](/enterprise/admin/user-management/customizing-user-messages-on-your-instance#creating-a-global-announcement-banner)."
{% endif %}
```shell
# Sets a message that's visible to everyone
$ ghe-announce -s MESSAGE
@@ -36,6 +32,22 @@ $ ghe-announce -u
> Removed the announcement message
```
{% ifversion ghe-announce-dismiss %}
To allow each user to dismiss the announcement for themselves, use the `-d` flag.
```shell
# Sets a user-dismissible message that's visible to everyone
$ ghe-announce -d -s MESSAGE
> Announcement message set.
# Removes a previously set message
$ ghe-announce -u
> Removed the announcement message, which was user dismissible: MESSAGE
```
{% endif %}
{% ifversion ghes %}
You can also set an announcement banner using the enterprise settings on {% data variables.product.product_name %}. For more information, see "[Customizing user messages on your instance](/enterprise/admin/user-management/customizing-user-messages-on-your-instance#creating-a-global-announcement-banner)."
{% endif %}
{% ifversion ghes > 3.1 %}
<!--For earlier releases of GHES, see the previous service `ghe-resque-info`-->

View File

@@ -117,6 +117,9 @@ You can also set an announcement banner in the administrative shell using a comm
1. Under "Announcement", in the text field, type the announcement you want displayed in a banner.
![Text field to enter announcement](/assets/images/enterprise/site-admin-settings/announcement-text-field.png)
1. Optionally, under "Expires on", select the calendar drop-down menu and click an expiration date.
![Calendar drop-down menu to choose expiration date](/assets/images/enterprise/site-admin-settings/expiration-drop-down.png)
![Calendar drop-down menu to choose expiration date](/assets/images/enterprise/site-admin-settings/expiration-drop-down.png){% ifversion ghe-announce-dismiss %}
1. Optionally, to allow each user to dismiss the announcement, select **User dismissible**.
![Screenshot of the "User dismissible" checkbox](/assets/images/enterprise/site-admin-settings/user-dismissible-checkbox.png){% endif %}
{% data reusables.enterprise_site_admin_settings.message-preview-save %}
{% endif %}

View File

@@ -0,0 +1,5 @@
# Reference: #2221.
# Documentation for dismissing GHES announcement banner
versions:
ghes: '>=3.6'
ghae: 'issue-6764'

View File

@@ -1,14 +1,17 @@
import { next, latest } from './enterprise-server-releases.js'
import versionSatisfiesRange from './version-satisfies-range.js'
// Special handling for frontmatter that evalues to the next GHES release number or a hardcoded `next`:
// we don't want to return it as an applicable version or it will become a permalink,
// but we also don't want to throw an error if no other versions are found.
// Special handling for frontmatter that evalues to the next GHES release number,
// GHAE `issue-\d{4}` or a hardcoded `next`. We don't want to return any of these
// as an applicable version or it will become a permalink, but we also don't want
// to throw an error if no other versions are found.
export default function checkIfNextVersionOnly(value) {
if (value === '*') return false
const ghesNextVersionOnly =
const ghesNextVersion =
versionSatisfiesRange(next, value) && !versionSatisfiesRange(latest, value)
return ghesNextVersionOnly || value === 'next'
const ghaeUpcomingVersion = value.includes('issue-')
return ghesNextVersion || ghaeUpcomingVersion || value === 'next'
}

View File

@@ -73,7 +73,7 @@ function getApplicableVersions(frontmatterVersions, filepath) {
!foundFeatureVersions.isNextVersionOnly
) {
throw new Error(
`No applicable versions found for ${filepath}. Please double-check the page's \`versions\` frontmatter.`
`${filepath} is not available in any currently supported version. Make sure the \`versions\` property includes at least one supported version.`
)
}

View File

@@ -6,7 +6,7 @@ export default function features(req, res, next) {
// Determine whether the currentVersion belongs to the list of versions the feature is available in.
Object.keys(req.context.site.data.features).forEach((featureName) => {
const { versions } = req.context.site.data.features[featureName]
const applicableVersions = getApplicableVersions(versions, req.path)
const applicableVersions = getApplicableVersions(versions, `data/features/${featureName}.yml`)
// Adding the resulting boolean to the context object gives us the ability to use
// `{% if featureName ... %}` conditionals in content files.