#6489 Make React locale selector act like a filter on the root page

Open kaedroho
Coverage Reach
admin/views/pages/edit.py admin/views/pages/create.py admin/views/pages/revisions.py admin/views/pages/workflow.py admin/views/pages/preview.py admin/views/pages/search.py admin/views/pages/history.py admin/views/pages/moderation.py admin/views/pages/move.py admin/views/pages/copy.py admin/views/pages/listing.py admin/views/pages/lock.py admin/views/pages/convert_alias.py admin/views/pages/unpublish.py admin/views/pages/delete.py admin/views/pages/ordering.py admin/views/pages/usage.py admin/views/pages/utils.py admin/views/workflows.py admin/views/generic.py admin/views/account.py admin/views/mixins.py admin/views/chooser.py admin/views/reports.py admin/views/home.py admin/views/collections.py admin/views/page_privacy.py admin/views/collection_privacy.py admin/views/userbar.py admin/views/tags.py admin/rich_text/converters/html_to_contentstate.py admin/rich_text/converters/editor_html.py admin/rich_text/converters/html_ruleset.py admin/rich_text/converters/contentstate_models.py admin/rich_text/converters/contentstate.py admin/rich_text/editors/hallo.py admin/rich_text/editors/draftail/__init__.py admin/rich_text/editors/draftail/features.py admin/rich_text/__init__.py admin/edit_handlers.py admin/forms/collections.py admin/forms/workflows.py admin/forms/pages.py admin/forms/models.py admin/forms/choosers.py admin/forms/view_restrictions.py admin/forms/tags.py admin/forms/auth.py admin/forms/search.py admin/forms/__init__.py admin/compare.py admin/widgets/chooser.py admin/widgets/datetime.py admin/widgets/button.py admin/widgets/filtered_select.py admin/widgets/tags.py admin/widgets/workflows.py admin/widgets/button_select.py admin/widgets/auto_height_text.py admin/widgets/__init__.py admin/wagtail_hooks.py admin/templatetags/wagtailadmin_tags.py admin/templatetags/wagtailuserbar.py admin/action_menu.py admin/mail.py admin/api/serializers.py admin/api/views.py admin/api/filters.py admin/api/urls.py admin/filters.py admin/auth.py admin/menu.py admin/userbar.py admin/viewsets/model.py admin/viewsets/__init__.py admin/viewsets/base.py admin/checks.py admin/search.py admin/urls/__init__.py admin/urls/pages.py admin/urls/collections.py admin/urls/workflows.py admin/urls/reports.py admin/urls/password_reset.py admin/site_summary.py admin/messages.py admin/log_action_registry.py admin/staticfiles.py admin/navigation.py admin/models.py admin/signal_handlers.py admin/localization.py admin/modal_workflow.py admin/apps.py admin/jinja2tags.py admin/datetimepicker.py admin/blocks.py admin/signals.py admin/__init__.py contrib/modeladmin/views.py contrib/modeladmin/options.py contrib/modeladmin/helpers/button.py contrib/modeladmin/helpers/permission.py contrib/modeladmin/helpers/url.py contrib/modeladmin/helpers/search.py contrib/modeladmin/helpers/__init__.py contrib/modeladmin/templatetags/modeladmin_tags.py contrib/modeladmin/menus.py contrib/modeladmin/mixins.py contrib/modeladmin/forms.py contrib/modeladmin/apps.py contrib/modeladmin/__init__.py contrib/redirects/views.py contrib/redirects/base_formats.py contrib/redirects/management/commands/import_redirects.py contrib/redirects/models.py contrib/redirects/forms.py contrib/redirects/tmp_storages.py contrib/redirects/middleware.py contrib/redirects/utils.py contrib/redirects/wagtail_hooks.py contrib/redirects/apps.py contrib/redirects/urls.py contrib/redirects/permissions.py contrib/redirects/__init__.py contrib/postgres_search/backend.py contrib/postgres_search/query.py contrib/postgres_search/utils.py contrib/postgres_search/models.py contrib/postgres_search/apps.py contrib/postgres_search/__init__.py contrib/forms/views.py contrib/forms/models.py contrib/forms/forms.py contrib/forms/utils.py contrib/forms/edit_handlers.py contrib/forms/wagtail_hooks.py contrib/forms/apps.py contrib/forms/urls.py contrib/forms/__init__.py contrib/frontend_cache/tests.py contrib/frontend_cache/backends.py contrib/frontend_cache/utils.py contrib/frontend_cache/signal_handlers.py contrib/frontend_cache/apps.py contrib/frontend_cache/__init__.py contrib/search_promotions/tests.py contrib/search_promotions/views.py contrib/search_promotions/forms.py contrib/search_promotions/wagtail_hooks.py contrib/search_promotions/models.py contrib/search_promotions/templatetags/wagtailsearchpromotions_tags.py contrib/search_promotions/apps.py contrib/search_promotions/admin_urls.py contrib/search_promotions/__init__.py contrib/routable_page/tests.py contrib/routable_page/models.py contrib/routable_page/templatetags/wagtailroutablepage_tags.py contrib/routable_page/apps.py contrib/routable_page/__init__.py contrib/settings/views.py contrib/settings/models.py contrib/settings/jinja2tags.py contrib/settings/registry.py contrib/settings/context_processors.py contrib/settings/forms.py contrib/settings/templatetags/wagtailsettings_tags.py contrib/settings/wagtail_hooks.py contrib/settings/apps.py contrib/settings/urls.py contrib/settings/permissions.py contrib/settings/__init__.py contrib/table_block/tests.py contrib/table_block/blocks.py contrib/table_block/templatetags/table_block_tags.py contrib/table_block/apps.py contrib/table_block/__init__.py contrib/sitemaps/tests.py contrib/sitemaps/sitemap_generator.py contrib/sitemaps/views.py contrib/sitemaps/apps.py contrib/sitemaps/__init__.py contrib/styleguide/views.py contrib/styleguide/wagtail_hooks.py contrib/styleguide/tests.py contrib/styleguide/apps.py contrib/styleguide/__init__.py core/models.py core/blocks/field_block.py core/blocks/stream_block.py core/blocks/base.py core/blocks/struct_block.py core/blocks/list_block.py core/blocks/static_block.py core/blocks/__init__.py core/blocks/utils.py core/management/commands/fixtree.py core/management/commands/publish_scheduled_pages.py core/management/commands/create_log_entries_from_revisions.py core/management/commands/replace_text.py core/management/commands/purge_revisions.py core/management/commands/move_pages.py core/management/commands/set_url_paths.py core/permission_policies/collections.py core/permission_policies/base.py core/permission_policies/__init__.py core/query.py core/rich_text/rewriters.py core/rich_text/feature_registry.py core/rich_text/__init__.py core/rich_text/pages.py core/utils.py core/templatetags/wagtailcore_tags.py core/fields.py core/whitelist.py core/treebeard.py core/wagtail_hooks.py core/hooks.py core/jinja2tags.py core/views.py core/signal_handlers.py core/forms.py core/workflows.py core/sites.py core/signals.py core/urls.py core/apps.py core/url_routing.py core/compat.py core/permissions.py core/__init__.py core/exceptions.py images/views/images.py images/views/multiple.py images/views/chooser.py images/views/serve.py images/models.py images/image_operations.py images/rect.py images/templatetags/wagtailimages_tags.py images/wagtail_hooks.py images/fields.py images/rich_text/contentstate.py images/rich_text/editor_html.py images/rich_text/__init__.py images/formats.py images/api/v2/views.py images/api/v2/serializers.py images/api/fields.py images/api/admin/views.py images/api/admin/serializers.py images/utils.py images/forms.py images/checks.py images/blocks.py images/widgets.py images/jinja2tags.py images/signal_handlers.py images/edit_handlers.py images/__init__.py images/apps.py images/shortcuts.py images/admin.py images/admin_urls.py images/permissions.py images/urls.py images/exceptions.py search/backends/elasticsearch2.py search/backends/base.py search/backends/db.py search/backends/elasticsearch7.py search/backends/__init__.py search/backends/elasticsearch5.py search/backends/elasticsearch6.py search/index.py search/management/commands/update_index.py search/management/commands/search_garbage_collect.py search/management/commands/wagtail_update_index.py search/utils.py search/models.py search/query.py search/views/queries.py search/signal_handlers.py search/apps.py search/queryset.py search/wagtail_hooks.py search/urls/admin.py search/forms.py search/__init__.py snippets/tests.py snippets/views/snippets.py snippets/views/chooser.py snippets/action_menu.py snippets/wagtail_hooks.py snippets/widgets.py snippets/models.py snippets/blocks.py snippets/permissions.py snippets/templatetags/wagtailsnippets_admin_tags.py snippets/edit_handlers.py snippets/apps.py snippets/urls.py snippets/__init__.py users/tests.py users/forms.py users/views/users.py users/views/groups.py users/wagtail_hooks.py users/templatetags/wagtailusers_tags.py users/models.py users/utils.py users/apps.py users/widgets.py users/urls/users.py users/__init__.py api/v2/views.py api/v2/serializers.py api/v2/filters.py api/v2/utils.py api/v2/router.py api/v2/signal_handlers.py api/v2/pagination.py api/v2/apps.py api/v2/__init__.py api/conf.py api/__init__.py documents/views/documents.py documents/views/chooser.py documents/views/serve.py documents/views/multiple.py documents/models.py documents/wagtail_hooks.py documents/rich_text/editor_html.py documents/rich_text/contentstate.py documents/rich_text/__init__.py documents/api/v2/views.py documents/api/v2/serializers.py documents/api/admin/views.py documents/forms.py documents/widgets.py documents/blocks.py documents/__init__.py documents/apps.py documents/signal_handlers.py documents/admin.py documents/edit_handlers.py documents/admin_urls.py documents/permissions.py documents/urls.py embeds/finders/oembed.py embeds/finders/embedly.py embeds/finders/__init__.py embeds/finders/base.py embeds/oembed_providers.py embeds/rich_text/contentstate.py embeds/rich_text/__init__.py embeds/rich_text/editor_html.py embeds/blocks.py embeds/models.py embeds/views/chooser.py embeds/embeds.py embeds/wagtail_hooks.py embeds/templatetags/wagtailembeds_tags.py embeds/format.py embeds/apps.py embeds/exceptions.py embeds/forms.py embeds/urls.py embeds/__init__.py utils/sendfile.py utils/setup.py utils/sendfile_streaming_backend.py utils/deprecation.py utils/decorators.py utils/version.py utils/widgets.py utils/apps.py utils/loading.py utils/urlpatterns.py utils/utils.py sites/tests.py sites/views.py sites/wagtail_hooks.py sites/forms.py sites/apps.py sites/__init__.py locales/tests.py locales/views.py locales/wagtail_hooks.py locales/forms.py locales/utils.py locales/apps.py locales/__init__.py bin/wagtail.py __init__.py

