Differential D20475 Diff 48880 src/applications/dashboard/paneltype/PhabricatorDashboardTabsPanelType.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/dashboard/paneltype/PhabricatorDashboardTabsPanelType.php
| Show First 20 Lines • Show All 81 Lines • ▼ Show 20 Lines | $remove_uri = id(new PhutilURI($remove_uri)) | ||||
| ->replaceQueryParam('contextPHID', $context_phid); | ->replaceQueryParam('contextPHID', $context_phid); | ||||
| $rename_uri = urisprintf('/dashboard/panel/tabs/%d/rename/', $id); | $rename_uri = urisprintf('/dashboard/panel/tabs/%d/rename/', $id); | ||||
| $rename_uri = id(new PhutilURI($rename_uri)) | $rename_uri = id(new PhutilURI($rename_uri)) | ||||
| ->replaceQueryParam('contextPHID', $context_phid); | ->replaceQueryParam('contextPHID', $context_phid); | ||||
| $selected = 0; | $selected = 0; | ||||
| $last_idx = null; | $key_list = array_keys($config); | ||||
| $next_keys = array(); | |||||
| $prev_keys = array(); | |||||
| for ($ii = 0; $ii < count($key_list); $ii++) { | |||||
| $next_keys[$key_list[$ii]] = idx($key_list, $ii + 1); | |||||
| $prev_keys[$key_list[$ii]] = idx($key_list, $ii - 1); | |||||
| } | |||||
| foreach ($config as $idx => $tab_spec) { | foreach ($config as $idx => $tab_spec) { | ||||
| $panel_id = idx($tab_spec, 'panelID'); | $panel_id = idx($tab_spec, 'panelID'); | ||||
| $subpanel = idx($panels, $panel_id); | $subpanel = idx($panels, $panel_id); | ||||
| $name = idx($tab_spec, 'name'); | $name = idx($tab_spec, 'name'); | ||||
| if (!strlen($name)) { | if (!strlen($name)) { | ||||
| if ($subpanel) { | if ($subpanel) { | ||||
| $name = $subpanel->getName(); | $name = $subpanel->getName(); | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | foreach ($config as $idx => $tab_spec) { | ||||
| $dropdown_menu->addAction( | $dropdown_menu->addAction( | ||||
| id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
| ->setName(pht('Rename Tab')) | ->setName(pht('Rename Tab')) | ||||
| ->setIcon('fa-pencil') | ->setIcon('fa-pencil') | ||||
| ->setHref($rename_tab_uri) | ->setHref($rename_tab_uri) | ||||
| ->setWorkflow(true)); | ->setWorkflow(true)); | ||||
| $move_uri = urisprintf('/dashboard/panel/tabs/%d/move/', $id); | |||||
| $prev_key = $prev_keys[$idx]; | |||||
| $prev_params = array( | |||||
| 'target' => $idx, | |||||
| 'after' => $prev_key, | |||||
| 'move' => 'prev', | |||||
| 'contextPHID' => $context_phid, | |||||
| ); | |||||
| $prev_uri = new PhutilURI($move_uri, $prev_params); | |||||
| $next_key = $next_keys[$idx]; | |||||
| $next_params = array( | |||||
| 'target' => $idx, | |||||
| 'after' => $next_key, | |||||
| 'move' => 'next', | |||||
| 'contextPHID' => $context_phid, | |||||
| ); | |||||
| $next_uri = new PhutilURI($move_uri, $next_params); | |||||
| $dropdown_menu->addAction( | |||||
| id(new PhabricatorActionView()) | |||||
| ->setName(pht('Move Tab Left')) | |||||
| ->setIcon('fa-chevron-left') | |||||
| ->setHref($prev_uri) | |||||
| ->setWorkflow(true) | |||||
| ->setDisabled(($prev_key === null) || !$can_edit)); | |||||
| $dropdown_menu->addAction( | |||||
| id(new PhabricatorActionView()) | |||||
| ->setName(pht('Move Tab Right')) | |||||
| ->setIcon('fa-chevron-right') | |||||
| ->setHref($next_uri) | |||||
| ->setWorkflow(true) | |||||
| ->setDisabled(($next_key === null) || !$can_edit)); | |||||
| $dropdown_menu->addAction( | $dropdown_menu->addAction( | ||||
| id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
| ->setName(pht('Remove Tab')) | ->setName(pht('Remove Tab')) | ||||
| ->setIcon('fa-times') | ->setIcon('fa-times') | ||||
| ->setHref($remove_tab_uri) | ->setHref($remove_tab_uri) | ||||
| ->setWorkflow(true)); | ->setWorkflow(true)); | ||||
| $dropdown_menu->addAction( | $dropdown_menu->addAction( | ||||
| Show All 16 Lines | foreach ($config as $idx => $tab_spec) { | ||||
| ->setDisabled(!$subpanel)); | ->setDisabled(!$subpanel)); | ||||
| $tab_view | $tab_view | ||||
| ->setActionIcon('fa-caret-down', '#') | ->setActionIcon('fa-caret-down', '#') | ||||
| ->setDropdownMenu($dropdown_menu); | ->setDropdownMenu($dropdown_menu); | ||||
| } | } | ||||
| $list->addMenuItem($tab_view); | $list->addMenuItem($tab_view); | ||||
| $last_idx = $idx; | |||||
| } | } | ||||
| if ($is_edit) { | if ($is_edit) { | ||||
| $actions = id(new PhabricatorActionListView()) | $actions = id(new PhabricatorActionListView()) | ||||
| ->setViewer($viewer); | ->setViewer($viewer); | ||||
| $add_last_uri = clone $add_uri; | $add_last_uri = clone $add_uri; | ||||
| $last_idx = last_key($config); | |||||
| if ($last_idx) { | if ($last_idx) { | ||||
| $add_last_uri->replaceQueryParam('after', $last_idx); | $add_last_uri->replaceQueryParam('after', $last_idx); | ||||
| } | } | ||||
| $actions->addAction( | $actions->addAction( | ||||
| id(new PhabricatorActionView()) | id(new PhabricatorActionView()) | ||||
| ->setName(pht('Add Existing Panel')) | ->setName(pht('Add Existing Panel')) | ||||
| ->setIcon('fa-window-maximize') | ->setIcon('fa-window-maximize') | ||||
| ▲ Show 20 Lines • Show All 116 Lines • Show Last 20 Lines | |||||