Differential D19191 Diff 45965 src/applications/owners/controller/PhabricatorOwnersPathsController.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/owners/controller/PhabricatorOwnersPathsController.php
| Show All 21 Lines | public function handleRequest(AphrontRequest $request) { | ||||
| if ($request->isFormPost()) { | if ($request->isFormPost()) { | ||||
| $paths = $request->getArr('path'); | $paths = $request->getArr('path'); | ||||
| $repos = $request->getArr('repo'); | $repos = $request->getArr('repo'); | ||||
| $excludes = $request->getArr('exclude'); | $excludes = $request->getArr('exclude'); | ||||
| $path_refs = array(); | $path_refs = array(); | ||||
| foreach ($paths as $key => $path) { | foreach ($paths as $key => $path) { | ||||
| if (!isset($repos[$key])) { | if (!isset($repos[$key]) || !strlen($repos[$key])) { | ||||
| throw new Exception( | throw new Exception( | ||||
| pht( | pht( | ||||
| 'No repository PHID for path "%s"!', | 'No repository PHID for path "%s"!', | ||||
| $key)); | $key)); | ||||
| } | } | ||||
| if (!isset($excludes[$key])) { | if (!isset($excludes[$key])) { | ||||
| throw new Exception( | throw new Exception( | ||||
| Show All 26 Lines | if ($request->isFormPost()) { | ||||
| return id(new AphrontRedirectResponse()) | return id(new AphrontRedirectResponse()) | ||||
| ->setURI($package->getURI()); | ->setURI($package->getURI()); | ||||
| } else { | } else { | ||||
| $paths = $package->getPaths(); | $paths = $package->getPaths(); | ||||
| $path_refs = mpull($paths, 'getRef'); | $path_refs = mpull($paths, 'getRef'); | ||||
| } | } | ||||
| $repos = id(new PhabricatorRepositoryQuery()) | $template = new AphrontTokenizerTemplateView(); | ||||
| ->setViewer($viewer) | |||||
| ->execute(); | $datasource = id(new DiffusionRepositoryDatasource()) | ||||
| ->setViewer($viewer); | |||||
| $tokenizer_spec = array( | |||||
| 'markup' => $template->render(), | |||||
| 'config' => array( | |||||
| 'src' => $datasource->getDatasourceURI(), | |||||
| 'browseURI' => $datasource->getBrowseURI(), | |||||
| 'placeholder' => $datasource->getPlaceholderText(), | |||||
| 'limit' => 1, | |||||
| ), | |||||
| ); | |||||
| $repo_map = array(); | foreach ($path_refs as $key => $path_ref) { | ||||
| foreach ($repos as $key => $repo) { | $path_refs[$key]['repositoryValue'] = $datasource->getWireTokens( | ||||
| $monogram = $repo->getMonogram(); | array( | ||||
| $name = $repo->getName(); | $path_ref['repositoryPHID'], | ||||
| $repo_map[$repo->getPHID()] = "{$monogram} {$name}"; | )); | ||||
| } | } | ||||
| asort($repos); | |||||
| $icon_test = id(new PHUIIconView()) | |||||
| ->setIcon('fa-spinner grey') | |||||
| ->setTooltip(pht('Validating...')); | |||||
| $icon_okay = id(new PHUIIconView()) | |||||
| ->setIcon('fa-check-circle green') | |||||
| ->setTooltip(pht('Path Exists in Repository')); | |||||
| $icon_fail = id(new PHUIIconView()) | |||||
| ->setIcon('fa-question-circle-o red') | |||||
| ->setTooltip(pht('Path Not Found On Default Branch')); | |||||
| $template = new AphrontTypeaheadTemplateView(); | $template = new AphrontTypeaheadTemplateView(); | ||||
| $template = $template->render(); | $template = $template->render(); | ||||
| Javelin::initBehavior( | Javelin::initBehavior( | ||||
| 'owners-path-editor', | 'owners-path-editor', | ||||
| array( | array( | ||||
| 'root' => 'path-editor', | 'root' => 'path-editor', | ||||
| 'table' => 'paths', | 'table' => 'paths', | ||||
| 'add_button' => 'addpath', | 'add_button' => 'addpath', | ||||
| 'repositories' => $repo_map, | |||||
| 'input_template' => $template, | 'input_template' => $template, | ||||
| 'pathRefs' => $path_refs, | 'pathRefs' => $path_refs, | ||||
| 'completeURI' => '/diffusion/services/path/complete/', | 'completeURI' => '/diffusion/services/path/complete/', | ||||
| 'validateURI' => '/diffusion/services/path/validate/', | 'validateURI' => '/diffusion/services/path/validate/', | ||||
| 'repositoryTokenizerSpec' => $tokenizer_spec, | |||||
| 'icons' => array( | |||||
| 'test' => hsprintf('%s', $icon_test), | |||||
| 'okay' => hsprintf('%s', $icon_okay), | |||||
| 'fail' => hsprintf('%s', $icon_fail), | |||||
| ), | |||||
| 'modeOptions' => array( | |||||
| 0 => pht('Include'), | |||||
| 1 => pht('Exclude'), | |||||
| ), | |||||
| )); | )); | ||||
| require_celerity_resource('owners-path-editor-css'); | require_celerity_resource('owners-path-editor-css'); | ||||
| $cancel_uri = $package->getURI(); | $cancel_uri = $package->getURI(); | ||||
| $form = id(new AphrontFormView()) | $form = id(new AphrontFormView()) | ||||
| ->setUser($viewer) | ->setUser($viewer) | ||||
| ▲ Show 20 Lines • Show All 59 Lines • Show Last 20 Lines | |||||