Page MenuHomePhabricator

D15808.diff
No OneTemporary

D15808.diff

diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -784,6 +784,7 @@
'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 @@
'DiffusionRepositoryStatusManagementPanel' => 'DiffusionRepositoryManagementPanel',
'DiffusionRepositoryStorageManagementPanel' => 'DiffusionRepositoryManagementPanel',
'DiffusionRepositorySymbolsController' => 'DiffusionRepositoryEditController',
+ 'DiffusionRepositorySymbolsManagementPanel' => 'DiffusionRepositoryManagementPanel',
'DiffusionRepositoryTag' => 'Phobject',
'DiffusionRepositoryTestAutomationController' => 'DiffusionRepositoryEditController',
'DiffusionRepositoryURIsIndexEngineExtension' => 'PhabricatorIndexEngineExtension',
diff --git a/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php b/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php
--- a/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php
+++ b/src/applications/diffusion/editor/DiffusionRepositoryEditEngine.php
@@ -183,6 +183,30 @@
->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'))
diff --git a/src/applications/diffusion/management/DiffusionRepositoryHistoryManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositoryHistoryManagementPanel.php
--- a/src/applications/diffusion/management/DiffusionRepositoryHistoryManagementPanel.php
+++ b/src/applications/diffusion/management/DiffusionRepositoryHistoryManagementPanel.php
@@ -10,7 +10,7 @@
}
public function getManagementPanelOrder() {
- return 900;
+ return 2000;
}
public function buildManagementPanelContent() {
diff --git a/src/applications/diffusion/management/DiffusionRepositorySymbolsManagementPanel.php b/src/applications/diffusion/management/DiffusionRepositorySymbolsManagementPanel.php
new file mode 100644
--- /dev/null
+++ b/src/applications/diffusion/management/DiffusionRepositorySymbolsManagementPanel.php
@@ -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);
+ }
+
+}
diff --git a/src/applications/repository/editor/PhabricatorRepositoryEditor.php b/src/applications/repository/editor/PhabricatorRepositoryEditor.php
--- a/src/applications/repository/editor/PhabricatorRepositoryEditor.php
+++ b/src/applications/repository/editor/PhabricatorRepositoryEditor.php
@@ -636,6 +636,43 @@
}
}
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;

File Metadata

Mime Type
text/plain
Expires
Oct 17 2024, 11:14 AM (4 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6721841
Default Alt Text
D15808.diff (7 KB)

Event Timeline