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

Let dashboard panel types use customfield to manage editing

Summary: Ref T3583. Use the same approach Harbormaster does to give panels cheap forms.

Test Plan:
{F149218}

{F149219}

{F149220}

Reviewers: chad, btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T3583

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

+136 -4
+9
src/__phutil_library_map__.php
··· 1440 1440 'PhabricatorDashboardPHIDTypeDashboard' => 'applications/dashboard/phid/PhabricatorDashboardPHIDTypeDashboard.php', 1441 1441 'PhabricatorDashboardPHIDTypePanel' => 'applications/dashboard/phid/PhabricatorDashboardPHIDTypePanel.php', 1442 1442 'PhabricatorDashboardPanel' => 'applications/dashboard/storage/PhabricatorDashboardPanel.php', 1443 + 'PhabricatorDashboardPanelCoreCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php', 1443 1444 'PhabricatorDashboardPanelCreateController' => 'applications/dashboard/controller/PhabricatorDashboardPanelCreateController.php', 1445 + 'PhabricatorDashboardPanelCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCustomField.php', 1444 1446 'PhabricatorDashboardPanelEditController' => 'applications/dashboard/controller/PhabricatorDashboardPanelEditController.php', 1445 1447 'PhabricatorDashboardPanelListController' => 'applications/dashboard/controller/PhabricatorDashboardPanelListController.php', 1446 1448 'PhabricatorDashboardPanelQuery' => 'applications/dashboard/query/PhabricatorDashboardPanelQuery.php', ··· 4249 4251 array( 4250 4252 0 => 'PhabricatorDashboardDAO', 4251 4253 1 => 'PhabricatorPolicyInterface', 4254 + 2 => 'PhabricatorCustomFieldInterface', 4255 + ), 4256 + 'PhabricatorDashboardPanelCoreCustomField' => 4257 + array( 4258 + 0 => 'PhabricatorDashboardPanelCustomField', 4259 + 1 => 'PhabricatorStandardCustomFieldInterface', 4252 4260 ), 4253 4261 'PhabricatorDashboardPanelCreateController' => 'PhabricatorDashboardController', 4262 + 'PhabricatorDashboardPanelCustomField' => 'PhabricatorCustomField', 4254 4263 'PhabricatorDashboardPanelEditController' => 'PhabricatorDashboardController', 4255 4264 'PhabricatorDashboardPanelListController' => 4256 4265 array(
+17 -2
src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php
··· 58 58 $v_name = $panel->getName(); 59 59 $e_name = true; 60 60 61 + $field_list = PhabricatorCustomField::getObjectFields( 62 + $panel, 63 + PhabricatorCustomField::ROLE_EDIT); 64 + $field_list 65 + ->setViewer($viewer) 66 + ->readFieldsFromStorage($panel); 67 + 61 68 $validation_exception = null; 62 69 if ($request->isFormPost()) { 63 70 $v_name = $request->getStr('name'); ··· 65 72 $xactions = array(); 66 73 67 74 $type_name = PhabricatorDashboardPanelTransaction::TYPE_NAME; 68 - 69 75 $xactions[] = id(new PhabricatorDashboardPanelTransaction()) 70 76 ->setTransactionType($type_name) 71 77 ->setNewValue($v_name); 72 78 79 + $field_xactions = $field_list->buildFieldTransactionsFromRequest( 80 + new PhabricatorDashboardPanelTransaction(), 81 + $request); 82 + $xactions = array_merge($xactions, $field_xactions); 83 + 73 84 try { 74 85 $editor = id(new PhabricatorDashboardPanelTransactionEditor()) 75 86 ->setActor($viewer) ··· 93 104 ->setLabel(pht('Name')) 94 105 ->setName('name') 95 106 ->setValue($v_name) 96 - ->setError($e_name)) 107 + ->setError($e_name)); 108 + 109 + $field_list->appendFieldsToForm($form); 110 + 111 + $form 97 112 ->appendChild( 98 113 id(new AphrontFormSubmitControl()) 99 114 ->setValue($button)
+42
src/applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php
··· 1 + <?php 2 + 3 + final class PhabricatorDashboardPanelCoreCustomField 4 + extends PhabricatorDashboardPanelCustomField 5 + implements PhabricatorStandardCustomFieldInterface { 6 + 7 + public function getStandardCustomFieldNamespace() { 8 + return 'dashboard:core'; 9 + } 10 + 11 + public function createFields($object) { 12 + $impl = $object->requireImplementation(); 13 + $specs = $impl->getFieldSpecifications(); 14 + return PhabricatorStandardCustomField::buildStandardFields($this, $specs); 15 + } 16 + 17 + public function shouldUseStorage() { 18 + return false; 19 + } 20 + 21 + public function readValueFromObject(PhabricatorCustomFieldInterface $object) { 22 + $key = $this->getProxy()->getRawStandardFieldKey(); 23 + $this->setValueFromStorage($object->getProperty($key)); 24 + } 25 + 26 + public function applyApplicationTransactionInternalEffects( 27 + PhabricatorApplicationTransaction $xaction) { 28 + $object = $this->getObject(); 29 + $key = $this->getProxy()->getRawStandardFieldKey(); 30 + 31 + $this->setValueFromApplicationTransactions($xaction->getNewValue()); 32 + $value = $this->getValueForStorage(); 33 + 34 + $object->setProperty($key, $value); 35 + } 36 + 37 + public function applyApplicationTransactionExternalEffects( 38 + PhabricatorApplicationTransaction $xaction) { 39 + return; 40 + } 41 + 42 + }
+6
src/applications/dashboard/customfield/PhabricatorDashboardPanelCustomField.php
··· 1 + <?php 2 + 3 + abstract class PhabricatorDashboardPanelCustomField 4 + extends PhabricatorCustomField { 5 + 6 + }
+10 -1
src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php
··· 5 5 abstract public function getPanelTypeKey(); 6 6 abstract public function getPanelTypeName(); 7 7 abstract public function getPanelTypeDescription(); 8 + abstract public function getFieldSpecifications(); 8 9 9 10 public static function getAllPanelTypes() { 10 11 static $types; ··· 43 44 PhabricatorUser $viewer, 44 45 PhabricatorDashboardPanel $panel) { 45 46 47 + $content = $this->renderPanelContent($viewer, $panel); 48 + 46 49 return id(new PHUIObjectBoxView()) 47 50 ->setHeaderText($panel->getName()) 48 - ->appendChild(pht('TODO: Panel content goes here.')); 51 + ->appendChild($content); 52 + } 53 + 54 + protected function renderPanelContent( 55 + PhabricatorUser $viewer, 56 + PhabricatorDashboardPanel $panel) { 57 + return pht('TODO: Panel content goes here.'); 49 58 } 50 59 51 60 public function shouldRenderAsync() {
+24
src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeText.php
··· 17 17 'provide instructions or context.'); 18 18 } 19 19 20 + public function getFieldSpecifications() { 21 + return array( 22 + 'text' => array( 23 + 'name' => pht('Text'), 24 + 'type' => 'remarkup', 25 + ), 26 + ); 27 + } 28 + 29 + protected function renderPanelContent( 30 + PhabricatorUser $viewer, 31 + PhabricatorDashboardPanel $panel) { 32 + 33 + $text = $panel->getProperty('text', ''); 34 + 35 + $text_content = PhabricatorMarkupEngine::renderOneObject( 36 + id(new PhabricatorMarkupOneOff())->setContent($text), 37 + 'default', 38 + $viewer); 39 + 40 + return id(new PHUIPropertyListView()) 41 + ->addTextContent($text_content); 42 + } 43 + 20 44 }
+26 -1
src/applications/dashboard/storage/PhabricatorDashboardPanel.php
··· 5 5 */ 6 6 final class PhabricatorDashboardPanel 7 7 extends PhabricatorDashboardDAO 8 - implements PhabricatorPolicyInterface { 8 + implements 9 + PhabricatorPolicyInterface, 10 + PhabricatorCustomFieldInterface { 9 11 10 12 protected $name; 11 13 protected $panelType; 12 14 protected $viewPolicy; 13 15 protected $editPolicy; 14 16 protected $properties = array(); 17 + 18 + private $customFields = self::ATTACHABLE; 15 19 16 20 public static function initializeNewPanel(PhabricatorUser $actor) { 17 21 return id(new PhabricatorDashboardPanel()) ··· 92 96 93 97 public function describeAutomaticCapability($capability) { 94 98 return null; 99 + } 100 + 101 + 102 + /* -( PhabricatorCustomFieldInterface )------------------------------------ */ 103 + 104 + 105 + public function getCustomFieldSpecificationForRole($role) { 106 + return array(); 107 + } 108 + 109 + public function getCustomFieldBaseClass() { 110 + return 'PhabricatorDashboardPanelCustomField'; 111 + } 112 + 113 + public function getCustomFields() { 114 + return $this->assertAttached($this->customFields); 115 + } 116 + 117 + public function attachCustomFields(PhabricatorCustomFieldAttachment $fields) { 118 + $this->customFields = $fields; 119 + return $this; 95 120 } 96 121 97 122 }
+2
src/applications/harbormaster/storage/configuration/HarbormasterBuildStep.php
··· 83 83 return pht('A build step has the same policies as its build plan.'); 84 84 } 85 85 86 + 86 87 /* -( PhabricatorCustomFieldInterface )------------------------------------ */ 88 + 87 89 88 90 public function getCustomFieldSpecificationForRole($role) { 89 91 return array();