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

Populate the "Quick Create" menu from EditEngine

Summary:
Ref T9908. When there are custom / renamed / policy considerations for applications, respect them in the quick create menu.

This has some performance implications, in that it makes every page slower by two queries (and potentially more, soon), which is quite bad. I have some ideas to mitigate this, but it's not the end of the world to eat these queries for now.

Test Plan: {F1017316}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9908

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

+75 -25
+1 -1
src/applications/home/application/PhabricatorHomeApplication.php
··· 100 100 $view = null; 101 101 if ($items) { 102 102 $view = new PHUIListView(); 103 - $view->newLabel(pht('Create New...')); 103 + $view->newLabel(pht('Quick Create')); 104 104 foreach ($items as $item) { 105 105 $view->addMenuItem($item); 106 106 }
+3 -9
src/applications/maniphest/application/PhabricatorManiphestApplication.php
··· 107 107 } 108 108 109 109 public function getQuickCreateItems(PhabricatorUser $viewer) { 110 - $items = array(); 111 - 112 - $item = id(new PHUIListItemView()) 113 - ->setName(pht('Maniphest Task')) 114 - ->setIcon('fa-anchor') 115 - ->setHref($this->getBaseURI().'task/create/'); 116 - $items[] = $item; 117 - 118 - return $items; 110 + return id(new ManiphestEditEngine()) 111 + ->setViewer($viewer) 112 + ->loadQuickCreateItems(); 119 113 } 120 114 121 115 public function supportsEmailIntegration() {
+3 -9
src/applications/paste/application/PhabricatorPasteApplication.php
··· 76 76 } 77 77 78 78 public function getQuickCreateItems(PhabricatorUser $viewer) { 79 - $items = array(); 80 - 81 - $item = id(new PHUIListItemView()) 82 - ->setName(pht('Paste')) 83 - ->setIcon('fa-clipboard') 84 - ->setHref($this->getBaseURI().'create/'); 85 - $items[] = $item; 86 - 87 - return $items; 79 + return id(new PhabricatorPasteEditEngine()) 80 + ->setViewer($viewer) 81 + ->loadQuickCreateItems(); 88 82 } 89 83 90 84 public function getMailCommandObjects() {
+64 -6
src/applications/transactions/editengine/PhabricatorEditEngine.php
··· 179 179 } 180 180 181 181 182 + /** 183 + * @task text 184 + */ 185 + protected function getQuickCreateMenuHeaderText() { 186 + return $this->getObjectCreateShortText(); 187 + } 188 + 189 + 182 190 /* -( Edit Engine Configuration )------------------------------------------ */ 183 191 184 192 ··· 872 880 final public function addActionToCrumbs(PHUICrumbsView $crumbs) { 873 881 $viewer = $this->getViewer(); 874 882 875 - $configs = id(new PhabricatorEditEngineConfigurationQuery()) 876 - ->setViewer($viewer) 877 - ->withEngineKeys(array($this->getEngineKey())) 878 - ->withIsDefault(true) 879 - ->withIsDisabled(false) 880 - ->execute(); 883 + $configs = $this->loadUsableConfigurationsForCreate(); 881 884 882 885 $dropdown = null; 883 886 $disabled = false; ··· 1377 1380 ->setViewer($viewer) 1378 1381 ->withEngineKeys(array($key)) 1379 1382 ->executeOne(); 1383 + } 1384 + 1385 + public function getIcon() { 1386 + $application = $this->getApplication(); 1387 + return $application->getFontIcon(); 1388 + } 1389 + 1390 + public function loadQuickCreateItems() { 1391 + $configs = $this->loadUsableConfigurationsForCreate(); 1392 + 1393 + $items = array(); 1394 + 1395 + if (!$configs) { 1396 + // No items to add. 1397 + } else if (count($configs) == 1) { 1398 + $config = head($configs); 1399 + $items[] = $this->newQuickCreateItem($config); 1400 + } else { 1401 + $group_name = $this->getQuickCreateMenuHeaderText(); 1402 + 1403 + $items[] = id(new PHUIListItemView()) 1404 + ->setType(PHUIListItemView::TYPE_LABEL) 1405 + ->setName($group_name); 1406 + 1407 + foreach ($configs as $config) { 1408 + $items[] = $this->newQuickCreateItem($config); 1409 + } 1410 + } 1411 + 1412 + return $items; 1413 + } 1414 + 1415 + private function loadUsableConfigurationsForCreate() { 1416 + $viewer = $this->getViewer(); 1417 + 1418 + return id(new PhabricatorEditEngineConfigurationQuery()) 1419 + ->setViewer($viewer) 1420 + ->withEngineKeys(array($this->getEngineKey())) 1421 + ->withIsDefault(true) 1422 + ->withIsDisabled(false) 1423 + ->execute(); 1424 + } 1425 + 1426 + private function newQuickCreateItem( 1427 + PhabricatorEditEngineConfiguration $config) { 1428 + 1429 + $item_name = $config->getName(); 1430 + $item_icon = $config->getIcon(); 1431 + $form_key = $config->getIdentifier(); 1432 + $item_uri = $this->getEditURI(null, "form/{$form_key}/"); 1433 + 1434 + return id(new PHUIListItemView()) 1435 + ->setName($item_name) 1436 + ->setIcon($item_icon) 1437 + ->setHref($item_uri); 1380 1438 } 1381 1439 1382 1440
+4
src/applications/transactions/storage/PhabricatorEditEngineConfiguration.php
··· 210 210 return $this->setProperty('defaults', $defaults); 211 211 } 212 212 213 + public function getIcon() { 214 + return $this->getEngine()->getIcon(); 215 + } 216 + 213 217 214 218 /* -( PhabricatorPolicyInterface )----------------------------------------- */ 215 219