mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-23 14:00:56 +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:
parent
4a901c788d
commit
470999caf6
6 changed files with 143 additions and 125 deletions
|
@ -11,7 +11,7 @@ final class PhabricatorApplicationOwners extends PhabricatorApplication {
|
|||
}
|
||||
|
||||
public function getShortDescription() {
|
||||
return 'Group Source Code';
|
||||
return pht('Group Source Code');
|
||||
}
|
||||
|
||||
public function getTitleGlyph() {
|
||||
|
|
|
@ -12,64 +12,58 @@ abstract class PhabricatorOwnersController extends PhabricatorController {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function buildStandardPageResponse($view, array $data) {
|
||||
|
||||
$page = $this->buildStandardPageView();
|
||||
|
||||
$page->setApplicationName('Owners');
|
||||
$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();
|
||||
switch ($filter) {
|
||||
case 'view/owned':
|
||||
case 'view/all':
|
||||
$crumbs = $this->buildApplicationCrumbs();
|
||||
|
||||
if ($filter == 'view/owned') {
|
||||
$title = pht('Owned Packages');
|
||||
} else {
|
||||
$title = pht('All Packages');
|
||||
}
|
||||
|
||||
$crumbs->addCrumb(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName($title));
|
||||
|
||||
$crumbs->addAction(
|
||||
id(new PhabricatorMenuItemView())
|
||||
->setName(pht('Create Package'))
|
||||
->setHref('/owners/new/')
|
||||
->setIcon('create'));
|
||||
|
||||
$nav->setCrumbs($crumbs);
|
||||
break;
|
||||
}
|
||||
|
||||
$response = new AphrontWebpageResponse();
|
||||
return $response->setContent($page->render());
|
||||
}
|
||||
|
||||
public function renderSideNav() {
|
||||
public function buildSideNavView() {
|
||||
$nav = new AphrontSideNavFilterView();
|
||||
$base_uri = new PhutilURI('/owners/');
|
||||
$nav->setBaseURI($base_uri);
|
||||
|
||||
$nav->addLabel('Packages');
|
||||
$nav->addLabel(pht('Packages'));
|
||||
$this->getExtraPackageViews($nav);
|
||||
$nav->addFilter('view/owned', 'Owned');
|
||||
$nav->addFilter('view/projects', 'Projects');
|
||||
$nav->addFilter('view/all', 'All');
|
||||
$nav->addFilter('view/owned', pht('Owned'));
|
||||
$nav->addFilter('view/projects', pht('Projects'));
|
||||
$nav->addFilter('view/all', pht('All'));
|
||||
|
||||
$nav->selectFilter($this->getSideNavFilter(), 'view/owned');
|
||||
|
||||
$filter = $nav->getSelectedFilter();
|
||||
switch ($filter) {
|
||||
case 'view/owned':
|
||||
$title = pht('Owned Packages');
|
||||
break;
|
||||
case 'view/all':
|
||||
$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(
|
||||
id(new PhabricatorCrumbView())
|
||||
->setName($title));
|
||||
|
||||
$crumbs->addAction(
|
||||
id(new PhabricatorMenuItemView())
|
||||
->setName(pht('Create Package'))
|
||||
->setHref('/owners/new/')
|
||||
->setIcon('create'));
|
||||
|
||||
$nav->setCrumbs($crumbs);
|
||||
|
||||
return $nav;
|
||||
}
|
||||
|
||||
public function buildApplicationMenu() {
|
||||
return $this->buildSideNavView()->getMenu();
|
||||
}
|
||||
|
||||
protected function getExtraPackageViews(AphrontSideNavFilterView $view) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -24,14 +24,16 @@ final class PhabricatorOwnersDeleteController
|
|||
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())
|
||||
->setUser($user)
|
||||
->setTitle('Really delete this package?')
|
||||
->setHeaderColor(PhabricatorActionHeaderView::HEADER_RED)
|
||||
->appendChild(hsprintf(
|
||||
'<p>Are you sure you want to delete the "%s" package? This operation '.
|
||||
'can not be undone.</p>',
|
||||
$package->getName()))
|
||||
->addSubmitButton('Delete')
|
||||
'<p>%s</p>',
|
||||
$text))
|
||||
->addSubmitButton(pht('Delete'))
|
||||
->addCancelButton('/owners/package/'.$package->getID().'/')
|
||||
->setSubmitURI($request->getRequestURI());
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ final class PhabricatorOwnersDetailController
|
|||
|
||||
$rows = array();
|
||||
|
||||
$rows[] = array('Name', $package->getName());
|
||||
$rows[] = array('Description', $package->getDescription());
|
||||
$rows[] = array(pht('Name'), $package->getName());
|
||||
$rows[] = array(pht('Description'), $package->getDescription());
|
||||
|
||||
$primary_owner = null;
|
||||
$primary_phid = $package->getPrimaryOwnerPHID();
|
||||
|
@ -58,18 +58,20 @@ final class PhabricatorOwnersDetailController
|
|||
array(),
|
||||
$handles[$primary_phid]->renderLink());
|
||||
}
|
||||
$rows[] = array('Primary Owner', $primary_owner);
|
||||
$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('Owners', $owner_links);
|
||||
$rows[] = array(pht('Owners'), $owner_links);
|
||||
|
||||
$rows[] = array(
|
||||
'Auditing',
|
||||
$package->getAuditingEnabled() ? 'Enabled' : 'Disabled',
|
||||
pht('Auditing'),
|
||||
$package->getAuditingEnabled() ?
|
||||
pht('Enabled') :
|
||||
pht('Disabled'),
|
||||
);
|
||||
|
||||
$path_links = array();
|
||||
|
@ -99,7 +101,7 @@ final class PhabricatorOwnersDetailController
|
|||
$path_link);
|
||||
}
|
||||
$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->setColumnClasses(
|
||||
|
@ -109,7 +111,9 @@ final class PhabricatorOwnersDetailController
|
|||
));
|
||||
|
||||
$panel = new AphrontPanelView();
|
||||
$panel->setHeader('Package Details for "'.$package->getName().'"');
|
||||
$panel->setNoBackground();
|
||||
$panel->setHeader(
|
||||
pht('Package Details for "%s"', $package->getName()));
|
||||
$panel->addButton(
|
||||
javelin_tag(
|
||||
'a',
|
||||
|
@ -118,7 +122,7 @@ final class PhabricatorOwnersDetailController
|
|||
'class' => 'button grey',
|
||||
'sigil' => 'workflow',
|
||||
),
|
||||
'Delete Package'));
|
||||
pht('Delete Package')));
|
||||
$panel->addButton(
|
||||
phutil_tag(
|
||||
'a',
|
||||
|
@ -126,7 +130,7 @@ final class PhabricatorOwnersDetailController
|
|||
'href' => '/owners/edit/'.$package->getID().'/',
|
||||
'class' => 'button',
|
||||
),
|
||||
'Edit Package'));
|
||||
pht('Edit Package')));
|
||||
$panel->appendChild($table);
|
||||
|
||||
$key = 'package/'.$package->getID();
|
||||
|
@ -154,14 +158,14 @@ final class PhabricatorOwnersDetailController
|
|||
|
||||
$commit_views[] = array(
|
||||
'view' => $view,
|
||||
'header' => 'Commits in this Package that Need Attention',
|
||||
'header' => pht('Commits in this Package that Need Attention'),
|
||||
'button' => phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $commit_uri->alter('status', 'open'),
|
||||
'class' => 'button grey',
|
||||
),
|
||||
'View All Problem Commits'),
|
||||
pht('View All Problem Commits')),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -175,18 +179,18 @@ final class PhabricatorOwnersDetailController
|
|||
$view = new PhabricatorAuditCommitListView();
|
||||
$view->setUser($user);
|
||||
$view->setCommits($all_commits);
|
||||
$view->setNoDataString('No commits in this package.');
|
||||
$view->setNoDataString(pht('No commits in this package.'));
|
||||
|
||||
$commit_views[] = array(
|
||||
'view' => $view,
|
||||
'header' => 'Recent Commits in Package',
|
||||
'header' => pht('Recent Commits in Package'),
|
||||
'button' => phutil_tag(
|
||||
'a',
|
||||
array(
|
||||
'href' => $commit_uri,
|
||||
'class' => 'button grey',
|
||||
),
|
||||
'View All Package Commits'),
|
||||
pht('View All Package Commits')),
|
||||
);
|
||||
|
||||
$phids = array();
|
||||
|
@ -199,6 +203,7 @@ final class PhabricatorOwnersDetailController
|
|||
$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']);
|
||||
|
@ -209,19 +214,24 @@ final class PhabricatorOwnersDetailController
|
|||
$commit_panels[] = $commit_panel;
|
||||
}
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
$nav = $this->buildSideNavView();
|
||||
$nav->appendChild($panel);
|
||||
$nav->appendChild($commit_panels);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$panel,
|
||||
$commit_panels,
|
||||
$nav,
|
||||
),
|
||||
array(
|
||||
'title' => "Package '".$package->getName()."'",
|
||||
'title' => pht("Package %s", $package->getName()),
|
||||
'dust' => true,
|
||||
'device' => true,
|
||||
));
|
||||
}
|
||||
|
||||
protected function getExtraPackageViews(AphrontSideNavFilterView $view) {
|
||||
$package = $this->package;
|
||||
$view->addFilter('package/'.$package->getID(), 'Details');
|
||||
$view->addFilter('package/'.$package->getID(), pht('Details'));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -65,21 +65,21 @@ final class PhabricatorOwnersEditController
|
|||
}
|
||||
|
||||
if (!strlen($package->getName())) {
|
||||
$e_name = 'Required';
|
||||
$errors[] = 'Package name is required.';
|
||||
$e_name = pht('Required');
|
||||
$errors[] = pht('Package name is required.');
|
||||
} else {
|
||||
$e_name = null;
|
||||
}
|
||||
|
||||
if (!$package->getPrimaryOwnerPHID()) {
|
||||
$e_primary = 'Required';
|
||||
$errors[] = 'Package must have a primary owner.';
|
||||
$e_primary = pht('Required');
|
||||
$errors[] = pht('Package must have a primary owner.');
|
||||
} else {
|
||||
$e_primary = null;
|
||||
}
|
||||
|
||||
if (!$path_refs) {
|
||||
$errors[] = 'Package must include at least one path.';
|
||||
$errors[] = pht('Package must include at least one path.');
|
||||
}
|
||||
|
||||
if (!$errors) {
|
||||
|
@ -93,8 +93,8 @@ final class PhabricatorOwnersEditController
|
|||
return id(new AphrontRedirectResponse())
|
||||
->setURI('/owners/package/'.$package->getID().'/');
|
||||
} catch (AphrontQueryDuplicateKeyException $ex) {
|
||||
$e_name = 'Duplicate';
|
||||
$errors[] = 'Package name must be unique.';
|
||||
$e_name = pht('Duplicate');
|
||||
$errors[] = pht('Package name must be unique.');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -115,7 +115,7 @@ final class PhabricatorOwnersEditController
|
|||
$error_view = null;
|
||||
if ($errors) {
|
||||
$error_view = new AphrontErrorView();
|
||||
$error_view->setTitle('Package Errors');
|
||||
$error_view->setTitle(pht('Package Errors'));
|
||||
$error_view->setErrors($errors);
|
||||
}
|
||||
|
||||
|
@ -184,14 +184,14 @@ final class PhabricatorOwnersEditController
|
|||
->setFlexible(true)
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setLabel('Name')
|
||||
->setLabel(pht('Name'))
|
||||
->setName('name')
|
||||
->setValue($package->getName())
|
||||
->setError($e_name))
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setDatasource('/typeahead/common/usersorprojects/')
|
||||
->setLabel('Primary Owner')
|
||||
->setLabel(pht('Primary Owner'))
|
||||
->setName('primary')
|
||||
->setLimit(1)
|
||||
->setValue($token_primary_owner)
|
||||
|
@ -199,20 +199,21 @@ final class PhabricatorOwnersEditController
|
|||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setDatasource('/typeahead/common/usersorprojects/')
|
||||
->setLabel('Owners')
|
||||
->setLabel(pht('Owners'))
|
||||
->setName('owners')
|
||||
->setValue($token_all_owners))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setName('auditing')
|
||||
->setLabel('Auditing')
|
||||
->setCaption('With auditing enabled, all future commits that touch '.
|
||||
'this package will be reviewed to make sure an owner '.
|
||||
'of the package is involved and the commit message has '.
|
||||
'a valid revision, reviewed by, and author.')
|
||||
->setLabel(pht('Auditing'))
|
||||
->setCaption(
|
||||
pht('With auditing enabled, all future commits that touch '.
|
||||
'this package will be reviewed to make sure an owner '.
|
||||
'of the package is involved and the commit message has '.
|
||||
'a valid revision, reviewed by, and author.'))
|
||||
->setOptions(array(
|
||||
'disabled' => 'Disabled',
|
||||
'enabled' => 'Enabled',
|
||||
'disabled' => pht('Disabled'),
|
||||
'enabled' => pht('Enabled'),
|
||||
))
|
||||
->setValue(
|
||||
$package->getAuditingEnabled()
|
||||
|
@ -220,7 +221,7 @@ final class PhabricatorOwnersEditController
|
|||
: 'disabled'))
|
||||
->appendChild(
|
||||
id(new AphrontFormInsetView())
|
||||
->setTitle('Paths')
|
||||
->setTitle(pht('Paths'))
|
||||
->addDivAttributes(array('id' => 'path-editor'))
|
||||
->setRightButton(javelin_tag(
|
||||
'a',
|
||||
|
@ -230,9 +231,10 @@ final class PhabricatorOwnersEditController
|
|||
'sigil' => 'addpath',
|
||||
'mustcapture' => true,
|
||||
),
|
||||
'Add New Path'))
|
||||
->setDescription('Specify the files and directories which comprise '.
|
||||
'this package.')
|
||||
pht('Add New Path')))
|
||||
->setDescription(
|
||||
pht('Specify the files and directories which comprise '.
|
||||
'this package.'))
|
||||
->setContent(javelin_tag(
|
||||
'table',
|
||||
array(
|
||||
|
@ -242,34 +244,38 @@ final class PhabricatorOwnersEditController
|
|||
'')))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextAreaControl())
|
||||
->setLabel('Description')
|
||||
->setLabel(pht('Description'))
|
||||
->setName('description')
|
||||
->setValue($package->getDescription()))
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->addCancelButton($cancel_uri)
|
||||
->setValue('Save Package'));
|
||||
->setValue(pht('Save Package')));
|
||||
|
||||
$header = id(new PhabricatorHeaderView())
|
||||
->setHeader($title);
|
||||
|
||||
$nav = $this->buildSideNavView();
|
||||
$nav->appendChild($error_view);
|
||||
$nav->appendChild($header);
|
||||
$nav->appendChild($form);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$error_view,
|
||||
$header,
|
||||
$form,
|
||||
$nav,
|
||||
),
|
||||
array(
|
||||
'title' => $title,
|
||||
'device' => true,
|
||||
'dust' => true,
|
||||
));
|
||||
}
|
||||
|
||||
protected function getExtraPackageViews(AphrontSideNavFilterView $view) {
|
||||
if ($this->id) {
|
||||
$view->addFilter('edit/'.$this->id, 'Edit');
|
||||
$view->addFilter('edit/'.$this->id, pht('Edit'));
|
||||
} else {
|
||||
$view->addFilter('new', 'New');
|
||||
$view->addFilter('new', pht('New'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -92,8 +92,8 @@ final class PhabricatorOwnersListController
|
|||
$having);
|
||||
$packages = $package->loadAllFromArray($data);
|
||||
|
||||
$header = 'Search Results';
|
||||
$nodata = 'No packages match your query.';
|
||||
$header = pht('Search Results');
|
||||
$nodata = pht('No packages match your query.');
|
||||
break;
|
||||
case 'owned':
|
||||
$data = queryfx_all(
|
||||
|
@ -105,8 +105,8 @@ final class PhabricatorOwnersListController
|
|||
$user->getPHID());
|
||||
$packages = $package->loadAllFromArray($data);
|
||||
|
||||
$header = 'Owned Packages';
|
||||
$nodata = 'No owned packages';
|
||||
$header = pht('Owned Packages');
|
||||
$nodata = pht('No owned packages');
|
||||
break;
|
||||
case 'projects':
|
||||
$projects = id(new PhabricatorProjectQuery())
|
||||
|
@ -128,14 +128,14 @@ final class PhabricatorOwnersListController
|
|||
}
|
||||
$packages = $package->loadAllFromArray($data);
|
||||
|
||||
$header = 'Owned Packages';
|
||||
$nodata = 'No owned packages';
|
||||
$header = pht('Owned Packages');
|
||||
$nodata = pht('No owned packages');
|
||||
break;
|
||||
case 'all':
|
||||
$packages = $package->loadAll();
|
||||
|
||||
$header = 'All Packages';
|
||||
$nodata = 'There are no defined packages.';
|
||||
$header = pht('All Packages');
|
||||
$nodata = pht('There are no defined packages.');
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,7 @@ final class PhabricatorOwnersListController
|
|||
);
|
||||
}
|
||||
|
||||
$callsigns = array('' => '(Any Repository)');
|
||||
$callsigns = array('' => pht('(Any Repository)'));
|
||||
$repositories = id(new PhabricatorRepository())
|
||||
->loadAllWhere('1 = 1 ORDER BY callsign');
|
||||
foreach ($repositories as $repository) {
|
||||
|
@ -168,42 +168,48 @@ final class PhabricatorOwnersListController
|
|||
->setUser($user)
|
||||
->setAction('/owners/view/search/')
|
||||
->setMethod('GET')
|
||||
->setNoShading(true)
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setName('name')
|
||||
->setLabel('Name')
|
||||
->setLabel(pht('Name'))
|
||||
->setValue($request->getStr('name')))
|
||||
->appendChild(
|
||||
id(new AphrontFormTokenizerControl())
|
||||
->setDatasource('/typeahead/common/usersorprojects/')
|
||||
->setLimit(1)
|
||||
->setName('owner')
|
||||
->setLabel('Owner')
|
||||
->setLabel(pht('Owner'))
|
||||
->setValue($owners_search_value))
|
||||
->appendChild(
|
||||
id(new AphrontFormSelectControl())
|
||||
->setName('repository')
|
||||
->setLabel('Repository')
|
||||
->setLabel(pht('Repository'))
|
||||
->setOptions($callsigns)
|
||||
->setValue($request->getStr('repository')))
|
||||
->appendChild(
|
||||
id(new AphrontFormTextControl())
|
||||
->setName('path')
|
||||
->setLabel('Path')
|
||||
->setLabel(pht('Path'))
|
||||
->setValue($request->getStr('path')))
|
||||
->appendChild(
|
||||
id(new AphrontFormSubmitControl())
|
||||
->setValue('Search for Packages'));
|
||||
->setValue(pht('Search for Packages')));
|
||||
|
||||
$filter->appendChild($form);
|
||||
|
||||
return $this->buildStandardPageResponse(
|
||||
$nav = $this->buildSideNavView();
|
||||
$nav->appendChild($filter);
|
||||
$nav->appendChild($content);
|
||||
|
||||
return $this->buildApplicationPage(
|
||||
array(
|
||||
$filter,
|
||||
$content,
|
||||
$nav,
|
||||
),
|
||||
array(
|
||||
'title' => 'Package Index',
|
||||
'title' => pht('Package Index'),
|
||||
'dust' => true,
|
||||
'device' => true,
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -304,17 +310,17 @@ final class PhabricatorOwnersListController
|
|||
array(
|
||||
'href' => '/audit/view/packagecommits/?phid='.$package->getPHID(),
|
||||
),
|
||||
'Related Commits')
|
||||
pht('Related Commits'))
|
||||
);
|
||||
}
|
||||
|
||||
$table = new AphrontTableView($rows);
|
||||
$table->setHeaders(
|
||||
array(
|
||||
'Name',
|
||||
'Owners',
|
||||
'Paths',
|
||||
'Related Commits',
|
||||
pht('Name'),
|
||||
pht('Owners'),
|
||||
pht('Paths'),
|
||||
pht('Related Commits'),
|
||||
));
|
||||
$table->setColumnClasses(
|
||||
array(
|
||||
|
@ -334,7 +340,7 @@ final class PhabricatorOwnersListController
|
|||
|
||||
protected function getExtraPackageViews(AphrontSideNavFilterView $view) {
|
||||
if ($this->view == 'search') {
|
||||
$view->addFilter('view/search', 'Search Results');
|
||||
$view->addFilter('view/search', pht('Search Results'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue