1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-15 03:12:41 +01:00
phorge-phorge/src/applications/owners/controller/detail/PhabricatorOwnersDetailController.php

230 lines
6.3 KiB
PHP
Raw Normal View History

2011-04-03 23:48:36 +02:00
<?php
/*
* Copyright 2012 Facebook, Inc.
2011-04-03 23:48:36 +02:00
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
final class PhabricatorOwnersDetailController
extends PhabricatorOwnersController {
2011-04-03 23:48:36 +02:00
2011-04-04 04:20:47 +02:00
private $id;
private $package;
2011-04-04 04:20:47 +02:00
public function willProcessRequest(array $data) {
2011-04-04 07:03:27 +02:00
$this->id = $data['id'];
2011-04-04 04:20:47 +02:00
}
2011-04-03 23:48:36 +02:00
public function processRequest() {
2011-04-04 04:20:47 +02:00
$request = $this->getRequest();
$user = $request->getUser();
2011-04-04 07:03:27 +02:00
$package = id(new PhabricatorOwnersPackage())->load($this->id);
if (!$package) {
return new Aphront404Response();
2011-04-04 04:20:47 +02:00
}
$this->package = $package;
2011-04-04 04:20:47 +02:00
2011-04-04 07:03:27 +02:00
$paths = $package->loadPaths();
$owners = $package->loadOwners();
2011-04-04 04:20:47 +02:00
2011-04-04 07:03:27 +02:00
$phids = array();
foreach ($paths as $path) {
$phids[$path->getRepositoryPHID()] = true;
}
foreach ($owners as $owner) {
$phids[$owner->getUserPHID()] = true;
}
$phids = array_keys($phids);
2011-04-04 04:20:47 +02:00
2011-04-04 07:03:27 +02:00
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
2011-04-04 04:20:47 +02:00
2011-04-04 07:03:27 +02:00
$rows = array();
2011-04-04 04:20:47 +02:00
2011-04-04 07:03:27 +02:00
$rows[] = array(
'Name',
phutil_escape_html($package->getName()));
$rows[] = array(
'Description',
phutil_escape_html($package->getDescription()));
2011-04-04 04:20:47 +02:00
2011-04-04 07:03:27 +02:00
$primary_owner = null;
$primary_phid = $package->getPrimaryOwnerPHID();
if ($primary_phid && isset($handles[$primary_phid])) {
$primary_owner =
'<strong>'.$handles[$primary_phid]->renderLink().'</strong>';
2011-04-04 04:20:47 +02:00
}
2011-04-04 07:03:27 +02:00
$rows[] = array(
'Primary Owner',
$primary_owner,
);
$owner_links = array();
foreach ($owners as $owner) {
$owner_links[] = $handles[$owner->getUserPHID()]->renderLink();
}
$owner_links = implode('<br />', $owner_links);
$rows[] = array(
'Owners',
$owner_links);
$rows[] = array(
'Auditing',
$package->getAuditingEnabled() ? 'Enabled' : 'Disabled',
);
2011-04-04 07:03:27 +02:00
$path_links = array();
foreach ($paths as $path) {
$callsign = $handles[$path->getRepositoryPHID()]->getName();
$repo = '<strong>'.phutil_escape_html($callsign).'</strong>';
2011-04-04 07:03:27 +02:00
$path_link = phutil_render_tag(
'a',
array(
'href' => '/diffusion/'.$callsign.'/browse/:'.$path->getPath(),
),
phutil_escape_html($path->getPath()));
$path_links[] = $repo.' '.$path_link;
}
$path_links = implode('<br />', $path_links);
$rows[] = array(
'Paths',
$path_links);
2011-04-04 04:20:47 +02:00
2011-04-04 07:03:27 +02:00
$table = new AphrontTableView($rows);
$table->setColumnClasses(
2011-04-04 04:20:47 +02:00
array(
2011-04-04 07:03:27 +02:00
'header',
'wide',
2011-04-04 04:20:47 +02:00
));
$panel = new AphrontPanelView();
2011-04-04 07:03:27 +02:00
$panel->setHeader(
'Package Details for "'.phutil_escape_html($package->getName()).'"');
$panel->addButton(
javelin_render_tag(
'a',
array(
'href' => '/owners/delete/'.$package->getID().'/',
'class' => 'button grey',
'sigil' => 'workflow',
),
'Delete Package'));
$panel->addButton(
phutil_render_tag(
'a',
array(
'href' => '/owners/edit/'.$package->getID().'/',
'class' => 'button',
),
'Edit Package'));
$panel->appendChild($table);
$key = 'package/'.$package->getID();
$this->setSideNavFilter($key);
2011-04-04 04:20:47 +02:00
$commit_views = array();
$commit_uri = id(new PhutilURI('/audit/view/packagecommits/'))
->setQueryParams(
array(
'phid' => $package->getPHID(),
));
$attention_query = id(new PhabricatorAuditCommitQuery())
->withPackagePHIDs(array($package->getPHID()))
->withStatus(PhabricatorAuditCommitQuery::STATUS_OPEN)
->needCommitData(true)
->setLimit(10);
$attention_commits = $attention_query->execute();
if ($attention_commits) {
$view = new PhabricatorAuditCommitListView();
$view->setUser($user);
$view->setCommits($attention_commits);
$commit_views[] = array(
'view' => $view,
'header' => 'Commits in this Package that Need Attention',
'button' => phutil_render_tag(
'a',
array(
'href' => $commit_uri->alter('status', 'open'),
'class' => 'button grey',
),
'View All Problem Commits'),
);
}
$all_query = id(new PhabricatorAuditCommitQuery())
->withPackagePHIDs(array($package->getPHID()))
->needCommitData(true)
->setLimit(100);
$all_commits = $all_query->execute();
$view = new PhabricatorAuditCommitListView();
$view->setUser($user);
$view->setCommits($all_commits);
$view->setNoDataString('No commits in this package.');
$commit_views[] = array(
'view' => $view,
'header' => 'Recent Commits in Package',
'button' => phutil_render_tag(
'a',
array(
'href' => $commit_uri,
'class' => 'button grey',
),
'View All Package Commits'),
);
$phids = array();
foreach ($commit_views as $commit_view) {
$phids[] = $commit_view['view']->getRequiredHandlePHIDs();
}
$phids = array_mergev($phids);
$handles = id(new PhabricatorObjectHandleData($phids))->loadHandles();
$commit_panels = array();
foreach ($commit_views as $commit_view) {
$commit_panel = new AphrontPanelView();
$commit_panel->setHeader(phutil_escape_html($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;
}
2011-04-03 23:48:36 +02:00
return $this->buildStandardPageResponse(
array(
$panel,
$commit_panels,
),
2011-04-03 23:48:36 +02:00
array(
2011-04-04 07:03:27 +02:00
'title' => "Package '".$package->getName()."'",
2011-04-03 23:48:36 +02:00
));
}
protected function getExtraPackageViews() {
$package = $this->package;
return array(
array('name' => 'Details',
'key' => 'package/'.$package->getID(),
));
}
2011-04-03 23:48:36 +02:00
}