Flags

Flags have been temporarily removed from this view while the flagging feature is refactored for better performance and user experience.

You can still use flags when viewing individual files. Flag-level thresholds will also remain on pull and merge requests in your repository provider.

More information can be found in our documentation.


@@ -184,7 +184,7 @@
Loading
184 184
            reverse('wagtailsnippets:list', args=['tests', 'advert'])
185 185
        )
186 186
187 -
        self.assertNotContains(response, 'French')
187 +
        self.assertNotContains(response, 'aria-label="French" class="u-link is-live">')
188 188
189 189
        # Check that the add URLs don't include the locale
190 190
        add_url = reverse('wagtailsnippets:add', args=['tests', 'advert'])
@@ -715,6 +715,9 @@
Loading
715 715
class TestLocaleSelectorOnEdit(BaseTestSnippetEditView):
716 716
    fixtures = ['test.json']
717 717
718 +
    LOCALE_SELECTOR_HTML = '<a href="javascript:void(0)" aria-label="English" class="c-dropdown__button  u-btn-current">'
719 +
    LOCALE_INDICATOR_HTML = '<use href="#icon-site"></use></svg>\n    English'
720 +
718 721
    def setUp(self):
719 722
        super().setUp()
720 723
        self.test_snippet = TranslatableSnippet.objects.create(text="This is a test")
