2011-03-08 02:25:47 +01:00
|
|
|
<?php
|
|
|
|
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
abstract class DiffusionBrowseController extends DiffusionController {
|
2013-09-19 20:57:33 +02:00
|
|
|
|
2013-09-23 21:53:41 +02:00
|
|
|
public function shouldAllowPublic() {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
protected function renderSearchForm($collapsed) {
|
2013-04-23 20:12:02 +02:00
|
|
|
$drequest = $this->getDiffusionRequest();
|
2014-02-01 20:48:28 +01:00
|
|
|
|
|
|
|
$forms = array();
|
2013-04-23 20:12:02 +02:00
|
|
|
$form = id(new AphrontFormView())
|
|
|
|
->setUser($this->getRequest()->getUser())
|
2013-08-26 20:53:11 +02:00
|
|
|
->setMethod('GET');
|
2013-04-23 20:12:02 +02:00
|
|
|
|
|
|
|
switch ($drequest->getRepository()->getVersionControlSystem()) {
|
|
|
|
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
2014-02-01 20:48:28 +01:00
|
|
|
$forms[] = id(clone $form)
|
|
|
|
->appendChild(pht('Search is not available in Subversion.'));
|
2013-04-23 20:12:02 +02:00
|
|
|
break;
|
|
|
|
default:
|
2014-02-01 20:48:28 +01:00
|
|
|
$forms[] = id(clone $form)
|
2013-04-23 20:12:02 +02:00
|
|
|
->appendChild(
|
2014-02-01 20:48:28 +01:00
|
|
|
id(new AphrontFormTextWithSubmitControl())
|
|
|
|
->setLabel(pht('File Name'))
|
|
|
|
->setSubmitLabel(pht('Search File Names'))
|
|
|
|
->setName('find')
|
|
|
|
->setValue($this->getRequest()->getStr('find')));
|
|
|
|
$forms[] = id(clone $form)
|
2013-04-23 20:12:02 +02:00
|
|
|
->appendChild(
|
2014-02-01 20:48:28 +01:00
|
|
|
id(new AphrontFormTextWithSubmitControl())
|
|
|
|
->setLabel(pht('Pattern'))
|
|
|
|
->setSubmitLabel(pht('Grep File Content'))
|
|
|
|
->setName('grep')
|
|
|
|
->setValue($this->getRequest()->getStr('grep')));
|
2013-04-23 20:12:02 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-02-01 20:48:28 +01:00
|
|
|
|
2013-05-11 17:23:19 +02:00
|
|
|
$filter = new AphrontListFilterView();
|
2014-02-01 20:48:28 +01:00
|
|
|
$filter->appendChild($forms);
|
|
|
|
|
2013-05-11 17:23:19 +02:00
|
|
|
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
if ($collapsed) {
|
2013-09-19 20:57:33 +02:00
|
|
|
$filter->setCollapsed(
|
|
|
|
pht('Show Search'),
|
|
|
|
pht('Hide Search'),
|
2014-02-01 20:48:28 +01:00
|
|
|
pht('Search for file names or content in this directory.'),
|
2013-09-19 20:57:33 +02:00
|
|
|
'#');
|
|
|
|
}
|
|
|
|
|
2013-05-11 17:23:19 +02:00
|
|
|
return $filter;
|
2013-04-23 20:12:02 +02:00
|
|
|
}
|
|
|
|
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
protected function markupText($text) {
|
2012-04-24 03:36:25 +02:00
|
|
|
$engine = PhabricatorMarkupEngine::newDiffusionMarkupEngine();
|
2013-03-04 21:33:05 +01:00
|
|
|
$engine->setConfig('viewer', $this->getRequest()->getUser());
|
2013-02-13 23:50:15 +01:00
|
|
|
$text = $engine->markupText($text);
|
2012-04-24 03:36:25 +02:00
|
|
|
|
2013-01-18 09:32:58 +01:00
|
|
|
$text = phutil_tag(
|
2012-04-24 03:36:25 +02:00
|
|
|
'div',
|
|
|
|
array(
|
|
|
|
'class' => 'phabricator-remarkup',
|
|
|
|
),
|
|
|
|
$text);
|
|
|
|
|
|
|
|
return $text;
|
|
|
|
}
|
|
|
|
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
protected function buildHeaderView(DiffusionRequest $drequest) {
|
2013-09-19 20:57:33 +02:00
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setUser($viewer)
|
2013-09-23 21:55:23 +02:00
|
|
|
->setHeader($this->renderPathLinks($drequest, $mode = 'browse'))
|
2013-09-19 20:57:33 +02:00
|
|
|
->setPolicyObject($drequest->getRepository());
|
|
|
|
|
|
|
|
return $header;
|
|
|
|
}
|
|
|
|
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
protected function buildActionView(DiffusionRequest $drequest) {
|
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$view = id(new PhabricatorActionListView())
|
|
|
|
->setUser($viewer);
|
|
|
|
|
|
|
|
$history_uri = $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'history',
|
|
|
|
));
|
|
|
|
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('View History'))
|
|
|
|
->setHref($history_uri)
|
2014-05-12 19:08:32 +02:00
|
|
|
->setIcon('fa-list'));
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
|
2014-05-13 22:52:48 +02:00
|
|
|
$behind_head = $drequest->getSymbolicCommit();
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
$head_uri = $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'commit' => '',
|
|
|
|
'action' => 'browse',
|
|
|
|
));
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Jump to HEAD'))
|
|
|
|
->setHref($head_uri)
|
2014-05-12 19:08:32 +02:00
|
|
|
->setIcon('fa-home')
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
->setDisabled(!$behind_head));
|
|
|
|
|
|
|
|
// TODO: Ideally, this should live in Owners and be event-triggered, but
|
|
|
|
// there's no reasonable object for it to react to right now.
|
|
|
|
|
2013-11-11 18:12:08 +01:00
|
|
|
$owners = 'PhabricatorApplicationOwners';
|
|
|
|
if (PhabricatorApplication::isClassInstalled($owners)) {
|
|
|
|
$owners_uri = id(new PhutilURI('/owners/view/search/'))
|
|
|
|
->setQueryParams(
|
|
|
|
array(
|
|
|
|
'repository' => $drequest->getCallsign(),
|
|
|
|
'path' => '/'.$drequest->getPath(),
|
|
|
|
));
|
|
|
|
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Find Owners'))
|
|
|
|
->setHref((string)$owners_uri)
|
2014-05-12 19:08:32 +02:00
|
|
|
->setIcon('fa-users'));
|
2013-11-11 18:12:08 +01:00
|
|
|
}
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
protected function buildPropertyView(
|
|
|
|
DiffusionRequest $drequest,
|
|
|
|
PhabricatorActionListView $actions) {
|
|
|
|
|
2013-09-19 20:57:33 +02:00
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
2013-10-11 16:53:56 +02:00
|
|
|
$view = id(new PHUIPropertyListView())
|
|
|
|
->setUser($viewer)
|
|
|
|
->setActionList($actions);
|
2013-09-19 20:57:33 +02:00
|
|
|
|
2014-05-13 22:51:45 +02:00
|
|
|
$stable_commit = $drequest->getStableCommit();
|
2013-09-19 20:57:33 +02:00
|
|
|
$callsign = $drequest->getRepository()->getCallsign();
|
|
|
|
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Commit'),
|
|
|
|
phutil_tag(
|
|
|
|
'a',
|
|
|
|
array(
|
|
|
|
'href' => $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'action' => 'commit',
|
|
|
|
'commit' => $stable_commit,
|
|
|
|
)),
|
|
|
|
),
|
|
|
|
$drequest->getRepository()->formatCommitName($stable_commit)));
|
|
|
|
|
2014-05-13 22:52:03 +02:00
|
|
|
if ($drequest->getSymbolicType() == 'tag') {
|
2013-11-04 21:16:53 +01:00
|
|
|
$symbolic = $drequest->getSymbolicCommit();
|
|
|
|
$view->addProperty(pht('Tag'), $symbolic);
|
2013-09-19 20:57:33 +02:00
|
|
|
|
2013-11-04 21:16:53 +01:00
|
|
|
$tags = $this->callConduitWithDiffusionRequest(
|
|
|
|
'diffusion.tagsquery',
|
|
|
|
array(
|
|
|
|
'names' => array($symbolic),
|
|
|
|
'needMessages' => true,
|
|
|
|
));
|
|
|
|
$tags = DiffusionRepositoryTag::newFromConduit($tags);
|
|
|
|
|
|
|
|
$tags = mpull($tags, null, 'getName');
|
|
|
|
$tag = idx($tags, $symbolic);
|
|
|
|
|
|
|
|
if ($tag && strlen($tag->getMessage())) {
|
|
|
|
$view->addSectionHeader(pht('Tag Content'));
|
|
|
|
$view->addTextContent($this->markupText($tag->getMessage()));
|
|
|
|
}
|
2013-09-19 20:57:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
protected function buildOpenRevisions() {
|
|
|
|
$user = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$drequest = $this->getDiffusionRequest();
|
|
|
|
$repository = $drequest->getRepository();
|
|
|
|
$path = $drequest->getPath();
|
|
|
|
|
|
|
|
$path_map = id(new DiffusionPathIDQuery(array($path)))->loadPathIDs();
|
|
|
|
$path_id = idx($path_map, $path);
|
|
|
|
if (!$path_id) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$revisions = id(new DifferentialRevisionQuery())
|
|
|
|
->setViewer($user)
|
|
|
|
->withPath($repository->getID(), $path_id)
|
|
|
|
->withStatus(DifferentialRevisionQuery::STATUS_OPEN)
|
|
|
|
->setOrder(DifferentialRevisionQuery::ORDER_PATH_MODIFIED)
|
|
|
|
->setLimit(10)
|
|
|
|
->needRelationships(true)
|
2014-02-19 02:57:45 +01:00
|
|
|
->needFlags(true)
|
|
|
|
->needDrafts(true)
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
->execute();
|
|
|
|
|
|
|
|
if (!$revisions) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$view = id(new DifferentialRevisionListView())
|
|
|
|
->setRevisions($revisions)
|
2014-02-19 02:57:45 +01:00
|
|
|
->setUser($user);
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
|
|
|
|
$phids = $view->getRequiredHandlePHIDs();
|
|
|
|
$handles = $this->loadViewerHandles($phids);
|
|
|
|
$view->setHandles($handles);
|
|
|
|
|
2013-10-01 23:35:31 +02:00
|
|
|
return id(new PHUIObjectBoxView())
|
|
|
|
->setHeaderText(pht('Pending Differential Revisions'))
|
|
|
|
->appendChild($view);
|
Improve organization of Diffusion browse controllers
Summary:
Currently we have this:
- DiffusionController (abstract, has some random shared browse code)
- DiffusionBrowseController (concrete, Handles routing, directories, and search)
- DiffusionBrowseFileController (concrete, handles files)
Instead, do this:
- DiffusionController (no browse-related code)
- DiffusionBrowseController (abstract, shared browse code)
- DiffusionBrowseMainController (concrete, handles routing)
- DiffusionBrowseDirectoryController (concrete, handles directories)
- DiffusionBrowseFileController (concrete, handles files)
- DiffusionBrowseSearchController (concrete, handles search)
Feels a lot cleaner.
Test Plan: Looked at directories, searches, and files.
Reviewers: btrahan
Reviewed By: btrahan
CC: aran
Differential Revision: https://secure.phabricator.com/D7045
2013-09-20 01:01:34 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-03-08 02:25:47 +01:00
|
|
|
}
|