Currently, "Dashboard main" and "Dashboard sidebar" regions appear on the blocks configuration page. This is confusing because they aren't really block regions in the same way as the rest of the block regions (they only appear on one page on your site, specifically the Dashboard). It's especially confusing because they appear as options even for a theme that does not display the dashboard page (e.g., for Garland in the standard install profile). See also #601932: Allow dashboard to limit available blocks for some background.

The reason they're currently there is that we need to provide a "blocks-module-style" UI for managing dashboard blocks (since this is intended to be the accessible fallback for people who cannot use the fancy drag-and-drop interaction on the Dashboard itself).

However, there is no reason we have to stick them on the blocks administration page - rather, we can provide a separate, duplicate UI for the dashboard blocks only. By using hook_form_alter() and a couple other tricks (and by cleaning up the block module's code a bit) we can do this with almost no code duplication at all.

The attached patch implements this. The patch is fully functional, although the UI still needs some polishing. For example, we would need to figure out where and how to cross-link all three pages in question (the Dashboard, the Blocks administration page, and this new "Dashboard administration page").

CommentFileSizeAuthor
#111 dashboard-blocks.patch4.48 KBbleen
#109 dashboard-blocks.patch4.48 KBbleen
#106 dashboard-blocks.patch4.48 KBbleen
#104 dashboard-blocks.patch4.54 KBbleen
#103 dashboard-blocks.patch4.54 KBbleen
#100 dashboard-blocks.patch4.08 KBbleen
#98 dashboard-blocks.patch4.54 KBbleen
#93 dashboard-regions.patch4.26 KBbleen
#92 dashboard-regions.patch3.91 KBbleen
#90 dashboard-regions.patch1.94 KBbleen
#83 dashboard-admin.png115.22 KBtstoeckler
#80 drupal.split-dashboard-blocks.80.patch40.62 KBDavid_Rothstein
#79 drupal.split-dashboard-blocks.78.patch40.68 KBximo
#74 drupal.split-dashboard-blocks.74.patch35.19 KBDavid_Rothstein
#71 drupal.split-dashboard-blocks.71.patch39.5 KBXen
#69 drupal.split-dashboard-blocks.68.patch39.47 KBXen
#66 drupal.split-dashboard-blocks.66.patch39.6 KBXen
#57 drupal.split-dashboard-blocks.57.patch40.79 KBrszrama
#50 dashboard-1.jpg7.34 KBlinclark
#50 dashboard-2.jpg5.39 KBlinclark
#50 dashboard-3.jpg7.54 KBlinclark
#49 drupal.split-dashboard-blocks.49.patch33.65 KBXen
#47 drupal.split-dashboard-blocks.47.patch33.4 KBXen
#41 drupal.split-dashboard-blocks.41.patch30.77 KBtstoeckler
#40 drupal.split-dashboard-blocks.40.patch32.73 KBsun
#37 split-dashboard-blocks-761956-37.patch32.86 KBDavid_Rothstein
#31 split-dashboard-blocks-761956-31.patch32.8 KBDavid_Rothstein
#29 split-dashboard-blocks-761956-29.patch32.85 KBDavid_Rothstein
#26 split-dashboard-blocks-761956-26.patch32.86 KBDavid_Rothstein
#23 split-dashboard-blocks-761956-23.patch32.86 KBDavid_Rothstein
#20 split-dashboard-blocks-761956-20.patch32.45 KBDavid_Rothstein
#20 dashboard-configure.png39.93 KBDavid_Rothstein
#20 dashboard-admin.png77.02 KBDavid_Rothstein
#20 blocks-admin.png88.32 KBDavid_Rothstein
#5 dashboard.jpeg35.75 KByoroy
#4 split-dashboard-blocks-761956-4.patch30.62 KBDavid_Rothstein
#2 configure-dashboard-page.png83.93 KBDavid_Rothstein
#2 configure-blocks-page.png83.86 KBDavid_Rothstein
#1 split-dashboard-blocks.patch16.95 KBDavid_Rothstein
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

David_Rothstein’s picture

Category: task » bug
Status: Active » Needs review
FileSize
16.95 KB

Patch.

David_Rothstein’s picture

And screenshots, showing the two separate pages. The Dashboard one only shows the dashboard regions (plus disabled blocks), while the Blocks one now has the dashboard regions removed, and looks like it would without the Dashboard module even being enabled.

Status: Needs review » Needs work

The last submitted patch, split-dashboard-blocks.patch, failed testing.

David_Rothstein’s picture

Status: Needs work » Needs review
FileSize
30.62 KB

Ugh, the failing tests were because this patch changed the form structure of the blocks administration form (and therefore slightly changed the HTML so that tests which tried to submit with the old HTML failed).

The change was that previously, all submitted blocks were at the top of the $form_state['values'] array, but this meant there was a (preexisting) bug in the block module when the submit handler for the form tried to loop through $form_state['values'] and save everything as a block to the database; this is a bug since this array certainly contains other things besides blocks (e.g. the submit button). With my patch, this manifested itself as ugly PHP notices, due to other changes the patch made, so it needed to be fixed here, and I decided to fix it properly by putting the blocks in $form_state['values']['blocks'] instead.

If not changing the HTML of the blocks administration form at all is a priority, it's certainly possible to work around that bug rather than fix it cleanly (and get a smaller patch file as a result), but I thought it was better to fix it. In any case, I think this one will probably take care of all the failing tests.

yoroy’s picture

FileSize
35.75 KB

Superscribe! Thanks, & yes, good start. I imagine this to be linked as a secondary tab in the *customize* dashboard screen only:

David_Rothstein’s picture

Ah, that makes sense... a little tricky, but should be possible.

We also need to think about how this works for someone who needs to visit that page for accessibility reasons, though - i.e. who cannot even configure the dashboard via the main drag-and-drop interface at all. (Currently, the help text for those people only shows up when JavaScript is turned off, but that's not really correct.)

The other thing I wonder about is someone who wants to move a block from the dashboard to the main site (or vice versa) - this is probably pretty rare, but with this patch it would be a two step process (first they have to disable it on the 'configure dashboard' page, then they have to go to the main blocks administration page to put it somewhere else) so they might need a little help in this case... e.g., if they are looking for a particular block but don't see it anywhere on the blocks administration page (because it's actually on the dashboard instead). That's why I was thinking there might need to be a little more cross-linking.

amc’s picture

Issue tags: +dashboard
catch’s picture

I like this, subscribing.

Bojhan’s picture

For the record, I was against the initial implementation in the D7UX: Dashboard issue - because it creates a concept which says that on /admin/structure/blocks regions would live of other parts then your site. And also advised it as a solution in #601932: Allow dashboard to limit available blocks - to know where I am coming from.

Then onto this implementation, it seems good. Obviously its a bit confusing at first that disabling and enabling a block is a two step process, but David explained to me that this is kind of an edge case. Other then that, I would think this issue needs some reviews, since its holding back a critical issue.

Me and yoroy discussed this on irc, the only label change we perceive is "Manage dashboard blocks" rather then "more". This design concept, could very much be conceived as a UI hack for the sake of accessibility. Placing it in the description or other common places, would only cause more clutter.

EvanDonovan’s picture

Subscribing.

Dries’s picture

I'm confused by the screenshot.

1. It looks like we're on the manage dashboard block page, and then there is another link to 'manage dashboard blocks'?

2. It seems like incorrect use of sub-tabs.

Bojhan’s picture

@Dries yes, its a UI hack - we are still experimenting I would say, the functionality almost entirely for accessibility sake.

Everett Zufelt’s picture

Subscribing

This is an interesting and somewhat complicated issue from a ux / accessibility perspective. There obviously needs to be an easy to understand and accessible method to rearrange blocks on the dashboard for users who cannot use drag-and-drop functionality.

I would be happy to discuss this in person in SF if anyone is interested.

David_Rothstein’s picture

Where are we with this issue?

Let's not get too caught up on discussing subtabs - that's not even part of the patch :) I suggest we go with a simple solution here first.

The link from the dashboard customization screen to the new admin/structure/dashboard page would partly be for accessibility, but serves other purposes too, especially with #601932: Allow dashboard to limit available blocks.

We put these kinds of supplemental links in help text all the time (block.module, shortcut.module, etc) and I think it's reasonable to do that here at least for the moment. Currently the text says:

Drag and drop these blocks to the columns below. Changes are automatically saved.

So what's the simplest and best way to link to admin/structure/dashboard from there? Maybe something like:

Drag and drop these blocks to the columns below. Changes are automatically saved. More options are available on the <a href="/admin/structure/dashboard">configuration page</a>.

Anyone care to tweak that?

Also, the patch still applies and seems to still work. Any more general reviews?

yoroy’s picture

Issue tags: -Usability, -dashboard

Status: Needs review » Needs work
Issue tags: +Usability, +dashboard

The last submitted patch, split-dashboard-blocks-761956-4.patch, failed testing.

YesCT’s picture

this is kind of, sort of blocking critical (priority-major and webchick beta blocker) issue: #601932: Allow dashboard to limit available blocks

Bojhan’s picture

@David could you reroll a patch we can apply and test? I am keen on fixing this before the #601932: Allow dashboard to limit available blocks issue, it should be possible - where to place this link is to be discussed, but honestly shouldn't keep this issue from moving.

With a new patch this can be set to needs review and will keep it moving.

yoroy’s picture

Priority: Normal » Critical

Issues that block criticals are critical themselves. A reroll of the patch would be appreciated. Lets get some of the last ux criticals moving again.

David_Rothstein’s picture

Status: Needs work » Needs review
FileSize
88.32 KB
77.02 KB
39.93 KB
32.45 KB

OK. Here is a reroll to chase HEAD, but only lightly tested - and with textual changes similar to what I proposed above. Screenshots are also attached.

Status: Needs review » Needs work

The last submitted patch, split-dashboard-blocks-761956-20.patch, failed testing.

Bojhan’s picture

Intresting, with a small label change I think that could work - since we have to have the changes are automatically saved anyway since we didn't implement any coherent auto-save interaction/visual

David_Rothstein’s picture

Status: Needs work » Needs review
FileSize
32.86 KB

Hopefully fixing the failing tests...

aspilicious’s picture

Ok...

GOOD
-----
1) testbot is green
2) still applies
3) I like the screenshots

BAD
----
1) I found two verbs in the doc headers (process and preprocess) that need to be rewritten to processes and preprocesses

So...

Can someone summarize what has to be done to mark this rtbc?
As this is needed for another critical I think we should pay attention to this (pretty big) patch

Bojhan’s picture

From my perspective only fixing the copywriting a little.

configuration page = Dashboard blocks overview page.

Disabling a block makes it available on the main blocks administration page = I dont get what this means.

Either way, I would love if David could envision how this would work with the checkbox parent issue #601932: Allow dashboard to limit available blocks

David_Rothstein’s picture

I fixed the "processes" and "preprocesses" stuff from #24 in the attached patch; no other changes for now.

