mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-19 05:12:41 +01:00
Port Repository "Symbols" to Manage/Panel UI
Summary: Ref T10748. Port this, add EditEngine support, add some type validation to the transaction. Test Plan: - Edited via EditEngine. - Edited via Conduit. - Viewed via Management UI. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10748 Differential Revision: https://secure.phabricator.com/D15808
This commit is contained in:
parent
fbc4967154
commit
8f81930b5d
5 changed files with 128 additions and 1 deletions
|
@ -784,6 +784,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionRepositoryStatusManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryStatusManagementPanel.php',
|
||||
'DiffusionRepositoryStorageManagementPanel' => 'applications/diffusion/management/DiffusionRepositoryStorageManagementPanel.php',
|
||||
'DiffusionRepositorySymbolsController' => 'applications/diffusion/controller/DiffusionRepositorySymbolsController.php',
|
||||
'DiffusionRepositorySymbolsManagementPanel' => 'applications/diffusion/management/DiffusionRepositorySymbolsManagementPanel.php',
|
||||
'DiffusionRepositoryTag' => 'applications/diffusion/data/DiffusionRepositoryTag.php',
|
||||
'DiffusionRepositoryTestAutomationController' => 'applications/diffusion/controller/DiffusionRepositoryTestAutomationController.php',
|
||||
'DiffusionRepositoryURIsIndexEngineExtension' => 'applications/diffusion/engineextension/DiffusionRepositoryURIsIndexEngineExtension.php',
|
||||
|
@ -5001,6 +5002,7 @@ phutil_register_library_map(array(
|
|||
'DiffusionRepositoryStatusManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
||||
'DiffusionRepositoryStorageManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
||||
'DiffusionRepositorySymbolsController' => 'DiffusionRepositoryEditController',
|
||||
'DiffusionRepositorySymbolsManagementPanel' => 'DiffusionRepositoryManagementPanel',
|
||||
'DiffusionRepositoryTag' => 'Phobject',
|
||||
'DiffusionRepositoryTestAutomationController' => 'DiffusionRepositoryEditController',
|
||||
'DiffusionRepositoryURIsIndexEngineExtension' => 'PhabricatorIndexEngineExtension',
|
||||
|
|
|
@ -183,6 +183,30 @@ final class DiffusionRepositoryEditEngine
|
|||
->setConduitDescription(pht('Change automation blueprints.'))
|
||||
->setConduitTypeDescription(pht('New blueprint PHIDs.'))
|
||||
->setValue($object->getAutomationBlueprintPHIDs()),
|
||||
id(new PhabricatorStringListEditField())
|
||||
->setKey('symbolLanguages')
|
||||
->setLabel(pht('Languages'))
|
||||
->setTransactionType(
|
||||
PhabricatorRepositoryTransaction::TYPE_SYMBOLS_LANGUAGE)
|
||||
->setIsCopyable(true)
|
||||
->setDescription(
|
||||
pht('Languages which define symbols in this repository.'))
|
||||
->setConduitDescription(
|
||||
pht('Change symbol languages for this repository.'))
|
||||
->setConduitTypeDescription(
|
||||
pht('New symbol langauges.'))
|
||||
->setValue($object->getSymbolLanguages()),
|
||||
id(new PhabricatorDatasourceEditField())
|
||||
->setKey('symbolRepositoryPHIDs')
|
||||
->setLabel(pht('Uses Symbols From'))
|
||||
->setTransactionType(
|
||||
PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES)
|
||||
->setIsCopyable(true)
|
||||
->setDatasource(new DiffusionRepositoryDatasource())
|
||||
->setDescription(pht('Repositories to link symbols from.'))
|
||||
->setConduitDescription(pht('Change symbol source repositories.'))
|
||||
->setConduitTypeDescription(pht('New symbol repositories.'))
|
||||
->setValue($object->getSymbolSources()),
|
||||
id(new PhabricatorPolicyEditField())
|
||||
->setKey('policy.push')
|
||||
->setLabel(pht('Push Policy'))
|
||||
|
|
|
@ -10,7 +10,7 @@ final class DiffusionRepositoryHistoryManagementPanel
|
|||
}
|
||||
|
||||
public function getManagementPanelOrder() {
|
||||
return 900;
|
||||
return 2000;
|
||||
}
|
||||
|
||||
public function buildManagementPanelContent() {
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
final class DiffusionRepositorySymbolsManagementPanel
|
||||
extends DiffusionRepositoryManagementPanel {
|
||||
|
||||
const PANELKEY = 'symbols';
|
||||
|
||||
public function getManagementPanelLabel() {
|
||||
return pht('Symbols');
|
||||
}
|
||||
|
||||
public function getManagementPanelOrder() {
|
||||
return 900;
|
||||
}
|
||||
|
||||
protected function buildManagementPanelActions() {
|
||||
$repository = $this->getRepository();
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$can_edit = PhabricatorPolicyFilter::hasCapability(
|
||||
$viewer,
|
||||
$repository,
|
||||
PhabricatorPolicyCapability::CAN_EDIT);
|
||||
|
||||
$symbols_uri = $repository->getPathURI('edit/symbols/');
|
||||
|
||||
return array(
|
||||
id(new PhabricatorActionView())
|
||||
->setIcon('fa-pencil')
|
||||
->setName(pht('Edit Symbols'))
|
||||
->setHref($symbols_uri)
|
||||
->setDisabled(!$can_edit)
|
||||
->setWorkflow(!$can_edit),
|
||||
);
|
||||
}
|
||||
|
||||
public function buildManagementPanelContent() {
|
||||
$repository = $this->getRepository();
|
||||
$viewer = $this->getViewer();
|
||||
|
||||
$view = id(new PHUIPropertyListView())
|
||||
->setViewer($viewer)
|
||||
->setActionList($this->newActions());
|
||||
|
||||
$languages = $repository->getSymbolLanguages();
|
||||
if ($languages) {
|
||||
$languages = implode(', ', $languages);
|
||||
} else {
|
||||
$languages = phutil_tag('em', array(), pht('Any'));
|
||||
}
|
||||
$view->addProperty(pht('Languages'), $languages);
|
||||
|
||||
$sources = $repository->getSymbolSources();
|
||||
if ($sources) {
|
||||
$sources = $viewer->renderHandleList($sources);
|
||||
} else {
|
||||
$sources = phutil_tag('em', array(), pht('This Repository Only'));
|
||||
}
|
||||
$view->addProperty(pht('Uses Symbols From'), $sources);
|
||||
|
||||
return $this->newBox(pht('Symbols'), $view);
|
||||
}
|
||||
|
||||
}
|
|
@ -636,6 +636,43 @@ final class PhabricatorRepositoryEditor
|
|||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case PhabricatorRepositoryTransaction::TYPE_SYMBOLS_SOURCES:
|
||||
foreach ($xactions as $xaction) {
|
||||
$old = $object->getSymbolSources();
|
||||
$new = $xaction->getNewValue();
|
||||
|
||||
// If the viewer is adding new repositories, make sure they are
|
||||
// valid and visible.
|
||||
$add = array_diff($new, $old);
|
||||
if (!$add) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$repositories = id(new PhabricatorRepositoryQuery())
|
||||
->setViewer($this->getActor())
|
||||
->withPHIDs($add)
|
||||
->execute();
|
||||
$repositories = mpull($repositories, null, 'getPHID');
|
||||
|
||||
foreach ($add as $phid) {
|
||||
if (isset($repositories[$phid])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$errors[] = new PhabricatorApplicationTransactionValidationError(
|
||||
$type,
|
||||
pht('Invalid'),
|
||||
pht(
|
||||
'Repository ("%s") does not exist, or you do not have '.
|
||||
'permission to see it.',
|
||||
$phid),
|
||||
$xaction);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
return $errors;
|
||||
|
|
Loading…
Reference in a new issue