Problem/Motivation

What is compared is selected on the revision overview.

But on the URL that displays the visual diff, the individual revisions compared are not indicated.
The text "Comparing two revisions:" is also pretty useless in this context.

This is bad UX.
Also, the navigation is unclear, when going back and forth between revisions.

The two-col plugin indicates the revision in the column and we don't want to have too much redundant information.
While we want to have the visual diff as slim as possible, it should still be clear to the user where we are.

Proposed resolution

Remaining tasks

User interface changes

CommentFileSizeAuthor
#61 interdiff-2801749-57-61.txt10.82 KBjohnchque
#61 unclear_what_is-2801749-61.patch9.03 KBjohnchque
#58 AdminView-Desktop.png49.4 KBdrobnjak
#58 UserView-Desktop.png55.18 KBdrobnjak
#58 UserView-Mobile.png52.75 KBdrobnjak
#58 unclear_what_is-2801749-57.patch9.61 KBdrobnjak
#58 interdiff-2801749-54-57.txt2.78 KBdrobnjak
#54 interdiff-2801749-50-54.txt465 bytesdrobnjak
#54 unclear_what_is-2801749-54.patch10.22 KBdrobnjak
#50 interdiff-2801749-47-50.txt7.64 KBdrobnjak
#50 unclear_what_is-2801749-50.patch10.81 KBdrobnjak
#47 interdiff-2801749-46-47.txt3.62 KBjohnchque
#47 unclear_what_is-2801749-47.patch9.49 KBjohnchque
#46 unclear_what_is-2801749-46.patch9.49 KBdrobnjak
#46 interdiff-2801749-43-46.txt2.35 KBdrobnjak
#43 interdiff-2801749-39-43.txt1.29 KBdrobnjak
#43 unclear_what_is-2801749-43.patch9.28 KBdrobnjak
#39 interdiff-2801749-37-39.txt483 bytesdrobnjak
#39 unclear_what_is-2801749-39.patch10.42 KBdrobnjak
#37 Screenshot from 2016-10-04 15-41-07.png53.67 KBdrobnjak
#37 Screenshot from 2016-10-04 15-41-30.png56.67 KBdrobnjak
#37 unclear_what_is-2801749-37.patch10.43 KBdrobnjak
#37 interdiff-2801749-33-37.txt5.58 KBdrobnjak
#33 Screenshot from 2016-10-03 15-13-54.png18.02 KBdrobnjak
#33 interdiff-2801749-30-33.txt2.4 KBdrobnjak
#33 unclear_what_is-2801749-33.patch7.32 KBdrobnjak
#30 unclear_what_is-2801749-30.patch7.12 KBdrobnjak
#30 interdiff-2801749-16-30.txt3.8 KBdrobnjak
#30 Screenshot from 2016-10-03 10-35-41.png27.77 KBdrobnjak
#20 interdiff-2801749-16-20.txt1.6 KBdrobnjak
#20 unclear_what_is-2801749-20.patch7.36 KBdrobnjak
#20 Screenshot from 2016-09-23 17-07-54.png45.82 KBdrobnjak
#19 Screen Shot 2016-09-23 at 14.44.47.png44.35 KBtduong
#16 interdiff-2801749-14-16.txt527 bytesdrobnjak
#16 unclear_what_is-2801749-16.patch5.66 KBdrobnjak
#14 interdiff-2801749-12-14.txt803 bytesdrobnjak
#14 unclear_what_is-2801749-14.patch5.67 KBdrobnjak
#12 interdiff-2801749-10-12.txt0 bytesdrobnjak
#12 unclear_what_is-2801749-12.patch5.66 KBdrobnjak
#10 interdiff-2801749-8-10.txt1.23 KBdrobnjak
#10 unclear_what_is-2801749-10.patch5.66 KBdrobnjak
#8 interdiff-2801749-4-8.txt4.04 KBdrobnjak
#8 unclear_what_is-2801749-8.patch4.67 KBdrobnjak
#8 Screenshot from 2016-09-22 15-40-57.png46.63 KBdrobnjak
#4 Screenshot from 2016-09-19 10-24-11.png52.95 KBjohnchque
#4 unclear_what_is-2801749-4.patch892 bytesjohnchque
#2 Screen Shot 2016-09-17 at 16.32.42 .png35.08 KBmiro_dietiker

Comments

miro_dietiker created an issue. See original summary.

miro_dietiker’s picture

Issue summary: View changes
StatusFileSize
new35.08 KB

Attaching example.

johnchque’s picture

Assigned: Unassigned » johnchque

should we add the revision links next to the "Comparing two revisions" text?

johnchque’s picture

Status: Active » Needs review
StatusFileSize
new892 bytes
new52.95 KB

Not really sure where to place the revision links.

miro_dietiker’s picture

Status: Needs review » Needs work

Now "Comparing:" is redundant, see the text above "Comparing two revisions:" where i'm confused that we don't explain yet what we are comparing in the first place.

The Navigation label is present although there is no navigation.
So, thinking out loud, the reference point (what revisions are compared) belong as much to the navigation as the previous / next links. Since they are in reference to the selected revisions.

So it's more a:
0. "Changes to " Entity/Node title + Breadcrumb
2. "Comparing" X VS Y
3. "Navigation" Prev / Next
4. "Layout" Z / Advanced settings
5. Diff Data

Plus semantically, a navigation doesn't make sense if it is empty. Either remove or provide an empty statement.

johnchque’s picture

ohhh fyi the navigation label appears in the screenshot because there was another link in the right of the screen, I checked the code and the navigation label doesn't appear when there are no more than two revisions.

drobnjak’s picture

Assigned: johnchque » drobnjak
drobnjak’s picture

Status: Needs work » Needs review
StatusFileSize
new46.63 KB
new4.67 KB
new4.04 KB

Edited weight typos and added values on the missing points (ex. diff display).
Currently weight for the "Comparing" div is 0 and for "Navigation" 1. They should swap but they don't. If "Comparing" weight is set to -1 then they swap the places. Screenshot included.

johnchque’s picture

Status: Needs review » Needs work

As discussed remove that extra wrapper for navigation, and things will work magically. :)

drobnjak’s picture

StatusFileSize
new5.66 KB
new1.23 KB

Done, it is working properly now

drobnjak’s picture

Status: Needs work » Needs review
drobnjak’s picture

StatusFileSize
new5.66 KB
new0 bytes

Comment 10 same as comment 8. I uploaded wrong patch.
Here it is now, with proper patch and working.

johnchque’s picture

Status: Needs review » Needs work
+++ b/src/Plugin/diff/Layout/VisualInlineDiffLayout.php
@@ -154,7 +154,18 @@ class VisualInlineDiffLayout extends DiffLayoutBase {
-
+    $build['diff_revisions'] = [
+      '#type' => 'item',
+      '#title' => $this->t('Comparing:'),
+      '#weight' => 0,
+    ];
+    $build['diff_revisions'][] = [
+      '#markup' => $this->buildRevisionLink($left_revision),
+      '#suffix' => '<br>',
+    ];
+    $build['diff_revisions'][] = [
+      '#markup' => $this->buildRevisionLink($right_revision),
+    ];

Please add a white line before and after this. If you can add a comment like: "Show the revisions that are compared." is also good.

drobnjak’s picture

Status: Needs work » Needs review
StatusFileSize
new5.67 KB
new803 bytes
johnchque’s picture

Status: Needs review » Needs work
+++ b/src/Plugin/diff/Layout/VisualInlineDiffLayout.php
@@ -154,6 +154,19 @@ class VisualInlineDiffLayout extends DiffLayoutBase {
+    // Show the revisions that are compared

"." missing at the end of the comment. Please also add a white line before this line.

drobnjak’s picture

StatusFileSize
new5.66 KB
new527 bytes
johnchque’s picture

Status: Needs work » Needs review

Don't forget to set it as needs review.

johnchque’s picture

Status: Needs review » Reviewed & tested by the community

Looks nice. Not really sure if the links are fine one below the other. Besides that I would say RTBC.

tduong’s picture

Status: Reviewed & tested by the community » Needs work
StatusFileSize
new44.35 KB

Tested this locally and I've noticed that if a revision is made in few seconds, the time displayed in the link is the same, thus it could confuse the user, but the revision log is also shown there (maybe needs a bit more work).

Usually this kind of page should not display too many info, but I guess it would be better to somehow show the revision log and the "date - time" (as a while link (?)) (?)

PS: @drobnjak, please remember to provide a new screenshot when you have some new UI updates ;)

drobnjak’s picture

Status: Needs work » Needs review
StatusFileSize
new45.82 KB
new7.36 KB
new1.6 KB

Status: Needs review » Needs work

The last submitted patch, 20: unclear_what_is-2801749-20.patch, failed testing.

tduong’s picture

+++ b/diff.install
@@ -53,19 +53,8 @@ function diff_update_8004() {
-  // The original update function had a bug, it set the new configuration of
-  // layout plugins using the old keys (which were changed). Update 8006 will
-  // fix this issue.
-}
-
-/**
- * Update settings, set the new keys of layout plugins.
- */
-function diff_update_8006() {
   $config = \Drupal::configFactory()->getEditable('diff.settings');
-  $layout_manager = \Drupal::service('plugin.manager.diff.layout');
-  $layout_manager->clearCachedDefinitions();
-  $plugins = $layout_manager->getDefinitions();
+  $plugins = \Drupal::service('plugin.manager.diff.layout')->getDefinitions();

I guess you didn't update your branch before :P

Otherwise looks really nice! :)

johnchque’s picture

Issue summary: View changes

That is an API change, not sure if we can make it now?

johnchque’s picture

Issue summary: View changes

Didn't want to change the IS.

johnchque’s picture

I was wondering if in the end we should remove the whole revision log since it is used also in the header. That info shouldn't go there. Not sure, would like to know Miro's feedback.

miro_dietiker’s picture

Yeah not sure about this. I will need some time to think about it and find some other references.

Brainstorming:
I quickly proposed that we could rely on the "outside in" pattern to show the navigation, similar to how Google Docs do.
The revision list could only list the two revisions we compare with a button for prev / next above / below each.
Alternatively we could list all revisions with a click handler to set it the "from" and "to" and even remove both prev / next links.

But before doing decisions, and reinventing the weel ourself, we should do proper research:
We should collect revision handling screenshots from common (content creation) applications.

johnchque’s picture

In that case would be better IMHO to place all the navigation things in the outside-in tray :)

