From daa47baddd792ba7600a05cb042213b43973887f Mon Sep 17 00:00:00 2001 From: Steve Steinwand <steven_ts@hotmail.com> Date: Thu, 9 Jun 2022 14:07:45 -0600 Subject: [PATCH] Add legacy and new status tags to the pattern library --- CHANGELOG.txt | 1 + docs/releases/4.0.md | 1 + .../wagtailadmin/shared/page_status_tag.html | 5 ++ .../shared/page_status_tag.stories.tsx | 34 +++++++++++++ .../shared/page_status_tag_new.html | 1 - .../shared/page_status_tag_new.stories.tsx | 51 +++++++++++++++++++ .../patternlibrary_override_tags.py | 5 ++ 7 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 wagtail/admin/templates/wagtailadmin/shared/page_status_tag.stories.tsx create mode 100644 wagtail/admin/templates/wagtailadmin/shared/page_status_tag_new.stories.tsx create mode 100644 wagtail/admin/templatetags/patternlibrary_override_tags.py diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 27d8c91b31..e56a6d19a3 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -50,6 +50,7 @@ Changelog * Deprecate the usage and documentation of the `wagtail.contrib.modeladmin.menus.SubMenu` class, provide a warning if used directing developers to use `wagtail.admin.menu.Menu` instead (Matt Westcott) * Remove legacy (non-next) breadcrumbs no longer used, remove `ModelAdmin` usage of breadcrumbs completely (Paarth Agarwal) * Replace human-readable-date hover pattern with accessible tooltip variant across all of admin (Bernd de Ridder) + * Add legacy and new status tags to the pattern library (Steven Steinwand) * Fix: Typo in `ResumeWorkflowActionFormatter` message (Stefan Hammer) * Fix: Throw a meaningful error when saving an image to an unrecognised image format (Christian Franke) * Fix: Remove extra padding for headers with breadcrumbs on mobile viewport (Steven Steinwand) diff --git a/docs/releases/4.0.md b/docs/releases/4.0.md index 8d3000f929..9f645879b7 100644 --- a/docs/releases/4.0.md +++ b/docs/releases/4.0.md @@ -57,6 +57,7 @@ When using a queryset to render a list of images, you can now use the `prefetch_ * Deprecate the usage and documentation of the `wagtail.contrib.modeladmin.menus.SubMenu` class, provide a warning if used directing developers to use `wagtail.admin.menu.Menu` instead (Matt Westcott) * Remove legacy (non-next) breadcrumbs no longer used, remove `ModelAdmin` usage of breadcrumbs completely (Paarth Agarwal) * Replace human-readable-date hover pattern with accessible tooltip variant across all of admin (Bernd de Ridder) + * Add legacy and new status tags to the pattern library (Steven Steinwand) ### Bug fixes diff --git a/wagtail/admin/templates/wagtailadmin/shared/page_status_tag.html b/wagtail/admin/templates/wagtailadmin/shared/page_status_tag.html index 9e0d89040f..72dd7e49d1 100644 --- a/wagtail/admin/templates/wagtailadmin/shared/page_status_tag.html +++ b/wagtail/admin/templates/wagtailadmin/shared/page_status_tag.html @@ -1,4 +1,9 @@ {% load i18n %} +{% comment "text/markdown" %} + Variables this template accepts: + + `page` - A wagtail page object +{% endcomment %} {% if page.live %} {% with page_url=page.url %} {% if page_url is not None %} diff --git a/wagtail/admin/templates/wagtailadmin/shared/page_status_tag.stories.tsx b/wagtail/admin/templates/wagtailadmin/shared/page_status_tag.stories.tsx new file mode 100644 index 0000000000..77060b7611 --- /dev/null +++ b/wagtail/admin/templates/wagtailadmin/shared/page_status_tag.stories.tsx @@ -0,0 +1,34 @@ +import React from 'react'; +import { Pattern, generateDocs } from 'storybook-django/src/react'; + +import template from './page_status_tag.html'; + +const { docs, argTypes } = generateDocs(template); + +export default { + parameters: { docs }, + argTypes: { + ...argTypes, + url: { + options: [null, 'https://wagtail.io'], + }, + }, +}; + +const Template = (args) => ( + <Pattern filename={__filename} context={{ page: args }} /> +); +export const Live = Template.bind({}); + +Live.args = { + live: true, + status_string: 'live', + url: null, +}; + +export const Draft = Template.bind({}); + +Draft.args = { + live: false, + status_string: 'draft', +}; diff --git a/wagtail/admin/templates/wagtailadmin/shared/page_status_tag_new.html b/wagtail/admin/templates/wagtailadmin/shared/page_status_tag_new.html index 70b607fae2..17746beb91 100644 --- a/wagtail/admin/templates/wagtailadmin/shared/page_status_tag_new.html +++ b/wagtail/admin/templates/wagtailadmin/shared/page_status_tag_new.html @@ -4,7 +4,6 @@ Variables accepted by this template: - `page` - A wagtail page object - - `classes` - String of extra css classes to pass to this component {% endcomment %} {% if page.live and page.url is not None %} diff --git a/wagtail/admin/templates/wagtailadmin/shared/page_status_tag_new.stories.tsx b/wagtail/admin/templates/wagtailadmin/shared/page_status_tag_new.stories.tsx new file mode 100644 index 0000000000..d1ce63d401 --- /dev/null +++ b/wagtail/admin/templates/wagtailadmin/shared/page_status_tag_new.stories.tsx @@ -0,0 +1,51 @@ +import React from 'react'; +import { Pattern, generateDocs } from 'storybook-django/src/react'; + +import template from './page_status_tag_new.html'; + +const { docs, argTypes } = generateDocs(template); + +export default { + parameters: { docs }, + argTypes: { ...argTypes }, +}; + +const PublicTemplate = (args) => ( + <Pattern + filename={__filename} + tags={{ + test_page_is_public: { + 'page as is_public': { + raw: false, + }, + }, + }} + context={{ page: args }} + /> +); + +export const Public = PublicTemplate.bind({}); +Public.args = { + live: true, + url: '#', +}; + +const PrivateTemplate = (args) => ( + <Pattern + filename={__filename} + tags={{ + test_page_is_public: { + 'page as is_public': { + raw: true, + }, + }, + }} + context={{ page: args }} + /> +); + +export const Private = PrivateTemplate.bind({}); +Private.args = { + live: true, + url: '#', +}; diff --git a/wagtail/admin/templatetags/patternlibrary_override_tags.py b/wagtail/admin/templatetags/patternlibrary_override_tags.py new file mode 100644 index 0000000000..86c48780dd --- /dev/null +++ b/wagtail/admin/templatetags/patternlibrary_override_tags.py @@ -0,0 +1,5 @@ +from pattern_library.monkey_utils import override_tag + +from wagtail.admin.templatetags.wagtailadmin_tags import register + +override_tag(register, name="test_page_is_public")