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

Add icons to the new repository edit nav

Summary:
Ref T10748. These:

  - Look nice.
  - Hint at panel contents / effects.
  - Hint which panels have been customized.
  - Allow panels with issues or errors to be highlighted with an alert/attention icon.

Test Plan: {F1256156}

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10748

Differential Revision: https://secure.phabricator.com/D15836
This commit is contained in:
epriestley 2016-05-03 06:54:50 -07:00
parent 319a9cefde
commit c3afddec9c
17 changed files with 227 additions and 10 deletions

View file

@ -7,7 +7,7 @@
*/
return array(
'names' => array(
'core.pkg.css' => 'ea0dfb3d',
'core.pkg.css' => '9968bf8d',
'core.pkg.js' => '6972d365',
'darkconsole.pkg.js' => 'e7393ebb',
'differential.pkg.css' => '7ba78475',
@ -113,7 +113,7 @@ return array(
'rsrc/css/font/font-lato.css' => 'c7ccd872',
'rsrc/css/font/phui-font-icon-base.css' => '6449bce8',
'rsrc/css/layout/phabricator-filetree-view.css' => 'fccf9f82',
'rsrc/css/layout/phabricator-side-menu-view.css' => '3a3d9f41',
'rsrc/css/layout/phabricator-side-menu-view.css' => 'dd849797',
'rsrc/css/layout/phabricator-source-code-view.css' => 'cbeef983',
'rsrc/css/phui/calendar/phui-calendar-day.css' => 'd1cf6f93',
'rsrc/css/phui/calendar/phui-calendar-list.css' => 'c1c7f338',
@ -780,7 +780,7 @@ return array(
'phabricator-remarkup-css' => '6aae5360',
'phabricator-search-results-css' => '7dea472c',
'phabricator-shaped-request' => '7cbe244b',
'phabricator-side-menu-view-css' => '3a3d9f41',
'phabricator-side-menu-view-css' => 'dd849797',
'phabricator-slowvote-css' => 'a94b7230',
'phabricator-source-code-view-css' => 'cbeef983',
'phabricator-standard-page-view' => 'e709f6d0',

View file

@ -106,9 +106,19 @@ final class DiffusionRepositoryManageController
->setBaseURI($base_uri);
foreach ($panels as $panel) {
$nav->addFilter(
$panel->getManagementPanelKey(),
$panel->getManagementPanelLabel());
$key = $panel->getManagementPanelKey();
$label = $panel->getManagementPanelLabel();
$icon = $panel->getManagementPanelIcon();
$href = $repository->getPathURI("manage/{$key}/");
$item = id(new PHUIListItemView())
->setKey($key)
->setName($label)
->setType(PHUIListItemView::TYPE_LINK)
->setHref($href)
->setIcon($icon);
$nav->addMenuItem($item);
}
$nav->selectFilter($selected);

View file

@ -13,6 +13,23 @@ final class DiffusionRepositoryActionsManagementPanel
return 1100;
}
public function getManagementPanelIcon() {
$repository = $this->getRepository();
$has_any =
$repository->getDetail('herald-disabled') ||
$repository->getDetail('disable-autoclose');
// NOTE: Any value here really means something is disabled, so try to
// hint that a little bit with the icon.
if ($has_any) {
return 'fa-comment-o';
} else {
return 'fa-commenting grey';
}
}
protected function getEditEngineFieldKeys() {
return array(
'publish',

View file

@ -19,6 +19,28 @@ final class DiffusionRepositoryAutomationManagementPanel
);
}
public function getManagementPanelIcon() {
$repository = $this->getRepository();
if (!$repository->canPerformAutomation()) {
return 'fa-truck grey';
}
$blueprint_phids = $repository->getAutomationBlueprintPHIDs();
if (!$blueprint_phids) {
return 'fa-truck grey';
}
$is_authorized = DrydockAuthorizationQuery::isFullyAuthorized(
$repository->getPHID(),
$blueprint_phids);
if (!$is_authorized) {
return 'fa-exclamation-triangle yellow';
}
return 'fa-truck';
}
protected function buildManagementPanelActions() {
$repository = $this->getRepository();
$viewer = $this->getViewer();

View file

@ -13,6 +13,16 @@ final class DiffusionRepositoryBasicsManagementPanel
return 100;
}
public function getManagementPanelIcon() {
$repository = $this->getRepository();
if (!$repository->isTracked()) {
return 'fa-ban indigo';
} else {
return 'fa-code';
}
}
protected function getEditEngineFieldKeys() {
return array(
'name',

View file

@ -13,6 +13,21 @@ final class DiffusionRepositoryBranchesManagementPanel
return 1000;
}
public function getManagementPanelIcon() {
$repository = $this->getRepository();
$has_any =
$repository->getDetail('default-branch') ||
$repository->getDetail('branch-filter') ||
$repository->getDetail('close-commits-filter');
if ($has_any) {
return 'fa-code-fork';
} else {
return 'fa-code-fork grey';
}
}
protected function getEditEngineFieldKeys() {
return array(
'defaultBranch',

View file

@ -13,6 +13,10 @@ final class DiffusionRepositoryHistoryManagementPanel
return 2000;
}
public function getManagementPanelIcon() {
return 'fa-list-ul';
}
public function buildManagementPanelContent() {
return $this->newTimeline();
}

View file

@ -38,6 +38,10 @@ abstract class DiffusionRepositoryManagementPanel
abstract public function getManagementPanelOrder();
abstract public function buildManagementPanelContent();
public function getManagementPanelIcon() {
return 'fa-pencil';
}
protected function buildManagementPanelActions() {
return array();
}

View file

@ -13,6 +13,38 @@ final class DiffusionRepositoryPoliciesManagementPanel
return 300;
}
public function getManagementPanelIcon() {
$viewer = $this->getViewer();
$repository = $this->getRepository();
$can_view = PhabricatorPolicyCapability::CAN_VIEW;
$can_edit = PhabricatorPolicyCapability::CAN_EDIT;
$can_push = DiffusionPushCapability::CAPABILITY;
$actual_values = array(
'spacePHID' => $repository->getSpacePHID(),
'view' => $repository->getPolicy($can_view),
'edit' => $repository->getPolicy($can_edit),
'push' => $repository->getPolicy($can_push),
);
$default = PhabricatorRepository::initializeNewRepository(
$viewer);
$default_values = array(
'spacePHID' => $default->getSpacePHID(),
'view' => $default->getPolicy($can_view),
'edit' => $default->getPolicy($can_edit),
'push' => $default->getPolicy($can_push),
);
if ($actual_values === $default_values) {
return 'fa-lock grey';
} else {
return 'fa-lock';
}
}
protected function getEditEngineFieldKeys() {
return array(
'policy.view',

View file

@ -13,6 +13,18 @@ final class DiffusionRepositoryStagingManagementPanel
return 700;
}
public function getManagementPanelIcon() {
$repository = $this->getRepository();
$staging_uri = $repository->getStagingURI();
if ($staging_uri) {
return 'fa-upload';
} else {
return 'fa-upload grey';
}
}
protected function getEditEngineFieldKeys() {
return array(
'stagingAreaURI',

View file

@ -13,6 +13,21 @@ final class DiffusionRepositoryStatusManagementPanel
return 200;
}
public function getManagementPanelIcon() {
$repository = $this->getRepository();
// TODO: We could try to show a warning icon in more cases, but just
// raise in the most serious cases for now.
$messages = $this->loadStatusMessages($repository);
$raw_error = $this->buildRepositoryRawError($repository, $messages);
if ($raw_error) {
return 'fa-exclamation-triangle red';
}
return 'fa-check grey';
}
protected function buildManagementPanelActions() {
$repository = $this->getRepository();
$viewer = $this->getViewer();
@ -46,9 +61,7 @@ final class DiffusionRepositoryStatusManagementPanel
pht('Update Frequency'),
$this->buildRepositoryUpdateInterval($repository));
$messages = id(new PhabricatorRepositoryStatusMessage())
->loadAllWhere('repositoryID = %d', $repository->getID());
$messages = mpull($messages, null, 'getStatusType');
$messages = $this->loadStatusMessages($repository);
$status = $this->buildRepositoryStatus($repository, $messages);
$raw_error = $this->buildRepositoryRawError($repository, $messages);
@ -469,5 +482,13 @@ final class DiffusionRepositoryStatusManagementPanel
return $raw_message;
}
private function loadStatusMessages(PhabricatorRepository $repository) {
$messages = id(new PhabricatorRepositoryStatusMessage())
->loadAllWhere('repositoryID = %d', $repository->getID());
$messages = mpull($messages, null, 'getStatusType');
return $messages;
}
}

View file

@ -13,6 +13,18 @@ final class DiffusionRepositoryStorageManagementPanel
return 600;
}
public function getManagementPanelIcon() {
$repository = $this->getRepository();
if ($repository->getAlmanacServicePHID()) {
return 'fa-sitemap';
} else if ($repository->isHosted()) {
return 'fa-folder';
} else {
return 'fa-download';
}
}
public function buildManagementPanelContent() {
return array(
$this->buildStorageStatusPanel(),

View file

@ -13,6 +13,20 @@ final class DiffusionRepositorySymbolsManagementPanel
return 900;
}
public function getManagementPanelIcon() {
$repository = $this->getRepository();
$has_any =
$repository->getSymbolLanguages() ||
$repository->getSymbolSources();
if ($has_any) {
return 'fa-link';
} else {
return 'fa-link grey';
}
}
protected function getEditEngineFieldKeys() {
return array(
'symbolLanguages',

View file

@ -9,8 +9,12 @@ final class DiffusionRepositoryURIsManagementPanel
return pht('Clone / Fetch / Mirror');
}
public function getManagementPanelIcon() {
return 'fa-cogs';
}
public function getManagementPanelOrder() {
return 300;
return 400;
}
public function buildManagementPanelContent() {

View file

@ -9,6 +9,35 @@ final class DrydockAuthorizationQuery extends DrydockQuery {
private $blueprintStates;
private $objectStates;
public static function isFullyAuthorized(
$object_phid,
array $blueprint_phids) {
if (!$blueprint_phids) {
return true;
}
$authorizations = id(new self())
->setViewer(PhabricatorUser::getOmnipotentUser())
->withObjectPHIDs(array($object_phid))
->withBlueprintPHIDs($blueprint_phids)
->execute();
$authorizations = mpull($authorizations, null, 'getBlueprintPHID');
foreach ($blueprint_phids as $phid) {
$authorization = idx($authorizations, $phid);
if (!$authorization) {
return false;
}
if (!$authorization->isAuthorized()) {
return false;
}
}
return true;
}
public function withIDs(array $ids) {
$this->ids = $ids;
return $this;

View file

@ -93,6 +93,11 @@ final class DrydockAuthorization extends DrydockDAO
return idx($map, $state, pht('<Unknown: %s>', $state));
}
public function isAuthorized() {
$state = $this->getBlueprintAuthorizationState();
return ($state == self::BLUEPRINTAUTH_AUTHORIZED);
}
/**
* Apply external authorization effects after a user chagnes the value of a
* blueprint selector control an object.

View file

@ -18,6 +18,12 @@
border-bottom-right-radius: 3px;
}
.phabricator-basic-nav .phabricator-side-menu .phui-list-item-icon {
margin-left: -12px;
text-align: center;
width: 24px;
}
.phabricator-basic-nav .phabricator-side-menu .phui-list-item-selected {
background-color: rgba({$alphablack},.05);
border-left: 4px solid {$sky};