@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.

Allow dashboard panels to be archived

Summary: Ref T5471. Adds an archived state for panels. Archived panels don't show up in the default query view or in the "Add Existing Panel" workflow.

Test Plan:
- Archived a panel.
- Activated a panel.
- Viewed / searched for archived/active panels.
- Popped "Add Existing Panel" dropdown and saw it omit archived panels.

Reviewers: chad

Reviewed By: chad

Subscribers: epriestley

Maniphest Tasks: T5471

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

+192 -3
+2
resources/sql/autopatches/20140629.dasharchive.1.sql
··· 1 + ALTER TABLE {$NAMESPACE}_dashboard.dashboard_panel 2 + ADD isArchived BOOL NOT NULL DEFAULT 0 AFTER editPolicy;
+2
src/__phutil_library_map__.php
··· 1499 1499 'PhabricatorDashboardPHIDTypeDashboard' => 'applications/dashboard/phid/PhabricatorDashboardPHIDTypeDashboard.php', 1500 1500 'PhabricatorDashboardPHIDTypePanel' => 'applications/dashboard/phid/PhabricatorDashboardPHIDTypePanel.php', 1501 1501 'PhabricatorDashboardPanel' => 'applications/dashboard/storage/PhabricatorDashboardPanel.php', 1502 + 'PhabricatorDashboardPanelArchiveController' => 'applications/dashboard/controller/PhabricatorDashboardPanelArchiveController.php', 1502 1503 'PhabricatorDashboardPanelCoreCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php', 1503 1504 'PhabricatorDashboardPanelCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCustomField.php', 1504 1505 'PhabricatorDashboardPanelEditController' => 'applications/dashboard/controller/PhabricatorDashboardPanelEditController.php', ··· 4334 4335 1 => 'PhabricatorPolicyInterface', 4335 4336 2 => 'PhabricatorCustomFieldInterface', 4336 4337 ), 4338 + 'PhabricatorDashboardPanelArchiveController' => 'PhabricatorDashboardController', 4337 4339 'PhabricatorDashboardPanelCoreCustomField' => 4338 4340 array( 4339 4341 0 => 'PhabricatorDashboardPanelCustomField',
+2
src/applications/dashboard/application/PhabricatorApplicationDashboard.php
··· 42 42 'create/' => 'PhabricatorDashboardPanelEditController', 43 43 'edit/(?:(?P<id>\d+)/)?' => 'PhabricatorDashboardPanelEditController', 44 44 'render/(?P<id>\d+)/' => 'PhabricatorDashboardPanelRenderController', 45 + 'archive/(?P<id>\d+)/' => 46 + 'PhabricatorDashboardPanelArchiveController', 45 47 ), 46 48 ), 47 49 );
+1
src/applications/dashboard/controller/PhabricatorDashboardAddPanelController.php
··· 60 60 61 61 $panels = id(new PhabricatorDashboardPanelQuery()) 62 62 ->setViewer($viewer) 63 + ->withArchived(false) 63 64 ->execute(); 64 65 65 66 if (!$panels) {
+66
src/applications/dashboard/controller/PhabricatorDashboardPanelArchiveController.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardPanelArchiveController 4 + extends PhabricatorDashboardController { 5 + 6 + private $id; 7 + 8 + public function willProcessRequest(array $data) { 9 + $this->id = $data['id']; 10 + } 11 + 12 + public function processRequest() { 13 + $request = $this->getRequest(); 14 + $viewer = $request->getUser(); 15 + 16 + $panel = id(new PhabricatorDashboardPanelQuery()) 17 + ->setViewer($viewer) 18 + ->withIDs(array($this->id)) 19 + ->requireCapabilities( 20 + array( 21 + PhabricatorPolicyCapability::CAN_VIEW, 22 + PhabricatorPolicyCapability::CAN_EDIT, 23 + )) 24 + ->executeOne(); 25 + if (!$panel) { 26 + return new Aphront404Response(); 27 + } 28 + 29 + $next_uri = '/'.$panel->getMonogram(); 30 + 31 + if ($request->isFormPost()) { 32 + $xactions = array(); 33 + $xactions[] = id(new PhabricatorDashboardPanelTransaction()) 34 + ->setTransactionType(PhabricatorDashboardPanelTransaction::TYPE_ARCHIVE) 35 + ->setNewValue((int)!$panel->getIsArchived()); 36 + 37 + id(new PhabricatorDashboardPanelTransactionEditor()) 38 + ->setActor($viewer) 39 + ->setContentSourceFromRequest($request) 40 + ->applyTransactions($panel, $xactions); 41 + 42 + return id(new AphrontRedirectResponse())->setURI($next_uri); 43 + } 44 + 45 + if ($panel->getIsArchived()) { 46 + $title = pht('Activate Panel?'); 47 + $body = pht( 48 + 'This panel will be reactivated and appear in other interfaces as '. 49 + 'an active panel.'); 50 + $submit_text = pht('Activate Panel'); 51 + } else { 52 + $title = pht('Archive Panel?'); 53 + $body = pht( 54 + 'This panel will be archived and no longer appear in lists of active '. 55 + 'panels.'); 56 + $submit_text = pht('Archive Panel'); 57 + } 58 + 59 + return $this->newDialog() 60 + ->setTitle($title) 61 + ->appendParagraph($body) 62 + ->addSubmitButton($submit_text) 63 + ->addCancelButton($next_uri); 64 + } 65 + 66 + }
+16
src/applications/dashboard/controller/PhabricatorDashboardPanelViewController.php
··· 96 96 ->setDisabled(!$can_edit) 97 97 ->setWorkflow(!$can_edit)); 98 98 99 + if (!$panel->getIsArchived()) { 100 + $archive_text = pht('Archive Panel'); 101 + $archive_icon = 'fa-times'; 102 + } else { 103 + $archive_text = pht('Activate Panel'); 104 + $archive_icon = 'fa-plus'; 105 + } 106 + 107 + $actions->addAction( 108 + id(new PhabricatorActionView()) 109 + ->setName($archive_text) 110 + ->setIcon($archive_icon) 111 + ->setHref($this->getApplicationURI("panel/archive/{$id}/")) 112 + ->setDisabled(!$can_edit) 113 + ->setWorkflow(true)); 114 + 99 115 $actions->addAction( 100 116 id(new PhabricatorActionView()) 101 117 ->setName(pht('View Standalone'))
+4
src/applications/dashboard/customfield/PhabricatorDashboardPanelTabsCustomField.php
··· 30 30 } 31 31 32 32 public function renderEditControl(array $handles) { 33 + // NOTE: This includes archived panels so we don't mutate the tabs 34 + // when saving a tab panel that includes archied panels. This whole UI is 35 + // hopefully temporary anyway. 36 + 33 37 $panels = id(new PhabricatorDashboardPanelQuery()) 34 38 ->setViewer($this->getViewer()) 35 39 ->execute();
+9
src/applications/dashboard/editor/PhabricatorDashboardPanelTransactionEditor.php
··· 11 11 $types[] = PhabricatorTransactions::TYPE_EDGE; 12 12 13 13 $types[] = PhabricatorDashboardPanelTransaction::TYPE_NAME; 14 + $types[] = PhabricatorDashboardPanelTransaction::TYPE_ARCHIVE; 14 15 15 16 return $types; 16 17 } ··· 24 25 return null; 25 26 } 26 27 return $object->getName(); 28 + case PhabricatorDashboardPanelTransaction::TYPE_ARCHIVE: 29 + return (int)$object->getIsArchived(); 27 30 } 28 31 29 32 return parent::getCustomTransactionOldValue($object, $xaction); ··· 35 38 switch ($xaction->getTransactionType()) { 36 39 case PhabricatorDashboardPanelTransaction::TYPE_NAME: 37 40 return $xaction->getNewValue(); 41 + case PhabricatorDashboardPanelTransaction::TYPE_ARCHIVE: 42 + return (int)$xaction->getNewValue(); 38 43 } 39 44 return parent::getCustomTransactionNewValue($object, $xaction); 40 45 } ··· 46 51 case PhabricatorDashboardPanelTransaction::TYPE_NAME: 47 52 $object->setName($xaction->getNewValue()); 48 53 return; 54 + case PhabricatorDashboardPanelTransaction::TYPE_ARCHIVE: 55 + $object->setIsArchived((int)$xaction->getNewValue()); 56 + return; 49 57 case PhabricatorTransactions::TYPE_VIEW_POLICY: 50 58 $object->setViewPolicy($xaction->getNewValue()); 51 59 return; ··· 63 71 64 72 switch ($xaction->getTransactionType()) { 65 73 case PhabricatorDashboardPanelTransaction::TYPE_NAME: 74 + case PhabricatorDashboardPanelTransaction::TYPE_ARCHIVE: 66 75 case PhabricatorTransactions::TYPE_VIEW_POLICY: 67 76 case PhabricatorTransactions::TYPE_EDIT_POLICY: 68 77 return;
+4
src/applications/dashboard/phid/PhabricatorDashboardPHIDTypePanel.php
··· 38 38 $handle->setName($panel->getMonogram()); 39 39 $handle->setFullName("{$monogram} {$name}"); 40 40 $handle->setURI("/{$monogram}"); 41 + 42 + if ($panel->getIsArchived()) { 43 + $handle->setStatus(PhabricatorObjectHandleStatus::STATUS_CLOSED); 44 + } 41 45 } 42 46 } 43 47
+15 -2
src/applications/dashboard/query/PhabricatorDashboardPanelQuery.php
··· 5 5 6 6 private $ids; 7 7 private $phids; 8 + private $archived; 8 9 9 10 public function withIDs(array $ids) { 10 11 $this->ids = $ids; ··· 16 17 return $this; 17 18 } 18 19 20 + public function withArchived($archived) { 21 + $this->archived = $archived; 22 + return $this; 23 + } 24 + 19 25 protected function loadPage() { 20 26 $table = new PhabricatorDashboardPanel(); 21 27 $conn_r = $table->establishConnection('r'); ··· 34 40 protected function buildWhereClause($conn_r) { 35 41 $where = array(); 36 42 37 - if ($this->ids) { 43 + if ($this->ids !== null) { 38 44 $where[] = qsprintf( 39 45 $conn_r, 40 46 'id IN (%Ld)', 41 47 $this->ids); 42 48 } 43 49 44 - if ($this->phids) { 50 + if ($this->phids !== null) { 45 51 $where[] = qsprintf( 46 52 $conn_r, 47 53 'phid IN (%Ls)', 48 54 $this->phids); 55 + } 56 + 57 + if ($this->archived !== null) { 58 + $where[] = qsprintf( 59 + $conn_r, 60 + 'isArchived = %d', 61 + (int)$this->archived); 49 62 } 50 63 51 64 $where[] = $this->buildPagingClause($conn_r);
+47 -1
src/applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php
··· 14 14 public function buildSavedQueryFromRequest(AphrontRequest $request) { 15 15 $saved = new PhabricatorSavedQuery(); 16 16 17 + $saved->setParameter('status', $request->getStr('status')); 18 + 17 19 return $saved; 18 20 } 19 21 20 22 public function buildQueryFromSavedQuery(PhabricatorSavedQuery $saved) { 21 23 $query = id(new PhabricatorDashboardPanelQuery()); 22 24 25 + $status = $saved->getParameter('status'); 26 + switch ($status) { 27 + case 'active': 28 + $query->withArchived(false); 29 + break; 30 + case 'archived': 31 + $query->withArchived(true); 32 + break; 33 + default: 34 + break; 35 + } 36 + 23 37 return $query; 24 38 } 25 39 26 40 public function buildSearchForm( 27 41 AphrontFormView $form, 28 42 PhabricatorSavedQuery $saved_query) { 29 - return; 43 + 44 + $status = $saved_query->getParameter('status', ''); 45 + 46 + $form 47 + ->appendChild( 48 + id(new AphrontFormSelectControl()) 49 + ->setLabel(pht('Status')) 50 + ->setName('status') 51 + ->setValue($status) 52 + ->setOptions( 53 + array( 54 + '' => pht('(All Panels)'), 55 + 'active' => pht('Active Panels'), 56 + 'archived' => pht('Archived Panels'), 57 + ))); 30 58 } 31 59 32 60 protected function getURI($path) { ··· 35 63 36 64 public function getBuiltinQueryNames() { 37 65 $names = array( 66 + 'active' => pht('Active Panels'), 38 67 'all' => pht('All Panels'), 39 68 ); 40 69 ··· 47 76 $query->setQueryKey($query_key); 48 77 49 78 switch ($query_key) { 79 + case 'active': 80 + return $query->setParameter('status', 'active'); 50 81 case 'all': 51 82 return $query; 52 83 } ··· 69 100 ->setHeader($panel->getName()) 70 101 ->setHref('/'.$panel->getMonogram()) 71 102 ->setObject($panel); 103 + 104 + $impl = $panel->getImplementation(); 105 + if ($impl) { 106 + $type_text = $impl->getPanelTypeName(); 107 + $type_icon = 'none'; 108 + } else { 109 + $type_text = nonempty($panel->getPanelType(), pht('Unknown Type')); 110 + $type_icon = 'fa-question'; 111 + } 112 + 113 + $item->addIcon($type_icon, $type_text); 114 + 115 + if ($panel->getIsArchived()) { 116 + $item->setDisabled(true); 117 + } 72 118 73 119 $list->addItem($item); 74 120 }
+1
src/applications/dashboard/storage/PhabricatorDashboardPanel.php
··· 13 13 protected $panelType; 14 14 protected $viewPolicy; 15 15 protected $editPolicy; 16 + protected $isArchived = 0; 16 17 protected $properties = array(); 17 18 18 19 private $customFields = self::ATTACHABLE;
+23
src/applications/dashboard/storage/PhabricatorDashboardPanelTransaction.php
··· 4 4 extends PhabricatorApplicationTransaction { 5 5 6 6 const TYPE_NAME = 'dashpanel:name'; 7 + const TYPE_ARCHIVE = 'dashboard:archive'; 7 8 8 9 public function getApplicationName() { 9 10 return 'dashboard'; ··· 36 37 $old, 37 38 $new); 38 39 } 40 + case self::TYPE_ARCHIVE: 41 + if ($new) { 42 + return pht( 43 + '%s archived this panel.', 44 + $author_link); 45 + } else { 46 + return pht( 47 + '%s activated this panel.', 48 + $author_link); 49 + } 39 50 } 40 51 41 52 return parent::getTitle(); ··· 66 77 $object_link, 67 78 $old, 68 79 $new); 80 + } 81 + case self::TYPE_ARCHIVE: 82 + if ($new) { 83 + return pht( 84 + '%s archived dashboard panel %s.', 85 + $author_link, 86 + $object_link); 87 + } else { 88 + return pht( 89 + '%s activated dashboard panel %s.', 90 + $author_link, 91 + $object_link); 69 92 } 70 93 } 71 94