In terms of how this interacts with #601932: Allow dashboard to limit available blocks I think just that it makes it possible for us to add new dashboard regions (including a potential "disabled-but-available-on-the-dashboard" region, distinct from regular disabled "non-dashboard" blocks) without adding any clutter to the block admin page. Otherwise I don't think they're necessarily related.

Disabling a block makes it available on the main blocks administration page = I dont get what this means.

It means that disabled blocks are shown on both pages, but the others aren't. I think it's important we communicate this well so let's think about it a bit, although the wording here would definitely be affected by #601932: Allow dashboard to limit available blocks in the end....

yoroy’s picture

Patch works as intended. My review focusses mostly on copywriting:

Welcome to d7 | d7

Lets not re-use the same flow of words of the normal blocks page description, makes it harder to tell the two apart. I tried to use simpler words.

__
Welcome to d7 | d7

- Suggest to use a more descriptive page title to differentiate it more clearly from 'Customize dashboard page'.
- Lets just call it a dashboard, and administrative is a very difficult word :-)
- I still wonder if we can do something else for the 'Disabled' label in the table itself. It's weird that disabling something actually also means enabling it somewhere else. I was thinking something like 'not available for dashboard', which is also a negative but only for the dashboard context.

EvanDonovan’s picture

@yoroy:

I like the wording changes you suggest. I haven't tested the patch, but this looks from the screenshots like it should be good.

Would "inactive" be better than "disabled"?

For the wording at the top of the table, you could say "Removing a block from the dashboard makes it available on the main blocks administration page."

David_Rothstein’s picture

Those changes make sense to me too, and I've made them in the attached patch.

Regarding this:

- I still wonder if we can do something else for the 'Disabled' label in the table itself. It's weird that disabling something actually also means enabling it somewhere else. I was thinking something like 'not available for dashboard', which is also a negative but only for the dashboard context.

as well as Bojhan's and Evan's comments about the help text at the top of the page, we should maybe wait for #601932: Allow dashboard to limit available blocks to handle that, since what we decide there affects what the appropriate text would be. (For now, we could maybe even just leave that help text off if we wanted to...) But I think those ideas make a fair amount of sense.

And if "makes it available on the main blocks administration page" is not clear we could be a bit more verbose here and say something more like "Blocks which are removed from the dashboard can be placed elsewhere in the Seven theme via the blocks administration page".

sun’s picture

+++ modules/block/block.admin.inc	9 Jul 2010 06:10:57 -0000
@@ -122,7 +172,7 @@ function block_admin_display_form($form,
 function block_admin_display_form_submit($form, &$form_state) {
...
-  foreach ($form_state['values'] as $block) {
+  foreach ($form_state['values']['blocks'] as $block) {

Love you for this change. Finally allows modules to extend that form! :)

+++ modules/dashboard/dashboard.module	9 Jul 2010 06:10:57 -0000
@@ -235,6 +268,86 @@ function dashboard_admin($launch_customi
+  require_once DRUPAL_ROOT . '/' . drupal_get_path('module', 'block') . '/block.admin.inc';

module_load_include() ?

+++ modules/dashboard/dashboard.module	9 Jul 2010 06:10:57 -0000
@@ -235,6 +268,86 @@ function dashboard_admin($launch_customi
+  // @todo: This assumes the current page is being displayed using the same
+  // theme that the dashboard is displayed in.

Proper syntax for @todo is explained on http://drupal.org/node/1354

+++ modules/dashboard/dashboard.module	9 Jul 2010 06:10:57 -0000
@@ -235,6 +268,86 @@ function dashboard_admin($launch_customi
+  $regions_to_remove = array_keys(array_diff_key(system_region_list($theme_key, REGIONS_VISIBLE), $dashboard_regions));
+  foreach ($blocks as $id => $block) {
+    if (in_array($block['region'], $regions_to_remove)) {

It looks like removing array_keys() for $regions_to_remove would allow to use the much simpler and faster isset() instead of in_array().

Aside from that, this looks ready to fly to me.

39 critical left. Go review some!

David_Rothstein’s picture

Thanks! I fixed those issues in the attached patch.

Regarding the last point, I also noticed another part of the patch - in_array($block['region']['#default_value'], array_keys($dashboard_regions)) - that could be simplified in a similar way, so I fixed that too. I must have been on an array_keys() binge while writing that :)

sun’s picture

Status: Needs review » Reviewed & tested by the community
+++ modules/dashboard/dashboard.module	23 Jul 2010 04:31:41 -0000
@@ -18,6 +18,11 @@ function dashboard_help($path, $arg) {
       return $output;
+    case 'admin/structure/dashboard':
+      // @todo: This assumes the current page is being displayed using the same

Aside from a missing newline between case and return, and @todo still having a colon behind it, this looks ready to fly for me.

+++ modules/dashboard/dashboard.module	23 Jul 2010 04:31:41 -0000
@@ -235,6 +268,86 @@ function dashboard_admin($launch_customi
+function template_preprocess_dashboard_admin_display_form(&$variables) {
+  template_preprocess_block_admin_display_form($variables);
+}

I wonder why that other preprocess function isn't registered in hook_theme() instead, but maybe this is the correct way. (I have no idea)

Aforementioned issues are minor, may be changed in a follow-up, or not.

40 critical left. Go review some!

Bojhan’s picture

Status: Reviewed & tested by the community » Needs review

One second, I am reviewing it - I am feeling the placement in the IA is somewhat weird.

Bojhan’s picture

Status: Needs review » Reviewed & tested by the community

Ok looks good, I am not sure it belongs in Structure at all though. We might want to move it somewhere else later.

amc’s picture

Re #34: There's an issue about moving the blocks system to Appearance: #567418: Move blocks page into appearance, although that may or may not be an appropriate place for this page, depending on whether or not we want "Appearance" to refer to user-facing settings only.

Bojhan’s picture

@amc that is not the appropriate place. I will comment in the other issue.

David_Rothstein’s picture

Oops, fixed the @todo colon and missing newline in the attached.

I wonder why that other preprocess function isn't registered in hook_theme() instead, but maybe this is the correct way. (I have no idea)

I think you might be right - at least the documentation makes it sound like that would work. I'll try to look into that later, but yeah, for now the patch certainly works as is.

David_Rothstein’s picture

I looked more into registering the preprocess function in hook_theme(). When you register a preprocess function in hook_theme() it turns out you are overriding all the preprocess functions, meaning in addition to the one you want to add you would also have to explicitly specify more general ones like template_preprocess() itself - not to mention any other modules' version thereof, such as contextual_preprocess() - or they won't get called.

I'm not sure if that's a bug or by design, but either way, we don't want to do that here :) So the patch in #37 should be good as is.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Looking through the code, this seems to be a pretty elegant solution to the problem. Great!

Unfortunately, the patch has gone stale, so I can't test it. :( Sorry. Would someone be able to do a quick re-roll?

sun’s picture

Status: Needs work » Reviewed & tested by the community
FileSize
32.73 KB

Re-rolled against HEAD.

tstoeckler’s picture

Previous patch did not remove the Dashboard regions from the block configuration form (for a single block).
Added dashboard_form_block_admin_configure_alter().
No other changes.

sun’s picture

Status: Reviewed & tested by the community » Needs review

Odd. @David, please re-confirm this patch.

David_Rothstein’s picture

Status: Needs review » Needs work

I don't think that code will work - what happens if you configure a dashboard block via that form?

I deliberately left this out originally, figuring that it wouldn't hurt to just have those options in the dropdown (and it's simpler to keep them there). I guess it's true, though, that it allows you to configure yourself into a black hole, by putting the block into a dashboard region for a theme that doesn't have the dashboard (then it's really hard to find your way back). Needs more thought, perhaps.

One option would be to only leave those options in the dropdown for the theme that displays the dashboard, and remove them for the other themes.

Bojhan’s picture

Can you make a patch that does work?

This issue been waiting for way to long to continue moving.

zzolo’s picture

When I apply the last patch in #41, I get the following error when I go to admin/structure/dashboard:

PHP Fatal error:  Call to undefined function  block_admin_display_prepare_blocks() in /site_path/modules/dashboard/dashboard.module on line 296

It seems like this function does not exist. Is it supposed to be in this patch, or already in core?

zzolo’s picture

Assigned: Unassigned » zzolo
Xen’s picture

drupal.split-dashboard-blocks.41.patch lost block_admin_display_prepare_blocks and changes to block_admin_display and block_admin_display_form

Applied 40.patch and copied the dashboard_form_block_admin_configure_alter from 41.

zzolo’s picture

So, this patch looks and works good for me.

Thinking about #43, this is an interesting problem. Here are some points, questions:

* If someone disables the dashboard module, then those configured blocks need to be updated (have their region removed).
* If a module provides dashboard regions and gets disabled, then those regions need to be removed from the blocks that were configured appropriately.
* If someone sets a dashboard block for a specific theme with dashboard regions, and the theme is switched or disabled, this is not a problem as blocks are configured per theme.

Overall, what needs to happen is when a module is disabled (and implementes hook_dashboard_regions), then something needs to get fired to take into account that blocks could be configured in that region for any theme. This is technically a different issue than the original, s the original is actually just based around the UI for blocks, not about the dashboard_region functionality.

Xen’s picture

Status: Needs work » Needs review
FileSize
33.65 KB

Addressing the problem of #43, here's the #47 patch with the added twist of hiding the dashboard regions for all themes but the current, which is assumed to be the admin theme.

Anonymous’s picture

FileSize
7.54 KB
5.39 KB
7.34 KB

If a module provides dashboard regions and gets disabled, then those regions need to be removed from the blocks that were configured appropriately.

There is a strange issue at work with the patch in #49. If you add the Recent comments block and then disable comments.module, the box that said "No comments available" is not removed, but instead changes to say "(empty)". When you re-enable comments, the heading shows up again, but the box still says empty.
Only local images are allowed.
Only local images are allowed.
Only local images are allowed.

zzolo’s picture

Status: Needs work » Needs review

So, thinking about this more. The way the block module handles this is not listening to a disable, but rehashing the blocks on the admin page in _block_rehash() which we call in block_admin_display_prepare_blocks() so this is good to go. Need someone with a little more exp to review as well.

Anonymous’s picture

Status: Needs review » Needs work
zzolo’s picture

Status: Needs review » Needs work

So, more into this, what we now need to do is implement a hook_cache_flushes() similar to blocks:

function block_flush_caches() {
  // Rehash blocks for active themes. We don't use list_themes() here,
  // because if MAINTENANCE_MODE is defined it skips reading the database,
  // and we can't tell which themes are active.
  $themes = db_query("SELECT name FROM {system} WHERE type = 'theme' AND status = 1");
  foreach ($themes as $theme) {
    _block_rehash($theme->name);
  }

  return array('cache_block');
}

I believe this is the issue with what @linclark describes in #50.

zzolo’s picture

After talking with @linclark, this problem seems to persist past what my previous problem describes. The _block_rehash() function must not be fully equipped for this. Looking into further.

Xen’s picture

Status: Needs work » Needs review

The problem described in #50 is another issue, it's still a problem without this patch.

Xen’s picture

Status: Needs review » Needs work

The tests are broken though.

rszrama’s picture

Status: Needs work » Needs review
FileSize
40.79 KB

Re-rolled to fix those test fails. The size difference from the last patch is due to my IDE fixing spacing issues in search.test.

Anonymous’s picture

I ran into the following problem. I am not sure whether this is exactly the steps, but want to post them now before we get kicked out.

  1. I assign Recent comments to Sidebar First.
  2. I assign Recent comments to Dashboard.
  3. I disable Comment module and Dashboard. The Recent comments box disappears in Sidebar First (as expected).
  4. I re-enable Comment module. The Recent comments block in Sidebar First does not return, even though it is in Sidebar First in my blocks list (NOT expected behavior).
  5. I re-enable Dashboard. Recent blocks in Sidebar First appears again
Xen’s picture

The "(empty)" thing seems to be a feature of dashboard. The dashboard blocks are rendered by the normal block system, and then moved to the dashboard regions. If a block isn't rendered (because it is empty, or configured to not be shown for some reason), dashboard adds a empty placeholder.

As the missing comment module block isn't rendered because it doesn't exist anymore, dashboard adds it in.

Xen’s picture

Re #48

* If someone disables the dashboard module, then those configured blocks need to be updated (have their region removed).
* If a module provides dashboard regions and gets disabled, then those regions need to be removed from the blocks that were configured appropriately.

But people would expect it to work like the regular blocks: reenabling the module brings the blocks back the same places (if you haven't messed with block settings in the meanwhile). However, one could make a case for dashboards being something else...

omar’s picture

I hope I'm not missing something (I'm a little new to reviewing patches).

I repeated the test described below.


I ran into the following problem. I am not sure whether this is exactly the steps, but want to post them now before we get kicked out.

1. I assign Recent comments to Sidebar First.
2. I assign Recent comments to Dashboard.
3. I disable Comment module and Dashboard. The Recent comments box disappears in Sidebar First (as expected).
4. I re-enable Comment module. The Recent comments block in Sidebar First does not return, even though it is in Sidebar First in my blocks list (NOT expected behavior).
5. I re-enable Dashboard. Recent blocks in Sidebar First appears again

Upon completing step number 4, re-enabling the comment module, I get the following error in the overlay:

FieldException: Attempt to create an instance of field comment_body on bundle comment_node_article that already has an instance of that field. in field_create_instance() (line 673 of /home/omar/web/drupal-7.x-dev/modules/field/field.crud.inc).

... and the "recent comments" are not displayed. Re-submitting the module form a second time (i.e. without changing anything) does *not* generate the error and the "recent comments" block appears. So I think that the result of step number 5 have nothing to do with the re-enabling of the dashboard module.

This behavior is the same whether or not the patch number 57 is applied.

I hope that this is helpful.

ronald_istos’s picture

Status: Needs review » Needs work

Have been playing around with this and there do seem to be some problems with caching.

On a clean install moving things around works ok but as soon as you disable and enable the dashboard module (or generally mess about as Lin describes in 58) things start behaving strangely. Blocks appears on both the dashboard and the main block page even though they are enabled for one or the other, etc.

There is also a set of messages saying that the blocks assigned to the Dashboard are assigned to invalid regions and have been disabled - this is not major but might be confusing for a user that things something went terribly wrong.

In order to get things back to some normality the cache needs to be cleared explicitly - so some more work on that needs to happen.

jenlampton’s picture

Status: Needs work » Needs review

Is anyone actively working on this patch? I'd be happy to pitch in and add some cache_clear_all calls to retest. I think the problems described in #61 might also be related to cache (but perhaps not #58).

ronald_istos’s picture

@jenlampton zzolo was working on this yesterday and looking at the comments above has been looking at caching issues - so would wait for him to chip in?

jenlampton’s picture

Status: Needs review » Needs work

thanks @ronald_istos. I just did some testing of my own and could not recreate the caching problems.

1. I assign Recent comments to Sidebar First.
2. I assign Recent comments to Dashboard.
3. I disable Comment module
4. I disable Dashboard module.
5. I re-enable Comment module.
Result: Block reappears in sidebar first (as expected) (Note: the error message in #61 comes from #877388: FieldException when re-enabling comment module)
6. I re-enable Dashboard.
Result: blocks to NOT appear in previous locations on Dashboard.

I even tried futzing around with some other stuff in the UI like turning off and on dashboard again, and off and on comment, but everything works as expected for me.

I wonder if the dashboard placement should not also be preserved, but I don't think that should be critical. Perhaps time for a new issue?

Xen’s picture

New patch based on #57 with fixes for:

* If someone disables the dashboard module, then those configured blocks need to be updated (have their region removed).

dashboard_disable implements this

* If a module provides dashboard regions and gets disabled, then those regions need to be removed from the blocks that were configured appropriately.

dashboard_modules_disabled implemented. Someone please test.

jenlampton’s picture

can you reroll this patch quickly without the a and b? Will try a find and replace if not.

*EDIT*

1) I don't think this is working. After the dashboard module is disabled, the value for 'region' in the block table is -1. When blocks are removed from regions via the UI, the whole record is removed from the block table.

2) ...

Xen’s picture

Ah, git thingies, I'll figure out what others do and reroll.

I have a block table full of -1 blocks. I took it for being the canonical 'disabled' value. I can remove them instead.

Xen’s picture

a/b fixed.

I looked at block_admin_display_form_submit which has this:

    $block['status'] = (int) ($block['region'] != BLOCK_REGION_NONE);
    $block['region'] = $block['status'] ? $block['region'] : '';

So i changed the disable hooks to to set the region to ''.

jenlampton’s picture

This is better, but I still don't think it's enough. As well as updating the region, I think we should be updating the status. The block's status needs to change from 1 to 0.

In both cases where an enabled block can't go on the dashboard because it disappears, the block should become disabled, no?

(It would also be nice if we could preserve the region for if/when the module gets enabled again, too)

Can we change the status instead of the region?

Xen’s picture

(It would also be nice if we could preserve the region for if/when the module gets enabled again, too)

Can't. Because of:

      if (!empty($block['region']) && $block['region'] != BLOCK_REGION_NONE && !isset($regions[$block['region']])) {
        drupal_set_message(t('The block %info was assigned to the invalid region %region and has been disabled.', array('%info' => $block['info'], '%region' => $block['region'])), 'warning');
        // Disabled modules are moved into the BLOCK_REGION_NONE later so no
        // need to move the bock to another region.
        $block['status'] = 0;

in _block_rehash.

Status = 0 added...

zzolo’s picture

Sorry, DrupalCon happened. I'll review/work on this probably on Friday during code sprint.

Yeah, the behavior of the block system is that if a region gets disabled (theme changes or module that offers regions gets disabled), then it just automatically updates the block table on cache flush or when going to block page.

Though, this may not be the best behavior, persay, it is alright for now, and it is important that the blocks get their region reset, so that they can be configured again (since the block system only allows a block to be enabled per theme per region).

So, in theory, we should not really have to handle this case, as it should already be handled for us. At least, thats the idea.

bojanz’s picture

Status: Needs work » Needs review

@Xen
After posting a patch, you need to change the status to "needs review" so that the bot can test it.

Let's do it now :)

David_Rothstein’s picture

I'm trying to catch up on this issue. It sounds to me like many of you are saying the bugs identified recently regarding disabling the dashboard module weren't caused by this patch, but rather are preexisting issues? If so, we should be creating separate issues for them...

If anyone believes they are caused by this patch, please test carefully both with and without the patch applied, reinstalling in between, and then explain what is different in the two situations (i.e., how the patch made things worse). Those are the only things we need to fix here :) Certainly playing around with the dashboard module without the patch applied, I can reproduce a lot of weirdness as well - so it seems to me that these bugs are probably not related?

Consequently, I've rerolled the patch and removed the dashboard disabling code. The attached patch is basically #40, plus the dashboard_form_block_admin_configure_alter() function that was added in the interim to fix the dropdown list on the configuration page, plus the additional test fixes that were added in the interim (at least, I hope I copied all of the latter over correctly - if not, the testbot will tell us :)

There is hopefully really only one main thing left to focus on in this issue. That is the following @todo, which now appears three times in the patch file :(

+  // @todo This assumes the current page is being displayed using the same
+  //   theme that the dashboard is displayed in.

So basically we are assuming that the dashboard is displayed in the same theme as various admin pages used to configure it. That is most likely true, but not necessarily. I wish there were an easy way to fix it, but I don't think so - there is no way to reliably find out what theme the Dashboard is actually displayed in (especially since in theory it could even be different for e.g. different users). We could start adding per-theme subtabs to the Dashboard configuration page (just like the Block configuration page has), but that wouldn't even fully solve the problem and would also probably be bad UX - we'd be providing screens to configure the dashboard blocks for a theme it doesn't actually display in.

Any thoughts on what to do here? It's probably enough of an edge case that I'm tempted to ignore it, or at least leave it for a followup issue :) If some module really wants to play around with the dashboard themes like that, maybe they can be responsible for making sure they don't break things. But I'm still a bit uneasy about it...

BarisW’s picture

Status: Needs review » Needs work

Your patch indeed makes the dashboard regions disappear. However, the blocks currently in these regions disappear as well.
So if we have a list of recent content on our dashboard page, we can not add this block to other blocks in the Admin theme.

Is this supposed to work like this?

Something else that's buggy (as you said, nothing to do with this patch) is the drag&drop interface on the Dashboard page. I've made a new issue for that (#895246: Dragging & dropping disabled blocks is buggy).

David_Rothstein’s picture

Status: Needs work » Needs review

Your patch indeed makes the dashboard regions disappear. However, the blocks currently in these regions disappear as well.

Not sure what you mean by "disappear"? Did you test this with a fresh installation of Drupal?

So if we have a list of recent content on our dashboard page, we can not add this block to other blocks in the Admin theme.

AFAIK that is the current and expected behavior without the patch as well. I seem to remember that multiple block "instances" was a feature request for Drupal 7 that didn't make it in.

BarisW’s picture

Allright, if that is the purpose, it makes sense. Wouldn't it be nice to have a small message on the blocks page as in 'Blocks that have been added to the Dashboard page are not available.'?

What's strange in this setup is that the Dashboard page uses Seven as theme, with it's own regions not used outside the dashboard. We'd had better created a seven_dashboard child theme to use for the Dashboard. If we had done so, we don't have to use your patch at all, and blocks can be added to Seven AND the dashboard as well.

Anyhow, I think your patch looks good and does what it should do.

BarisW’s picture

Making it a subtheme wouldn't be achievable I guess, as other themes can be a admin theme as well.
I tested it without Javascript and that also workes great.

I found one small bug: the link to the Dahboard page on admin/structure/dashboard points to the wrong url.

ximo’s picture

The "Add block" form didn't have dashboard regions hidden from its region select lists. I added a form_alter for that form. It simply calls the form_alter for the configure form as they're basically the same (block.admin.inc does the same thing when building the forms).

function dashboard_form_block_add_block_form_alter(&$form, &$form_state) {
  dashboard_form_block_admin_configure_alter($form, $form_state);
}

I also combined two nested if clauses in dashboard_form_block_admin_configure_alter().

Other than that, I agree with David that it's tempting to leave the @todos for a spin-off issue. It looks a bit tricky, but I don't think it's critical in itself, it feels like only an edge case could cause problems.

David_Rothstein’s picture

@BarisW, that is a very interesting idea actually. As you say, we couldn't do it exactly like that (because we can't require every Drupal 7 theme to ship with a dashboard-specific subtheme!) but I wonder if it would be possible to have a single, hidden theme which Dashboard module can alter to work that way?

I'll look into that later if I have some time. If it works, it might solve a bunch of bugs at once, including this one. It's better as a separate issue, though, because there's no guarantee it will work, and anyway, the changes to the block module which make up the bulk of this patch are probably a good bugfix in their own right (since they make the block module's pages more alterable), even if in the end the dashboard module does not wind up needing to use them itself.

I found one small bug: the link to the Dahboard page on admin/structure/dashboard points to the wrong url.

Good catch - that dates back from when the Dashboard module previously took over the 'admin' URL, but it no longer does that anymore. Fixed in the attached.

Bojhan’s picture

After all this work, can there be some screenshots describing what the proposed interaction is?

tstoeckler’s picture

Haven't applied the most recent patch, but coming from earlier ones, I don't think much has changed visually; as in, no new visual elements have been introduced. On admin/build/block admin/structure/blocks, with the patch the dashboard regions are not visible, and with them all blocks that are on the dashboard. Also, if you click configure on one of the blocks, the select list to choose the region for the block does also not show the Dashboard regions. Only For the admin theme, which is assumed (see above) to be the theme the dashboard is displayed in.

tstoeckler’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
115.22 KB

I just reread the patch and tried it out extensively. I tried enabling and moving around normal blocks and dashboard blocks, with and without JS and disabling dashboard module. Nothing unexpected happened. Setting to RTBC.

For Bojhan I attached a screenshot of admin/structure/dashboard, because that's the only thing that's new. Note, that only people without JS ever go there because JS-users use the fancy drag-and-drop interface (of course they can navigate there manually through the toolbar, for instance). The screenshot is taken with JS (otherwise, the 'grippies' would not appear etc). In general it is really the same thing as admin/build/blocks (hey, it actually uses the same code...), so nothing special.

zzolo’s picture

Assigned: zzolo » Unassigned
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Great work, folks. Committed to HEAD.

Bojhan’s picture

No idea what happend here, should we reopen #601932: Allow dashboard to limit available blocks, Dashboard in structure?

webchick’s picture

The dashboard *settings* page is in structure, yeah. It's a fall-back in case the default drag-and-drop interface doesn't work.

bleen’s picture

Status: Fixed » Active

I hate reopening this, but I noticed today that the dashboard regions are not showing up on the /admin/structure/dashboard page.

Configure available dashboard blocks | d7

Bojhan confirmed this on IRC :(

This makes a bleen sad

David_Rothstein’s picture

It looks like there was a change to the form API recently, so that now both dashboard_form_block_admin_display_form_alter() and dashboard_form_dashboard_admin_display_form_alter() are being called on this form.

Here, we are/were relying on the fact that since the form ID is 'dashboard_admin_display_form', only the second alter hook would be called.

Looks like this was introduced a couple days ago, probably via #757154: Base form_id via hook_forms() not taken into account for #validate, #submit, hook_form_FORMID_alter(). I haven't looked carefully enough to see if it was intentional or not.

Guess this means we should have some tests here also :)

bleen’s picture

Status: Active » Needs review
FileSize
1.94 KB

this should do it

sun’s picture

Status: Needs review » Needs work
+++ modules/dashboard/dashboard.module	13 Sep 2010 00:52:58 -0000
@@ -313,15 +313,17 @@ function dashboard_admin_blocks() {
 function dashboard_form_block_admin_display_form_alter(&$form, &$form_state) {
...
+  if ($form['#form_id'] == 'block_admin_display_form') {

$form_id is passed as third argument and should be used here.

Overall, however, this is very odd and at least deserves a code comment, and I'm entirely not sure what's going on in Dashboard module.

Powered by Dreditor.

bleen’s picture

Status: Needs work » Needs review
FileSize
3.91 KB

This patch has tests too ... I wasn't sure what the best way was to test this, but this definitely works.

bleen’s picture

FileSize
4.26 KB

...and this patch has tests as well as changes based on #91

sun’s picture

+++ modules/dashboard/dashboard.module	13 Sep 2010 02:23:19 -0000
@@ -310,18 +310,22 @@ function dashboard_admin_blocks() {
+  // administration form and from the options list on that form. Because this
+  // function is called for both the dashboard block configuration form and the
+  // standard bloack configuration form, the form_id must be checked.

Thanks, but who is guilty for that double-calling? Is Dashboard module implementing hook_forms()?

Powered by Dreditor.

bleen’s picture

yup:

function dashboard_forms() {
  // Reroute the dashboard configuration form to the main blocks administration
  // form. This allows us to distinguish them by form ID in hook_form_alter().
  $forms['dashboard_admin_display_form'] = array(
    'callback' => 'block_admin_display_form',
  );

  return $forms;
}

I dont understand this well enough to suggest removing it ... though it seems like maybe we should? Thoughts?

sun’s picture

Ah-ha, thanks! :) Now we want to cross-reference that knowledge in the added code comment; i.e., so that we don't simply state what happens, but instead why something happens. That's the essence of code comments. (Or in other words: It's obvious that by looking at the code we are in a hook_form_FORMID_alter() function and, although we are in a fom_id-specific alter hook, that the code somehow takes the actual $form_id into account, prior to performing any changes. We need to document the non-obvious.)

Thanks for driving this home, bleen18!

David_Rothstein’s picture

Yup, I think we need that hook_forms() for exactly the reason we are hitting here: We want the two forms to share the same constructor but be able to alter them independently.

Before, this behaved the way we wanted automatically, but with the change introduced in the other issue (which does appear to be intentional, and even documented in the module upgrade guide already :), we just need to check the form IDs explicitly, so the patch looks like the right approach. However, given the intention of the new behavior, perhaps instead of this:

if ($form_id == 'block_admin_display_form')

we actually want this?

if ($form_id != 'dashboard_admin_display_form')

I think that might make more sense, because it would then be saying that we want to alter the block admin form and all forms that derive from it to not show the dashboard regions - with the exception of our dashboard form, where we want to allow them.

The tests look good, although there are some (minor) code style issues, and also I think we want some PHPDoc for DashboardAdminTestCase? Ideally, we'd also use XPath assertions such as assertFieldByXPath() and assertNoFieldByXPath() to check for the HTML we're looking for on the page; although more annoying to write, they are more robust, especially since in this case we have an assertion that HTML is not present (which is easy to get a false positive for if you check for a specific HTML string rather than the XPath).

bleen’s picture

FileSize
4.54 KB

how bout this

sun’s picture

Status: Needs review » Needs work
+++ modules/dashboard/dashboard.module	14 Sep 2010 01:00:01 -0000
@@ -310,18 +310,23 @@ function dashboard_admin_blocks() {
+  // standard bloack configuration form so that both forms can share the same

Wonderful. Just that "bloack" somehow managed to get between your fingers ;)

+++ modules/dashboard/dashboard.test	14 Sep 2010 01:00:01 -0000
@@ -58,3 +58,45 @@ class DashboardAccessTestCase extends Dr
+class DashboardAdminTestCase extends DrupalWebTestCase {

Missing phpDoc. Do we really need an entire new test case for this? It doesn't seem to do anything special, so I suspect it could be merged into one of the existing.

Powered by Dreditor.

bleen’s picture

Status: Needs work » Needs review
FileSize
4.08 KB

how bout this

bleen’s picture

Status: Needs review » Needs work

wait .. makin a quick change to testname

sun’s picture

Status: Needs work » Reviewed & tested by the community

Thanks!

Please wait for green light before commit.

bleen’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
4.54 KB

this one

bleen’s picture

FileSize
4.54 KB

blaaarg!! found another typo

David_Rothstein’s picture

  1. +  if ($form_id == 'block_admin_display_form') {
    

    Did anyone have any thoughts on my comment above that perhaps we should be checking $form_id != 'dashboard_admin_display_form instead?

    It's probably more of a theoretical concern, but if someone else actually is reusing the block admin form constructor on a different page, I think we likely want our alter function to run on them too.

  2. +      'name' => 'Dashboard',
    +      'description' => 'Test blocks as used by the dashboard.',
    

    Given the description, maybe the name should actually be 'Dashboard blocks'?

  3. +    foreach($dashboard_regions as $region => $description){
    

    Minor, and only if you are rerolling for another reason, but here - as well as a couple other places in the tests - there should be a blank space before the opening parentheses and after the closing one.

  4. +    foreach($dashboard_regions as $region => $description){
    +      foreach($dashboard_regions as $region => $description){
    

    Looks like this is accidentally duplicated?

    Also, it seems like you aren't using the description anywhere in this test, so instead of using the dashboard_region_descriptions() function to get the list of regions, it seems like the test could use the dashboard_regions() function instead, and the code would be a little simpler.

bleen’s picture

FileSize
4.48 KB

I meant to do (1) ... but just forgot. This patch covers all the points from #105

Status: Needs review » Needs work

The last submitted patch, dashboard-blocks.patch, failed testing.

David_Rothstein’s picture

Looks good except for that :)

If you get a chance while rerolling, might as well fix these:

+    foreach ($dashboard_regions as $region => $description){
+    foreach ($dashboard_regions as $region => $description){

[still missing a space between the ")" and "{"]

Otherwise, seems like it's RTBC.

bleen’s picture

FileSize
4.48 KB

rerolled... will pass test and fixed spacing from #107

sun’s picture

+++ modules/dashboard/dashboard.test	14 Sep 2010 15:36:28 -0000
@@ -6,11 +6,11 @@
-class DashboardAccessTestCase extends DrupalWebTestCase {
+class DashboarBlocksTestCase extends DrupalWebTestCase {

Still a typo here.

Powered by Dreditor.

bleen’s picture

Status: Needs work » Needs review
FileSize
4.48 KB

blaaarg

sun’s picture

Status: Needs review » Reviewed & tested by the community

Thanks! :)

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Awesome!

Committed to HEAD. Thanks! :)

Status: Fixed » Closed (fixed)

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

David_Rothstein’s picture

For the issues raised above about bugs that occur when the dashboard module is disabled (and @BarisW's suggestion of fixing that by having the dashboard use its own subtheme), I've created this issue:

#950878: Disabling the dashboard module permanently removes all blocks from the dashboard