Merge pull request #28370 from github/imjohnbo-content-plan-6764
Add dismiss option to Enterprise announcement banner
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 40 KiB |
@@ -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.
|
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
|
```shell
|
||||||
# Sets a message that's visible to everyone
|
# Sets a message that's visible to everyone
|
||||||
$ ghe-announce -s MESSAGE
|
$ ghe-announce -s MESSAGE
|
||||||
@@ -36,6 +32,22 @@ $ ghe-announce -u
|
|||||||
> Removed the announcement message
|
> 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 %}
|
{% ifversion ghes > 3.1 %}
|
||||||
<!--For earlier releases of GHES, see the previous service `ghe-resque-info`-->
|
<!--For earlier releases of GHES, see the previous service `ghe-resque-info`-->
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
1. Under "Announcement", in the text field, type the announcement you want displayed in a banner.
|
||||||

|

|
||||||
1. Optionally, under "Expires on", select the calendar drop-down menu and click an expiration date.
|
1. Optionally, under "Expires on", select the calendar drop-down menu and click an expiration date.
|
||||||

|
{% ifversion ghe-announce-dismiss %}
|
||||||
|
1. Optionally, to allow each user to dismiss the announcement, select **User dismissible**.
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
{% data reusables.enterprise_site_admin_settings.message-preview-save %}
|
{% data reusables.enterprise_site_admin_settings.message-preview-save %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
5
data/features/ghe-announce-dismiss.yml
Normal file
5
data/features/ghe-announce-dismiss.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Reference: #2221.
|
||||||
|
# Documentation for dismissing GHES announcement banner
|
||||||
|
versions:
|
||||||
|
ghes: '>=3.6'
|
||||||
|
ghae: 'issue-6764'
|
||||||
@@ -1,14 +1,17 @@
|
|||||||
import { next, latest } from './enterprise-server-releases.js'
|
import { next, latest } from './enterprise-server-releases.js'
|
||||||
import versionSatisfiesRange from './version-satisfies-range.js'
|
import versionSatisfiesRange from './version-satisfies-range.js'
|
||||||
|
|
||||||
// Special handling for frontmatter that evalues to the next GHES release number or a hardcoded `next`:
|
// Special handling for frontmatter that evalues to the next GHES release number,
|
||||||
// we don't want to return it as an applicable version or it will become a permalink,
|
// GHAE `issue-\d{4}` or a hardcoded `next`. We don't want to return any of these
|
||||||
// but we also don't want to throw an error if no other versions are found.
|
// 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) {
|
export default function checkIfNextVersionOnly(value) {
|
||||||
if (value === '*') return false
|
if (value === '*') return false
|
||||||
|
|
||||||
const ghesNextVersionOnly =
|
const ghesNextVersion =
|
||||||
versionSatisfiesRange(next, value) && !versionSatisfiesRange(latest, value)
|
versionSatisfiesRange(next, value) && !versionSatisfiesRange(latest, value)
|
||||||
|
|
||||||
return ghesNextVersionOnly || value === 'next'
|
const ghaeUpcomingVersion = value.includes('issue-')
|
||||||
|
|
||||||
|
return ghesNextVersion || ghaeUpcomingVersion || value === 'next'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ function getApplicableVersions(frontmatterVersions, filepath) {
|
|||||||
!foundFeatureVersions.isNextVersionOnly
|
!foundFeatureVersions.isNextVersionOnly
|
||||||
) {
|
) {
|
||||||
throw new Error(
|
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.`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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.
|
// Determine whether the currentVersion belongs to the list of versions the feature is available in.
|
||||||
Object.keys(req.context.site.data.features).forEach((featureName) => {
|
Object.keys(req.context.site.data.features).forEach((featureName) => {
|
||||||
const { versions } = req.context.site.data.features[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
|
// Adding the resulting boolean to the context object gives us the ability to use
|
||||||
// `{% if featureName ... %}` conditionals in content files.
|
// `{% if featureName ... %}` conditionals in content files.
|
||||||
|
|||||||
Reference in New Issue
Block a user