1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32:42 +01:00

Restore "Limit" to dashboard Query panels

Summary: See PHI1220. Ref T13272. I accidentally left the ability to set a query limit behind when updating this.

Test Plan: Edited a query panel, set/removed the limit, tried to set an invalid limit.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13272

Differential Revision: https://secure.phabricator.com/D20472
This commit is contained in:
epriestley 2019-04-25 10:28:41 -07:00
parent dfbc4c1cd3
commit 45f01dc716
4 changed files with 57 additions and 0 deletions

View file

@ -3007,6 +3007,7 @@ phutil_register_library_map(array(
'PhabricatorDashboardQueryPanelApplicationEditField' => 'applications/dashboard/editfield/PhabricatorDashboardQueryPanelApplicationEditField.php',
'PhabricatorDashboardQueryPanelApplicationTransaction' => 'applications/dashboard/xaction/panel/PhabricatorDashboardQueryPanelApplicationTransaction.php',
'PhabricatorDashboardQueryPanelInstallController' => 'applications/dashboard/controller/PhabricatorDashboardQueryPanelInstallController.php',
'PhabricatorDashboardQueryPanelLimitTransaction' => 'applications/dashboard/xaction/panel/PhabricatorDashboardQueryPanelLimitTransaction.php',
'PhabricatorDashboardQueryPanelQueryEditField' => 'applications/dashboard/editfield/PhabricatorDashboardQueryPanelQueryEditField.php',
'PhabricatorDashboardQueryPanelQueryTransaction' => 'applications/dashboard/xaction/panel/PhabricatorDashboardQueryPanelQueryTransaction.php',
'PhabricatorDashboardQueryPanelType' => 'applications/dashboard/paneltype/PhabricatorDashboardQueryPanelType.php',
@ -9045,6 +9046,7 @@ phutil_register_library_map(array(
'PhabricatorDashboardQueryPanelApplicationEditField' => 'PhabricatorEditField',
'PhabricatorDashboardQueryPanelApplicationTransaction' => 'PhabricatorDashboardPanelPropertyTransaction',
'PhabricatorDashboardQueryPanelInstallController' => 'PhabricatorDashboardController',
'PhabricatorDashboardQueryPanelLimitTransaction' => 'PhabricatorDashboardPanelPropertyTransaction',
'PhabricatorDashboardQueryPanelQueryEditField' => 'PhabricatorEditField',
'PhabricatorDashboardQueryPanelQueryTransaction' => 'PhabricatorDashboardPanelPropertyTransaction',
'PhabricatorDashboardQueryPanelType' => 'PhabricatorDashboardPanelType',

View file

@ -41,9 +41,17 @@ final class PhabricatorDashboardQueryPanelType
PhabricatorDashboardQueryPanelQueryTransaction::TRANSACTIONTYPE)
->setValue($panel->getProperty('key', ''));
$limit_field = id(new PhabricatorIntEditField())
->setKey('limit')
->setLabel(pht('Limit'))
->setTransactionType(
PhabricatorDashboardQueryPanelLimitTransaction::TRANSACTIONTYPE)
->setValue($panel->getProperty('limit'));
return array(
$application_field,
$query_field,
$limit_field,
);
}

View file

@ -0,0 +1,43 @@
<?php
final class PhabricatorDashboardQueryPanelLimitTransaction
extends PhabricatorDashboardPanelPropertyTransaction {
const TRANSACTIONTYPE = 'search.limit';
protected function getPropertyKey() {
return 'limit';
}
public function generateNewValue($object, $value) {
if (!$value) {
return null;
}
return $value;
}
public function validateTransactions($object, array $xactions) {
$errors = array();
$old_value = $object->getProperty($this->getPropertyKey());
foreach ($xactions as $xaction) {
$new_value = $xaction->getNewValue();
if ($new_value === $old_value) {
continue;
}
if ($new_value < 0) {
$errors[] = $this->newInvalidError(
pht(
'Query result limit must be empty, or at least 1.'),
$xaction);
continue;
}
}
return $errors;
}
}

View file

@ -7,6 +7,10 @@ final class PhabricatorIntEditField
return new AphrontFormTextControl();
}
protected function newHTTPParameterType() {
return new AphrontIntHTTPParameterType();
}
protected function newConduitParameterType() {
return new ConduitIntParameterType();
}