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

Add ability to archive a Dashboard

Summary: Let's people archive unused Dashboards (if they have permission).

Test Plan: Archive and Unarchive a dashboard, view history, view search, build new filters.

Reviewers: btrahan, epriestley

Reviewed By: epriestley

Subscribers: epriestley, Korvin

Maniphest Tasks: T6443

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

+169 -4
+2
resources/sql/autopatches/20150722.dashboard.1.sql
··· 1 + ALTER TABLE {$NAMESPACE}_dashboard.dashboard 2 + ADD status VARCHAR(32) NOT NULL COLLATE {$COLLATE_TEXT};
+2
resources/sql/autopatches/20150722.dashboard.2.sql
··· 1 + UPDATE {$NAMESPACE}_dashboard.dashboard 2 + SET status = 'open';
+13 -1
src/applications/dashboard/controller/PhabricatorDashboardEditController.php
··· 67 67 } 68 68 69 69 $v_name = $dashboard->getName(); 70 + $v_stat = $dashboard->getStatus(); 70 71 $v_layout_mode = $dashboard->getLayoutConfigObject()->getLayoutMode(); 71 72 $e_name = true; 72 73 ··· 77 78 $v_view_policy = $request->getStr('viewPolicy'); 78 79 $v_edit_policy = $request->getStr('editPolicy'); 79 80 $v_projects = $request->getArr('projects'); 81 + $v_stat = $request->getStr('status'); 80 82 81 83 $xactions = array(); 82 84 83 85 $type_name = PhabricatorDashboardTransaction::TYPE_NAME; 84 86 $type_layout_mode = PhabricatorDashboardTransaction::TYPE_LAYOUT_MODE; 87 + $type_stat = PhabricatorDashboardTransaction::TYPE_STATUS; 85 88 $type_view_policy = PhabricatorTransactions::TYPE_VIEW_POLICY; 86 89 $type_edit_policy = PhabricatorTransactions::TYPE_EDIT_POLICY; 87 90 ··· 97 100 $xactions[] = id(new PhabricatorDashboardTransaction()) 98 101 ->setTransactionType($type_edit_policy) 99 102 ->setNewValue($v_edit_policy); 103 + $xactions[] = id(new PhabricatorDashboardTransaction()) 104 + ->setTransactionType($type_stat) 105 + ->setNewValue($v_stat); 100 106 101 107 $proj_edge_type = PhabricatorProjectObjectHasProjectEdgeType::EDGECONST; 102 108 $xactions[] = id(new PhabricatorDashboardTransaction()) ··· 157 163 ->setLabel(pht('Layout Mode')) 158 164 ->setName('layout_mode') 159 165 ->setValue($v_layout_mode) 160 - ->setOptions($layout_mode_options)); 166 + ->setOptions($layout_mode_options)) 167 + ->appendChild( 168 + id(new AphrontFormSelectControl()) 169 + ->setLabel(pht('Status')) 170 + ->setName('status') 171 + ->setValue($v_stat) 172 + ->setOptions($dashboard->getStatusNameMap())); 161 173 162 174 $form->appendControl( 163 175 id(new AphrontFormTokenizerControl())
+14 -1
src/applications/dashboard/controller/PhabricatorDashboardManageController.php
··· 81 81 private function buildHeaderView(PhabricatorDashboard $dashboard) { 82 82 $viewer = $this->getRequest()->getUser(); 83 83 84 + if ($dashboard->isClosed()) { 85 + $status_icon = 'fa-ban'; 86 + $status_color = 'dark'; 87 + } else { 88 + $status_icon = 'fa-check'; 89 + $status_color = 'bluegrey'; 90 + } 91 + 92 + $status_name = idx( 93 + PhabricatorDashboard::getStatusNameMap(), 94 + $dashboard->getStatus()); 95 + 84 96 return id(new PHUIHeaderView()) 85 97 ->setUser($viewer) 86 98 ->setHeader($dashboard->getName()) 87 - ->setPolicyObject($dashboard); 99 + ->setPolicyObject($dashboard) 100 + ->setStatus($status_icon, $status_color, $status_name); 88 101 } 89 102 90 103 private function buildActionView(PhabricatorDashboard $dashboard) {
+11
src/applications/dashboard/editor/PhabricatorDashboardTransactionEditor.php
··· 51 51 $types[] = PhabricatorTransactions::TYPE_EDGE; 52 52 53 53 $types[] = PhabricatorDashboardTransaction::TYPE_NAME; 54 + $types[] = PhabricatorDashboardTransaction::TYPE_STATUS; 54 55 $types[] = PhabricatorDashboardTransaction::TYPE_LAYOUT_MODE; 55 56 56 57 return $types; ··· 65 66 return null; 66 67 } 67 68 return $object->getName(); 69 + case PhabricatorDashboardTransaction::TYPE_STATUS: 70 + if ($this->getIsNewObject()) { 71 + return null; 72 + } 73 + return $object->getStatus(); 68 74 case PhabricatorDashboardTransaction::TYPE_LAYOUT_MODE: 69 75 if ($this->getIsNewObject()) { 70 76 return null; ··· 81 87 PhabricatorApplicationTransaction $xaction) { 82 88 switch ($xaction->getTransactionType()) { 83 89 case PhabricatorDashboardTransaction::TYPE_NAME: 90 + case PhabricatorDashboardTransaction::TYPE_STATUS: 84 91 case PhabricatorDashboardTransaction::TYPE_LAYOUT_MODE: 85 92 return $xaction->getNewValue(); 86 93 } ··· 93 100 switch ($xaction->getTransactionType()) { 94 101 case PhabricatorDashboardTransaction::TYPE_NAME: 95 102 $object->setName($xaction->getNewValue()); 103 + return; 104 + case PhabricatorDashboardTransaction::TYPE_STATUS: 105 + $object->setStatus($xaction->getNewValue()); 96 106 return; 97 107 case PhabricatorDashboardTransaction::TYPE_LAYOUT_MODE: 98 108 $old_layout = $object->getLayoutConfigObject(); ··· 120 130 121 131 switch ($xaction->getTransactionType()) { 122 132 case PhabricatorDashboardTransaction::TYPE_NAME: 133 + case PhabricatorDashboardTransaction::TYPE_STATUS: 123 134 case PhabricatorDashboardTransaction::TYPE_LAYOUT_MODE: 124 135 return; 125 136 }
+13
src/applications/dashboard/query/PhabricatorDashboardQuery.php
··· 5 5 6 6 private $ids; 7 7 private $phids; 8 + private $statuses; 8 9 9 10 private $needPanels; 10 11 private $needProjects; ··· 16 17 17 18 public function withPHIDs(array $phids) { 18 19 $this->phids = $phids; 20 + return $this; 21 + } 22 + 23 + public function withStatuses(array $statuses) { 24 + $this->statuses = $statuses; 19 25 return $this; 20 26 } 21 27 ··· 106 112 $conn, 107 113 'phid IN (%Ls)', 108 114 $this->phids); 115 + } 116 + 117 + if ($this->statuses !== null) { 118 + $where[] = qsprintf( 119 + $conn, 120 + 'status IN (%Ls)', 121 + $this->statuses); 109 122 } 110 123 111 124 return $where;
+42 -2
src/applications/dashboard/query/PhabricatorDashboardSearchEngine.php
··· 17 17 } 18 18 19 19 protected function buildCustomSearchFields() { 20 - return array(); 20 + return array( 21 + id(new PhabricatorSearchCheckboxesField()) 22 + ->setKey('statuses') 23 + ->setLabel(pht('Status')) 24 + ->setOptions(PhabricatorDashboard::getStatusNameMap()), 25 + ); 21 26 } 22 27 23 28 protected function getURI($path) { ··· 26 31 27 32 protected function getBuiltinQueryNames() { 28 33 return array( 34 + 'open' => pht('Active Dashboards'), 29 35 'all' => pht('All Dashboards'), 30 36 ); 31 37 } 32 38 33 39 public function buildSavedQueryFromBuiltin($query_key) { 34 - 35 40 $query = $this->newSavedQuery(); 36 41 $query->setQueryKey($query_key); 37 42 38 43 switch ($query_key) { 39 44 case 'all': 40 45 return $query; 46 + case 'open': 47 + return $query->setParameter( 48 + 'statuses', 49 + array( 50 + PhabricatorDashboard::STATUS_ACTIVE, 51 + )); 41 52 } 42 53 43 54 return parent::buildSavedQueryFromBuiltin($query_key); ··· 45 56 46 57 protected function buildQueryFromParameters(array $map) { 47 58 $query = $this->newQuery(); 59 + 60 + if ($map['statuses']) { 61 + $query->withStatuses($map['statuses']); 62 + } 63 + 48 64 return $query; 49 65 } 50 66 ··· 123 139 ->setNoDataString(pht('No Projects')) 124 140 ->setSlim(true) 125 141 ->setHandles($project_handles)); 142 + 143 + if ($dashboard->isClosed()) { 144 + $item->setDisabled(true); 145 + } 146 + 147 + $can_edit = PhabricatorPolicyFilter::hasCapability( 148 + $viewer, 149 + $dashboard, 150 + PhabricatorPolicyCapability::CAN_EDIT); 151 + 152 + $href_view = $this->getApplicationURI("manage/{$id}/"); 153 + $item->addAction( 154 + id(new PHUIListItemView()) 155 + ->setName(pht('Manage')) 156 + ->setIcon('fa-th') 157 + ->setHref($href_view)); 158 + 159 + $href_edit = $this->getApplicationURI("edit/{$id}/"); 160 + $item->addAction( 161 + id(new PHUIListItemView()) 162 + ->setName(pht('Edit')) 163 + ->setIcon('fa-pencil') 164 + ->setHref($href_edit) 165 + ->setDisabled(!$can_edit)); 126 166 127 167 $list->addItem($item); 128 168 }
+17
src/applications/dashboard/storage/PhabricatorDashboard.php
··· 14 14 protected $name; 15 15 protected $viewPolicy; 16 16 protected $editPolicy; 17 + protected $status; 17 18 protected $layoutConfig = array(); 19 + 20 + const STATUS_ACTIVE = 'active'; 21 + const STATUS_ARCHIVED = 'archived'; 18 22 19 23 private $panelPHIDs = self::ATTACHABLE; 20 24 private $panels = self::ATTACHABLE; ··· 26 30 ->setName('') 27 31 ->setViewPolicy(PhabricatorPolicies::POLICY_USER) 28 32 ->setEditPolicy($actor->getPHID()) 33 + ->setStatus(self::STATUS_ACTIVE) 29 34 ->attachPanels(array()) 30 35 ->attachPanelPHIDs(array()); 31 36 } 32 37 38 + public static function getStatusNameMap() { 39 + return array( 40 + self::STATUS_ACTIVE => pht('Active'), 41 + self::STATUS_ARCHIVED => pht('Archived'), 42 + ); 43 + } 44 + 33 45 public static function copyDashboard( 34 46 PhabricatorDashboard $dst, 35 47 PhabricatorDashboard $src) { ··· 48 60 ), 49 61 self::CONFIG_COLUMN_SCHEMA => array( 50 62 'name' => 'text255', 63 + 'status' => 'text32', 51 64 ), 52 65 ) + parent::getConfiguration(); 53 66 } ··· 94 107 95 108 public function getPanels() { 96 109 return $this->assertAttached($this->panels); 110 + } 111 + 112 + public function isClosed() { 113 + return ($this->getStatus() == self::STATUS_ARCHIVED); 97 114 } 98 115 99 116
+55
src/applications/dashboard/storage/PhabricatorDashboardTransaction.php
··· 4 4 extends PhabricatorApplicationTransaction { 5 5 6 6 const TYPE_NAME = 'dashboard:name'; 7 + const TYPE_STATUS = 'dashboard:status'; 7 8 const TYPE_LAYOUT_MODE = 'dashboard:layoutmode'; 8 9 9 10 public function getApplicationName() { ··· 37 38 $old, 38 39 $new); 39 40 } 41 + break; 42 + case self::TYPE_STATUS: 43 + if ($new == PhabricatorDashboard::STATUS_ACTIVE) { 44 + return pht( 45 + '%s activated this dashboard', 46 + $author_link); 47 + } else { 48 + return pht( 49 + '%s archived this dashboard', 50 + $author_link); 51 + } 52 + break; 40 53 } 41 54 42 55 return parent::getTitle(); ··· 68 81 $old, 69 82 $new); 70 83 } 84 + break; 85 + case self::TYPE_STATUS: 86 + if ($new == PhabricatorDashboard::STATUS_ACTIVE) { 87 + return pht( 88 + '%s activated dashboard %s.', 89 + $author_link, 90 + $object_link); 91 + } else { 92 + return pht( 93 + '%s archived dashboard %s.', 94 + $author_link, 95 + $object_link); 96 + } 97 + break; 71 98 } 72 99 73 100 return parent::getTitleForFeed(); ··· 83 110 return PhabricatorTransactions::COLOR_GREEN; 84 111 } 85 112 break; 113 + case self::TYPE_STATUS: 114 + if ($new == PhabricatorDashboard::STATUS_ACTIVE) { 115 + return PhabricatorTransactions::COLOR_GREEN; 116 + } else { 117 + return PhabricatorTransactions::COLOR_INDIGO; 118 + } 119 + break; 86 120 } 87 121 88 122 return parent::getColor(); 123 + } 124 + 125 + public function getIcon() { 126 + $new = $this->getNewValue(); 127 + 128 + switch ($this->getTransactionType()) { 129 + case self::TYPE_NAME: 130 + return 'fa-pencil'; 131 + break; 132 + case self::TYPE_STATUS: 133 + if ($new == PhabricatorDashboard::STATUS_ACTIVE) { 134 + return 'fa-check'; 135 + } else { 136 + return 'fa-ban'; 137 + } 138 + break; 139 + case self::TYPE_LAYOUT_MODE: 140 + return 'fa-columns'; 141 + break; 142 + } 143 + return parent::getIcon(); 89 144 } 90 145 91 146 public function shouldHide() {