@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Allow custom queries to be deleted

Summary:
Ref T2625. Currently, custom saved queries can be edited but not deleted. Allow them to be deleted. Also:

- Clean up an unused property in `PhabricatorPasteViewController`.
- Fix an issue with left nav highlighting of builtin queries.
- Improve submit behavior for edits.
- Add a cancel button on edits.

Test Plan: Saved, edited and deleted queries.

Reviewers: btrahan, blc

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T2625

Differential Revision: https://secure.phabricator.com/D6059

+99 -8
+2
src/__phutil_library_map__.php
··· 1362 1362 'PhabricatorSearchConfigOptions' => 'applications/search/config/PhabricatorSearchConfigOptions.php', 1363 1363 'PhabricatorSearchController' => 'applications/search/controller/PhabricatorSearchController.php', 1364 1364 'PhabricatorSearchDAO' => 'applications/search/storage/PhabricatorSearchDAO.php', 1365 + 'PhabricatorSearchDeleteController' => 'applications/search/controller/PhabricatorSearchDeleteController.php', 1365 1366 'PhabricatorSearchDocument' => 'applications/search/storage/document/PhabricatorSearchDocument.php', 1366 1367 'PhabricatorSearchDocumentField' => 'applications/search/storage/document/PhabricatorSearchDocumentField.php', 1367 1368 'PhabricatorSearchDocumentIndexer' => 'applications/search/index/PhabricatorSearchDocumentIndexer.php', ··· 3147 3148 'PhabricatorSearchConfigOptions' => 'PhabricatorApplicationConfigOptions', 3148 3149 'PhabricatorSearchController' => 'PhabricatorSearchBaseController', 3149 3150 'PhabricatorSearchDAO' => 'PhabricatorLiskDAO', 3151 + 'PhabricatorSearchDeleteController' => 'PhabricatorSearchBaseController', 3150 3152 'PhabricatorSearchDocument' => 'PhabricatorSearchDAO', 3151 3153 'PhabricatorSearchDocumentField' => 'PhabricatorSearchDAO', 3152 3154 'PhabricatorSearchDocumentRelationship' => 'PhabricatorSearchDAO',
+5
src/applications/paste/controller/PhabricatorPasteQueriesController.php
··· 40 40 $item->addIcon('none', $date_created); 41 41 $item->addAction( 42 42 id(new PhabricatorMenuItemView()) 43 + ->setIcon('delete') 44 + ->setHref('/search/delete/'.$named_query->getQueryKey().'/') 45 + ->setWorkflow(true)); 46 + $item->addAction( 47 + id(new PhabricatorMenuItemView()) 43 48 ->setIcon('edit') 44 49 ->setHref('/search/edit/'.$named_query->getQueryKey().'/')); 45 50 }
+2 -3
src/applications/paste/controller/PhabricatorPasteViewController.php
··· 2 2 3 3 final class PhabricatorPasteViewController extends PhabricatorPasteController { 4 4 5 + private $id; 6 + 5 7 public function shouldAllowPublic() { 6 8 return true; 7 9 } 8 - 9 - private $id; 10 - private $handles; 11 10 12 11 public function willProcessRequest(array $data) { 13 12 $this->id = $data['id'];
+5
src/applications/paste/query/PhabricatorPasteSearchEngine.php
··· 84 84 return '/paste/query/'.$query->getQueryKey().'/'; 85 85 } 86 86 87 + public function getQueryManagementURI() { 88 + return '/paste/savedqueries/'; 89 + } 90 + 87 91 public function getBuiltinQueryNames() { 88 92 $names = array( 89 93 'all' => pht('All Pastes'), ··· 99 103 public function buildSavedQueryFromBuiltin($query_key) { 100 104 101 105 $query = $this->newSavedQuery(); 106 + $query->setQueryKey($query_key); 102 107 103 108 switch ($query_key) { 104 109 case 'all':
+1
src/applications/search/application/PhabricatorApplicationSearch.php
··· 35 35 'hovercard/(?P<mode>retrieve|test)/' => 36 36 'PhabricatorSearchHovercardController', 37 37 'edit/(?P<queryKey>[^/]+)/' => 'PhabricatorSearchEditController', 38 + 'delete/(?P<queryKey>[^/]+)/' => 'PhabricatorSearchDeleteController', 38 39 ), 39 40 ); 40 41 }
+60
src/applications/search/controller/PhabricatorSearchDeleteController.php
··· 1 + <?php 2 + 3 + /** 4 + * @group search 5 + */ 6 + final class PhabricatorSearchDeleteController 7 + extends PhabricatorSearchBaseController { 8 + 9 + private $queryKey; 10 + 11 + public function willProcessRequest(array $data) { 12 + $this->queryKey = idx($data, 'queryKey'); 13 + } 14 + 15 + public function processRequest() { 16 + $request = $this->getRequest(); 17 + $user = $request->getUser(); 18 + 19 + $saved_query = id(new PhabricatorSavedQueryQuery()) 20 + ->setViewer($user) 21 + ->withQueryKeys(array($this->queryKey)) 22 + ->executeOne(); 23 + 24 + if (!$saved_query) { 25 + return new Aphront404Response(); 26 + } 27 + 28 + $engine = $saved_query->newEngine(); 29 + 30 + $named_query = id(new PhabricatorNamedQueryQuery()) 31 + ->setViewer($user) 32 + ->withQueryKeys(array($saved_query->getQueryKey())) 33 + ->withUserPHIDs(array($user->getPHID())) 34 + ->executeOne(); 35 + if (!$named_query) { 36 + return new Aphront404Response(); 37 + } 38 + 39 + $return_uri = $engine->getQueryManagementURI(); 40 + 41 + if ($request->isDialogFormPost()) { 42 + $named_query->delete(); 43 + return id(new AphrontRedirectResponse())->setURI($return_uri); 44 + } 45 + 46 + $dialog = id(new AphrontDialogView()) 47 + ->setUser($user) 48 + ->setTitle(pht("Really Delete Query?")) 49 + ->appendChild( 50 + pht( 51 + 'Really delete the query "%s"? You can not undo this. Remember '. 52 + 'all the great times you had filtering results together?', 53 + $named_query->getQueryName())) 54 + ->addCancelButton($return_uri) 55 + ->addSubmitButton(pht('Delete Query')); 56 + 57 + return id(new AphrontDialogResponse())->setDialog($dialog); 58 + } 59 + 60 + }
+12 -5
src/applications/search/controller/PhabricatorSearchEditController.php
··· 25 25 return new Aphront404Response(); 26 26 } 27 27 28 - $engine = $saved_query->newEngine(); 28 + $engine = $saved_query->newEngine()->setViewer($user); 29 + 30 + $complete_uri = $engine->getQueryManagementURI(); 31 + $cancel_uri = $complete_uri; 29 32 30 33 $named_query = id(new PhabricatorNamedQueryQuery()) 31 34 ->setViewer($user) ··· 37 40 ->setUserPHID($user->getPHID()) 38 41 ->setQueryKey($saved_query->getQueryKey()) 39 42 ->setEngineClassName($saved_query->getEngineClassName()); 43 + 44 + // If we haven't saved the query yet, this is a "Save..." operation, so 45 + // take the user back to the query if they cancel instead of back to the 46 + // management interface. 47 + $cancel_uri = $engine->getQueryResultsPageURI($saved_query); 40 48 } 41 49 42 50 $e_name = true; ··· 53 61 54 62 if (!$errors) { 55 63 $named_query->save(); 56 - 57 - $results_uri = $engine->getQueryResultsPageURI($saved_query); 58 - return id(new AphrontRedirectResponse())->setURI($results_uri); 64 + return id(new AphrontRedirectResponse())->setURI($complete_uri); 59 65 } 60 66 } 61 67 ··· 76 82 77 83 $form->appendChild( 78 84 id(new AphrontFormSubmitControl()) 79 - ->setValue(pht('Save Query'))); 85 + ->setValue(pht('Save Query')) 86 + ->addCancelButton($cancel_uri)); 80 87 81 88 if ($named_query->getID()) { 82 89 $title = pht('Edit Saved Query');
+12
src/applications/search/engine/PhabricatorApplicationSearchEngine.php
··· 5 5 * creating and storing saved queries. 6 6 * 7 7 * @task builtin Builtin Queries 8 + * @task uri Query URIs 8 9 * 9 10 * @group search 10 11 */ ··· 57 58 * 58 59 * @param PhabricatorSavedQuery The query to build a URI for. 59 60 * @return string URI where the query can be executed. 61 + * @task uri 60 62 */ 61 63 abstract public function getQueryResultsPageURI(PhabricatorSavedQuery $query); 64 + 65 + 66 + /** 67 + * Return an application URI for query management. This is used when, e.g., 68 + * a query deletion operation is cancelled. 69 + * 70 + * @return string URI where queries can be managed. 71 + * @task uri 72 + */ 73 + abstract public function getQueryManagementURI(); 62 74 63 75 64 76 public function newSavedQuery() {