miro_dietiker’s picture

Yeah. But it would be optional. So it will be a follow-up and can be post release.
I created #2808623: Use outside-in for diff / revision navigation

We just need to decide what is the simplified minimum gpal for the release.

miro_dietiker’s picture

drobnjak’s picture

Status: Needs work » Needs review
StatusFileSize
new27.77 KB
new3.8 KB
new7.12 KB

Removed semi-colon and uploading new patch as @miro_dietiker suggested.

Status: Needs review » Needs work

The last submitted patch, 30: unclear_what_is-2801749-30.patch, failed testing.

miro_dietiker’s picture

We learned in the other issue about mockup, that also the author per revision is relevant.
So we have 3 infos to display: Date, Author, Message
The author is currently missing.

Concatenating them looks bad / unaligned.
Should we use a flex display for this?

drobnjak’s picture

Status: Needs work » Needs review
StatusFileSize
new7.32 KB
new2.4 KB
new18.02 KB

I added author in the middle between revision date and message since the revision message is much longer than the author name in some cases. They are concatenated now. Implementing flex or columns would be time consuming and since the current navigation will probably move into the sidebar after this issue https://www.drupal.org/node/2808623 , I think it is better to devote time to investigate outside-in possibility to implement it with the diff module before implementing flex or column layout here for the navigation.

drobnjak’s picture

Status: Needs review » Needs work
miro_dietiker’s picture

So yeah, since the message itself is variable width, it really makes sense to have the revision log last.
Really not sure about the dashes. If a readable separator then we could use " by " like on node/ID/revisions

miro_dietiker’s picture

Ah, and we should make author a link. It always is.

drobnjak’s picture

Status: Needs work » Needs review
StatusFileSize
new5.58 KB
new10.43 KB
new56.67 KB
new53.67 KB

As @miro_dietiker suggested, I implemented flex layout. I also changed author to be a link and did the css adjustments to support different resolutions, tablet and smartphone screens.

Status: Needs review » Needs work

The last submitted patch, 37: unclear_what_is-2801749-37.patch, failed testing.

drobnjak’s picture

StatusFileSize
new10.42 KB
new483 bytes

Test fix

drobnjak’s picture

Status: Needs work » Needs review
johnchque’s picture

