1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-27 01:02:42 +01:00

Modernize Owners package view UI elements

Summary: Ref T8320. Use modern/standard UI elements to render package details.

Test Plan: {F437131}

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8320

Differential Revision: https://secure.phabricator.com/D13025
This commit is contained in:
epriestley 2015-05-27 10:29:31 -07:00
parent 6d5d34e6a8
commit 05bd6a1682
2 changed files with 150 additions and 104 deletions

View file

@ -7,7 +7,7 @@
*/ */
return array( return array(
'names' => array( 'names' => array(
'core.pkg.css' => '439658b5', 'core.pkg.css' => '4e7df908',
'core.pkg.js' => '328799d0', 'core.pkg.js' => '328799d0',
'darkconsole.pkg.js' => 'e7393ebb', 'darkconsole.pkg.js' => 'e7393ebb',
'differential.pkg.css' => '30602b8c', 'differential.pkg.css' => '30602b8c',
@ -134,7 +134,7 @@ return array(
'rsrc/css/phui/phui-document.css' => '94d5dcd8', 'rsrc/css/phui/phui-document.css' => '94d5dcd8',
'rsrc/css/phui/phui-feed-story.css' => 'c9f3a0b5', 'rsrc/css/phui/phui-feed-story.css' => 'c9f3a0b5',
'rsrc/css/phui/phui-fontkit.css' => 'dd8ddf27', 'rsrc/css/phui/phui-fontkit.css' => 'dd8ddf27',
'rsrc/css/phui/phui-form-view.css' => '79793450', 'rsrc/css/phui/phui-form-view.css' => '808329f2',
'rsrc/css/phui/phui-form.css' => 'f535f938', 'rsrc/css/phui/phui-form.css' => 'f535f938',
'rsrc/css/phui/phui-header-view.css' => '75aaf372', 'rsrc/css/phui/phui-header-view.css' => '75aaf372',
'rsrc/css/phui/phui-icon.css' => 'bc766998', 'rsrc/css/phui/phui-icon.css' => 'bc766998',
@ -443,7 +443,7 @@ return array(
'rsrc/js/core/behavior-device.js' => 'a205cf28', 'rsrc/js/core/behavior-device.js' => 'a205cf28',
'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '6d49590e', 'rsrc/js/core/behavior-drag-and-drop-textarea.js' => '6d49590e',
'rsrc/js/core/behavior-error-log.js' => '6882e80a', 'rsrc/js/core/behavior-error-log.js' => '6882e80a',
'rsrc/js/core/behavior-fancy-datepicker.js' => '5c0f680f', 'rsrc/js/core/behavior-fancy-datepicker.js' => '510b5809',
'rsrc/js/core/behavior-file-tree.js' => '88236f00', 'rsrc/js/core/behavior-file-tree.js' => '88236f00',
'rsrc/js/core/behavior-form.js' => '5c54cbf3', 'rsrc/js/core/behavior-form.js' => '5c54cbf3',
'rsrc/js/core/behavior-gesture.js' => '3ab51e2c', 'rsrc/js/core/behavior-gesture.js' => '3ab51e2c',
@ -576,7 +576,7 @@ return array(
'javelin-behavior-durable-column' => '16c695bf', 'javelin-behavior-durable-column' => '16c695bf',
'javelin-behavior-error-log' => '6882e80a', 'javelin-behavior-error-log' => '6882e80a',
'javelin-behavior-event-all-day' => '38dcf3c8', 'javelin-behavior-event-all-day' => '38dcf3c8',
'javelin-behavior-fancy-datepicker' => '5c0f680f', 'javelin-behavior-fancy-datepicker' => '510b5809',
'javelin-behavior-global-drag-and-drop' => 'c8e57404', 'javelin-behavior-global-drag-and-drop' => 'c8e57404',
'javelin-behavior-herald-rule-editor' => '7ebaeed3', 'javelin-behavior-herald-rule-editor' => '7ebaeed3',
'javelin-behavior-high-security-warning' => 'a464fe03', 'javelin-behavior-high-security-warning' => 'a464fe03',
@ -776,7 +776,7 @@ return array(
'phui-font-icon-base-css' => '3dad2ae3', 'phui-font-icon-base-css' => '3dad2ae3',
'phui-fontkit-css' => 'dd8ddf27', 'phui-fontkit-css' => 'dd8ddf27',
'phui-form-css' => 'f535f938', 'phui-form-css' => 'f535f938',
'phui-form-view-css' => '79793450', 'phui-form-view-css' => '808329f2',
'phui-header-view-css' => '75aaf372', 'phui-header-view-css' => '75aaf372',
'phui-icon-view-css' => 'bc766998', 'phui-icon-view-css' => 'bc766998',
'phui-image-mask-css' => '5a8b09c8', 'phui-image-mask-css' => '5a8b09c8',
@ -1175,6 +1175,13 @@ return array(
'javelin-typeahead-source', 'javelin-typeahead-source',
'javelin-util', 'javelin-util',
), ),
'510b5809' => array(
'javelin-behavior',
'javelin-util',
'javelin-dom',
'javelin-stratcom',
'javelin-vector',
),
'519705ea' => array( '519705ea' => array(
'javelin-install', 'javelin-install',
'javelin-dom', 'javelin-dom',
@ -1242,13 +1249,6 @@ return array(
'javelin-uri', 'javelin-uri',
'javelin-routable', 'javelin-routable',
), ),
'5c0f680f' => array(
'javelin-behavior',
'javelin-util',
'javelin-dom',
'javelin-stratcom',
'javelin-vector',
),
'5c54cbf3' => array( '5c54cbf3' => array(
'javelin-behavior', 'javelin-behavior',
'javelin-stratcom', 'javelin-stratcom',

View file

@ -19,7 +19,6 @@ final class PhabricatorOwnersDetailController
} }
$paths = $package->loadPaths(); $paths = $package->loadPaths();
$owners = $package->loadOwners();
$repository_phids = array(); $repository_phids = array();
foreach ($paths as $path) { foreach ($paths as $path) {
@ -36,98 +35,18 @@ final class PhabricatorOwnersDetailController
$repositories = array(); $repositories = array();
} }
$phids = array(); $actions = $this->buildPackageActionView($package);
foreach ($owners as $owner) { $properties = $this->buildPackagePropertyView($package);
$phids[$owner->getUserPHID()] = true; $properties->setActionList($actions);
}
$phids = array_keys($phids);
$handles = $this->loadViewerHandles($phids); $header = id(new PHUIHeaderView())
->setUser($viewer)
->setHeader($package->getName())
->setPolicyObject($package);
$rows = array(); $panel = id(new PHUIObjectBoxView())
->setHeader($header)
$rows[] = array(pht('Name'), $package->getName()); ->addPropertyList($properties);
$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() ? "\xE2\x80\x93" : '+'),
$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 PHUIObjectBoxView();
$header = new PHUIHeaderView();
$header->setHeader(
pht('Package Details for "%s"', $package->getName()));
$header->addActionLink(
id(new PHUIButtonView())
->setTag('a')
->setHref('/owners/delete/'.$package->getID().'/')
->addSigil('workflow')
->setText(pht('Delete Package')));
$header->addActionLink(
id(new PHUIButtonView())
->setTag('a')
->setHref('/owners/edit/'.$package->getID().'/')
->setText(pht('Edit Package')));
$panel->setHeader($header);
$panel->appendChild($table);
$commit_views = array(); $commit_views = array();
@ -209,11 +128,138 @@ final class PhabricatorOwnersDetailController
array( array(
$crumbs, $crumbs,
$panel, $panel,
$this->renderPathsTable($paths, $repositories),
$commit_panels, $commit_panels,
), ),
array( array(
'title' => pht('Package %s', $package->getName()), 'title' => $package->getName(),
)); ));
} }
private function buildPackagePropertyView(PhabricatorOwnersPackage $package) {
$viewer = $this->getViewer();
$view = id(new PHUIPropertyListView())
->setUser($viewer);
$primary_phid = $package->getPrimaryOwnerPHID();
if ($primary_phid) {
$primary_owner = $viewer->renderHandle($primary_phid);
} else {
$primary_owner = phutil_tag('em', array(), pht('None'));
}
$view->addProperty(pht('Primary Owner'), $primary_owner);
// TODO: needOwners() this on the Query.
$owners = $package->loadOwners();
if ($owners) {
$owner_list = $viewer->renderHandleList(mpull($owners, 'getUserPHID'));
} else {
$owner_list = phutil_tag('em', array(), pht('None'));
}
$view->addProperty(pht('Owners'), $owner_list);
if ($package->getAuditingEnabled()) {
$auditing = pht('Enabled');
} else {
$auditing = pht('Disabled');
}
$view->addProperty(pht('Auditing'), $auditing);
$description = $package->getDescription();
if (strlen($description)) {
$view->addSectionHeader(pht('Description'));
$view->addTextContent(
$output = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($description),
'default',
$viewer));
}
return $view;
}
private function buildPackageActionView(PhabricatorOwnersPackage $package) {
$viewer = $this->getViewer();
// TODO: Implement this capability.
$can_edit = true;
$id = $package->getID();
$edit_uri = $this->getApplicationURI("/edit/{$id}/");
$delete_uri = $this->getApplicationURI("/delete/{$id}/");
$view = id(new PhabricatorActionListView())
->setUser($viewer)
->setObject($package)
->addAction(
id(new PhabricatorActionView())
->setName(pht('Edit Package'))
->setIcon('fa-pencil')
->setDisabled(!$can_edit)
->setWorkflow(!$can_edit)
->setHref($edit_uri))
->addAction(
id(new PhabricatorActionView())
->setName(pht('Delete Package'))
->setIcon('fa-times')
->setDisabled(!$can_edit)
->setWorkflow(true)
->setHref($delete_uri));
return $view;
}
private function renderPathsTable(array $paths, array $repositories) {
$viewer = $this->getViewer();
$rows = 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',
));
$path_link = phutil_tag(
'a',
array(
'href' => (string)$href,
),
$path->getPath());
$rows[] = array(
($path->getExcluded() ? '-' : '+'),
$repo->getName(),
$path_link,
);
}
$table = id(new AphrontTableView($rows))
->setHeaders(
array(
null,
pht('Repository'),
pht('Path'),
))
->setColumnClasses(
array(
null,
null,
'wide',
));
return id(new PHUIObjectBoxView())
->setHeaderText(pht('Paths'))
->appendChild($table);
}
} }