Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New "Content by owner" View #104

Open
wants to merge 23 commits into
base: 1.x
Choose a base branch
from

Conversation

MariosORION
Copy link
Contributor

@MariosORION MariosORION commented Jun 28, 2024

This is for issue #85.

Changes:

  • Adding new View page /admin/content/localgov-content-by-owner that lists content by owner (relationship to service contact required):
localgov_workflows_notifications-issue-85-content-by-user-view-back-office
  • Adding dynamic menu link that only gets placed if the View above is present:
localgov_workflows_notifications-issue-85-dynamic-menu-link
  • Adding dynamic local task that only gets generated if the View above is present (see below for screenshot).

I've tested this with a new user, service contact tied to that user and a service page with that service contact assigned; here's how the new View looks like (some columns are sortable just like the vanilla content View):
localgov_workflows_notifications-issue-85-content-by-user-view-and-dynamic-local-task

To add the View when localgov_workflow_notifications is already enabled, Councils can manually import the View's YML configuration (views.view.localgov_content_by_owner.yml) into their site:
views.view.localgov_content_by_owner.yml.zip

Benefits of this approach:

  • No additional module required (verf). There is also a patch required for this module to avoid a fatal error when a VERF select exposed filter is added to the View (issue https://www.drupal.org/project/verf/issues/3113519)
  • The "Content by owner" View can be optionally enabled and only comes to play when the localgov_workflow_notifications sub-module is enabled
    Possible cons of this approach:
  • The new "Content by owner" View is on its own distinct path and not integrated with the default Content View (which might be appealing for some Councils as it also keeps the main Content View clean)

@markconroy
Copy link
Member

@MariosORION can you check the merge conflict issue here, and I can give it a test then. Thanks.

@MariosORION
Copy link
Contributor Author

@markconroy thanks for reviewing - Conflicts resolved but some tests are failing - do we resolve these on the main repo?

@stephen-cox
Copy link
Member

@MariosORION All tests are passing in the 1.x branch so it's likely that something in the PR is breaking them. Unfortunately, Paratest is not giving a nice error message so the tests will need to be run locally to find what is breaking.

If you want a hand looking at this, are you able to run the tests for this module and post error here? This should allow us to debug it.

@MariosORION
Copy link
Contributor Author

@stephen-cox I tried to set up tests to run them locally with no luck. I'll give it another go but if you have any hints on how to configure them locally with PHPStorm feel free to share...

@stephen-cox
Copy link
Member

@MariosORION Are you using Lando or DDev for development? These should both be setup to run tests out of the box.

For Lando, you can run PHPUnit tests just for this module with: lando phpunit web/modules/contrib/localgov_workflows

@stephen-cox stephen-cox self-requested a review September 4, 2024 13:59
@stephen-cox
Copy link
Member

@MariosORION I have run the PHPUnit tests locally and (as I suspected) the errors are due to schema errors on the view configuration. There are a number of these errors

Drupal\Core\Config\Schema\SchemaIncompleteException: Schema errors for views.view.localgov_content_by_owner with the following errors: views.view.localgov_content_by_owner:display.default.display_options.fields.changed.settings.time_diff.description missing schema

/app/web/core/lib/Drupal/Core/Config/Development/ConfigSchemaChecker.php:98
/app/web/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php:111
/app/web/core/lib/Drupal/Core/Config/Config.php:230
/app/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php:278
/app/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php:486
/app/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php:257
/app/web/core/lib/Drupal/Core/Entity/EntityBase.php:354
/app/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php:614
/app/web/core/lib/Drupal/Core/Config/ConfigInstaller.php:389
/app/web/core/lib/Drupal/Core/Config/ConfigInstaller.php:149
/app/web/core/lib/Drupal/Core/ProxyClass/Config/ConfigInstaller.php:75
/app/web/core/lib/Drupal/Core/Extension/ModuleInstaller.php:326
/app/web/core/lib/Drupal/Core/ProxyClass/Extension/ModuleInstaller.php:83
/app/web/core/lib/Drupal/Core/Test/FunctionalTestSetupTrait.php:500
/app/web/core/tests/Drupal/Tests/BrowserTestBase.php:575
/app/web/core/tests/Drupal/Tests/BrowserTestBase.php:370
/app/web/modules/contrib/localgov_workflows/modules/localgov_workflows_notifications/tests/src/Functional/ServiceContactWidgetTest.php:59
/app/vendor/phpunit/phpunit/src/Framework/TestResult.php:729

There's also an error coming from the kernel test as the view is in the install directory. As it's a view that provides extra functionality I suggest moving it into the optional directory.

Copy link
Member

@stephen-cox stephen-cox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made a couple of suggestions that should fix the failing tests.

@MariosORION
Copy link
Contributor Author

Thanks for reviewing @stephen-cox , I'll put in some time this afternoon to clear this up.

…emoving time_diff description from View's YML
@MariosORION MariosORION requested review from stephen-cox and removed request for finnlewis September 4, 2024 15:00
@MariosORION MariosORION self-assigned this Sep 4, 2024
@stephen-cox
Copy link
Member

This now works fine. There are no filters on the view, but there's further discussion on this on the issue, but for this it comes down to whether this is required sooner rather than later. If we want this sooner we can merge this now, but when the filters are ready we will need an update hook to apply them to existing installs.

One further thought is the content tasks are now a bit busy and don't look good at medium screen widths

image

Should the link for this be moved under the content task?

Do you have thoughts on these things @willguv?

@willguv
Copy link
Member

willguv commented Oct 21, 2024

@stephen-cox @MariosORION I've got a slight change to this. We also need to be vary about calling these contacts "owners" as they don't own the content, just check it

So how about:

  1. Put "Content by owner" in the "Service Contacts" menu
  • Tab 1 is labelled "Contacts"and shows the service contact view
  • Tab 2 is labelled "Content" and shows the content by owner view
  1. On the "Contacts" view, provide a "View content" option in the edit menu of each contact. Links to a view of content checked by that person

@finnlewis
Copy link
Member

@MariosORION would you be able to address the changes suggested by @willguv in the last comment?

@MariosORION
Copy link
Contributor Author

I'll be working on these @finnlewis @willguv.

@MariosORION
Copy link
Contributor Author

MariosORION commented Nov 1, 2024

@willguv

Admin menu addition:
85-content-by-owner-admin-menu-child

Local tasks added to provide two tabs: "Contacts" (/admin/content/localgov-service-contact) and "Content" (/admin/content/localgov-service-contact/content-by-owner):
85-tab-1-contacts
85-tab-2-content

Operation link added for every row on the Service contacts screen:
85-service-contact-operation-link-to-content-by-owner-view

Each "View content" operation link contains a dynamic parameter, the service contact's ID which has also been added to the View as a contextual link, allowing for linking to a filtered version of the content by owner View (/admin/content/localgov-service-contact/content-by-owner?service-contact-id=1):
85-content-by-owner-View-filtered-version

…operation link to service contact entity collection linking to filtered content by owner View based on the View's contextual filter
…operation link to service contact entity collection linking to filtered content by owner View based on the View's contextual filter
Copy link
Member

@stephen-cox stephen-cox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MariosORION This looks to work well for new installs!

@willguv Do we want to add this to existing installs?

From the looks of the code we just need to add an update hook to install the view configuration

@MariosORION
Copy link
Contributor Author

@stephen-cox thanks for reviewing!
(Yes, the View is the only thing that needs importing as the custom code only runs if the View is enabled).

@willguv
Copy link
Member

willguv commented Nov 5, 2024

Lovely job @MariosORION thanks for doing this

@stephen-cox would be great to include for existing installs please

@willguv
Copy link
Member

willguv commented Nov 5, 2024

@MariosORION could you do an update hook for this please?

@MariosORION
Copy link
Contributor Author

@willguv sure, @stephen-cox can you please give the added update hook a go?

@stephen-cox stephen-cox self-assigned this Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants