1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-11 07:11:04 +01:00

Modernize Owners

Summary: phts, crumbs, dust, standard navs.

Test Plan: Used owners on web and mobile.

Reviewers: epriestley, btrahan

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D5980
This commit is contained in:
Chad Little 2013-05-21 15:31:24 -07:00
parent 4a901c788d
commit 470999caf6
6 changed files with 143 additions and 125 deletions

View file

@ -11,7 +11,7 @@ final class PhabricatorApplicationOwners extends PhabricatorApplication {
} }
public function getShortDescription() { public function getShortDescription() {
return 'Group Source Code'; return pht('Group Source Code');
} }
public function getTitleGlyph() { public function getTitleGlyph() {

View file

@ -12,30 +12,39 @@ abstract class PhabricatorOwnersController extends PhabricatorController {
return $this; return $this;
} }
public function buildStandardPageResponse($view, array $data) { public function buildSideNavView() {
$nav = new AphrontSideNavFilterView();
$base_uri = new PhutilURI('/owners/');
$nav->setBaseURI($base_uri);
$page = $this->buildStandardPageView(); $nav->addLabel(pht('Packages'));
$this->getExtraPackageViews($nav);
$nav->addFilter('view/owned', pht('Owned'));
$nav->addFilter('view/projects', pht('Projects'));
$nav->addFilter('view/all', pht('All'));
$page->setApplicationName('Owners'); $nav->selectFilter($this->getSideNavFilter(), 'view/owned');
$page->setBaseURI('/owners/');
$page->setTitle(idx($data, 'title'));
$page->setGlyph("\xE2\x98\x81");
$nav = $this->renderSideNav();
$nav->appendChild($view);
$page->appendChild($nav);
$filter = $nav->getSelectedFilter(); $filter = $nav->getSelectedFilter();
switch ($filter) { switch ($filter) {
case 'view/owned': case 'view/owned':
case 'view/all':
$crumbs = $this->buildApplicationCrumbs();
if ($filter == 'view/owned') {
$title = pht('Owned Packages'); $title = pht('Owned Packages');
} else { break;
case 'view/all':
$title = pht('All Packages'); $title = pht('All Packages');
break;
case 'view/projects':
$title = pht('Projects');
break;
case 'new':
$title = pht('New Package');
break;
default:
$title = pht('Package');
break;
} }
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb( $crumbs->addCrumb(
id(new PhabricatorCrumbView()) id(new PhabricatorCrumbView())
->setName($title)); ->setName($title));
@ -47,29 +56,14 @@ abstract class PhabricatorOwnersController extends PhabricatorController {
->setIcon('create')); ->setIcon('create'));
$nav->setCrumbs($crumbs); $nav->setCrumbs($crumbs);
break;
}
$response = new AphrontWebpageResponse();
return $response->setContent($page->render());
}
public function renderSideNav() {
$nav = new AphrontSideNavFilterView();
$base_uri = new PhutilURI('/owners/');
$nav->setBaseURI($base_uri);
$nav->addLabel('Packages');
$this->getExtraPackageViews($nav);
$nav->addFilter('view/owned', 'Owned');
$nav->addFilter('view/projects', 'Projects');
$nav->addFilter('view/all', 'All');
$nav->selectFilter($this->getSideNavFilter(), 'view/owned');
return $nav; return $nav;
} }
public function buildApplicationMenu() {
return $this->buildSideNavView()->getMenu();
}
protected function getExtraPackageViews(AphrontSideNavFilterView $view) { protected function getExtraPackageViews(AphrontSideNavFilterView $view) {
return; return;
} }

View file

@ -24,14 +24,16 @@ final class PhabricatorOwnersDeleteController
return id(new AphrontRedirectResponse())->setURI('/owners/'); return id(new AphrontRedirectResponse())->setURI('/owners/');
} }
$text = pht('Are you sure you want to delete the "%s" package? This '.
'operation can not be undone.', $package->getName());
$dialog = id(new AphrontDialogView()) $dialog = id(new AphrontDialogView())
->setUser($user) ->setUser($user)
->setTitle('Really delete this package?') ->setTitle('Really delete this package?')
->setHeaderColor(PhabricatorActionHeaderView::HEADER_RED)
->appendChild(hsprintf( ->appendChild(hsprintf(
'<p>Are you sure you want to delete the "%s" package? This operation '. '<p>%s</p>',
'can not be undone.</p>', $text))
$package->getName())) ->addSubmitButton(pht('Delete'))
->addSubmitButton('Delete')
->addCancelButton('/owners/package/'.$package->getID().'/') ->addCancelButton('/owners/package/'.$package->getID().'/')
->setSubmitURI($request->getRequestURI()); ->setSubmitURI($request->getRequestURI());

View file

@ -47,8 +47,8 @@ final class PhabricatorOwnersDetailController
$rows = array(); $rows = array();
$rows[] = array('Name', $package->getName()); $rows[] = array(pht('Name'), $package->getName());
$rows[] = array('Description', $package->getDescription()); $rows[] = array(pht('Description'), $package->getDescription());
$primary_owner = null; $primary_owner = null;
$primary_phid = $package->getPrimaryOwnerPHID(); $primary_phid = $package->getPrimaryOwnerPHID();
@ -58,18 +58,20 @@ final class PhabricatorOwnersDetailController
array(), array(),
$handles[$primary_phid]->renderLink()); $handles[$primary_phid]->renderLink());
} }
$rows[] = array('Primary Owner', $primary_owner); $rows[] = array(pht('Primary Owner'), $primary_owner);
$owner_links = array(); $owner_links = array();
foreach ($owners as $owner) { foreach ($owners as $owner) {
$owner_links[] = $handles[$owner->getUserPHID()]->renderLink(); $owner_links[] = $handles[$owner->getUserPHID()]->renderLink();
} }
$owner_links = phutil_implode_html(phutil_tag('br'), $owner_links); $owner_links = phutil_implode_html(phutil_tag('br'), $owner_links);
$rows[] = array('Owners', $owner_links); $rows[] = array(pht('Owners'), $owner_links);
$rows[] = array( $rows[] = array(
'Auditing', pht('Auditing'),
$package->getAuditingEnabled() ? 'Enabled' : 'Disabled', $package->getAuditingEnabled() ?
pht('Enabled') :
pht('Disabled'),
); );
$path_links = array(); $path_links = array();
@ -99,7 +101,7 @@ final class PhabricatorOwnersDetailController
$path_link); $path_link);
} }
$path_links = phutil_implode_html(phutil_tag('br'), $path_links); $path_links = phutil_implode_html(phutil_tag('br'), $path_links);
$rows[] = array('Paths', $path_links); $rows[] = array(pht('Paths'), $path_links);
$table = new AphrontTableView($rows); $table = new AphrontTableView($rows);
$table->setColumnClasses( $table->setColumnClasses(
@ -109,7 +111,9 @@ final class PhabricatorOwnersDetailController
)); ));
$panel = new AphrontPanelView(); $panel = new AphrontPanelView();
$panel->setHeader('Package Details for "'.$package->getName().'"'); $panel->setNoBackground();
$panel->setHeader(
pht('Package Details for "%s"', $package->getName()));
$panel->addButton( $panel->addButton(
javelin_tag( javelin_tag(
'a', 'a',
@ -118,7 +122,7 @@ final class PhabricatorOwnersDetailController
'class' => 'button grey', 'class' => 'button grey',
'sigil' => 'workflow', 'sigil' => 'workflow',
), ),
'Delete Package')); pht('Delete Package')));
$panel->addButton( $panel->addButton(
phutil_tag( phutil_tag(
'a', 'a',
@ -126,7 +130,7 @@ final class PhabricatorOwnersDetailController
'href' => '/owners/edit/'.$package->getID().'/', 'href' => '/owners/edit/'.$package->getID().'/',
'class' => 'button', 'class' => 'button',
), ),
'Edit Package')); pht('Edit Package')));
$panel->appendChild($table); $panel->appendChild($table);
$key = 'package/'.$package->getID(); $key = 'package/'.$package->getID();
@ -154,14 +158,14 @@ final class PhabricatorOwnersDetailController
$commit_views[] = array( $commit_views[] = array(
'view' => $view, 'view' => $view,
'header' => 'Commits in this Package that Need Attention', 'header' => pht('Commits in this Package that Need Attention'),
'button' => phutil_tag( 'button' => phutil_tag(
'a', 'a',
array( array(
'href' => $commit_uri->alter('status', 'open'), 'href' => $commit_uri->alter('status', 'open'),
'class' => 'button grey', 'class' => 'button grey',
), ),
'View All Problem Commits'), pht('View All Problem Commits')),
); );
} }
@ -175,18 +179,18 @@ final class PhabricatorOwnersDetailController
$view = new PhabricatorAuditCommitListView(); $view = new PhabricatorAuditCommitListView();
$view->setUser($user); $view->setUser($user);
$view->setCommits($all_commits); $view->setCommits($all_commits);
$view->setNoDataString('No commits in this package.'); $view->setNoDataString(pht('No commits in this package.'));
$commit_views[] = array( $commit_views[] = array(
'view' => $view, 'view' => $view,
'header' => 'Recent Commits in Package', 'header' => pht('Recent Commits in Package'),
'button' => phutil_tag( 'button' => phutil_tag(
'a', 'a',
array( array(
'href' => $commit_uri, 'href' => $commit_uri,
'class' => 'button grey', 'class' => 'button grey',
), ),
'View All Package Commits'), pht('View All Package Commits')),
); );
$phids = array(); $phids = array();
@ -199,6 +203,7 @@ final class PhabricatorOwnersDetailController
$commit_panels = array(); $commit_panels = array();
foreach ($commit_views as $commit_view) { foreach ($commit_views as $commit_view) {
$commit_panel = new AphrontPanelView(); $commit_panel = new AphrontPanelView();
$commit_panel->setNoBackground();
$commit_panel->setHeader($commit_view['header']); $commit_panel->setHeader($commit_view['header']);
if (isset($commit_view['button'])) { if (isset($commit_view['button'])) {
$commit_panel->addButton($commit_view['button']); $commit_panel->addButton($commit_view['button']);
@ -209,19 +214,24 @@ final class PhabricatorOwnersDetailController
$commit_panels[] = $commit_panel; $commit_panels[] = $commit_panel;
} }
return $this->buildStandardPageResponse( $nav = $this->buildSideNavView();
$nav->appendChild($panel);
$nav->appendChild($commit_panels);
return $this->buildApplicationPage(
array( array(
$panel, $nav,
$commit_panels,
), ),
array( array(
'title' => "Package '".$package->getName()."'", 'title' => pht("Package %s", $package->getName()),
'dust' => true,
'device' => true,
)); ));
} }
protected function getExtraPackageViews(AphrontSideNavFilterView $view) { protected function getExtraPackageViews(AphrontSideNavFilterView $view) {
$package = $this->package; $package = $this->package;
$view->addFilter('package/'.$package->getID(), 'Details'); $view->addFilter('package/'.$package->getID(), pht('Details'));
} }
} }

View file

@ -65,21 +65,21 @@ final class PhabricatorOwnersEditController
} }
if (!strlen($package->getName())) { if (!strlen($package->getName())) {
$e_name = 'Required'; $e_name = pht('Required');
$errors[] = 'Package name is required.'; $errors[] = pht('Package name is required.');
} else { } else {
$e_name = null; $e_name = null;
} }
if (!$package->getPrimaryOwnerPHID()) { if (!$package->getPrimaryOwnerPHID()) {
$e_primary = 'Required'; $e_primary = pht('Required');
$errors[] = 'Package must have a primary owner.'; $errors[] = pht('Package must have a primary owner.');
} else { } else {
$e_primary = null; $e_primary = null;
} }
if (!$path_refs) { if (!$path_refs) {
$errors[] = 'Package must include at least one path.'; $errors[] = pht('Package must include at least one path.');
} }
if (!$errors) { if (!$errors) {
@ -93,8 +93,8 @@ final class PhabricatorOwnersEditController
return id(new AphrontRedirectResponse()) return id(new AphrontRedirectResponse())
->setURI('/owners/package/'.$package->getID().'/'); ->setURI('/owners/package/'.$package->getID().'/');
} catch (AphrontQueryDuplicateKeyException $ex) { } catch (AphrontQueryDuplicateKeyException $ex) {
$e_name = 'Duplicate'; $e_name = pht('Duplicate');
$errors[] = 'Package name must be unique.'; $errors[] = pht('Package name must be unique.');
} }
} }
} else { } else {
@ -115,7 +115,7 @@ final class PhabricatorOwnersEditController
$error_view = null; $error_view = null;
if ($errors) { if ($errors) {
$error_view = new AphrontErrorView(); $error_view = new AphrontErrorView();
$error_view->setTitle('Package Errors'); $error_view->setTitle(pht('Package Errors'));
$error_view->setErrors($errors); $error_view->setErrors($errors);
} }
@ -184,14 +184,14 @@ final class PhabricatorOwnersEditController
->setFlexible(true) ->setFlexible(true)
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel('Name') ->setLabel(pht('Name'))
->setName('name') ->setName('name')
->setValue($package->getName()) ->setValue($package->getName())
->setError($e_name)) ->setError($e_name))
->appendChild( ->appendChild(
id(new AphrontFormTokenizerControl()) id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/usersorprojects/') ->setDatasource('/typeahead/common/usersorprojects/')
->setLabel('Primary Owner') ->setLabel(pht('Primary Owner'))
->setName('primary') ->setName('primary')
->setLimit(1) ->setLimit(1)
->setValue($token_primary_owner) ->setValue($token_primary_owner)
@ -199,20 +199,21 @@ final class PhabricatorOwnersEditController
->appendChild( ->appendChild(
id(new AphrontFormTokenizerControl()) id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/usersorprojects/') ->setDatasource('/typeahead/common/usersorprojects/')
->setLabel('Owners') ->setLabel(pht('Owners'))
->setName('owners') ->setName('owners')
->setValue($token_all_owners)) ->setValue($token_all_owners))
->appendChild( ->appendChild(
id(new AphrontFormSelectControl()) id(new AphrontFormSelectControl())
->setName('auditing') ->setName('auditing')
->setLabel('Auditing') ->setLabel(pht('Auditing'))
->setCaption('With auditing enabled, all future commits that touch '. ->setCaption(
pht('With auditing enabled, all future commits that touch '.
'this package will be reviewed to make sure an owner '. 'this package will be reviewed to make sure an owner '.
'of the package is involved and the commit message has '. 'of the package is involved and the commit message has '.
'a valid revision, reviewed by, and author.') 'a valid revision, reviewed by, and author.'))
->setOptions(array( ->setOptions(array(
'disabled' => 'Disabled', 'disabled' => pht('Disabled'),
'enabled' => 'Enabled', 'enabled' => pht('Enabled'),
)) ))
->setValue( ->setValue(
$package->getAuditingEnabled() $package->getAuditingEnabled()
@ -220,7 +221,7 @@ final class PhabricatorOwnersEditController
: 'disabled')) : 'disabled'))
->appendChild( ->appendChild(
id(new AphrontFormInsetView()) id(new AphrontFormInsetView())
->setTitle('Paths') ->setTitle(pht('Paths'))
->addDivAttributes(array('id' => 'path-editor')) ->addDivAttributes(array('id' => 'path-editor'))
->setRightButton(javelin_tag( ->setRightButton(javelin_tag(
'a', 'a',
@ -230,9 +231,10 @@ final class PhabricatorOwnersEditController
'sigil' => 'addpath', 'sigil' => 'addpath',
'mustcapture' => true, 'mustcapture' => true,
), ),
'Add New Path')) pht('Add New Path')))
->setDescription('Specify the files and directories which comprise '. ->setDescription(
'this package.') pht('Specify the files and directories which comprise '.
'this package.'))
->setContent(javelin_tag( ->setContent(javelin_tag(
'table', 'table',
array( array(
@ -242,34 +244,38 @@ final class PhabricatorOwnersEditController
''))) '')))
->appendChild( ->appendChild(
id(new AphrontFormTextAreaControl()) id(new AphrontFormTextAreaControl())
->setLabel('Description') ->setLabel(pht('Description'))
->setName('description') ->setName('description')
->setValue($package->getDescription())) ->setValue($package->getDescription()))
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->addCancelButton($cancel_uri) ->addCancelButton($cancel_uri)
->setValue('Save Package')); ->setValue(pht('Save Package')));
$header = id(new PhabricatorHeaderView()) $header = id(new PhabricatorHeaderView())
->setHeader($title); ->setHeader($title);
$nav = $this->buildSideNavView();
$nav->appendChild($error_view);
$nav->appendChild($header);
$nav->appendChild($form);
return $this->buildApplicationPage( return $this->buildApplicationPage(
array( array(
$error_view, $nav,
$header,
$form,
), ),
array( array(
'title' => $title, 'title' => $title,
'device' => true,
'dust' => true, 'dust' => true,
)); ));
} }
protected function getExtraPackageViews(AphrontSideNavFilterView $view) { protected function getExtraPackageViews(AphrontSideNavFilterView $view) {
if ($this->id) { if ($this->id) {
$view->addFilter('edit/'.$this->id, 'Edit'); $view->addFilter('edit/'.$this->id, pht('Edit'));
} else { } else {
$view->addFilter('new', 'New'); $view->addFilter('new', pht('New'));
} }
} }
} }

View file

@ -92,8 +92,8 @@ final class PhabricatorOwnersListController
$having); $having);
$packages = $package->loadAllFromArray($data); $packages = $package->loadAllFromArray($data);
$header = 'Search Results'; $header = pht('Search Results');
$nodata = 'No packages match your query.'; $nodata = pht('No packages match your query.');
break; break;
case 'owned': case 'owned':
$data = queryfx_all( $data = queryfx_all(
@ -105,8 +105,8 @@ final class PhabricatorOwnersListController
$user->getPHID()); $user->getPHID());
$packages = $package->loadAllFromArray($data); $packages = $package->loadAllFromArray($data);
$header = 'Owned Packages'; $header = pht('Owned Packages');
$nodata = 'No owned packages'; $nodata = pht('No owned packages');
break; break;
case 'projects': case 'projects':
$projects = id(new PhabricatorProjectQuery()) $projects = id(new PhabricatorProjectQuery())
@ -128,14 +128,14 @@ final class PhabricatorOwnersListController
} }
$packages = $package->loadAllFromArray($data); $packages = $package->loadAllFromArray($data);
$header = 'Owned Packages'; $header = pht('Owned Packages');
$nodata = 'No owned packages'; $nodata = pht('No owned packages');
break; break;
case 'all': case 'all':
$packages = $package->loadAll(); $packages = $package->loadAll();
$header = 'All Packages'; $header = pht('All Packages');
$nodata = 'There are no defined packages.'; $nodata = pht('There are no defined packages.');
break; break;
} }
@ -156,7 +156,7 @@ final class PhabricatorOwnersListController
); );
} }
$callsigns = array('' => '(Any Repository)'); $callsigns = array('' => pht('(Any Repository)'));
$repositories = id(new PhabricatorRepository()) $repositories = id(new PhabricatorRepository())
->loadAllWhere('1 = 1 ORDER BY callsign'); ->loadAllWhere('1 = 1 ORDER BY callsign');
foreach ($repositories as $repository) { foreach ($repositories as $repository) {
@ -168,42 +168,48 @@ final class PhabricatorOwnersListController
->setUser($user) ->setUser($user)
->setAction('/owners/view/search/') ->setAction('/owners/view/search/')
->setMethod('GET') ->setMethod('GET')
->setNoShading(true)
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setName('name') ->setName('name')
->setLabel('Name') ->setLabel(pht('Name'))
->setValue($request->getStr('name'))) ->setValue($request->getStr('name')))
->appendChild( ->appendChild(
id(new AphrontFormTokenizerControl()) id(new AphrontFormTokenizerControl())
->setDatasource('/typeahead/common/usersorprojects/') ->setDatasource('/typeahead/common/usersorprojects/')
->setLimit(1) ->setLimit(1)
->setName('owner') ->setName('owner')
->setLabel('Owner') ->setLabel(pht('Owner'))
->setValue($owners_search_value)) ->setValue($owners_search_value))
->appendChild( ->appendChild(
id(new AphrontFormSelectControl()) id(new AphrontFormSelectControl())
->setName('repository') ->setName('repository')
->setLabel('Repository') ->setLabel(pht('Repository'))
->setOptions($callsigns) ->setOptions($callsigns)
->setValue($request->getStr('repository'))) ->setValue($request->getStr('repository')))
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setName('path') ->setName('path')
->setLabel('Path') ->setLabel(pht('Path'))
->setValue($request->getStr('path'))) ->setValue($request->getStr('path')))
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue('Search for Packages')); ->setValue(pht('Search for Packages')));
$filter->appendChild($form); $filter->appendChild($form);
return $this->buildStandardPageResponse( $nav = $this->buildSideNavView();
$nav->appendChild($filter);
$nav->appendChild($content);
return $this->buildApplicationPage(
array( array(
$filter, $nav,
$content,
), ),
array( array(
'title' => 'Package Index', 'title' => pht('Package Index'),
'dust' => true,
'device' => true,
)); ));
} }
@ -304,17 +310,17 @@ final class PhabricatorOwnersListController
array( array(
'href' => '/audit/view/packagecommits/?phid='.$package->getPHID(), 'href' => '/audit/view/packagecommits/?phid='.$package->getPHID(),
), ),
'Related Commits') pht('Related Commits'))
); );
} }
$table = new AphrontTableView($rows); $table = new AphrontTableView($rows);
$table->setHeaders( $table->setHeaders(
array( array(
'Name', pht('Name'),
'Owners', pht('Owners'),
'Paths', pht('Paths'),
'Related Commits', pht('Related Commits'),
)); ));
$table->setColumnClasses( $table->setColumnClasses(
array( array(
@ -334,7 +340,7 @@ final class PhabricatorOwnersListController
protected function getExtraPackageViews(AphrontSideNavFilterView $view) { protected function getExtraPackageViews(AphrontSideNavFilterView $view) {
if ($this->view == 'search') { if ($this->view == 'search') {
$view->addFilter('view/search', 'Search Results'); $view->addFilter('view/search', pht('Search Results'));
} }
} }
} }