@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix some off-by-one issues when drag-and-dropping dashboard panels

Summary: Fixes T5321. There were a couple of off-by-one issues here which could result in inserts into the wrong position.

Test Plan:
- Dragged panels to the top, bottom, and first position of columns.
- Dragged panels from one column to another.
- Reloaded the page after drags, things stayed where I put them.

Reviewers: chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T5321

Differential Revision: https://secure.phabricator.com/D9573

+14 -11
+14 -11
src/applications/dashboard/controller/PhabricatorDashboardMovePanelController.php
··· 41 41 $layout_config->removePanel($panel_phid); 42 42 $panel_location_grid = $layout_config->getPanelLocations(); 43 43 44 - $panel_columns = idx($panel_location_grid, $column_id, array()); 45 - if ($panel_columns) { 44 + $column_phids = idx($panel_location_grid, $column_id, array()); 45 + $column_phids = array_values($column_phids); 46 + if ($column_phids) { 46 47 $insert_at = 0; 47 - $new_panel_columns = $panel_columns; 48 - foreach ($panel_columns as $index => $curr_panel_phid) { 49 - if ($curr_panel_phid === $before_phid) { 50 - $insert_at = max($index - 1, 0); 48 + foreach ($column_phids as $index => $phid) { 49 + if ($phid === $before_phid) { 50 + $insert_at = $index; 51 51 break; 52 52 } 53 - if ($curr_panel_phid === $after_phid) { 54 - $insert_at = $index; 53 + if ($phid === $after_phid) { 54 + $insert_at = $index + 1; 55 55 break; 56 56 } 57 57 } 58 + 59 + $new_column_phids = $column_phids; 58 60 array_splice( 59 - $new_panel_columns, 61 + $new_column_phids, 60 62 $insert_at, 61 63 0, 62 64 array($panel_phid)); 63 65 } else { 64 - $new_panel_columns = array(0 => $panel_phid); 66 + $new_column_phids = array(0 => $panel_phid); 65 67 } 66 - $panel_location_grid[$column_id] = $new_panel_columns; 68 + 69 + $panel_location_grid[$column_id] = $new_column_phids; 67 70 $layout_config->setPanelLocations($panel_location_grid); 68 71 $dashboard->setLayoutConfigFromObject($layout_config); 69 72 $dashboard->save();