Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13976735
D8919.id21165.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Referenced Files
None
Subscribers
None
D8919.id21165.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -1440,7 +1440,9 @@
'PhabricatorDashboardPHIDTypeDashboard' => 'applications/dashboard/phid/PhabricatorDashboardPHIDTypeDashboard.php',
'PhabricatorDashboardPHIDTypePanel' => 'applications/dashboard/phid/PhabricatorDashboardPHIDTypePanel.php',
'PhabricatorDashboardPanel' => 'applications/dashboard/storage/PhabricatorDashboardPanel.php',
+ 'PhabricatorDashboardPanelCoreCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php',
'PhabricatorDashboardPanelCreateController' => 'applications/dashboard/controller/PhabricatorDashboardPanelCreateController.php',
+ 'PhabricatorDashboardPanelCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelCustomField.php',
'PhabricatorDashboardPanelEditController' => 'applications/dashboard/controller/PhabricatorDashboardPanelEditController.php',
'PhabricatorDashboardPanelListController' => 'applications/dashboard/controller/PhabricatorDashboardPanelListController.php',
'PhabricatorDashboardPanelQuery' => 'applications/dashboard/query/PhabricatorDashboardPanelQuery.php',
@@ -4249,8 +4251,15 @@
array(
0 => 'PhabricatorDashboardDAO',
1 => 'PhabricatorPolicyInterface',
+ 2 => 'PhabricatorCustomFieldInterface',
+ ),
+ 'PhabricatorDashboardPanelCoreCustomField' =>
+ array(
+ 0 => 'PhabricatorDashboardPanelCustomField',
+ 1 => 'PhabricatorStandardCustomFieldInterface',
),
'PhabricatorDashboardPanelCreateController' => 'PhabricatorDashboardController',
+ 'PhabricatorDashboardPanelCustomField' => 'PhabricatorCustomField',
'PhabricatorDashboardPanelEditController' => 'PhabricatorDashboardController',
'PhabricatorDashboardPanelListController' =>
array(
diff --git a/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php b/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php
--- a/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php
+++ b/src/applications/dashboard/controller/PhabricatorDashboardPanelEditController.php
@@ -58,6 +58,13 @@
$v_name = $panel->getName();
$e_name = true;
+ $field_list = PhabricatorCustomField::getObjectFields(
+ $panel,
+ PhabricatorCustomField::ROLE_EDIT);
+ $field_list
+ ->setViewer($viewer)
+ ->readFieldsFromStorage($panel);
+
$validation_exception = null;
if ($request->isFormPost()) {
$v_name = $request->getStr('name');
@@ -65,11 +72,15 @@
$xactions = array();
$type_name = PhabricatorDashboardPanelTransaction::TYPE_NAME;
-
$xactions[] = id(new PhabricatorDashboardPanelTransaction())
->setTransactionType($type_name)
->setNewValue($v_name);
+ $field_xactions = $field_list->buildFieldTransactionsFromRequest(
+ new PhabricatorDashboardPanelTransaction(),
+ $request);
+ $xactions = array_merge($xactions, $field_xactions);
+
try {
$editor = id(new PhabricatorDashboardPanelTransactionEditor())
->setActor($viewer)
@@ -93,7 +104,11 @@
->setLabel(pht('Name'))
->setName('name')
->setValue($v_name)
- ->setError($e_name))
+ ->setError($e_name));
+
+ $field_list->appendFieldsToForm($form);
+
+ $form
->appendChild(
id(new AphrontFormSubmitControl())
->setValue($button)
diff --git a/src/applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php b/src/applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/dashboard/customfield/PhabricatorDashboardPanelCoreCustomField.php
@@ -0,0 +1,42 @@
+<?php
+
+final class PhabricatorDashboardPanelCoreCustomField
+ extends PhabricatorDashboardPanelCustomField
+ implements PhabricatorStandardCustomFieldInterface {
+
+ public function getStandardCustomFieldNamespace() {
+ return 'dashboard:core';
+ }
+
+ public function createFields($object) {
+ $impl = $object->requireImplementation();
+ $specs = $impl->getFieldSpecifications();
+ return PhabricatorStandardCustomField::buildStandardFields($this, $specs);
+ }
+
+ public function shouldUseStorage() {
+ return false;
+ }
+
+ public function readValueFromObject(PhabricatorCustomFieldInterface $object) {
+ $key = $this->getProxy()->getRawStandardFieldKey();
+ $this->setValueFromStorage($object->getProperty($key));
+ }
+
+ public function applyApplicationTransactionInternalEffects(
+ PhabricatorApplicationTransaction $xaction) {
+ $object = $this->getObject();
+ $key = $this->getProxy()->getRawStandardFieldKey();
+
+ $this->setValueFromApplicationTransactions($xaction->getNewValue());
+ $value = $this->getValueForStorage();
+
+ $object->setProperty($key, $value);
+ }
+
+ public function applyApplicationTransactionExternalEffects(
+ PhabricatorApplicationTransaction $xaction) {
+ return;
+ }
+
+}
diff --git a/src/applications/dashboard/customfield/PhabricatorDashboardPanelCustomField.php b/src/applications/dashboard/customfield/PhabricatorDashboardPanelCustomField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/dashboard/customfield/PhabricatorDashboardPanelCustomField.php
@@ -0,0 +1,6 @@
+<?php
+
+abstract class PhabricatorDashboardPanelCustomField
+ extends PhabricatorCustomField {
+
+}
diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php
--- a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php
+++ b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelType.php
@@ -5,6 +5,7 @@
abstract public function getPanelTypeKey();
abstract public function getPanelTypeName();
abstract public function getPanelTypeDescription();
+ abstract public function getFieldSpecifications();
public static function getAllPanelTypes() {
static $types;
@@ -43,9 +44,17 @@
PhabricatorUser $viewer,
PhabricatorDashboardPanel $panel) {
+ $content = $this->renderPanelContent($viewer, $panel);
+
return id(new PHUIObjectBoxView())
->setHeaderText($panel->getName())
- ->appendChild(pht('TODO: Panel content goes here.'));
+ ->appendChild($content);
+ }
+
+ protected function renderPanelContent(
+ PhabricatorUser $viewer,
+ PhabricatorDashboardPanel $panel) {
+ return pht('TODO: Panel content goes here.');
}
public function shouldRenderAsync() {
diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeText.php b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeText.php
--- a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeText.php
+++ b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeText.php
@@ -17,4 +17,28 @@
'provide instructions or context.');
}
+ public function getFieldSpecifications() {
+ return array(
+ 'text' => array(
+ 'name' => pht('Text'),
+ 'type' => 'remarkup',
+ ),
+ );
+ }
+
+ protected function renderPanelContent(
+ PhabricatorUser $viewer,
+ PhabricatorDashboardPanel $panel) {
+
+ $text = $panel->getProperty('text', '');
+
+ $text_content = PhabricatorMarkupEngine::renderOneObject(
+ id(new PhabricatorMarkupOneOff())->setContent($text),
+ 'default',
+ $viewer);
+
+ return id(new PHUIPropertyListView())
+ ->addTextContent($text_content);
+ }
+
}
diff --git a/src/applications/dashboard/storage/PhabricatorDashboardPanel.php b/src/applications/dashboard/storage/PhabricatorDashboardPanel.php
--- a/src/applications/dashboard/storage/PhabricatorDashboardPanel.php
+++ b/src/applications/dashboard/storage/PhabricatorDashboardPanel.php
@@ -5,7 +5,9 @@
*/
final class PhabricatorDashboardPanel
extends PhabricatorDashboardDAO
- implements PhabricatorPolicyInterface {
+ implements
+ PhabricatorPolicyInterface,
+ PhabricatorCustomFieldInterface {
protected $name;
protected $panelType;
@@ -13,6 +15,8 @@
protected $editPolicy;
protected $properties = array();
+ private $customFields = self::ATTACHABLE;
+
public static function initializeNewPanel(PhabricatorUser $actor) {
return id(new PhabricatorDashboardPanel())
->setName('')
@@ -94,4 +98,25 @@
return null;
}
+
+/* -( PhabricatorCustomFieldInterface )------------------------------------ */
+
+
+ public function getCustomFieldSpecificationForRole($role) {
+ return array();
+ }
+
+ public function getCustomFieldBaseClass() {
+ return 'PhabricatorDashboardPanelCustomField';
+ }
+
+ public function getCustomFields() {
+ return $this->assertAttached($this->customFields);
+ }
+
+ public function attachCustomFields(PhabricatorCustomFieldAttachment $fields) {
+ $this->customFields = $fields;
+ return $this;
+ }
+
}
diff --git a/src/applications/harbormaster/storage/configuration/HarbormasterBuildStep.php b/src/applications/harbormaster/storage/configuration/HarbormasterBuildStep.php
--- a/src/applications/harbormaster/storage/configuration/HarbormasterBuildStep.php
+++ b/src/applications/harbormaster/storage/configuration/HarbormasterBuildStep.php
@@ -83,8 +83,10 @@
return pht('A build step has the same policies as its build plan.');
}
+
/* -( PhabricatorCustomFieldInterface )------------------------------------ */
+
public function getCustomFieldSpecificationForRole($role) {
return array();
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 19 2024, 3:28 PM (4 w, 2 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6732785
Default Alt Text
D8919.id21165.diff (9 KB)
Attached To
Mode
D8919: Let dashboard panel types use customfield to manage editing
Attached
Detach File
Event Timeline
Log In to Comment