@@ -725,7 +728,7 @@
Loading
725 728
    def test_locale_selector(self):
726 729
        response = self.get()
727 730
728 -
        self.assertContains(response, 'English')
731 +
        self.assertContains(response, self.LOCALE_SELECTOR_HTML)
729 732
730 733
        switch_to_french_url = reverse('wagtailsnippets:edit', args=['snippetstests', 'translatablesnippet', quote(self.test_snippet_fr.pk)])
731 734
        self.assertContains(response, f'<a href="{switch_to_french_url}" aria-label="French" class="u-link is-live">')
@@ -735,7 +738,7 @@
Loading
735 738
736 739
        response = self.get()
737 740
738 -
        self.assertContains(response, 'English')
741 +
        self.assertContains(response, self.LOCALE_INDICATOR_HTML)
739 742
740 743
        switch_to_french_url = reverse('wagtailsnippets:edit', args=['snippetstests', 'translatablesnippet', quote(self.test_snippet_fr.pk)])
741 744
        self.assertNotContains(response, f'<a href="{switch_to_french_url}" aria-label="French" class="u-link is-live">')
@@ -744,7 +747,7 @@
Loading
744 747
    def test_locale_selector_not_present_when_i18n_disabled(self):
745 748
        response = self.get()
746 749
747 -
        self.assertNotContains(response, 'English')
750 +
        self.assertNotContains(response, self.LOCALE_SELECTOR_HTML)
748 751
749 752
        switch_to_french_url = reverse('wagtailsnippets:edit', args=['snippetstests', 'translatablesnippet', quote(self.test_snippet_fr.pk)])
750 753
        self.assertNotContains(response, f'<a href="{switch_to_french_url}" aria-label="French" class="u-link is-live">')
