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();
|
|
|
|
$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:
|
|
|
|
$form->appendChild(pht('Search is not available in Subversion.'));
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
$form
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextControl())
|
|
|
|
->setLabel(pht('Search Here'))
|
|
|
|
->setName('grep')
|
|
|
|
->setValue($this->getRequest()->getStr('grep'))
|
2013-09-19 20:57:33 +02:00
|
|
|
->setCaption(pht('Enter a regular expression.')))
|
2013-04-23 20:12:02 +02:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
2013-09-19 20:57:33 +02:00
|
|
|
->setValue(pht('Search File Content')));
|
2013-04-23 20:12:02 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2013-05-11 17:23:19 +02:00
|
|
|
$filter = new AphrontListFilterView();
|
|
|
|
$filter->appendChild($form);
|
|
|
|
|
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'),
|
|
|
|
pht('Search for file content in this directory.'),
|
|
|
|
'#');
|
|
|
|
}
|
|
|
|
|
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)
|
|
|
|
->setHeader($this->renderPathLinks($drequest))
|
|
|
|
->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)
|
2013-09-20 01:01:58 +02:00
|
|
|
->setIcon('history'));
|
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
|
|
|
|
|
|
|
$behind_head = $drequest->getRawCommit();
|
|
|
|
$head_uri = $drequest->generateURI(
|
|
|
|
array(
|
|
|
|
'commit' => '',
|
|
|
|
'action' => 'browse',
|
|
|
|
));
|
|
|
|
$view->addAction(
|
|
|
|
id(new PhabricatorActionView())
|
|
|
|
->setName(pht('Jump to HEAD'))
|
|
|
|
->setHref($head_uri)
|
|
|
|
->setIcon('home')
|
|
|
|
->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.
|
|
|
|
|
|
|
|
$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)
|
|
|
|
->setIcon('preview'));
|
|
|
|
|
|
|
|
return $view;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function buildPropertyView(DiffusionRequest $drequest) {
|
2013-09-19 20:57:33 +02:00
|
|
|
$viewer = $this->getRequest()->getUser();
|
|
|
|
|
|
|
|
$view = id(new PhabricatorPropertyListView())
|
|
|
|
->setUser($viewer);
|
|
|
|
|
|
|
|
$stable_commit = $drequest->getStableCommitName();
|
|
|
|
$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)));
|
|
|
|
|
|
|
|
if ($drequest->getTagContent()) {
|
|
|
|
$view->addProperty(
|
|
|
|
pht('Tag'),
|
|
|
|
$drequest->getSymbolicCommit());
|
|
|
|
|
|
|
|
$view->addSectionHeader(pht('Tag Content'));
|
|
|
|
$view->addTextContent($this->markupText($drequest->getTagContent()));
|
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
->execute();
|
|
|
|
|
|
|
|
if (!$revisions) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$view = id(new DifferentialRevisionListView())
|
|
|
|
->setRevisions($revisions)
|
|
|
|
->setFields(DifferentialRevisionListView::getDefaultFields($user))
|
|
|
|
->setUser($user)
|
|
|
|
->loadAssets();
|
|
|
|
|
|
|
|
$phids = $view->getRequiredHandlePHIDs();
|
|
|
|
$handles = $this->loadViewerHandles($phids);
|
|
|
|
$view->setHandles($handles);
|
|
|
|
|
|
|
|
$header = id(new PHUIHeaderView())
|
|
|
|
->setHeader(pht('Pending Differential Revisions'));
|
|
|
|
|
|
|
|
return array(
|
|
|
|
$header,
|
|
|
|
$view,
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2011-03-08 02:25:47 +01:00
|
|
|
}
|