Page MenuHomePhabricator

Add an action to adding Panels from ApplicationSearch
ClosedPublic

Authored by chad on Mar 20 2017, 7:39 PM.
Tags
None
Referenced Files
F13285292: D17516.id.diff
Mon, Jun 3, 6:29 PM
F13277925: D17516.diff
Fri, May 31, 3:48 PM
F13260790: D17516.diff
Mon, May 27, 12:23 AM
F13252629: D17516.id42125.diff
Sat, May 25, 1:54 AM
F13252568: D17516.id.diff
Sat, May 25, 1:48 AM
F13250812: D17516.id42129.diff
Fri, May 24, 5:44 PM
F13249290: D17516.id42127.diff
Fri, May 24, 8:06 AM
F13238790: D17516.id42125.diff
Tue, May 21, 9:15 PM
Subscribers

Details

Summary

Ref T5307. This adds an additional action to Use Results for creating a panel from the query.

Test Plan

Navigate to Maniphest, select dropdown for Use Results. Try any of the following:

  • Try to set a panel without a name (fail)
  • Muck up query or engine (fail)
  • Set a fake Dashboard ID (fail)

Give panel a name and select a dashboard I have edit permissions to, get taken to dashboard.

Diff Detail

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

src/applications/dashboard/controller/PhabricatorDashboardQueryPanelInstallController.php
63–70

I don't know how to save these custom fields since the user isn't setting them and I want them hidden.

For the moment, you can just hard-code transactions of type PhabricatorTransactions::TYPE_CUSTOMFIELD:

$xactions[] = id(new PhabricatorDashboardPanelTransaction())
  ->setTransactionType(PhabricatorTransactions::TYPE_CUSTOMFIELD)
  ->setMetadataValue('customfield:key', $field_key)
  ->setNewValue($field_value);

I believe the $field_key is std:dashboard:core:class for the SearchEngine class, and std:dashboard:core:key for the query key.

chad planned changes to this revision.Mar 20 2017, 7:57 PM
  • validate errors, set fields correctly
This revision was automatically updated to reflect the committed changes.

I meant to type arc diff I swear

  • Ideally, use $e_name = true; and $e_name = pht('Required'); to provide grey "Required" text before submission and red "Required" text after submission if the name is missing.
  • Extra-ideally, maybe prefill the name with the query name? Not sure if this gets reasonable results or is easy to do. I can point you in the right direction if you want to try.
  • Maybe put dashboard IDs in the <select />, or use the existing PhabricatorDashboardDatasource + typeahead? I get like 20 copies of "New Simple Dashboard" on my local install.
src/applications/dashboard/controller/PhabricatorDashboardQueryPanelInstallController.php
30

I think this check is too strict: if I run an ad hoc query (just type some random stuff into fields) I should still be able to turn it into a dashboard panel, but it won't be a "named" query.

I think the right check is this (basically: we're OK if the query key is a builtin query, or the query key is a saved query). It doesn't have to be a named query:

if ($engine->isBuiltinQuery($query_key)) {
  $ok = true;
} else {
  $saved_query = id(new PhabricatorSavedQueryQuery())
    ->setViewer($viewer)
    ->withEngineClassNames(array($engine_class))
    ->withQueryKeys(array($query_key))
    ->executeOne();
  if ($saved_query) {
    $ok = true;
  }
}

if (!$ok) {
  // 404
}
131

I think you can use $engine->getQueryResultsPageURI($query_key) for this, should get you back to the results page.

src/applications/search/controller/PhabricatorApplicationSearchController.php
558–560

nothin' says "this is a menu" like fa-bars