mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-20 05:42:40 +01:00
Provide detailed status information about repository state/progress
Summary: Replace the blanket "daemons not running" warning with a lot more specific detail, to try to make it easier for users to figure out how to set up repositories correctly. The next change here will add some additional status information from the daemons, so this panel can report results in greater detail. Test Plan: See screenshots. Reviewers: btrahan, chad Reviewed By: btrahan CC: aran Differential Revision: https://secure.phabricator.com/D7458
This commit is contained in:
parent
93d7a1451b
commit
2d01da14fd
4 changed files with 148 additions and 13 deletions
|
@ -96,6 +96,12 @@ abstract class DiffusionController extends PhabricatorController {
|
|||
}
|
||||
}
|
||||
|
||||
if (!$repository->isTracked()) {
|
||||
return new PhabricatorVCSResponse(
|
||||
403,
|
||||
pht('This repository is inactive.'));
|
||||
}
|
||||
|
||||
$is_push = !$this->isReadOnlyRequest($repository);
|
||||
|
||||
switch ($repository->getServeOverHTTP()) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
abstract class DiffusionRepositoryEditController
|
||||
extends DiffusionController {
|
||||
|
||||
public function buildApplicationCrumbs() {
|
||||
public function buildApplicationCrumbs($is_main = false) {
|
||||
$crumbs = parent::buildApplicationCrumbs();
|
||||
|
||||
if ($this->diffusionRequest) {
|
||||
|
@ -16,10 +16,16 @@ abstract class DiffusionRepositoryEditController
|
|||
->setName('r'.$repository->getCallsign())
|
||||
->setHref($repo_uri));
|
||||
|
||||
$crumbs->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName(pht('Edit'))
|
||||
->setHref($edit_uri));
|
||||
if ($is_main) {
|
||||
$crumbs->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName(pht('Edit Repository')));
|
||||
} else {
|
||||
$crumbs->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName(pht('Edit'))
|
||||
->setHref($edit_uri));
|
||||
}
|
||||
}
|
||||
|
||||
return $crumbs;
|
||||
|
|
|
@ -19,22 +19,20 @@ final class DiffusionRepositoryEditMainController
|
|||
$is_hg = false;
|
||||
switch ($repository->getVersionControlSystem()) {
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
|
||||
$has_local = true;
|
||||
$is_git = true;
|
||||
break;
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
||||
$has_local = $repository->isHosted();
|
||||
$is_svn = true;
|
||||
break;
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
|
||||
$has_local = true;
|
||||
$is_hg = true;
|
||||
break;
|
||||
}
|
||||
|
||||
$has_branches = ($is_git || $is_hg);
|
||||
$has_local = $repository->usesLocalWorkingCopy();
|
||||
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
$crumbs = $this->buildApplicationCrumbs($is_main = true);
|
||||
|
||||
$title = pht('Edit %s', $repository->getName());
|
||||
|
||||
|
@ -199,16 +197,16 @@ final class DiffusionRepositoryEditMainController
|
|||
->setUser($viewer)
|
||||
->setActionList($actions);
|
||||
|
||||
$view->addProperty(pht('Name'), $repository->getName());
|
||||
$view->addProperty(pht('ID'), $repository->getID());
|
||||
$view->addProperty(pht('PHID'), $repository->getPHID());
|
||||
|
||||
$type = PhabricatorRepositoryType::getNameForRepositoryType(
|
||||
$repository->getVersionControlSystem());
|
||||
|
||||
$view->addProperty(pht('Type'), $type);
|
||||
$view->addProperty(pht('Callsign'), $repository->getCallsign());
|
||||
|
||||
$view->addProperty(
|
||||
pht('Status'),
|
||||
$this->buildRepositoryStatus($repository));
|
||||
|
||||
$description = $repository->getDetail('description');
|
||||
$view->addSectionHeader(pht('Description'));
|
||||
if (!strlen($description)) {
|
||||
|
@ -562,4 +560,119 @@ final class DiffusionRepositoryEditMainController
|
|||
return $view;
|
||||
}
|
||||
|
||||
private function buildRepositoryStatus(
|
||||
PhabricatorRepository $repository) {
|
||||
|
||||
$view = new PHUIStatusListView();
|
||||
|
||||
if ($repository->isTracked()) {
|
||||
$view->addItem(
|
||||
id(new PHUIStatusItemView())
|
||||
->setIcon('accept-green')
|
||||
->setTarget(pht('Repository Active')));
|
||||
} else {
|
||||
$view->addItem(
|
||||
id(new PHUIStatusItemView())
|
||||
->setIcon('warning')
|
||||
->setTarget(pht('Repository Inactive'))
|
||||
->setNote(
|
||||
pht('Activate this repository to begin or resume import.')));
|
||||
return $view;
|
||||
}
|
||||
|
||||
$doc_href = PhabricatorEnv::getDocLink(
|
||||
'article/Managing_Daemons_with_phd.html');
|
||||
$daemon_instructions = pht(
|
||||
'Use %s to start daemons. See %s.',
|
||||
phutil_tag('tt', array(), 'bin/phd start'),
|
||||
phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $doc_href,
|
||||
),
|
||||
pht('Managing Daemons with phd')));
|
||||
|
||||
|
||||
$pull_daemon = id(new PhabricatorDaemonLogQuery())
|
||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
||||
->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE)
|
||||
->withDaemonClasses(array('PhabricatorRepositoryPullLocalDaemon'))
|
||||
->setLimit(1)
|
||||
->execute();
|
||||
|
||||
if ($pull_daemon) {
|
||||
$view->addItem(
|
||||
id(new PHUIStatusItemView())
|
||||
->setIcon('accept-green')
|
||||
->setTarget(pht('Pull Daemon Running')));
|
||||
} else {
|
||||
$view->addItem(
|
||||
id(new PHUIStatusItemView())
|
||||
->setIcon('warning-red')
|
||||
->setTarget(pht('Pull Daemon Not Running'))
|
||||
->setNote($daemon_instructions));
|
||||
}
|
||||
|
||||
|
||||
$task_daemon = id(new PhabricatorDaemonLogQuery())
|
||||
->setViewer(PhabricatorUser::getOmnipotentUser())
|
||||
->withStatus(PhabricatorDaemonLogQuery::STATUS_ALIVE)
|
||||
->withDaemonClasses(array('PhabricatorTaskmasterDaemon'))
|
||||
->setLimit(1)
|
||||
->execute();
|
||||
if ($task_daemon) {
|
||||
$view->addItem(
|
||||
id(new PHUIStatusItemView())
|
||||
->setIcon('accept-green')
|
||||
->setTarget(pht('Task Daemon Running')));
|
||||
} else {
|
||||
$view->addItem(
|
||||
id(new PHUIStatusItemView())
|
||||
->setIcon('warning-red')
|
||||
->setTarget(pht('Task Daemon Not Running'))
|
||||
->setNote($daemon_instructions));
|
||||
}
|
||||
|
||||
$local_parent = dirname($repository->getLocalPath());
|
||||
if (Filesystem::pathExists($local_parent)) {
|
||||
$view->addItem(
|
||||
id(new PHUIStatusItemView())
|
||||
->setIcon('accept-green')
|
||||
->setTarget(pht('Storage Directory OK'))
|
||||
->setNote(phutil_tag('tt', array(), $local_parent)));
|
||||
} else {
|
||||
$view->addItem(
|
||||
id(new PHUIStatusItemView())
|
||||
->setIcon('warning-red')
|
||||
->setTarget(pht('No Storage Directory'))
|
||||
->setNote(
|
||||
pht(
|
||||
'Storage directory %s does not exist, or is not readable by '.
|
||||
'the webserver. Create this directory or make it readable.',
|
||||
phutil_tag('tt', array(), $local_parent))));
|
||||
return $view;
|
||||
}
|
||||
|
||||
if ($repository->usesLocalWorkingCopy()) {
|
||||
$local_path = $repository->getLocalPath();
|
||||
if (Filesystem::pathExists($local_path)) {
|
||||
$view->addItem(
|
||||
id(new PHUIStatusItemView())
|
||||
->setIcon('accept-green')
|
||||
->setTarget(pht('Working Copy OK'))
|
||||
->setNote(phutil_tag('tt', array(), $local_path)));
|
||||
} else {
|
||||
$view->addItem(
|
||||
id(new PHUIStatusItemView())
|
||||
->setIcon('time-orange')
|
||||
->setTarget(pht('No Working Copy Yet'))
|
||||
->setNote(
|
||||
pht('Waiting for daemons to build a working copy.')));
|
||||
return $view;
|
||||
}
|
||||
}
|
||||
|
||||
return $view;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -805,6 +805,16 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
|
|||
}
|
||||
}
|
||||
|
||||
public function usesLocalWorkingCopy() {
|
||||
switch ($this->getVersionControlSystem()) {
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_SVN:
|
||||
return $this->isHosted();
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_GIT:
|
||||
case PhabricatorRepositoryType::REPOSITORY_TYPE_MERCURIAL:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* -( PhabricatorPolicyInterface )----------------------------------------- */
|
||||
|
||||
|
|
Loading…
Reference in a new issue