We’ve enabled moderation workflow and scheduler to media bundles.
Now whenever I try to add media from the entity browser, Schedule a status change link is not appearing in entity form after I upload the file.
Steps to reproduce:
- Go to node creation form
- Click on add media and we can see a modal with three-tab. First one is media view, second one is tab to upload the file.
- I click on upload
- Once I upload the file, Ajax request will get called and in the next step it will present us inline entity form of the given media type to add title etc.
- On this form Schedule a status change link is not appearing
Upon debugging I found that:
location:
Drupal\lightning_media\Plugin\EntityBrowser\Widget
In EntityFormProxy.php
there is a static method called ajax() which is doing replace work for the ajax call on file upload.
The react code that we have written inside `lightning_workflow/modules/lightning_scheduler/js/index.es6.js` is not being invoked when we update DOM using Ajax Commands.
Possible solution:
Possible solution is to first attach the library in the `entity_browser_media_browser_form`
/**
* Implements hook_form_FORM_ID_alter().
*/
function ightning_scheduler_form_entity_browser_media_browser_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$form['widget_selector']['#attached']['library'][] = 'lightning_scheduler/widget';
}The second step is to update `index.es6.js` so that it includes drupal.behaviours.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 3102706-1.patch | 236.76 KB | ank.g9 |
Comments
Comment #2
ank.g9 commentedThis patch is without compiled JS file
Comment #3
ank.g9 commentedComment #4
phenaproximaThanks for the patch, but I don't think this is something I can commit. It oversteps the boundaries of Lightning Workflow and Lightning Media and is not the correct approach, IMHO.
The scheduler's React code, IIRC, is attached to any moderation state widget that shows up in any form. You should, therefore, be able to make it appear in that inline entity form by making the media type moderatable -- you can do that by configuring the workflow to apply to the media type(s) in question -- and then ensuring that the "moderation state" field is displayed in the applicable "Media browser" form mode. In other words, this does not need a patch; it should be doable just by modifying your site's configuration.
I'm going to close this issue as "works as designed" for now, but if you encounter trouble with the approach I outlined above, feel free to reopen it and we'll work on it more!