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

Allow Drydock blueprints to be tagged and searched, and give types some little icons

Summary:
Ref T10457.

  - Let blueprints be tagged so you can search and annotate them a little more easily.
  - Give each blueprint type an optional icon to make things a little easier to parse visually.

Test Plan:
  - Tagged blueprints.
  - Searched by tags.
  - Looked at nice little icons.

{F1139712}

Reviewers: chad

Reviewed By: chad

Subscribers: yelirekim

Maniphest Tasks: T10457

Differential Revision: https://secure.phabricator.com/D15392
This commit is contained in:
epriestley 2016-03-03 05:52:21 -08:00
parent 1bdf988556
commit fc0dc02bb9
11 changed files with 93 additions and 7 deletions

View file

@ -0,0 +1,16 @@
CREATE TABLE {$NAMESPACE}_drydock.edge (
src VARBINARY(64) NOT NULL,
type INT UNSIGNED NOT NULL,
dst VARBINARY(64) NOT NULL,
dateCreated INT UNSIGNED NOT NULL,
seq INT UNSIGNED NOT NULL,
dataID INT UNSIGNED,
PRIMARY KEY (src, type, dst),
KEY `src` (src, type, dateCreated, seq),
UNIQUE KEY `key_dst` (dst, type, src)
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};
CREATE TABLE {$NAMESPACE}_drydock.edgedata (
id INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
data LONGTEXT NOT NULL COLLATE {$COLLATE_TEXT}
) ENGINE=InnoDB, COLLATE {$COLLATE_TEXT};

View file

