Add "status" option to allow enabling / disabling snippets

Created on 15 May 2024, 9 months ago
Updated 10 July 2024, 7 months ago

Problem/Motivation

I think it's best practice and a nice to have to be able to set the status disabled for assets. That way you could temporarily disable them without using workarounds

Steps to reproduce

Proposed resolution

  • Add "status" property
  • Add an "Enabled" checkbox to the top of asset injector entity form
  • Show the status property in the overview table

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Fixed

Version

2.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

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

Merge Requests

Comments & Activities

  • Issue created by @Anybody
  • First commit to issue fork.
  • πŸ‡©πŸ‡ͺGermany lrwebks Porta Westfalica
  • Merge request !17Resolve #3447258 "Add status option" β†’ (Open) created by lrwebks
  • Assigned to lrwebks
  • Status changed to Needs work 8 months ago
  • πŸ‡©πŸ‡ͺGermany lrwebks Porta Westfalica

    The functionality of the CSS and JS config entities having a status value is already there and they can be enabled and disabled via command in the list view. The target now should be to simply add a list column displaying the status and an additional checkbox in the Form where the user would expect it.

  • Status changed to Needs review 8 months ago
  • πŸ‡©πŸ‡ͺGermany lrwebks Porta Westfalica

    I do believe that's already it! As far as I'm aware, everything works as expected (the base functionality was already there, as mentioned). A tiny but not unimportant change!

  • Status changed to Needs work 8 months ago
  • πŸ‡©πŸ‡ͺGermany lrwebks Porta Westfalica

    I think we need to add a new test for the forms here, to check if everything is saved correctly, so I'll be doing that.

  • Status changed to Needs review 8 months ago
  • πŸ‡©πŸ‡ͺGermany lrwebks Porta Westfalica
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 8
    last update 8 months ago
    10 pass
  • Status changed to Needs work 8 months ago
  • πŸ‡©πŸ‡ͺGermany Grevil

    Added a few comments, back to NW!

  • πŸ‡©πŸ‡ͺGermany Grevil

    Ok, I just took a quick look at the tests and I am shocked at the state of them. "testJsInjector()" doesn't even test any javascript, but css instead, and only whether the css files exist, not even if the css is applied correctly...

    So I'd say you do a quick test overhaul here. Create a new Functional Javascript test class "AssetInjectorFunctionalJsTest", which contains two tests "testInjectedJs" and "testInjectedCss".

    For "testInjectedCss", inject some css and test if it is injected correctly (Mink doesn't have specific css tests, but the evaluateScript() method will help, similiar to how it was done in https://stackoverflow.com/questions/25494456/is-it-possible-tests-css-st...).
    You can keep the old "testCssInjector" test.

    For "testInjectedJs", Inject a js alert for the front page only (""), go to the front page and await the alert (there is a driver method for this). And please delete the old "testJsInjector" method.

    Both tests should also revisit the page and see if the css / js is NOT injected anymore, after the asset entity's status is set to false. This way, this overhaul isn't too much out of scope πŸ˜›.

    Tip: Create the the entities programmatically for better performance! 😊

  • πŸ‡©πŸ‡ͺGermany Grevil

    If one of the maintainer feels like the tests are too far out of scope, we can always split the test adjustments, but they are definitely needed!!

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 8
    last update 8 months ago
    10 pass, 2 fail
  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 8
    last update 8 months ago
    11 pass
  • Status changed to Needs review 8 months ago
  • πŸ‡©πŸ‡ͺGermany lrwebks Porta Westfalica

    So, back to review again!

  • Status changed to Needs work 8 months ago
  • πŸ‡©πŸ‡ͺGermany Grevil

    Added a few comments!

  • Open in Jenkins β†’ Open on Drupal.org β†’
    Core: 10.2.1 + Environment: PHP 8.1 & MySQL 8
    last update 8 months ago
    11 pass
  • Status changed to Needs review 8 months ago
  • πŸ‡©πŸ‡ͺGermany lrwebks Porta Westfalica

    Well, it's ready for review again!

  • Issue was unassigned.
  • Status changed to RTBC 8 months ago
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Thanks, LGTM now! Tests are also green.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Note to maintainer: After merging this, please set ✨ Add a "Notes" textarea to each inject RTBC to NW to add a line for that feature to the tests and merge it afterwards.

  • πŸ‡ΊπŸ‡ΈUnited States pookmish

    The MR seems to address more testing than the actual feature requested, and the feature requested is entirely just a cosmetic change the form. No functionality changed. This works for me.

    MRs aren't merging for me, so I'll commit and push up

    • pookmish β†’ committed bd679bd9 on 8.x-2.x
      Issue #3447258 by LRWebks, Anybody, Grevil: Add "status" option to allow...
  • Status changed to Fixed 7 months ago
  • πŸ‡ΊπŸ‡ΈUnited States pookmish
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    @pookmish thank you very much!
    Could you please check the credits accordingly in the fixed issues? The old commit message "crediting" is unrelated to the credit system.
    We're not doing this for credits, but it would be nice to reward the developers.

  • πŸ‡ΊπŸ‡ΈUnited States pookmish
  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024