Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F13980092
D20382.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
D20382.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
@@ -2973,7 +2973,11 @@
'PhabricatorDashboardProfileMenuItem' => 'applications/search/menuitem/PhabricatorDashboardProfileMenuItem.php',
'PhabricatorDashboardProjectInstallWorkflow' => 'applications/dashboard/install/PhabricatorDashboardProjectInstallWorkflow.php',
'PhabricatorDashboardQuery' => 'applications/dashboard/query/PhabricatorDashboardQuery.php',
+ 'PhabricatorDashboardQueryPanelApplicationEditField' => 'applications/dashboard/editfield/PhabricatorDashboardQueryPanelApplicationEditField.php',
+ 'PhabricatorDashboardQueryPanelApplicationTransaction' => 'applications/dashboard/xaction/panel/PhabricatorDashboardQueryPanelApplicationTransaction.php',
'PhabricatorDashboardQueryPanelInstallController' => 'applications/dashboard/controller/PhabricatorDashboardQueryPanelInstallController.php',
+ 'PhabricatorDashboardQueryPanelQueryEditField' => 'applications/dashboard/editfield/PhabricatorDashboardQueryPanelQueryEditField.php',
+ 'PhabricatorDashboardQueryPanelQueryTransaction' => 'applications/dashboard/xaction/panel/PhabricatorDashboardQueryPanelQueryTransaction.php',
'PhabricatorDashboardQueryPanelType' => 'applications/dashboard/paneltype/PhabricatorDashboardQueryPanelType.php',
'PhabricatorDashboardRemarkupRule' => 'applications/dashboard/remarkup/PhabricatorDashboardRemarkupRule.php',
'PhabricatorDashboardRemovePanelController' => 'applications/dashboard/controller/PhabricatorDashboardRemovePanelController.php',
@@ -8952,7 +8956,11 @@
'PhabricatorDashboardProfileMenuItem' => 'PhabricatorProfileMenuItem',
'PhabricatorDashboardProjectInstallWorkflow' => 'PhabricatorDashboardObjectInstallWorkflow',
'PhabricatorDashboardQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
+ 'PhabricatorDashboardQueryPanelApplicationEditField' => 'PhabricatorEditField',
+ 'PhabricatorDashboardQueryPanelApplicationTransaction' => 'PhabricatorDashboardPanelPropertyTransaction',
'PhabricatorDashboardQueryPanelInstallController' => 'PhabricatorDashboardController',
+ 'PhabricatorDashboardQueryPanelQueryEditField' => 'PhabricatorEditField',
+ 'PhabricatorDashboardQueryPanelQueryTransaction' => 'PhabricatorDashboardPanelPropertyTransaction',
'PhabricatorDashboardQueryPanelType' => 'PhabricatorDashboardPanelType',
'PhabricatorDashboardRemarkupRule' => 'PhabricatorObjectRemarkupRule',
'PhabricatorDashboardRemovePanelController' => 'PhabricatorDashboardController',
diff --git a/src/applications/dashboard/editfield/PhabricatorDashboardQueryPanelApplicationEditField.php b/src/applications/dashboard/editfield/PhabricatorDashboardQueryPanelApplicationEditField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/dashboard/editfield/PhabricatorDashboardQueryPanelApplicationEditField.php
@@ -0,0 +1,59 @@
+<?php
+
+final class PhabricatorDashboardQueryPanelApplicationEditField
+ extends PhabricatorEditField {
+
+ private $controlID;
+
+ protected function newControl() {
+ $engines = id(new PhutilClassMapQuery())
+ ->setAncestorClass('PhabricatorApplicationSearchEngine')
+ ->setFilterMethod('canUseInPanelContext')
+ ->execute();
+
+ $all_apps = id(new PhabricatorApplicationQuery())
+ ->setViewer($this->getViewer())
+ ->withUnlisted(false)
+ ->withInstalled(true)
+ ->execute();
+ foreach ($engines as $index => $engine) {
+ if (!isset($all_apps[$engine->getApplicationClassName()])) {
+ unset($engines[$index]);
+ continue;
+ }
+ }
+
+ $options = array();
+
+ $value = $this->getValueForControl();
+ if (strlen($value) && empty($engines[$value])) {
+ $options[$value] = $value;
+ }
+
+ $engines = msort($engines, 'getResultTypeDescription');
+ foreach ($engines as $class_name => $engine) {
+ $options[$class_name] = $engine->getResultTypeDescription();
+ }
+
+ return id(new AphrontFormSelectControl())
+ ->setID($this->getControlID())
+ ->setOptions($options);
+ }
+
+ protected function newHTTPParameterType() {
+ return new AphrontSelectHTTPParameterType();
+ }
+
+ public function getControlID() {
+ if (!$this->controlID) {
+ $this->controlID = celerity_generate_unique_node_id();
+ }
+
+ return $this->controlID;
+ }
+
+ protected function newConduitParameterType() {
+ return new ConduitStringParameterType();
+ }
+
+}
diff --git a/src/applications/dashboard/editfield/PhabricatorDashboardQueryPanelQueryEditField.php b/src/applications/dashboard/editfield/PhabricatorDashboardQueryPanelQueryEditField.php
new file mode 100644
--- /dev/null
+++ b/src/applications/dashboard/editfield/PhabricatorDashboardQueryPanelQueryEditField.php
@@ -0,0 +1,77 @@
+<?php
+
+final class PhabricatorDashboardQueryPanelQueryEditField
+ extends PhabricatorEditField {
+
+ private $applicationControlID;
+
+ public function setApplicationControlID($id) {
+ $this->applicationControlID = $id;
+ return $this;
+ }
+
+ public function getApplicationControlID() {
+ return $this->applicationControlID;
+ }
+
+ protected function newControl() {
+ $engines = id(new PhutilClassMapQuery())
+ ->setAncestorClass('PhabricatorApplicationSearchEngine')
+ ->setFilterMethod('canUseInPanelContext')
+ ->execute();
+
+ $value = $this->getValueForControl();
+
+ $queries = array();
+ $seen = false;
+ foreach ($engines as $engine_class => $engine) {
+ $engine->setViewer($this->getViewer());
+ $engine_queries = $engine->loadEnabledNamedQueries();
+ $query_map = mpull($engine_queries, 'getQueryName', 'getQueryKey');
+ asort($query_map);
+
+ foreach ($query_map as $key => $name) {
+ $queries[$engine_class][] = array('key' => $key, 'name' => $name);
+ if ($key == $value) {
+ $seen = true;
+ }
+ }
+ }
+
+ if (strlen($value) && !$seen) {
+ $name = pht('Custom Query ("%s")', $value);
+ } else {
+ $name = pht('(None)');
+ }
+
+ $options = array($value => $name);
+
+ $application_id = $this->getApplicationControlID();
+ $control_id = celerity_generate_unique_node_id();
+
+ Javelin::initBehavior(
+ 'dashboard-query-panel-select',
+ array(
+ 'applicationID' => $application_id,
+ 'queryID' => $control_id,
+ 'options' => $queries,
+ 'value' => array(
+ 'key' => strlen($value) ? $value : null,
+ 'name' => $name,
+ ),
+ ));
+
+ return id(new AphrontFormSelectControl())
+ ->setID($control_id)
+ ->setOptions($options);
+ }
+
+ protected function newHTTPParameterType() {
+ return new AphrontSelectHTTPParameterType();
+ }
+
+ protected function newConduitParameterType() {
+ return new ConduitStringParameterType();
+ }
+
+}
diff --git a/src/applications/dashboard/paneltype/PhabricatorDashboardQueryPanelType.php b/src/applications/dashboard/paneltype/PhabricatorDashboardQueryPanelType.php
--- a/src/applications/dashboard/paneltype/PhabricatorDashboardQueryPanelType.php
+++ b/src/applications/dashboard/paneltype/PhabricatorDashboardQueryPanelType.php
@@ -22,8 +22,29 @@
}
protected function newEditEngineFields(PhabricatorDashboardPanel $panel) {
- // TODO: Restore this using EditEngine instead of CustomField.
- return array();
+ $application_field =
+ id(new PhabricatorDashboardQueryPanelApplicationEditField())
+ ->setKey('class')
+ ->setLabel(pht('Search For'))
+ ->setTransactionType(
+ PhabricatorDashboardQueryPanelApplicationTransaction::TRANSACTIONTYPE)
+ ->setValue($panel->getProperty('class', ''));
+
+ $application_id = $application_field->getControlID();
+
+ $query_field =
+ id(new PhabricatorDashboardQueryPanelQueryEditField())
+ ->setKey('key')
+ ->setLabel(pht('Query'))
+ ->setApplicationControlID($application_id)
+ ->setTransactionType(
+ PhabricatorDashboardQueryPanelQueryTransaction::TRANSACTIONTYPE)
+ ->setValue($panel->getProperty('key', ''));
+
+ return array(
+ $application_field,
+ $query_field,
+ );
}
public function initializeFieldsFromRequest(
diff --git a/src/applications/dashboard/xaction/panel/PhabricatorDashboardQueryPanelApplicationTransaction.php b/src/applications/dashboard/xaction/panel/PhabricatorDashboardQueryPanelApplicationTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/dashboard/xaction/panel/PhabricatorDashboardQueryPanelApplicationTransaction.php
@@ -0,0 +1,12 @@
+<?php
+
+final class PhabricatorDashboardQueryPanelApplicationTransaction
+ extends PhabricatorDashboardPanelPropertyTransaction {
+
+ const TRANSACTIONTYPE = 'query.application';
+
+ protected function getPropertyKey() {
+ return 'class';
+ }
+
+}
diff --git a/src/applications/dashboard/xaction/panel/PhabricatorDashboardQueryPanelQueryTransaction.php b/src/applications/dashboard/xaction/panel/PhabricatorDashboardQueryPanelQueryTransaction.php
new file mode 100644
--- /dev/null
+++ b/src/applications/dashboard/xaction/panel/PhabricatorDashboardQueryPanelQueryTransaction.php
@@ -0,0 +1,12 @@
+<?php
+
+final class PhabricatorDashboardQueryPanelQueryTransaction
+ extends PhabricatorDashboardPanelPropertyTransaction {
+
+ const TRANSACTIONTYPE = 'search.query';
+
+ protected function getPropertyKey() {
+ return 'key';
+ }
+
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Oct 20, 8:26 AM (4 w, 1 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6731630
Default Alt Text
D20382.diff (9 KB)
Attached To
Mode
D20382: Rebuild query panels on top of EditEngine
Attached
Detach File
Event Timeline
Log In to Comment