Page MenuHomePhabricator

D9600.diff
No OneTemporary

D9600.diff

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
@@ -1498,6 +1498,7 @@
'PhabricatorDashboardPanelSearchApplicationCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelSearchApplicationCustomField.php',
'PhabricatorDashboardPanelSearchEngine' => 'applications/dashboard/query/PhabricatorDashboardPanelSearchEngine.php',
'PhabricatorDashboardPanelSearchQueryCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelSearchQueryCustomField.php',
+ 'PhabricatorDashboardPanelTabsCustomField' => 'applications/dashboard/customfield/PhabricatorDashboardPanelTabsCustomField.php',
'PhabricatorDashboardPanelTransaction' => 'applications/dashboard/storage/PhabricatorDashboardPanelTransaction.php',
'PhabricatorDashboardPanelTransactionEditor' => 'applications/dashboard/editor/PhabricatorDashboardPanelTransactionEditor.php',
'PhabricatorDashboardPanelTransactionQuery' => 'applications/dashboard/query/PhabricatorDashboardPanelTransactionQuery.php',
@@ -4319,6 +4320,7 @@
'PhabricatorDashboardPanelSearchApplicationCustomField' => 'PhabricatorStandardCustomField',
'PhabricatorDashboardPanelSearchEngine' => 'PhabricatorApplicationSearchEngine',
'PhabricatorDashboardPanelSearchQueryCustomField' => 'PhabricatorStandardCustomField',
+ 'PhabricatorDashboardPanelTabsCustomField' => 'PhabricatorStandardCustomField',
'PhabricatorDashboardPanelTransaction' => 'PhabricatorApplicationTransaction',
'PhabricatorDashboardPanelTransactionEditor' => 'PhabricatorApplicationTransactionEditor',
'PhabricatorDashboardPanelTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
diff --git a/src/applications/dashboard/customfield/PhabricatorDashboardPanelTabsCustomField.php b/src/applications/dashboard/customfield/PhabricatorDashboardPanelTabsCustomField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/dashboard/customfield/PhabricatorDashboardPanelTabsCustomField.php
@@ -0,0 +1,71 @@
+<?php
+
+final class PhabricatorDashboardPanelTabsCustomField
+ extends PhabricatorStandardCustomField {
+
+ public function getFieldType() {
+ return 'dashboard.tabs';
+ }
+
+ public function shouldAppearInApplicationSearch() {
+ return false;
+ }
+
+ public function readValueFromRequest(AphrontRequest $request) {
+ $value = array();
+
+ $names = $request->getArr($this->getFieldKey().'_name');
+ $panels = $request->getArr($this->getFieldKey().'_panelID');
+ foreach ($names as $idx => $name) {
+ $panel_id = idx($panels, $idx);
+ if (strlen($name) && $panel_id) {
+ $value[] = array(
+ 'name' => $name,
+ 'panelID' => $panel_id,
+ );
+ }
+ }
+
+ $this->setFieldValue($value);
+ }
+
+ public function renderEditControl(array $handles) {
+ $panels = id(new PhabricatorDashboardPanelQuery())
+ ->setViewer($this->getViewer())
+ ->execute();
+
+ $panel_map = array();
+ foreach ($panels as $panel) {
+ $panel_map[$panel->getID()] = pht(
+ '%s %s',
+ $panel->getMonogram(),
+ $panel->getName());
+ }
+ $panel_map = array(
+ '' => pht('(None)'),
+ ) + $panel_map;
+
+ $value = $this->getFieldValue();
+ if (!is_array($value)) {
+ $value = array();
+ }
+
+ $out = array();
+ for ($ii = 1; $ii <= 6; $ii++) {
+ $tab = idx($value, ($ii - 1), array());
+ $out[] = id(new AphrontFormTextControl())
+ ->setName($this->getFieldKey().'_name[]')
+ ->setValue(idx($tab, 'name'))
+ ->setLabel(pht('Tab %d Name', $ii));
+
+ $out[] = id(new AphrontFormSelectControl())
+ ->setName($this->getFieldKey().'_panelID[]')
+ ->setValue(idx($tab, 'panelID'))
+ ->setOptions($panel_map)
+ ->setLabel(pht('Tab %d Panel', $ii));
+ }
+
+ return $out;
+ }
+
+}
diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeTabs.php b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeTabs.php
--- a/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeTabs.php
+++ b/src/applications/dashboard/paneltype/PhabricatorDashboardPanelTypeTabs.php
@@ -19,8 +19,8 @@
public function getFieldSpecifications() {
return array(
'config' => array(
- 'name' => pht('JSON Config'),
- 'type' => 'remarkup',
+ 'name' => pht('Tabs'),
+ 'type' => 'dashboard.tabs',
),
);
}
@@ -35,9 +35,13 @@
PhabricatorDashboardPanel $panel,
PhabricatorDashboardPanelRenderingEngine $engine) {
- $config = phutil_json_decode($panel->getProperty('config'), null);
- if ($config === null) {
- throw new Exception(pht('The configuration is not valid JSON.'));
+ $config = $panel->getProperty('config');
+ if (!is_array($config)) {
+ // NOTE: The older version of this panel stored raw JSON.
+ $config = phutil_json_decode($config, null);
+ if ($config === null) {
+ throw new Exception(pht('The configuration is not valid JSON.'));
+ }
}
$list = id(new PHUIListView())

File Metadata

Mime Type
text/plain
Expires
Sun, Oct 6, 3:00 AM (21 h, 35 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6675459
Default Alt Text
D9600.diff (5 KB)

Event Timeline