public function processRequest() { $request = $this->getRequest(); $edit_query = new HeraldEditLogQuery(); if ($this->id) { $edit_query->withRuleIDs(array($this->id)); } $pager = new AphrontPagerView(); $pager->setURI($request->getRequestURI(), 'offset'); $pager->setOffset($request->getStr('offset')); $edits = $edit_query->executeWithOffsetPager($pager); $need_phids = mpull($edits, 'getEditorPHID'); $handles = $this->loadViewerHandles($need_phids); $list_view = id(new HeraldRuleEditHistoryView())->setEdits($edits)->setHandles($handles)->setUser($this->getRequest()->getUser()); $panel = new AphrontPanelView(); $panel->setHeader(pht('Edit History')); $panel->appendChild($list_view); $panel->setNoBackground(); $crumbs = $this->buildApplicationCrumbs($can_create = false)->addTextCrumb(pht('Edit History'), $this->getApplicationURI('herald/history')); $nav = $this->buildSideNavView(); $nav->selectFilter('history'); $nav->appendChild($panel); $nav->setCrumbs($crumbs); return $this->buildApplicationPage($nav, array('title' => pht('Rule Edit History'))); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $log = id(new PhabricatorDaemonLogQuery())->setViewer($user)->withIDs(array($this->id))->setAllowStatusWrites(true)->executeOne(); if (!$log) { return new Aphront404Response(); } $events = id(new PhabricatorDaemonLogEvent())->loadAllWhere('logID = %d ORDER BY id DESC LIMIT 1000', $log->getID()); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Daemon %s', $log->getID())); $header = id(new PHUIHeaderView())->setHeader($log->getDaemon()); $tag = id(new PHUITagView())->setType(PHUITagView::TYPE_STATE); $status = $log->getStatus(); switch ($status) { case PhabricatorDaemonLog::STATUS_UNKNOWN: $tag->setBackgroundColor(PHUITagView::COLOR_ORANGE); $tag->setName(pht('Unknown')); break; case PhabricatorDaemonLog::STATUS_RUNNING: $tag->setBackgroundColor(PHUITagView::COLOR_GREEN); $tag->setName(pht('Running')); break; case PhabricatorDaemonLog::STATUS_DEAD: $tag->setBackgroundColor(PHUITagView::COLOR_RED); $tag->setName(pht('Dead')); break; case PhabricatorDaemonLog::STATUS_WAIT: $tag->setBackgroundColor(PHUITagView::COLOR_BLUE); $tag->setName(pht('Waiting')); break; case PhabricatorDaemonLog::STATUS_EXITING: $tag->setBackgroundColor(PHUITagView::COLOR_YELLOW); $tag->setName(pht('Exiting')); break; case PhabricatorDaemonLog::STATUS_EXITED: $tag->setBackgroundColor(PHUITagView::COLOR_GREY); $tag->setName(pht('Exited')); break; } $header->addTag($tag); $env_hash = PhabricatorEnv::calculateEnvironmentHash(); if ($log->getEnvHash() != $env_hash) { $tag = id(new PHUITagView())->setType(PHUITagView::TYPE_STATE)->setBackgroundColor(PHUITagView::COLOR_YELLOW)->setName(pht('Stale Config')); $header->addTag($tag); } $properties = $this->buildPropertyListView($log); $event_view = id(new PhabricatorDaemonLogEventsView())->setUser($user)->setEvents($events); $event_panel = new AphrontPanelView(); $event_panel->setNoBackground(); $event_panel->appendChild($event_view); $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties); return $this->buildApplicationPage(array($crumbs, $object_box, $event_panel), array('title' => pht('Daemon Log'), 'device' => false)); }
public function processRequest() { $drequest = $this->diffusionRequest; $results = $this->getBrowseQueryResults(); $reason = $results->getReasonForEmptyResultSet(); $content = array(); $actions = $this->buildActionView($drequest); $properties = $this->buildPropertyView($drequest, $actions); $object_box = id(new PHUIObjectBoxView())->setHeader($this->buildHeaderView($drequest))->addPropertyList($properties); $content[] = $object_box; $content[] = $this->renderSearchForm($collapsed = true); if (!$results->isValidResults()) { $empty_result = new DiffusionEmptyResultView(); $empty_result->setDiffusionRequest($drequest); $empty_result->setDiffusionBrowseResultSet($results); $empty_result->setView($this->getRequest()->getStr('view')); $content[] = $empty_result; } else { $phids = array(); foreach ($results->getPaths() as $result) { $data = $result->getLastCommitData(); if ($data) { if ($data->getCommitDetail('authorPHID')) { $phids[$data->getCommitDetail('authorPHID')] = true; } } } $phids = array_keys($phids); $handles = $this->loadViewerHandles($phids); $browse_table = new DiffusionBrowseTableView(); $browse_table->setDiffusionRequest($drequest); $browse_table->setHandles($handles); $browse_table->setPaths($results->getPaths()); $browse_table->setUser($this->getRequest()->getUser()); $browse_panel = new AphrontPanelView(); $browse_panel->appendChild($browse_table); $browse_panel->setNoBackground(); $content[] = $browse_panel; } $content[] = $this->buildOpenRevisions(); $readme = $this->callConduitWithDiffusionRequest('diffusion.readmequery', array('paths' => $results->getPathDicts(), 'commit' => $drequest->getStableCommit())); if ($readme) { $box = new PHUIBoxView(); $box->appendChild($readme); $box->addPadding(PHUI::PADDING_LARGE); $object_box = id(new PHUIObjectBoxView())->setHeaderText(pht('README'))->appendChild($box); $content[] = $object_box; } $crumbs = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'browse')); return $this->buildApplicationPage(array($crumbs, $content), array('title' => array(nonempty(basename($drequest->getPath()), '/'), $drequest->getRepository()->getCallsign() . ' Repository'))); }
public function processRequest() { $request = $this->getRequest(); $event = id(new PhabricatorDaemonLogEvent())->load($this->id); if (!$event) { return new Aphront404Response(); } $event_view = id(new PhabricatorDaemonLogEventsView())->setEvents(array($event))->setUser($request->getUser())->setCombinedLog(true)->setShowFullMessage(true); $log_panel = new AphrontPanelView(); $log_panel->appendChild($event_view); $log_panel->setNoBackground(); $daemon_id = $event->getLogID(); $crumbs = $this->buildApplicationCrumbs()->addTextCrumb(pht('Daemon %s', $daemon_id), $this->getApplicationURI("log/{$daemon_id}/"))->addTextCrumb(pht('Event %s', $event->getID())); return $this->buildApplicationPage(array($crumbs, $log_panel), array('title' => pht('Combined Daemon Log'), 'device' => false)); }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $is_admin = $user->getIsAdmin(); $repos = id(new PhabricatorRepositoryQuery())->setViewer($user)->execute(); $repos = msort($repos, 'getName'); $rows = array(); foreach ($repos as $repo) { if ($repo->isTracked()) { $diffusion_link = phutil_tag('a', array('href' => '/diffusion/' . $repo->getCallsign() . '/'), 'View in Diffusion'); } else { $diffusion_link = phutil_tag('em', array(), 'Not Tracked'); } $rows[] = array($repo->getCallsign(), $repo->getName(), PhabricatorRepositoryType::getNameForRepositoryType($repo->getVersionControlSystem()), $diffusion_link, phutil_tag('a', array('class' => 'button small grey', 'href' => '/diffusion/' . $repo->getCallsign() . '/edit/'), 'Edit')); } $table = new AphrontTableView($rows); $table->setHeaders(array('Callsign', 'Repository', 'Type', 'Diffusion', '')); $table->setColumnClasses(array(null, 'wide', null, null, 'action')); $table->setColumnVisibility(array(true, true, true, true, $is_admin)); $panel = new AphrontPanelView(); $panel->setHeader('Repositories'); if ($is_admin) { $panel->setCreateButton('Create New Repository', '/diffusion/new/'); } $panel->appendChild($table); $panel->setNoBackground(); $projects = id(new PhabricatorRepositoryArcanistProject())->loadAll(); $rows = array(); foreach ($projects as $project) { $repo = idx($repos, $project->getRepositoryID()); if ($repo) { $repo_name = $repo->getName(); } else { $repo_name = '-'; } $rows[] = array($project->getName(), $repo_name, phutil_tag('a', array('href' => '/repository/project/edit/' . $project->getID() . '/', 'class' => 'button grey small'), 'Edit'), javelin_tag('a', array('href' => '/repository/project/delete/' . $project->getID() . '/', 'class' => 'button grey small', 'sigil' => 'workflow'), 'Delete')); } $project_table = new AphrontTableView($rows); $project_table->setHeaders(array('Project ID', 'Repository', '', '')); $project_table->setColumnClasses(array('', 'wide', 'action', 'action')); $project_table->setColumnVisibility(array(true, true, $is_admin, $is_admin)); $project_panel = new AphrontPanelView(); $project_panel->setHeader('Arcanist Projects'); $project_panel->appendChild($project_table); $project_panel->setNoBackground(); return $this->buildStandardPageResponse(array($panel, $project_panel), array('title' => 'Repository List')); }
public function processRequest() { $drequest = $this->diffusionRequest; $request = $this->getRequest(); $viewer = $request->getUser(); $repository = $drequest->getRepository(); $page_size = $request->getInt('pagesize', 100); $offset = $request->getInt('offset', 0); $params = array('commit' => $drequest->getCommit(), 'path' => $drequest->getPath(), 'offset' => $offset, 'limit' => $page_size + 1); if (!$request->getBool('copies')) { $params['needDirectChanges'] = true; $params['needChildChanges'] = true; } $history_results = $this->callConduitWithDiffusionRequest('diffusion.historyquery', $params); $history = DiffusionPathChange::newFromConduit($history_results['pathChanges']); $pager = new AphrontPagerView(); $pager->setPageSize($page_size); $pager->setOffset($offset); $history = $pager->sliceResults($history); $pager->setURI($request->getRequestURI(), 'offset'); $show_graph = !strlen($drequest->getPath()); $content = array(); $history_table = new DiffusionHistoryTableView(); $history_table->setUser($request->getUser()); $history_table->setDiffusionRequest($drequest); $history_table->setHistory($history); $history_table->loadRevisions(); $phids = $history_table->getRequiredHandlePHIDs(); $handles = $this->loadViewerHandles($phids); $history_table->setHandles($handles); if ($show_graph) { $history_table->setParents($history_results['parents']); $history_table->setIsHead($offset == 0); } $history_panel = new AphrontPanelView(); $history_panel->appendChild($history_table); $history_panel->appendChild($pager); $history_panel->setNoBackground(); $content[] = $history_panel; $header = id(new PHUIHeaderView())->setUser($viewer)->setPolicyObject($repository)->setHeader($this->renderPathLinks($drequest, $mode = 'history')); $actions = $this->buildActionView($drequest); $properties = $this->buildPropertyView($drequest, $actions); $object_box = id(new PHUIObjectBoxView())->setHeader($header)->addPropertyList($properties); $crumbs = $this->buildCrumbs(array('branch' => true, 'path' => true, 'view' => 'history')); return $this->buildApplicationPage(array($crumbs, $object_box, $content), array('title' => array(pht('History'), pht('%s Repository', $drequest->getRepository()->getCallsign())))); }
public function buildCommitPanel() { $request = $this->getRequest(); $user = $request->getUser(); $phids = array($user->getPHID()); $query = id(new DiffusionCommitQuery())->setViewer($user)->withAuthorPHIDs($phids)->withAuditStatus(DiffusionCommitQuery::AUDIT_STATUS_CONCERN)->needCommitData(true)->needAuditRequests(true)->setLimit(10); $commits = $query->execute(); if (!$commits) { return $this->renderMinipanel('No Problem Commits', 'No one has raised concerns with your commits.'); } $view = id(new PhabricatorAuditListView())->setCommits($commits)->setUser($user); $phids = $view->getRequiredHandlePHIDs(); $handles = $this->loadViewerHandles($phids); $view->setHandles($handles); $title = pht('Problem Commits'); $href = '/audit/'; $panel = new AphrontPanelView(); $panel->setHeader($this->renderSectionHeader($title, $href)); $panel->appendChild($view); $panel->setNoBackground(); return $panel; }
private function buildMergesTable(PhabricatorRepositoryCommit $commit) { $drequest = $this->getDiffusionRequest(); $limit = 50; $merges = array(); try { $merges = $this->callConduitWithDiffusionRequest('diffusion.mergedcommitsquery', array('commit' => $drequest->getCommit(), 'limit' => $limit + 1)); } catch (ConduitException $ex) { if ($ex->getMessage() != 'ERR-UNSUPPORTED-VCS') { throw $ex; } } if (!$merges) { return null; } $caption = null; if (count($merges) > $limit) { $merges = array_slice($merges, 0, $limit); $caption = "This commit merges more than {$limit} changes. Only the first " . "{$limit} are shown."; } $history_table = new DiffusionHistoryTableView(); $history_table->setUser($this->getRequest()->getUser()); $history_table->setDiffusionRequest($drequest); $history_table->setHistory($merges); $history_table->loadRevisions(); $phids = $history_table->getRequiredHandlePHIDs(); $handles = $this->loadViewerHandles($phids); $history_table->setHandles($handles); $panel = new AphrontPanelView(); $panel->setHeader(pht('Merged Changes')); $panel->setCaption($caption); $panel->appendChild($history_table); $panel->setNoBackground(); return $panel; }
private function renderPackageTable(array $packages, $header, $nodata) { assert_instances_of($packages, 'PhabricatorOwnersPackage'); if ($packages) { $package_ids = mpull($packages, 'getID'); $owners = id(new PhabricatorOwnersOwner())->loadAllWhere('packageID IN (%Ld)', $package_ids); $paths = id(new PhabricatorOwnersPath())->loadAllWhere('packageID in (%Ld)', $package_ids); $phids = array(); foreach ($owners as $owner) { $phids[$owner->getUserPHID()] = true; } $phids = array_keys($phids); $handles = $this->loadViewerHandles($phids); $repository_phids = array(); foreach ($paths as $path) { $repository_phids[$path->getRepositoryPHID()] = true; } if ($repository_phids) { $repositories = id(new PhabricatorRepositoryQuery())->setViewer($this->getRequest()->getUser())->withPHIDs(array_keys($repository_phids))->execute(); } else { $repositories = array(); } $repositories = mpull($repositories, null, 'getPHID'); $owners = mgroup($owners, 'getPackageID'); $paths = mgroup($paths, 'getPackageID'); } else { $handles = array(); $repositories = array(); $owners = array(); $paths = array(); } $rows = array(); foreach ($packages as $package) { $pkg_owners = idx($owners, $package->getID(), array()); foreach ($pkg_owners as $key => $owner) { $pkg_owners[$key] = $handles[$owner->getUserPHID()]->renderLink(); if ($owner->getUserPHID() == $package->getPrimaryOwnerPHID()) { $pkg_owners[$key] = phutil_tag('strong', array(), $pkg_owners[$key]); } } $pkg_owners = phutil_implode_html(phutil_tag('br'), $pkg_owners); $pkg_paths = idx($paths, $package->getID(), array()); foreach ($pkg_paths as $key => $path) { $repo = idx($repositories, $path->getRepositoryPHID()); if ($repo) { $href = DiffusionRequest::generateDiffusionURI(array('callsign' => $repo->getCallsign(), 'branch' => $repo->getDefaultBranch(), 'path' => $path->getPath(), 'action' => 'browse')); $pkg_paths[$key] = hsprintf('%s %s%s', $path->getExcluded() ? "–" : '+', phutil_tag('strong', array(), $repo->getName()), phutil_tag('a', array('href' => (string) $href), $path->getPath())); } else { $pkg_paths[$key] = $path->getPath(); } } $pkg_paths = phutil_implode_html(phutil_tag('br'), $pkg_paths); $rows[] = array(phutil_tag('a', array('href' => '/owners/package/' . $package->getID() . '/'), $package->getName()), $pkg_owners, $pkg_paths, phutil_tag('a', array('href' => '/audit/view/packagecommits/?phid=' . $package->getPHID()), pht('Related Commits'))); } $table = new AphrontTableView($rows); $table->setHeaders(array(pht('Name'), pht('Owners'), pht('Paths'), pht('Related Commits'))); $table->setColumnClasses(array('pri', '', 'wide wrap', 'narrow')); $panel = new AphrontPanelView(); $panel->setHeader($header); $panel->appendChild($table); $panel->setNoBackground(); return $panel; }
public function processRequest() { $request = $this->getRequest(); $user = $request->getUser(); $package = id(new PhabricatorOwnersPackage())->load($this->id); if (!$package) { return new Aphront404Response(); } $this->package = $package; $paths = $package->loadPaths(); $owners = $package->loadOwners(); $repository_phids = array(); foreach ($paths as $path) { $repository_phids[$path->getRepositoryPHID()] = true; } if ($repository_phids) { $repositories = id(new PhabricatorRepositoryQuery())->setViewer($user)->withPHIDs(array_keys($repository_phids))->execute(); $repositories = mpull($repositories, null, 'getPHID'); } else { $repositories = array(); } $phids = array(); foreach ($owners as $owner) { $phids[$owner->getUserPHID()] = true; } $phids = array_keys($phids); $handles = $this->loadViewerHandles($phids); $rows = array(); $rows[] = array(pht('Name'), $package->getName()); $rows[] = array(pht('Description'), $package->getDescription()); $primary_owner = null; $primary_phid = $package->getPrimaryOwnerPHID(); if ($primary_phid && isset($handles[$primary_phid])) { $primary_owner = phutil_tag('strong', array(), $handles[$primary_phid]->renderLink()); } $rows[] = array(pht('Primary Owner'), $primary_owner); $owner_links = array(); foreach ($owners as $owner) { $owner_links[] = $handles[$owner->getUserPHID()]->renderLink(); } $owner_links = phutil_implode_html(phutil_tag('br'), $owner_links); $rows[] = array(pht('Owners'), $owner_links); $rows[] = array(pht('Auditing'), $package->getAuditingEnabled() ? pht('Enabled') : pht('Disabled')); $path_links = array(); foreach ($paths as $path) { $repo = idx($repositories, $path->getRepositoryPHID()); if (!$repo) { continue; } $href = DiffusionRequest::generateDiffusionURI(array('callsign' => $repo->getCallsign(), 'branch' => $repo->getDefaultBranch(), 'path' => $path->getPath(), 'action' => 'browse')); $repo_name = phutil_tag('strong', array(), $repo->getName()); $path_link = phutil_tag('a', array('href' => (string) $href), $path->getPath()); $path_links[] = hsprintf('%s %s %s', $path->getExcluded() ? "–" : '+', $repo_name, $path_link); } $path_links = phutil_implode_html(phutil_tag('br'), $path_links); $rows[] = array(pht('Paths'), $path_links); $table = new AphrontTableView($rows); $table->setColumnClasses(array('header', 'wide')); $panel = new AphrontPanelView(); $panel->setNoBackground(); $panel->setHeader(pht('Package Details for "%s"', $package->getName())); $panel->addButton(javelin_tag('a', array('href' => '/owners/delete/' . $package->getID() . '/', 'class' => 'button grey', 'sigil' => 'workflow'), pht('Delete Package'))); $panel->addButton(phutil_tag('a', array('href' => '/owners/edit/' . $package->getID() . '/', 'class' => 'button'), pht('Edit Package'))); $panel->appendChild($table); $key = 'package/' . $package->getID(); $this->setSideNavFilter($key); $commit_views = array(); $commit_uri = id(new PhutilURI('/audit/view/packagecommits/'))->setQueryParams(array('phid' => $package->getPHID())); $attention_commits = id(new DiffusionCommitQuery())->setViewer($request->getUser())->withAuditorPHIDs(array($package->getPHID()))->withAuditStatus(DiffusionCommitQuery::AUDIT_STATUS_CONCERN)->needCommitData(true)->setLimit(10)->execute(); if ($attention_commits) { $view = id(new PhabricatorAuditListView())->setUser($user)->setCommits($attention_commits); $commit_views[] = array('view' => $view, 'header' => pht('Commits in this Package that Need Attention'), 'button' => phutil_tag('a', array('href' => $commit_uri->alter('status', 'open'), 'class' => 'button grey'), pht('View All Problem Commits'))); } $all_commits = id(new DiffusionCommitQuery())->setViewer($request->getUser())->withAuditorPHIDs(array($package->getPHID()))->needCommitData(true)->setLimit(100)->execute(); $view = id(new PhabricatorAuditListView())->setUser($user)->setCommits($all_commits)->setNoDataString(pht('No commits in this package.')); $commit_views[] = array('view' => $view, 'header' => pht('Recent Commits in Package'), 'button' => phutil_tag('a', array('href' => $commit_uri, 'class' => 'button grey'), pht('View All Package Commits'))); $phids = array(); foreach ($commit_views as $commit_view) { $phids[] = $commit_view['view']->getRequiredHandlePHIDs(); } $phids = array_mergev($phids); $handles = $this->loadViewerHandles($phids); $commit_panels = array(); foreach ($commit_views as $commit_view) { $commit_panel = new AphrontPanelView(); $commit_panel->setNoBackground(); $commit_panel->setHeader($commit_view['header']); if (isset($commit_view['button'])) { $commit_panel->addButton($commit_view['button']); } $commit_view['view']->setHandles($handles); $commit_panel->appendChild($commit_view['view']); $commit_panels[] = $commit_panel; } $nav = $this->buildSideNavView(); $nav->appendChild($panel); $nav->appendChild($commit_panels); return $this->buildApplicationPage(array($nav), array('title' => pht('Package %s', $package->getName()))); }