mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-23 07:12:41 +01:00
Render an edit link in Diffusion directory views
Summary: If the user has an editor configured, an Edit link appears next to the History link. Somewhat suboptimally, the column is still there if there are no edit links, it's just empty. I don't know if it matters... Test Plan: Load Diffusion pages while changing editor setting in preferences. Reviewers: epriestley Reviewed By: epriestley CC: aran, Korvin, avivey Maniphest Tasks: T1558 Differential Revision: https://secure.phabricator.com/D3124
This commit is contained in:
parent
9a19cfb9de
commit
ce8bcf887d
3 changed files with 41 additions and 0 deletions
|
@ -85,6 +85,7 @@ final class DiffusionBrowseController extends DiffusionController {
|
|||
$browse_table->setDiffusionRequest($drequest);
|
||||
$browse_table->setHandles($handles);
|
||||
$browse_table->setPaths($results);
|
||||
$browse_table->setUser($this->getRequest()->getUser());
|
||||
|
||||
$browse_panel = new AphrontPanelView();
|
||||
$browse_panel->appendChild($browse_table);
|
||||
|
|
|
@ -93,6 +93,7 @@ final class DiffusionRepositoryController extends DiffusionController {
|
|||
$browse_table->setDiffusionRequest($drequest);
|
||||
$browse_table->setHandles($handles);
|
||||
$browse_table->setPaths($browse_results);
|
||||
$browse_table->setUser($this->getRequest()->getUser());
|
||||
|
||||
$browse_panel = new AphrontPanelView();
|
||||
$browse_panel->setHeader('Browse Repository');
|
||||
|
|
|
@ -20,6 +20,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
|
||||
private $paths;
|
||||
private $handles = array();
|
||||
private $user;
|
||||
|
||||
public function setPaths(array $paths) {
|
||||
assert_instances_of($paths, 'DiffusionRepositoryPath');
|
||||
|
@ -46,6 +47,11 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
return phutil_escape_html($name);
|
||||
}
|
||||
|
||||
public function setUser(PhabricatorUser $user) {
|
||||
$this->user = $user;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public static function renderLastModifiedColumns(
|
||||
PhabricatorRepository $repository,
|
||||
array $handles,
|
||||
|
@ -115,6 +121,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
|
||||
$need_pull = array();
|
||||
$rows = array();
|
||||
$show_edit = false;
|
||||
foreach ($this->paths as $path) {
|
||||
|
||||
$dir_slash = null;
|
||||
|
@ -184,8 +191,26 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
}
|
||||
}
|
||||
|
||||
$editor_button = '';
|
||||
if ($this->user) {
|
||||
$editor_link = $this->user->loadEditorLink(
|
||||
$base_path.$path->getPath(),
|
||||
1,
|
||||
$request->getRepository()->getCallsign());
|
||||
if ($editor_link) {
|
||||
$show_edit = true;
|
||||
$editor_button = phutil_render_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $editor_link,
|
||||
),
|
||||
'Edit');
|
||||
}
|
||||
}
|
||||
|
||||
$rows[] = array(
|
||||
$this->linkHistory($base_path.$path->getPath().$dir_slash),
|
||||
$editor_button,
|
||||
$browse_link,
|
||||
$dict['commit'],
|
||||
$dict['date'],
|
||||
|
@ -204,6 +229,7 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
$view->setHeaders(
|
||||
array(
|
||||
'History',
|
||||
'Edit',
|
||||
'Path',
|
||||
'Modified',
|
||||
'Date',
|
||||
|
@ -218,11 +244,24 @@ final class DiffusionBrowseTableView extends DiffusionView {
|
|||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'right',
|
||||
'',
|
||||
'',
|
||||
'wide',
|
||||
));
|
||||
$view->setColumnVisibility(
|
||||
array(
|
||||
true,
|
||||
$show_edit,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
true,
|
||||
));
|
||||
return $view->render();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue