Problem/Motivation

We had a project with a lot of views and the need to expose some views via JSON:API. Unfortunately it is a mess updating hundreds of views to disable the resource where not needed.

Proposed resolution

Provide a form with a batch processor or/and a drush command for disabling the resources for all views.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

daniel.pernold created an issue. See original summary.

anybody’s picture

This would mitigate the need for this (also helpful) feature I think? #3587946: Invert the logic and disable "Expose via JSON:API" by default (Opt-in)

Still it would be helpful to have a form for bulk (de-)activation!

anybody’s picture

Title: Add ability to disable resources in batch / drush » Add a settings page to disable resources in batch / drush
Issue tags: +Novice

Much of the code needed for enable / disable of the extenders can be found in the .install file of this module: https://git.drupalcode.org/project/jsonapi_views/-/blob/8.x-1.x/jsonapi_...

It just needs a settings page listing the views, their status as checkboxes and a batch to save the changes.

kieran.cott made their first commit to this issue’s fork.

kieran.cott’s picture

Added an MR for this that adds a new JSON:API Views settings page at /admin/config/services/jsonapi/views, listing enabled View displays with checkboxes for whether each display is exposed as a JSON:API Views resource.

Changes are saved through Batch API operations grouped by View entity, and the form updates the existing display_extenders.jsonapi_views.enabled display setting.

Also added some functional coverage for access control, default checkbox states, and bulk enabling/disabling display exposure.

kieran.cott’s picture

Status: Active » Needs review
anybody’s picture

Status: Needs review » Needs work

Nice work @kieran.cott - just left a little comment

kieran.cott’s picture

Status: Needs work » Needs review
kieran.cott’s picture

OK all set, let me know if any further tweaks needed!

kieran.cott’s picture

Status: Needs review » Reviewed & tested by the community