Add config actions for views

Created on 24 August 2022, about 2 years ago
Updated 21 May 2024, 6 months ago

Problem/Motivation

While ๐Ÿ“Œ Determine which core config entity methods should be config actions Fixed will be straightforward for some of the more basic configuration entities, for others it will be relatively complex. Not surprisingly, views is on the complex end of the spectrum.

Our best indicator for concrete use cases is looking to core config that's been overridden in an install profile, since that provides a concrete use case. So an initial exercise to begin to scope config actions requirements for looking at how core's module-provided views such as views.view.taxonomy_term.ymlhave been overridden in the demo_umami profile.

Sample diffs run from the root of a Drupal core repo:

diff -u core/modules/node/config/optional/views.view.frontpage.yml core/profiles/demo_umami/config/install/views.view.frontpage.yml
diff -u core/modules/taxonomy/config/optional/views.view.taxonomy_term.yml core/profiles/demo_umami/config/install/views.view.taxonomy_term.yml

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

๐Ÿ“Œ Task
Status

Active

Version

11.0

Component

Code

Created by

๐Ÿ‡จ๐Ÿ‡ฆCanada nedjo

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States thejimbirch Cape Cod, Massachusetts
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany a.dmitriiev

    Should this issue be moved to Drupal project?

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany a.dmitriiev
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany a.dmitriiev
  • @admitriiev opened merge request.
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany a.dmitriiev

    Uploading patch to use in Drupal CMS for config actions on views, that need to add/remove/update filters/fields and other options of the display.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany a.dmitriiev
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany a.dmitriiev

    The MR contains 3 new config actions for view entity type:

    1. setDisplayOption - allows to set a display option like filters, fields, pager, etc .
    Parameters:
    option (required) - the name of the option to manage, can be filters, fields, pager, etc (any option that view display can have)
    settings (required) - the option settings. This varies from option type.
    display_id (optional) - the display id, if non is provided the default is used.
    Example usage:

    view.view.my_view:
      setDisplayOption:
        display_id: default
        option: pager
        settings:
          type: mini
          options:
            offset: 0
            pagination_heading_level: h4
            items_per_page: 10
            total_pages: null
            id: 0
            tags:
              next: โ€บโ€บ
              previous: โ€นโ€น
            expose:
              items_per_page: false
              items_per_page_label: 'Items per page'
              items_per_page_options: '5, 10, 25, 50'
              items_per_page_options_all: false
              items_per_page_options_all_label: '- All -'
              offset: false
              offset_label: Offset
    

    2. addItemToDisplayOption allows to add the item to views display option. The difference from setDisplayOption is that the existing option settings are preserved and only the new item is added to the option settings.
    Parameters:
    The same as for setDisplayOption, plus one more item - for the name of the item to add.
    Example usage:

        views.view.drupal_cms_search:
          addItemToDisplayOption:
            display_id: default
            option: filters
            item: facets_type
            settings:
              id: facets_type
              table: search_api_index_drupal_cms
              field: facets_type
              relationship: none
              group_type: group
              admin_label: ''
              plugin_id: facets_filter
              operator: '='
              value: ''
              group: 1
              exposed: true
              expose:
                operator_id: ''
                label: 'Content type'
                description: ''
                use_operator: false
                operator: ''
                operator_limit_selection: false
                operator_list: { }
                identifier: type
                required: false
                multiple: true
                remember_roles:
                  authenticated: authenticated
              is_grouped: false
              group_info:
                label: ''
                description: ''
                identifier: ''
                optional: true
                widget: select
                multiple: false
                remember: false
                default_group: All
                default_group_multiple: { }
                group_items: { }
              hierarchy: false
              label_display: visible
              facet:
                query_operator: or
                min_count: 1
                show_numbers: true
                processor_configs:
                  translate_entity:
                    weights:
                      build: 5
                    settings: { }
    

    3. removeItemFromDisplayOption allows to remove the item from views display option.
    Parameters:
    The same as for addItemToDisplayOption, minus one settings as it is not needed for item that is removed.
    Example usage:

        views.view.drupal_cms_search:
          removeItemFromDisplayOption:
            display_id: default
            option: filters
            item: facets_type
    
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany a.dmitriiev

    I have also exposed 2 methods from view entity class: addDisplay and duplicateDisplayAsType as Action Methods to use as config actions.

  • The Needs Review Queue Bot โ†’ tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany a.dmitriiev

    There are some tests with blocks that are failing, I assume not related to the tests form MR.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia nmudgal

    Looks like it was just a fluke. Rerunning the pipeline resolved the failing test issue.

Production build 0.71.5 2024