Status: Needs review » Needs work
  1. +++ b/src/DiffLayoutBase.php
    @@ -112,14 +113,34 @@ abstract class DiffLayoutBase extends PluginBase implements DiffLayoutInterface,
    +      ¶
    

    Wrong indentation.

  2. +++ b/src/Form/RevisionOverviewForm.php
    @@ -244,7 +244,7 @@ class RevisionOverviewForm extends FormBase {
    +                  Url::fromRoute('c', ['node' => $node->id(), 'node_revision' => $vid, 'langcode' => $langcode]) :
    

    Why are you changing the route?

  3. +++ b/src/Tests/DiffRevisionTest.php
    @@ -95,7 +95,8 @@ class DiffRevisionTest extends DiffTestBase {
    -    $this->assertEqual((string) $comment, 'Revision 2 comment');
    +    $this->assertEqual((string) $comment, '
    +        ');
    

    Why this change is needed?

The last submitted patch, 39: unclear_what_is-2801749-39.patch, failed testing.

drobnjak’s picture

Status: Needs work » Needs review
StatusFileSize
new9.28 KB
new1.29 KB

Responding to comment #41
1. Indentation fixed
2. Route change happened accidentally while searching through code and it went unseen in the commit
3. When DiffLayoutBase changes were introduced $comment moved position and its value is now "\n " which was changed in the test

New patch uploaded with fixes for the tests

johnchque’s picture

Status: Needs review » Needs work

Hmmm just tested manually, with your changes the header of the Split/Unified fields layout is broken, it basically adds too much space when a revision has a log and the other doesn't. We better need to remove the revision log when using that function on the header of those layouts. I'm not really sure how to fix this, there might be lots of ways. but for sure we cannot allow have the table headers like they are now.

johnchque’s picture

+++ b/src/DiffLayoutBase.php
@@ -112,14 +112,34 @@ abstract class DiffLayoutBase extends PluginBase implements DiffLayoutInterface,
+      $revision_link = '
+        <div class="comparation-flex-container">
+          <div class="comparation-flex-item-date">';
+            $revision_link.=$revision_date_url;
+            $revision_link.='</div>
+          <div class="comparation-flex-item-author">';
+            $revision_link.=$revision_author_url;
+            $revision_link.='</div>
+          <div class="comparation-flex-item-message">';
+            $revision_link.=$revision_log;
+            $revision_link.='</div>
+        </div>';

btw this cannot be done in this way, better if you change it to type => item and create the elements inside.

drobnjak’s picture

StatusFileSize
new2.35 KB
new9.49 KB

Changed the code, this time using type -> item

johnchque’s picture

Status: Needs work » Needs review
StatusFileSize
new9.49 KB
new3.62 KB

This fixes your problem of array, not really sure if the changes are according with what you wanted to do. please check the markup.

Status: Needs review » Needs work

The last submitted patch, 47: unclear_what_is-2801749-47.patch, failed testing.

miro_dietiker’s picture

  1. +++ b/src/DiffLayoutBase.php
    @@ -114,43 +114,34 @@
    +        '#type' => 'link',
    +        '#title' => $revision->getRevisionUser()->getDisplayName(),
    +        '#url' => Url::fromUri(\Drupal::request()->getUriForPath('/user/' . $user_id)),
    

    Hm, you set the type to link, but it should only be a link if the user has the permission to access user profiles, see

    access user profiles:
      title: 'View user information'
    

    I tested and the link is always output, even if the user has no permission. That's bad UX.
    We should apply a similar pattern like core does it.

    function template_preprocess_node(&$variables) {
      $variables['author_name'] = drupal_render($variables['elements']['uid']);
      unset($variables['elements']['uid']);
    

    Where uid is the entity reference field to the author.
    And if you look in more detail it's as simple as an element with #theme => 'username' with #account and the User entity.

  2. +++ b/src/Plugin/diff/Layout/VisualInlineDiffLayout.php
    @@ -170,14 +170,14 @@
    -      '#markup' => $this->buildRevisionLink($left_revision),
    ...
    -      '#markup' => $this->buildRevisionLink($right_revision),
    ...
    +    $build['diff_revisions']['previous_revision'] = $this->buildRevisionLink($left_revision);
    ...
    +    $build['diff_revisions']['revision'] = $this->buildRevisionLink($right_revision);
    

    It'a not revision VS previous_revision. It's just two revisions compared.
    Only \Drupal\diff\DiffEntityComparison::summary uses revision, previous_revision.
    The code uses the terms left_revision, right_revision even if it's not visually left / right. Stick to it.

drobnjak’s picture

StatusFileSize
new10.81 KB
new7.64 KB

Split revision log creation for visual inline from split fields and unified fields since it was breaking the header and DiffRevisionTest. Changed previous_revision and revision to left and right as it is used in the code.
Uploading a patch now for tests, and if it passes tests and reviews it would be ready to commit. I suggest creating follow up for the 49.1. and access to user profiles.

drobnjak’s picture

Status: Needs work » Needs review

The last submitted patch, 46: unclear_what_is-2801749-46.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 50: unclear_what_is-2801749-50.patch, failed testing.

drobnjak’s picture

Status: Needs work » Needs review
StatusFileSize
new10.22 KB
new465 bytes

Small test fix

johnchque’s picture

Status: Needs review » Needs work
  1. +++ b/src/DiffLayoutBase.php
    @@ -118,7 +177,7 @@ abstract class DiffLayoutBase extends PluginBase implements DiffLayoutInterface,
    +        ]))->toString(),
    

    unrelated change.

  2. +++ b/src/DiffLayoutBase.php
    @@ -126,8 +185,8 @@ abstract class DiffLayoutBase extends PluginBase implements DiffLayoutInterface,
    -
    -  /**
    +  ¶
    +      /**
    

    Indentation change unrelated.

As suggested, add #access to don't display those elements when the user doesn't have access/enough permissions.

tduong’s picture

Some more feedback details:

  1. +++ b/src/DiffLayoutBase.php
    @@ -93,7 +93,66 @@ abstract class DiffLayoutBase extends PluginBase implements DiffLayoutInterface,
    +      //Creating author URL.
    ...
    +       //Creating revision date URL.
    
    +++ b/src/Plugin/diff/Layout/VisualInlineDiffLayout.php
    @@ -166,6 +166,19 @@ class VisualInlineDiffLayout extends DiffLayoutBase {
    +    //Show the revisions that are compared.
    

    Add a white-space between "//" and your comment.
    Here is the general Drupal API documentation standards.
    And generally it starts as an "imperative verb".

  2. +++ b/src/DiffLayoutBase.php
    @@ -93,7 +93,66 @@ abstract class DiffLayoutBase extends PluginBase implements DiffLayoutInterface,
    +      $revision_link['author'] = [
    +        '#type' => 'link',
    +        '#title' => $revision->getRevisionUser()->getDisplayName(),
    +        '#url' => Url::fromUri(\Drupal::request()->getUriForPath('/user/' . $user_id)),
    +        '#attributes' => [
    +          'class' => ['comparation-flex-item-author'],
    +        ],
    +      ];
    

    As mentioned in the previous comments, you will need to wrap this block into an if checking for the "View user information" permission like
    $user->hasPermission('access user profiles').

    And you can do this like in RevisionOverviewForm::buildForm():

    $username = [
                '#theme' => 'username',
                '#account' => $revision->getRevisionAuthor(),
              ];
    
  3. +++ b/src/DiffLayoutBase.php
    @@ -126,8 +185,8 @@ abstract class DiffLayoutBase extends PluginBase implements DiffLayoutInterface,
    +  ¶
    +      /**
    

    Reformat/revert this, as also John said.

  4. +++ b/src/Plugin/diff/Layout/VisualInlineDiffLayout.php
    @@ -166,6 +166,19 @@ class VisualInlineDiffLayout extends DiffLayoutBase {
    +    $build['diff_revisions']['left_revision'] = $this->buildRevisionLinkVisualInline($left_revision);
    +    $build['diff_revisions']['left_revision']['#prefix'] = '<div class="comparation-flex-container">';
    +    $build['diff_revisions']['left_revision']['#suffix'] = '</div>';
    +    $build['diff_revisions']['right_revision'] = $this->buildRevisionLinkVisualInline($right_revision);
    +    $build['diff_revisions']['right_revision']['#prefix'] = '<div class="comparation-flex-container">';
    +    $build['diff_revisions']['right_revision']['#suffix'] = '</div>';
    

    Let's do these as two blocks like

    $build['diff_revisions']['left_revision'] = [
      '#prefix' => ...
      '#suffix' => ...
    ];
    

    to make these line length less than 80 (?)

johnchque’s picture

+++ b/src/Plugin/diff/Layout/VisualInlineDiffLayout.php
@@ -166,6 +166,19 @@ class VisualInlineDiffLayout extends DiffLayoutBase {
+      'weight' => 0,

please, don't forget the # before weight.

drobnjak’s picture

Added changes from previous comments. I also provided screenshots for different resolutions.

drobnjak’s picture

Status: Needs work » Needs review
johnchque’s picture

Assigned: drobnjak » johnchque

I actually realized that the css shouldn't be in the general css. Will change it.

johnchque’s picture

StatusFileSize
new9.03 KB
new10.82 KB

Now placed the code for be more plugin specific, we don't want to mix functions between layouts ;).

miro_dietiker’s picture

Status: Needs review » Fixed

Committed... with some comment fix.

But the CSS file needs a rename similar to the plugin name. Plz create follow-up.

johnchque’s picture

I also noticed that. Follow-up created.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.