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

Clean up dead code from old task list

Summary:
Removes a bunch of dead stuff:

  - Old side nav with hard-coded filters.
  - Old edit/list/delete/update interfaces for those filters.
  - Old `buildStandardPageResponse()`.
  - Some other junk with no callsites.
  - Reduce the number of places where the "Create Task" button is built.

Test Plan: `grep`; used list view, batch editor, reports.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Differential Revision: https://secure.phabricator.com/D6985
This commit is contained in:
epriestley 2013-09-13 11:29:08 -07:00
parent d97d8d5fc4
commit 23c5fccaa3
11 changed files with 43 additions and 414 deletions

View file

@ -706,9 +706,6 @@ phutil_register_library_map(array(
'ManiphestReplyHandler' => 'applications/maniphest/mail/ManiphestReplyHandler.php',
'ManiphestReportController' => 'applications/maniphest/controller/ManiphestReportController.php',
'ManiphestSavedQuery' => 'applications/maniphest/storage/ManiphestSavedQuery.php',
'ManiphestSavedQueryDeleteController' => 'applications/maniphest/controller/ManiphestSavedQueryDeleteController.php',
'ManiphestSavedQueryEditController' => 'applications/maniphest/controller/ManiphestSavedQueryEditController.php',
'ManiphestSavedQueryListController' => 'applications/maniphest/controller/ManiphestSavedQueryListController.php',
'ManiphestSearchIndexer' => 'applications/maniphest/search/ManiphestSearchIndexer.php',
'ManiphestSubpriorityController' => 'applications/maniphest/controller/ManiphestSubpriorityController.php',
'ManiphestSubscribeController' => 'applications/maniphest/controller/ManiphestSubscribeController.php',
@ -2771,9 +2768,6 @@ phutil_register_library_map(array(
'ManiphestReplyHandler' => 'PhabricatorMailReplyHandler',
'ManiphestReportController' => 'ManiphestController',
'ManiphestSavedQuery' => 'ManiphestDAO',
'ManiphestSavedQueryDeleteController' => 'ManiphestController',
'ManiphestSavedQueryEditController' => 'ManiphestController',
'ManiphestSavedQueryListController' => 'ManiphestController',
'ManiphestSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
'ManiphestSubpriorityController' => 'ManiphestController',
'ManiphestSubscribeController' => 'ManiphestController',

View file

@ -68,11 +68,6 @@ final class PhabricatorApplicationManiphest extends PhabricatorApplication {
),
'export/(?P<key>[^/]+)/' => 'ManiphestExportController',
'subpriority/' => 'ManiphestSubpriorityController',
'custom/' => array(
'' => 'ManiphestSavedQueryListController',
'edit/(?:(?P<id>[1-9]\d*)/)?' => 'ManiphestSavedQueryEditController',
'delete/(?P<id>[1-9]\d*)/' => 'ManiphestSavedQueryDeleteController',
),
'subscribe/(?P<action>add|rem)/(?P<id>[1-9]\d*)/'
=> 'ManiphestSubscribeController',
),

View file

@ -36,10 +36,6 @@ final class ManiphestBatchEditController extends ManiphestController {
->setURI('/maniphest/query/?ids='.$task_ids);
}
$panel = new AphrontPanelView();
$panel->setHeader(pht('Maniphest Batch Editor'));
$panel->setNoBackground();
$handle_phids = mpull($tasks, 'getOwnerPHID');
$handles = $this->loadViewerHandles($handle_phids);
@ -125,15 +121,26 @@ final class ManiphestBatchEditController extends ManiphestController {
->appendChild(
id(new AphrontFormSubmitControl())
->setValue(pht('Update Tasks'))
->addCancelButton('/maniphest/', 'Done'));
->addCancelButton('/maniphest/'));
$panel->appendChild($form);
$title = pht('Batch Editor');
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName($title));
return $this->buildStandardPageResponse(
$panel,
$form_box = id(new PHUIFormBoxView())
->setHeaderText(pht('Batch Edit Tasks'))
->setForm($form);
return $this->buildApplicationPage(
array(
'title' => pht('Batch Editor'),
$crumbs,
$form_box,
),
array(
'title' => $title,
));
}

View file

@ -1,87 +1,43 @@
<?php
/**
* @group maniphest
*/
abstract class ManiphestController extends PhabricatorController {
private $defaultQuery;
public function buildStandardPageResponse($view, array $data) {
$page = $this->buildStandardPageView();
$page->setApplicationName(pht('Maniphest'));
$page->setBaseURI('/maniphest/');
$page->setTitle(idx($data, 'title'));
$page->setGlyph("\xE2\x9A\x93");
$page->appendPageObjects(idx($data, 'pageObjects', array()));
$page->appendChild($view);
$page->setSearchDefaultScope(PhabricatorSearchScope::SCOPE_OPEN_TASKS);
$response = new AphrontWebpageResponse();
return $response->setContent($page->render());
public function buildApplicationMenu() {
return $this->buildSideNavView(true)->getMenu();
}
protected function buildBaseSideNav($filter = null, $for_app = false) {
public function buildSideNavView($for_app = false) {
$user = $this->getRequest()->getUser();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI('/maniphest/view/'));
$request = $this->getRequest();
$user = $request->getUser();
$custom = id(new ManiphestSavedQuery())->loadAllWhere(
'userPHID = %s ORDER BY isDefault DESC, name ASC',
$user->getPHID());
// TODO: Enforce uniqueness. Currently, it's possible to save the same
// query under multiple names, and then SideNavFilterView explodes on
// duplicate keys. Generally, we should clean up the custom/saved query
// code as it's a bit of a mess.
$custom = mpull($custom, null, 'getQueryKey');
if ($custom) {
$nav->addLabel('Saved Queries');
foreach ($custom as $query) {
if ($query->getIsDefault()) {
$this->defaultQuery = $query;
}
$nav->addFilter(
'Q:'.$query->getQueryKey(),
$query->getName(),
'/maniphest/view/custom/?key='.$query->getQueryKey());
}
$nav->addFilter('saved', pht('Edit...'), '/maniphest/custom/');
}
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
if ($for_app) {
$nav->addFilter('', pht('Create Task'),
$this->getApplicationURI('task/create/'));
$nav->addFilter('create', pht('Create Task'));
}
$nav->addLabel(pht('User Tasks'));
$nav->addFilter('action', pht('Assigned'));
$nav->addFilter('created', pht('Created'));
$nav->addFilter('subscribed', pht('Subscribed'));
$nav->addFilter('triage', pht('Need Triage'));
$nav->addLabel(pht('User Projects'));
$nav->addFilter('projecttriage', pht('Need Triage'));
$nav->addFilter('projectall', pht('All Tasks'));
$nav->addLabel('All Tasks');
$nav->addFilter('alltriage', pht('Need Triage'));
$nav->addFilter('all', pht('All Tasks'));
$nav->addLabel(pht('Custom'));
$nav->addFilter('custom', pht('Custom Query'));
$nav->addFilter('report', pht('Reports'), '/maniphest/report/');
id(new ManiphestTaskSearchEngine())
->setViewer($user)
->addNavigationItems($nav->getMenu());
$nav->addLabel(pht('Reports'));
$nav->addFilter('reports', pht('Reports'), 'report/');
$nav->selectFilter(null);
return $nav;
}
public function buildApplicationMenu() {
return $this->buildBaseSideNav(null, true)->getMenu();
}
protected function buildApplicationCrumbs() {
$crumbs = parent::buildApplicationCrumbs();
protected function getDefaultQuery() {
return $this->defaultQuery;
$crumbs->addAction(
id(new PHUIListItemView())
->setName(pht('Create Task'))
->setHref($this->getApplicationURI('task/create/'))
->setIcon('create'));
return $crumbs;
}
protected function renderSingleTask(ManiphestTask $task) {

View file

@ -28,10 +28,6 @@ final class ManiphestReportController extends ManiphestController {
return id(new AphrontRedirectResponse())->setURI($uri);
}
$base_nav = $this->buildBaseSideNav();
$base_nav->selectFilter('report', 'report');
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI('/maniphest/report/'));
$nav->addLabel(pht('Open Tasks'));
@ -63,7 +59,7 @@ final class ManiphestReportController extends ManiphestController {
id(new PhabricatorCrumbView())
->setName(pht('Reports'))));
return $this->buildStandardPageResponse(
return $this->buildApplicationPage(
$nav,
array(
'title' => pht('Maniphest Reports'),

View file

@ -1,48 +0,0 @@
<?php
/**
* @group maniphest
*/
final class ManiphestSavedQueryDeleteController extends ManiphestController {
private $id;
public function willProcessRequest(array $data) {
$this->id = $data['id'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$id = $this->id;
$query = id(new ManiphestSavedQuery())->load($id);
if (!$query) {
return new Aphront404Response();
}
if ($query->getUserPHID() != $user->getPHID()) {
return new Aphront400Response();
}
if ($request->isDialogFormPost()) {
$query->delete();
return id(new AphrontRedirectResponse())->setURI('/maniphest/custom/');
}
$name = $query->getName();
$inst = pht(
'Really delete the query "%s"? It will be lost forever!', $name);
$dialog = id(new AphrontDialogView())
->setUser($user)
->setTitle(pht('Really delete this query?'))
->appendChild(hsprintf(
'<p>%s</p>',
$inst))
->addCancelButton('/maniphest/custom/')
->addSubmitButton(pht('Delete'));
return id(new AphrontDialogResponse())->setDialog($dialog);
}
}

View file

@ -1,105 +0,0 @@
<?php
/**
* @group maniphest
*/
final class ManiphestSavedQueryEditController extends ManiphestController {
private $id;
public function willProcessRequest(array $data) {
$this->id = idx($data, 'id');
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$key = $request->getStr('key');
if (!$key) {
$id = nonempty($this->id, $request->getInt('id'));
if (!$id) {
return new Aphront404Response();
}
$query = id(new ManiphestSavedQuery())->load($id);
if (!$query) {
return new Aphront404Response();
}
if ($query->getUserPHID() != $user->getPHID()) {
return new Aphront400Response();
}
} else {
$query = new ManiphestSavedQuery();
$query->setUserPHID($user->getPHID());
$query->setQueryKey($key);
$query->setIsDefault(0);
}
$e_name = true;
$errors = array();
if ($request->isFormPost()) {
$e_name = null;
$query->setName($request->getStr('name'));
if (!strlen($query->getName())) {
$e_name = pht('Required');
$errors[] = pht('Saved query name is required.');
}
if (!$errors) {
$query->save();
return id(new AphrontRedirectResponse())->setURI('/maniphest/custom/');
}
}
if ($errors) {
$error_view = new AphrontErrorView();
$error_view->setTitle(pht('Form Errors'));
$error_view->setErrors($errors);
} else {
$error_view = null;
}
if ($query->getID()) {
$header = pht('Edit Saved Query');
$cancel_uri = '/maniphest/custom/';
} else {
$header = pht('New Saved Query');
$cancel_uri = '/maniphest/view/custom/?key='.$key;
}
$form = id(new AphrontFormView())
->setUser($user)
->addHiddenInput('key', $key)
->addHiddenInput('id', $query->getID())
->appendChild(
id(new AphrontFormTextControl())
->setLabel(pht('Name'))
->setValue($query->getName())
->setName('name')
->setError($e_name))
->appendChild(
id(new AphrontFormSubmitControl())
->addCancelButton($cancel_uri)
->setValue(pht('Save')));
$panel = new AphrontPanelView();
$panel->setHeader($header);
$panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
$nav = $this->buildBaseSideNav();
// The side nav won't show "Saved Queries..." until you have at least one.
$nav->selectFilter('saved', 'custom');
$nav->appendChild($error_view);
$nav->appendChild($panel);
return $this->buildApplicationPage(
$nav,
array(
'title' => pht('Saved Queries'),
'device' => true,
));
}
}

View file

@ -1,133 +0,0 @@
<?php
/**
* @group maniphest
*/
final class ManiphestSavedQueryListController extends ManiphestController {
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$nav = $this->buildBaseSideNav();
$queries = id(new ManiphestSavedQuery())->loadAllWhere(
'userPHID = %s ORDER BY name ASC',
$user->getPHID());
$default = null;
if ($request->isFormPost()) {
$new_default = null;
foreach ($queries as $query) {
if ($query->getID() == $request->getInt('default')) {
$new_default = $query;
}
}
if ($this->getDefaultQuery()) {
$this->getDefaultQuery()->setIsDefault(0)->save();
}
if ($new_default) {
$new_default->setIsDefault(1)->save();
}
return id(new AphrontRedirectResponse())->setURI('/maniphest/custom/');
}
$rows = array();
foreach ($queries as $query) {
if ($query->getIsDefault()) {
$default = $query;
}
$rows[] = array(
phutil_tag(
'input',
array(
'type' => 'radio',
'name' => 'default',
'value' => $query->getID(),
'checked' => ($query->getIsDefault() ? 'checked' : null),
)),
phutil_tag(
'a',
array(
'href' => '/maniphest/view/custom/?key='.$query->getQueryKey(),
),
$query->getName()),
phutil_tag(
'a',
array(
'href' => '/maniphest/custom/edit/'.$query->getID().'/',
'class' => 'grey small button',
),
'Edit'),
javelin_tag(
'a',
array(
'href' => '/maniphest/custom/delete/'.$query->getID().'/',
'class' => 'grey small button',
'sigil' => 'workflow',
),
'Delete'),
);
}
$rows[] = array(
phutil_tag(
'input',
array(
'type' => 'radio',
'name' => 'default',
'value' => 0,
'checked' => ($default === null ? 'checked' : null),
)),
phutil_tag('em', array(), pht('No Default')),
'',
'',
);
$table = new AphrontTableView($rows);
$table->setHeaders(
array(
pht('Default'),
pht('Name'),
pht('Edit'),
pht('Delete'),
));
$table->setColumnClasses(
array(
'radio',
'wide pri',
'action',
'action',
));
$panel = new AphrontPanelView();
$panel->setHeader(pht('Saved Custom Queries'));
$panel->addButton(
phutil_tag(
'button',
array(),
pht('Save Default Query')));
$panel->appendChild($table);
$form = phabricator_form(
$user,
array(
'method' => 'POST',
'action' => $request->getRequestURI(),
),
$panel->render());
$nav->selectFilter('saved', 'saved');
$nav->appendChild($form);
return $this->buildApplicationPage(
$nav,
array(
'title' => pht('Saved Queries'),
'device' => true,
));
}
}

View file

@ -337,12 +337,7 @@ final class ManiphestTaskDetailController extends ManiphestController {
id(new PhabricatorCrumbView())
->setName($object_name)
->setHref('/'.$object_name))
->setActionList($actions)
->addAction(
id(new PHUIListItemView())
->setHref($this->getApplicationURI('/task/create/'))
->setName(pht('Create Task'))
->setIcon('create'));
->setActionList($actions);
$header = $this->buildHeaderView($task);
$properties = $this->buildPropertyView($task, $aux_fields, $edges, $engine);

View file

@ -554,13 +554,7 @@ final class ManiphestTaskEditController extends ManiphestController {
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb(
id(new PhabricatorCrumbView())
->setName($header_name)
->setHref($this->getApplicationURI('/task/create/')))
->addAction(
id(new PHUIListItemView())
->setHref($this->getApplicationURI('/task/create/'))
->setName(pht('Create Task'))
->setIcon('create'));
->setName($header_name));
return $this->buildApplicationPage(
array(

View file

@ -181,28 +181,6 @@ final class ManiphestTaskListController
}
}
public function buildSideNavView($for_app = false) {
$user = $this->getRequest()->getUser();
$nav = new AphrontSideNavFilterView();
$nav->setBaseURI(new PhutilURI($this->getApplicationURI()));
if ($for_app) {
$nav->addFilter('create', pht('Create Task'));
}
id(new ManiphestTaskSearchEngine())
->setViewer($user)
->addNavigationItems($nav->getMenu());
$nav->addLabel(pht('Reports'));
$nav->addFilter('reports', pht('Reports'), 'report/');
$nav->selectFilter(null);
return $nav;
}
private function renderBatchEditor(PhabricatorSavedQuery $saved_query) {
$user = $this->getRequest()->getUser();