@@ -754,7 +757,7 @@
Loading
754 757
755 758
        response = self.get()
756 759
757 -
        self.assertNotContains(response, 'English')
760 +
        self.assertNotContains(response, self.LOCALE_SELECTOR_HTML)
758 761
        self.assertNotContains(response, 'aria-label="French" class="u-link is-live">')
759 762
760 763

@@ -14,6 +14,7 @@
Loading
14 14
from django.template.loader import render_to_string
15 15
from django.templatetags.static import static
16 16
from django.utils import timezone
17 +
from django.utils.encoding import force_str
17 18
from django.utils.html import avoid_wrapping, format_html, format_html_join
18 19
from django.utils.safestring import mark_safe
19 20
from django.utils.timesince import timesince
@@ -27,7 +28,7 @@
Loading
27 28
from wagtail.admin.staticfiles import versioned_static as versioned_static_func
28 29
from wagtail.core import hooks
29 30
from wagtail.core.models import (
30 -
    Collection, CollectionViewRestriction, Page, PageLogEntry, PageViewRestriction,
31 +
    Collection, CollectionViewRestriction, Locale, Page, PageLogEntry, PageViewRestriction,
31 32
    UserPagePermissionsProxy)
32 33
from wagtail.core.utils import accepts_kwarg, camelcase_to_underscore
33 34
from wagtail.core.utils import cautious_slugify as _cautious_slugify
@@ -637,3 +638,19 @@
Loading
637 638
        # we were passed None or something else that isn't a valid user object; return
638 639
        # empty string to replicate the behaviour of {{ user.get_full_name|default:user.get_username }}
639 640
        return ''
641 +
642 +
643 +
@register.simple_tag
644 +
def i18n_enabled():
645 +
    return getattr(settings, 'WAGTAIL_I18N_ENABLED', False)
646 +
647 +
648 +
@register.simple_tag
649 +
def locales():
650 +
    return json.dumps([
651 +
        {
652 +
            'code': locale.language_code,
653 +
            'display_name': force_str(locale.get_display_name()),
654 +
        }
655 +
        for locale in Locale.objects.all()
656 +
    ])

Learn more Showing 36 files with coverage changes found.

client/src/utils/actions.ts
Loading file...
client/src/components/Explorer/PageCount.tsx
Loading file...
client/src/components/LoadingSpinner/LoadingSpinner.js
Loading file...
client/src/includes/initSubmenus.js
Loading file...
client/src/components/Draftail/blocks/ImageBlock.js
Loading file...
client/src/components/Draftail/decorators/TooltipEntity.js
Loading file...
client/src/components/Draftail/decorators/Link.js
Loading file...
client/src/api/client.js
Loading file...
client/src/components/Explorer/index.tsx
Loading file...
wagtail/admin/static_src/wagtailadmin/js/page-editor.js
Loading file...
client/src/includes/initSkipLink.js
Loading file...
wagtail/admin/static_src/wagtailadmin/app/wagtailadmin.entry.js
Loading file...
client/src/components/Draftail/index.js
Loading file...
client/src/utils/focus.js
Loading file...
client/src/components/Icon/Icon.js
Loading file...
client/src/includes/initIE11Warning.js
Loading file...
client/src/index.ts
Loading file...
client/src/components/Draftail/Tooltip/Tooltip.js
Loading file...
client/src/components/Draftail/DraftUtils.js
Loading file...
client/src/components/PublicationStatus/PublicationStatus.js
Loading file...
client/src/components/Explorer/Explorer.tsx
Loading file...
wagtail/admin/static_src/wagtailadmin/js/vendor/jquery-3.5.1.min.js
Loading file...
client/src/components/Draftail/EditorFallback/EditorFallback.js
Loading file...
client/src/components/Draftail/decorators/Document.js
Loading file...
wagtail/admin/static_src/wagtailadmin/js/vendor/urlify.js
Loading file...
client/src/components/Draftail/blocks/MediaBlock.js
Loading file...
client/src/components/Explorer/ExplorerToggle.tsx
Loading file...
client/src/components/Portal/Portal.js
Loading file...
wagtail/admin/static_src/wagtailadmin/app/draftail.entry.js
Loading file...
client/src/components/UpgradeNotification/index.js
Loading file...
client/src/components/Draftail/sources/ModalWorkflowSource.js
Loading file...
client/src/components/Transition/Transition.js
Loading file...
client/src/utils/version.js
Loading file...
client/src/components/Button/Button.js
Loading file...
client/src/components/Explorer/reducers/explorer.ts
Loading file...
client/src/components/Draftail/blocks/EmbedBlock.js
Loading file...
Files Coverage
wagtail 0.58% 90.60%
Project Totals (395 files) 90.60%
Loading