mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-11 17:32:41 +01:00
3db82cb2ec
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
60 lines
1.5 KiB
PHP
60 lines
1.5 KiB
PHP
<?php
|
|
|
|
/**
|
|
* @group search
|
|
*/
|
|
final class PhabricatorSearchDeleteController
|
|
extends PhabricatorSearchBaseController {
|
|
|
|
private $queryKey;
|
|
|
|
public function willProcessRequest(array $data) {
|
|
$this->queryKey = idx($data, 'queryKey');
|
|
}
|
|
|
|
public function processRequest() {
|
|
$request = $this->getRequest();
|
|
$user = $request->getUser();
|
|
|
|
$saved_query = id(new PhabricatorSavedQueryQuery())
|
|
->setViewer($user)
|
|
->withQueryKeys(array($this->queryKey))
|
|
->executeOne();
|
|
|
|
if (!$saved_query) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$engine = $saved_query->newEngine();
|
|
|
|
$named_query = id(new PhabricatorNamedQueryQuery())
|
|
->setViewer($user)
|
|
->withQueryKeys(array($saved_query->getQueryKey()))
|
|
->withUserPHIDs(array($user->getPHID()))
|
|
->executeOne();
|
|
if (!$named_query) {
|
|
return new Aphront404Response();
|
|
}
|
|
|
|
$return_uri = $engine->getQueryManagementURI();
|
|
|
|
if ($request->isDialogFormPost()) {
|
|
$named_query->delete();
|
|
return id(new AphrontRedirectResponse())->setURI($return_uri);
|
|
}
|
|
|
|
$dialog = id(new AphrontDialogView())
|
|
->setUser($user)
|
|
->setTitle(pht("Really Delete Query?"))
|
|
->appendChild(
|
|
pht(
|
|
'Really delete the query "%s"? You can not undo this. Remember '.
|
|
'all the great times you had filtering results together?',
|
|
$named_query->getQueryName()))
|
|
->addCancelButton($return_uri)
|
|
->addSubmitButton(pht('Delete Query'));
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
}
|
|
|
|
}
|