Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
Let's assume you use both diff module and moderation_state on the same page.
Both modules want to expand the revision history page, to show a) the diff form and b) the workflow state of each revision.
Proposed resolution
Integrate diff into views:
Remaining tasks
* Write tests
* Maybe wait on https://www.drupal.org/node/2634212
User interface changes
API changes
Data model changes
Comment | File | Size | Author |
---|---|---|---|
#52 | interdiff-2636406-48-52.txt | 2.22 KB | phenaproxima |
#52 | 2636406-52.patch | 24.46 KB | phenaproxima |
#46 | interdiff-2636406-45-46.txt | 1.33 KB | phenaproxima |
#46 | 2636406-46.patch | 24.49 KB | phenaproxima |
#45 | interdiff-2636406-41-45.txt | 8.43 KB | phenaproxima |
Comments
Comment #2
dawehnerThere we go.
Comment #3
damiankloip CreditAttribution: damiankloip commentedForm*
Comment #4
dawehnerNo.
Its
DiffFrom
andDiffTo
.Do you have some better naming?
DiffFromForm
andDiffToForm
?Comment #5
damiankloip CreditAttribution: damiankloip commentedOHHH AHH AHAHAA
Comment #6
dawehnerWe need to ensure that all radio entries follow the same name attribute
Comment #7
lhangea CreditAttribution: lhangea commented@dawehner Thanks for your work ! It's really nice that we can use view for this one.
Still, it's not very clear for me yet how are we going to proceed with integration between diff and moderation_state module. Which module is going to provide the view ? Are both modules going to provide their own separate view and when used together the diff view is disabled and the moderation_state one is configured to include the diff form ?
As for waiting on the generic diff controller I think we can work on this first since there are tasks postponed on it and anyway the order doesn't really matter for diff anyway.
Comment #8
dawehnerThis is indeed a good question.
My general idea was to be honest to provide it more as a site builder tool. At least for my custom usecase it was supposed to be customized anyway.
On the other hand, I see where you are coming from. Talked a bit with @berdir on IRC.
One thing we could do is to
a) Ship a view without diff support in moderation_state
b) Have a optional configuration file with diff support included in
moderation_state
c) Have a
hook_module_installed()
hook inmoderation_state
which disables / removes the first view| enables the second view.Of course we could do it the other way round as well, but well, its the classical N^2 integration problem.
Comment #9
dawehnerExpanded the patch with some test coverage + minor fixes.
In case you wonder about the diff form key. This is basically a copy of what bulk forms do. Its not strictly needed, but its just a good way in case people build crazy views.
Comment #11
dawehnerFixed the test failures.
Comment #13
dawehnerMeh
Comment #15
jibranLooks ready to me.
Doc block missing.
@param part of the doc block is missing.
Doc block missing.
Comment #16
dawehnerAll of those points applies to #2634212: Offer a diff controller for all entity types leveraging entity API module
Comment #17
dawehnerOh wait, this is actually the wrong patch ...
Comment #19
dawehnerI asked fago to create a DEV release, this should help a bit.
Comment #21
mikemiles86Comment #22
phenaproximaRe-rolled.
Comment #25
dawehnerSee https://www.drupal.org/node/2634212#comment-10804570
Comment #26
mikemiles86Comment #27
juliaschwarz CreditAttribution: juliaschwarz commentedThis is an improved version of patch #11 (https://www.drupal.org/files/issues/2636406-11.patch) where the path to test files is changed (/modules -> /tests/modules).
I chose #11 as according to @dawehner this is the actual patch for this issue.
As I understand it #13 and #22 belong to https://www.drupal.org/node/2634212.
Please correct me, if I'm wrong!
Comment #28
juliaschwarz CreditAttribution: juliaschwarz commentedComment #30
dawehnerOh yeah you are absolutely right, these two patches have been the one from the other issue.
Ideally we should get the alpha release out so we can depend on entity module, but this is future ...
@JuliaBayer
Does that patch work fine for you? I'm pretty happy about it, but I might be quite biased.
Comment #31
juliaschwarz CreditAttribution: juliaschwarz commented@dawehner
Yes, it works and helps us very much. Thank you!
Comment #32
josephdpurcell CreditAttribution: josephdpurcell at Palantir.net for Acquia commentedComment #33
juampynr CreditAttribution: juampynr at Lullabot commentedComment #35
juampynr CreditAttribution: juampynr at Lullabot commentedRe-testing #27.
Comment #37
juliaschwarz CreditAttribution: juliaschwarz commentedI open my view within a modal dialog. By clicking on 'Compare' I want it to stay within the modal, but by default a new page is loaded.
Try 1: Enable ajax for view (within Views API). -> This doesn't seem to work for the Compare button (equal to bulk actions).
Try 2: Use a form_alter hook to add an ajax callback. -> This only works, if I have no exposed filter added to the view. But I need to filter by author. In this case (with exposed filter and added ajax callback for compare button) first the filter form is loaded which then expects an ajax callback too. As I won't define an ajax callback for the filter, nothing happens and i get the following Ajax Error:
ResponseText: {"message":"A fatal error occurred: The specified #ajax callback is empty or not callable."}
Does anybody know this problem?
Comment #38
Alan D. CreditAttribution: Alan D. commentedFlagged #641480: Expose diff functionality to views as a duplicate, since there are no patches in that older thread.
Comment #39
shubham_singhal CreditAttribution: shubham_singhal commentedHey, how can I do it on Drupal 7.
I have created a set of pages and I'll update them from time to time. On the home page I want to show the updated things (only updated content) and not the complete page. People shall see what new content is available as form of posts like we do from 'promote to front page'. I have created a view for content revision but can't integrate the diff module with it. Also there is no other way round to solve my problem.
Thanks
Shubham
(Technical Writer)
Comment #41
phenaproximaRerollèd.
Comment #42
phenaproximaThis can be condensed a bit:
array_filter(get_entity_types(), function () { ... })
This is missing a doc comment.
As a micro-optimization, we could just foreach through the fields and return ASAP.
If the entities can't be loaded for any reason, things are going to blow up. Can we add a couple of sanity checks here?
Can there be a comment explaining why nodes need different handling from other entity types?
No doc comment?
Will getCacheMaxAge() prevent this placeholder from being render-cached? I ask so that we don't run into an issue like the one over in #2758767: [Needs tests] EB views that sort in descending order are broken by render caching.
Should we use Drupal's JSON serializer here? I think it wraps around json_encode(), but using Drupal's components is probably best practice.
Ditto about using Drupal's serializer.
I haven't done a line-by-line review, but this look awfully similar to what's in the DiffFrom plugin. Can they both inherit this code from their base class? Or better yet, do they even need to be two different plugins? Can't we simply use the same plugin for both the diff__from and diff__to fields?
Doc comment.
Comment #44
dawehner@phenaproxima
Thank you for your response! As said on IRC, its great that people actually care about it.
Feel free to fix whatever you find.
Yes <3
I couldn't care less. This is some internal PHP variable which will never be returns as HTTP response.
Yeah I haven't put an effort into trying to share code. Feel free to try out!
Comment #45
phenaproximaThe failing test should still fail, but this addresses some of my comments from #42.
Comment #46
phenaproximaThis oughta fix the failures!
Comment #48
phenaproximaComment #49
dawehnerFor me this patch looks kinda great, but well, I'm a bit biased :)
Is this actually needed here?
$view->field
is documented as\Drupal\views\Plugin\views\field\FieldPluginBase[]
Is that some form of missing form validation or so? I mean ideally we would never get to it.
I couldn't care less about it. Its never exposed to the user
Comment #50
phenaproxima1. PHPStorm didn't seem to be able to detect it on its own, but it certainly is documented. Will remove.
2. What do you mean by form validation? I agree it's a bit kludgey, but the point is to avoid fatal errors. Happy to take any suggestions on how to improve that bail-out code.
3. If you don't care, then I guess I don't need to change this :)
Comment #51
dawehnerI got that, but do we maybe have to be more defensive before evening reaching this piece of code?
Yeah, just saying :)
Comment #52
phenaproximaHow's this?
Comment #53
dawehnerSeems reasonable :)
I like this patch, but you know, I'm a bit biased.
Comment #55
miro_dietikerLooks pretty fine.
Nit: some comments lack a final ".".
Also..
Is this comment stuff needed? Seems like no real help to me.
I thought about accessibility here and if this is enough to cover ARIA requirements...
First thought if we should offer different title for "from" and "to"...
Then compared with the default node diff tab to see the radio has no title / alt at all... and that the operations is abused for from and neither to nor the row action button has a table heading. Needs a major revisit there...
I guess we should create followups to investigate the accessibility situation.
Comment #56
dawehnerGood point!
Well its how other forms are generated in views. Just to be clear, this is defensive programming of the case that somehow for whatever reason the replacement doesn't work.
Comment #57
dawehnerBut sure we can drop it, when you think it is not worth here.
Comment #59
miro_dietikerCommitted, works nicely.
Also, i added some help text. The emptyness was confusing in the add dialog.
Pity / sorry, not yet in diff alpha3, but we should go beta soon anyway after working through the cleanup issues.
Interesting things happen when you end up creating a view that is not limited to a node.
Comparing two revisions of different nodes results in a 403 link that tries to compare node a in context of node a with a revision id of node b.
No idea if we could somehow avoid this misconfiguration. ;-)
The 7.x branch is not our business. Feel free to mark for backport. :-)
Comment #61
ksenzeeWould a maintainer please reopen this issue and move it to the 7.x queue for backport?