Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett’s picture

Title: Move procedural code from views_ui.module and admin.inc to ViewUi » Move procedural code from views_ui.module and admin.inc to ViewUI
Issue tags: +VDC
tim.plunkett’s picture

Status: Active » Needs review
FileSize
44.38 KB
58.53 KB

Here's a first pass. One patch includes #1788232: Move UI properties from ViewExecutable to a new ViewUI class.
There's more to do!

tim.plunkett’s picture

FileSize
78.83 KB

More code!

tim.plunkett’s picture

FileSize
117.25 KB

Another patch. I'll need to change some stuff when #1791238: Remove ViewStorageController::save() goes in.

tim.plunkett’s picture

FileSize
117.08 KB

Rerolled now that its in.

dawehner’s picture

+++ b/includes/admin.incundefined
@@ -2930,11 +1884,11 @@ function views_ui_reorder_displays_form($form, &$form_state) {
-        '#default_value' => isset($display->deleted),
+        '#default_value' => isset($display['deleted']),
       ),
     );
 
-    if (isset($display->deleted) && $display->deleted) {

oh, i'm sorry

+++ b/lib/Drupal/views/Plugin/views/access/Role.phpundefined
@@ -65,7 +65,7 @@ public function buildOptionsForm(&$form, &$form_state) {
-      '#options' => array_map('check_plain', views_ui_get_roles()),
+      '#options' => array_map('check_plain', $this->getRoles()),
       '#description' => t('Only the checked roles will be able to access this display. Note that users with "access all views" can see any view, regardless of role.'),
     );
   }
@@ -81,4 +81,22 @@ public function submitOptionsForm(&$form, &$form_state) {

@@ -81,4 +81,22 @@ public function submitOptionsForm(&$form, &$form_state) {
     $form_state['values']['access_options']['role'] = array_filter($form_state['values']['access_options']['role']);
   }
 
+  /**
+   * Get a list of roles in the system.
+   */
+  protected function getRoles() {
+    static $roles = NULL;
+    if (!isset($roles)) {
+      $roles = array();
+      // Uses db_query() rather than db_select() because the query is static and
+      // does not include any variables.
+      $result = $result = db_query("SELECT r.rid, r.name FROM {role} r ORDER BY r.name");
+      foreach ($result as $obj) {
+        $roles[$obj->rid] = $obj->name;
+      }
+    }
+
+    return $roles;

What about using array_map('check_plain', user_roles(TRUE)), instead? The argument validator is doing that already.

+++ b/lib/Drupal/views/ViewExecutable.phpundefined
@@ -1820,14 +1820,15 @@ public function createDuplicate() {
+  public function cloneView($ui = FALSE) {
+    $storage = clone $this->storage;

Why not extending/overriding the cloneView method in the UI class?

dawehner’s picture

FileSize
3.58 KB

It is always a question whether you have just a broken code or also a broken test,
especially the addDisplay test is a bit confusing why it fails.

Status: Needs review » Needs work

The last submitted patch, views-1792860-7.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
121.96 KB

Combining the two patches.

Status: Needs review » Needs work

The last submitted patch, views-1792860-9.patch, failed testing.

Lars Toomre’s picture

Oh gosh... both of the patches in #1793510: Move views toward D8 documentation standard in longer apply after this lands. Both of those cleaned up much of the documentation for admin.inc and views_ui.module.

tim.plunkett’s picture

@Lars Toomre which is why that was postponed. This drastically changes the function signatures, almost none of those fixes would be relevant after this patch.

Lars Toomre’s picture

Understood @tim.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
210.7 KB

Addressed #6, moved more code.
Leaving out the tests until DisplayTest is added in another issue.

Status: Needs review » Needs work

The last submitted patch, views-1792860-14.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
207.49 KB

Apparently, you can't use methods with #pre_render. Everything else uses c_u_f_a() so you can

aspilicious’s picture

Less procedural crap in .inc and module files++

To big to review in a patch. But +1 for the idea.

tim.plunkett’s picture

FileSize
208.11 KB

Since it has gotten rather unmanageable, maybe it'd be better to stop here and commit this, then move forward in smaller chunks?

Assuming this passes, of course.

Status: Needs review » Needs work

The last submitted patch, views-1792860-18.patch, failed testing.

tim.plunkett’s picture

Assigned: tim.plunkett » dawehner
Status: Needs work » Needs review
FileSize
208.15 KB

Whoops, missed the reordering fix I wrote! This should pass.

dawehner’s picture

Status: Needs review » Needs work

This is impressive work so far! Warning: this is no complete review, but as aspilicious said it is hard to review

+++ b/includes/admin.incundefined
@@ -81,298 +19,17 @@ function views_ui_preview(ViewUI $view, $display_id, $args = array()) {
+  $form_state['build_info']['callback'] = array('Drupal\views\ViewUI', 'addForm');

In general i'm wondering whether we should use the same naming as on the plugins, so buildAddForm, validateAddForm etc.

dawehner’s picture

Status: Needs work » Active

Update status, a deeper review this evening.

dawehner’s picture

Status: Active » Needs review

add back.

tim.plunkett’s picture

As I said on IRC:

I went back and renamed most of the methods, but I missed that one I guess. I wasn't too worried about it, because I thought we could do an inventory of them all when its done, and then rename and group them along some sane patterns

dawehner’s picture

Assigned: dawehner » Unassigned
Status: Needs review » Fixed
./includes/admin.inc:1209:  $types = ViewUI::viewsHandlerTypes();
./includes/admin.inc:1241:  $types = ViewUI::viewsHandlerTypes();
./includes/admin.inc:1256:  $types = ViewUI::viewsHandlerTypes();
./includes/admin.inc:1481:  $types = ViewUI::viewsHandlerTypes();
./includes/admin.inc:1517:  $types = ViewUI::viewsHandlerTypes();
./includes/admin.inc:1783:  $types = ViewUI::viewsHandlerTypes();
./includes/admin.inc:1906:  $types = ViewUI::viewsHandlerTypes();
./includes/admin.inc:2090:      $types = ViewUI::viewsHandlerTypes();
./includes/admin.inc:2210:  $types = ViewUI::viewsHandlerTypes();
./includes/admin.inc:2264:  $types = ViewUI::viewsHandlerTypes();
./includes/admin.inc:2340:      $types = ViewUI::viewsHandlerTypes();
./includes/admin.inc:2441:      $types = ViewUI::viewsHandlerTypes();
./includes/admin.inc:2512:      $types = ViewUI::viewsHandlerTypes();
./includes/admin.inc:3186:  $handler_types = ViewUI::viewsHandlerTypes();

I stumbled upon these changes but yeah it kind of makes sense because this file currently uses just ViewUI, so this is fine.

We should really get this in!

tim.plunkett’s picture

Status: Fixed » Needs review
FileSize
52.63 KB
tim.plunkett’s picture

#26: views-1792860-26.patch queued for re-testing.

tim.plunkett’s picture

Assigned: Unassigned » dawehner

I think this should be the last patch down this line, and do the rest in #1798574: Refactor Views UI to be a form controller later.

dawehner’s picture

+++ b/lib/Drupal/views/ViewUI.phpundefined
index 9a4a227..7ab31f7 100644
--- a/theme/theme.inc

The problem with a theme/theme.inc is that this code is loaded on all pages, which involves a view, not only in the admin interface, maybe we want to change this?

tim.plunkett’s picture

FileSize
48.31 KB
61.16 KB

I agree with #29.
This had to happen sooner or later.
Moved the relevant code into a views_ui module folder.

Status: Needs review » Needs work

The last submitted patch, views-1792860-30.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
62.38 KB

Missed a couple of namespace changes.

Status: Needs review » Needs work

The last submitted patch, views-1792860-32.patch, failed testing.

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
4 KB
65.22 KB

Whoops, missed the poorly named views_container.

Status: Needs review » Needs work

The last submitted patch, views-1792860-34.patch, failed testing.

dawehner’s picture

Status: Needs work » Reviewed & tested by the community
+++ b/views_ui/theme/theme.incundefined
diff --git a/theme/views-ui-display-tab-bucket.tpl.php b/views_ui/theme/views-ui-display-tab-bucket.tpl.php
rename from theme/views-ui-display-tab-bucket.tpl.php
rename to views_ui/theme/views-ui-display-tab-bucket.tpl.php

It is great that you renamed and moved all the files ...

I think this can go in, it is a great improvement!

dawehner’s picture

Status: Reviewed & tested by the community » Needs work

... well

tim.plunkett’s picture

Status: Needs work » Needs review
FileSize
65.27 KB

Missed one thing!

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Back to rtbc

tim.plunkett’s picture

Assigned: dawehner » tim.plunkett
FileSize
65.32 KB

This conflicted with #1760284: Rewrite ViewListController to use the core EntityListController, rerolling. If it passes I'll commit it.

tim.plunkett’s picture

Assigned: tim.plunkett » Unassigned
Status: Reviewed & tested by the community » Fixed

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