@ -966,6 +966,7 @@ phutil_register_library_map(array(
'DrydockResourceViewController' => 'applications/drydock/controller/DrydockResourceViewController.php',
'DrydockSFTPFilesystemInterface' => 'applications/drydock/interface/filesystem/DrydockSFTPFilesystemInterface.php',
'DrydockSSHCommandInterface' => 'applications/drydock/interface/command/DrydockSSHCommandInterface.php',
'DrydockSchemaSpec' => 'applications/drydock/storage/DrydockSchemaSpec.php',
'DrydockSlotLock' => 'applications/drydock/storage/DrydockSlotLock.php',
'DrydockSlotLockException' => 'applications/drydock/exception/DrydockSlotLockException.php',
'DrydockSlotLockFailureLogType' => 'applications/drydock/logtype/DrydockSlotLockFailureLogType.php',
@ -4975,6 +4976,7 @@ phutil_register_library_map(array(
'PhabricatorPolicyInterface',
'PhabricatorCustomFieldInterface',
'PhabricatorNgramsInterface',
'PhabricatorProjectInterface',
),
'DrydockBlueprintController' => 'DrydockController',
'DrydockBlueprintCoreCustomField' => array(
@ -5094,6 +5096,7 @@ phutil_register_library_map(array(
'DrydockResourceViewController' => 'DrydockResourceController',
'DrydockSFTPFilesystemInterface' => 'DrydockFilesystemInterface',
'DrydockSSHCommandInterface' => 'DrydockCommandInterface',
'DrydockSchemaSpec' => 'PhabricatorConfigSchemaSpec',
'DrydockSlotLock' => 'DrydockDAO',
'DrydockSlotLockException' => 'Exception',
'DrydockSlotLockFailureLogType' => 'DrydockLogType',

View file

@ -15,6 +15,10 @@ final class DrydockAlmanacServiceHostBlueprintImplementation
return pht('Almanac Hosts');
}
public function getBlueprintIcon() {
return 'fa-server';
}
public function getDescription() {
return pht(
'Allows Drydock to lease existing hosts defined in an Almanac service '.

View file

@ -15,6 +15,10 @@ abstract class DrydockBlueprintImplementation extends Phobject {
abstract public function getBlueprintName();
abstract public function getDescription();
public function getBlueprintIcon() {
return 'fa-map-o';
}
public function getFieldSpecifications() {
$fields = array();

View file

@ -13,6 +13,10 @@ final class DrydockWorkingCopyBlueprintImplementation
return pht('Working Copy');
}
public function getBlueprintIcon() {
return 'fa-folder-open';
}
public function getDescription() {
return pht('Allows Drydock to check out working copies of repositories.');
}

View file

@ -52,9 +52,15 @@ final class DrydockBlueprintEditController extends DrydockBlueprintController {
foreach ($implementations as $implementation_name => $implementation) {
$disabled = !$implementation->isEnabled();
$impl_icon = $implementation->getBlueprintIcon();
$impl_name = $implementation->getBlueprintName();
$impl_icon = id(new PHUIIconView())
->setIcon($impl_icon, 'lightgreytext');
$control->addButton(
$implementation_name,
$implementation->getBlueprintName(),
array($impl_icon, ' ', $impl_name),
array(
pht('Provides: %s', $implementation->getType()),
phutil_tag('br'),

View file

@ -127,8 +127,12 @@ final class DrydockBlueprintViewController extends DrydockBlueprintController {
private function buildPropertyListView(
DrydockBlueprint $blueprint,
PhabricatorActionListView $actions) {
$viewer = $this->getViewer();
$view = id(new PHUIPropertyListView())
->setUser($viewer)
->setObject($blueprint);
$view = new PHUIPropertyListView();
$view->setActionList($actions);
$view->addProperty(

View file

@ -77,15 +77,29 @@ final class DrydockBlueprintSearchEngine
assert_instances_of($blueprints, 'DrydockBlueprint');
$viewer = $this->requireViewer();
if ($blueprints) {
$edge_query = id(new PhabricatorEdgeQuery())
->withSourcePHIDs(mpull($blueprints, 'getPHID'))
->withEdgeTypes(
array(
PhabricatorProjectObjectHasProjectEdgeType::EDGECONST,
));
$edge_query->execute();
}
$view = new PHUIObjectItemListView();
foreach ($blueprints as $blueprint) {
$impl = $blueprint->getImplementation();
$item = id(new PHUIObjectItemView())
->setHeader($blueprint->getBlueprintName())
->setHref($this->getApplicationURI('/blueprint/'.$blueprint->getID()))
->setHref($blueprint->getURI())
->setObjectName(pht('Blueprint %d', $blueprint->getID()));
if (!$blueprint->getImplementation()->isEnabled()) {
if (!$impl->isEnabled()) {
$item->setDisabled(true);
$item->addIcon('fa-chain-broken grey', pht('Implementation'));
}
@ -95,7 +109,24 @@ final class DrydockBlueprintSearchEngine
$item->addIcon('fa-ban grey', pht('Disabled'));
}
$item->addAttribute($blueprint->getImplementation()->getBlueprintName());
$impl_icon = $impl->getBlueprintIcon();
$impl_name = $impl->getBlueprintName();
$impl_icon = id(new PHUIIconView())
->setIcon($impl_icon, 'lightgreytext');
$item->addAttribute(array($impl_icon, ' ', $impl_name));
$phid = $blueprint->getPHID();
$project_phids = $edge_query->getDestinationPHIDs(array($phid));
if ($project_phids) {
$project_handles = $viewer->loadHandles($project_phids);
$item->addAttribute(
id(new PHUIHandleTagListView())
->setLimit(4)
->setSlim(true)
->setHandles($project_handles));
}
$view->addItem($item);
}

View file

@ -9,7 +9,8 @@ final class DrydockBlueprint extends DrydockDAO
PhabricatorApplicationTransactionInterface,
PhabricatorPolicyInterface,
PhabricatorCustomFieldInterface,
PhabricatorNgramsInterface {
PhabricatorNgramsInterface,
PhabricatorProjectInterface {
protected $className;
protected $blueprintName;
@ -119,6 +120,11 @@ final class DrydockBlueprint extends DrydockDAO
return $log->save();
}
public function getURI() {
$id = $this->getID();
return "/drydock/blueprint/{$id}/";
}
/* -( Allocating Resources )----------------------------------------------- */

View file

@ -0,0 +1,9 @@
<?php
final class DrydockSchemaSpec extends PhabricatorConfigSchemaSpec {
public function buildSchemata() {
$this->buildEdgeSchemata(new DrydockBlueprint());
}
}

View file

@ -84,7 +84,6 @@ final class HarbormasterBuildPlanSearchEngine
$viewer = $this->requireViewer();
if ($plans) {
$edge_query = id(new PhabricatorEdgeQuery())
->withSourcePHIDs(mpull($plans, 'getPHID'))