1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-24 06:20:56 +01:00

Rename project -> product on edit/create UIs

Summary: Ref T3092. Ref T3549. Modernize the product creation and edit UIs and make them say "product" instead of "project".

Test Plan:
  - Created products.
  - Edited products.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T3092, T3549

Differential Revision: https://secure.phabricator.com/D8636
This commit is contained in:
epriestley 2014-03-29 09:16:40 -07:00
parent 98b0b5e62b
commit 8c88180ee1
4 changed files with 94 additions and 106 deletions

View file

@ -2516,6 +2516,8 @@ phutil_register_library_map(array(
'ReleephPHIDTypeRequest' => 'applications/releeph/phid/ReleephPHIDTypeRequest.php', 'ReleephPHIDTypeRequest' => 'applications/releeph/phid/ReleephPHIDTypeRequest.php',
'ReleephProductActionController' => 'applications/releeph/controller/project/ReleephProductActionController.php', 'ReleephProductActionController' => 'applications/releeph/controller/project/ReleephProductActionController.php',
'ReleephProductController' => 'applications/releeph/controller/project/ReleephProductController.php', 'ReleephProductController' => 'applications/releeph/controller/project/ReleephProductController.php',
'ReleephProductCreateController' => 'applications/releeph/controller/project/ReleephProductCreateController.php',
'ReleephProductEditController' => 'applications/releeph/controller/project/ReleephProductEditController.php',
'ReleephProductEditor' => 'applications/releeph/editor/ReleephProductEditor.php', 'ReleephProductEditor' => 'applications/releeph/editor/ReleephProductEditor.php',
'ReleephProductHistoryController' => 'applications/releeph/controller/project/ReleephProductHistoryController.php', 'ReleephProductHistoryController' => 'applications/releeph/controller/project/ReleephProductHistoryController.php',
'ReleephProductListController' => 'applications/releeph/controller/project/ReleephProductListController.php', 'ReleephProductListController' => 'applications/releeph/controller/project/ReleephProductListController.php',
@ -2525,8 +2527,6 @@ phutil_register_library_map(array(
'ReleephProductViewController' => 'applications/releeph/controller/project/ReleephProductViewController.php', 'ReleephProductViewController' => 'applications/releeph/controller/project/ReleephProductViewController.php',
'ReleephProject' => 'applications/releeph/storage/ReleephProject.php', 'ReleephProject' => 'applications/releeph/storage/ReleephProject.php',
'ReleephProjectController' => 'applications/releeph/controller/ReleephProjectController.php', 'ReleephProjectController' => 'applications/releeph/controller/ReleephProjectController.php',
'ReleephProjectCreateController' => 'applications/releeph/controller/project/ReleephProjectCreateController.php',
'ReleephProjectEditController' => 'applications/releeph/controller/project/ReleephProjectEditController.php',
'ReleephProjectQuery' => 'applications/releeph/query/ReleephProjectQuery.php', 'ReleephProjectQuery' => 'applications/releeph/query/ReleephProjectQuery.php',
'ReleephReasonFieldSpecification' => 'applications/releeph/field/specification/ReleephReasonFieldSpecification.php', 'ReleephReasonFieldSpecification' => 'applications/releeph/field/specification/ReleephReasonFieldSpecification.php',
'ReleephRequest' => 'applications/releeph/storage/ReleephRequest.php', 'ReleephRequest' => 'applications/releeph/storage/ReleephRequest.php',
@ -5491,6 +5491,8 @@ phutil_register_library_map(array(
'ReleephPHIDTypeRequest' => 'PhabricatorPHIDType', 'ReleephPHIDTypeRequest' => 'PhabricatorPHIDType',
'ReleephProductActionController' => 'ReleephProductController', 'ReleephProductActionController' => 'ReleephProductController',
'ReleephProductController' => 'ReleephController', 'ReleephProductController' => 'ReleephController',
'ReleephProductCreateController' => 'ReleephProjectController',
'ReleephProductEditController' => 'ReleephProductController',
'ReleephProductEditor' => 'PhabricatorApplicationTransactionEditor', 'ReleephProductEditor' => 'PhabricatorApplicationTransactionEditor',
'ReleephProductHistoryController' => 'ReleephProductController', 'ReleephProductHistoryController' => 'ReleephProductController',
'ReleephProductListController' => 'ReleephProductListController' =>
@ -5512,8 +5514,6 @@ phutil_register_library_map(array(
1 => 'PhabricatorPolicyInterface', 1 => 'PhabricatorPolicyInterface',
), ),
'ReleephProjectController' => 'ReleephController', 'ReleephProjectController' => 'ReleephController',
'ReleephProjectCreateController' => 'ReleephProjectController',
'ReleephProjectEditController' => 'ReleephProjectController',
'ReleephProjectQuery' => 'PhabricatorCursorPagedPolicyAwareQuery', 'ReleephProjectQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
'ReleephReasonFieldSpecification' => 'ReleephFieldSpecification', 'ReleephReasonFieldSpecification' => 'ReleephFieldSpecification',
'ReleephRequest' => 'ReleephRequest' =>

View file

@ -36,10 +36,10 @@ final class PhabricatorApplicationReleeph extends PhabricatorApplication {
'' => 'ReleephProductListController', '' => 'ReleephProductListController',
'project/' => array( 'project/' => array(
'(?:query/(?P<queryKey>[^/]+)/)?' => 'ReleephProductListController', '(?:query/(?P<queryKey>[^/]+)/)?' => 'ReleephProductListController',
'create/' => 'ReleephProjectCreateController', 'create/' => 'ReleephProductCreateController',
'(?P<projectID>[1-9]\d*)/' => array( '(?P<projectID>[1-9]\d*)/' => array(
'(?:query/(?P<queryKey>[^/]+)/)?' => 'ReleephProductViewController', '(?:query/(?P<queryKey>[^/]+)/)?' => 'ReleephProductViewController',
'edit/' => 'ReleephProjectEditController', 'edit/' => 'ReleephProductEditController',
'cutbranch/' => 'ReleephBranchCreateController', 'cutbranch/' => 'ReleephBranchCreateController',
'action/(?P<action>.+)/' => 'ReleephProductActionController', 'action/(?P<action>.+)/' => 'ReleephProductActionController',
'history/' => 'ReleephProductHistoryController', 'history/' => 'ReleephProductHistoryController',

View file

@ -1,6 +1,6 @@
<?php <?php
final class ReleephProjectCreateController extends ReleephProjectController { final class ReleephProductCreateController extends ReleephProjectController {
public function processRequest() { public function processRequest() {
$request = $this->getRequest(); $request = $this->getRequest();
@ -18,7 +18,7 @@ final class ReleephProjectCreateController extends ReleephProjectController {
if (!$name) { if (!$name) {
$e_name = pht('Required'); $e_name = pht('Required');
$errors[] = pht( $errors[] = pht(
'Your Releeph project should have a simple descriptive name.'); 'Your product should have a simple, descriptive name.');
} }
if (!$trunk_branch) { if (!$trunk_branch) {
@ -31,7 +31,7 @@ final class ReleephProjectCreateController extends ReleephProjectController {
$pr_repository = $arc_project->loadRepository(); $pr_repository = $arc_project->loadRepository();
if (!$errors) { if (!$errors) {
$releeph_project = id(new ReleephProject()) $releeph_product = id(new ReleephProject())
->setName($name) ->setName($name)
->setTrunkBranch($trunk_branch) ->setTrunkBranch($trunk_branch)
->setRepositoryPHID($pr_repository->getPHID()) ->setRepositoryPHID($pr_repository->getPHID())
@ -40,21 +40,20 @@ final class ReleephProjectCreateController extends ReleephProjectController {
->setIsActive(1); ->setIsActive(1);
try { try {
$releeph_project->save(); $releeph_product->save();
return id(new AphrontRedirectResponse()) return id(new AphrontRedirectResponse())
->setURI($releeph_project->getURI()); ->setURI($releeph_product->getURI());
} catch (AphrontQueryDuplicateKeyException $ex) { } catch (AphrontQueryDuplicateKeyException $ex) {
$e_name = pht('Not Unique'); $e_name = pht('Not Unique');
$errors[] = pht( $errors[] = pht('Another product already uses this name.');
'Another project already uses this name.');
} }
} }
} }
$arc_project_options = $this->getArcProjectSelectOptions($arc_projects); $arc_project_options = $this->getArcProjectSelectOptions($arc_projects);
$project_name_input = id(new AphrontFormTextControl()) $product_name_input = id(new AphrontFormTextControl())
->setLabel(pht('Name')) ->setLabel(pht('Name'))
->setDisableAutocomplete(true) ->setDisableAutocomplete(true)
->setName('name') ->setName('name')
@ -79,14 +78,14 @@ final class ReleephProjectCreateController extends ReleephProjectController {
$branch_name_preview = id(new ReleephBranchPreviewView()) $branch_name_preview = id(new ReleephBranchPreviewView())
->setLabel(pht('Example Branch')) ->setLabel(pht('Example Branch'))
->addControl('projectName', $project_name_input) ->addControl('projectName', $product_name_input)
->addControl('arcProjectID', $arc_project_input) ->addControl('arcProjectID', $arc_project_input)
->addStatic('template', '') ->addStatic('template', '')
->addStatic('isSymbolic', false); ->addStatic('isSymbolic', false);
$form = id(new AphrontFormView()) $form = id(new AphrontFormView())
->setUser($request->getUser()) ->setUser($request->getUser())
->appendChild($project_name_input) ->appendChild($product_name_input)
->appendChild($arc_project_input) ->appendChild($arc_project_input)
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
@ -100,15 +99,15 @@ final class ReleephProjectCreateController extends ReleephProjectController {
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->addCancelButton('/releeph/project/') ->addCancelButton('/releeph/project/')
->setValue(pht('Create'))); ->setValue(pht('Create Release Product')));
$form_box = id(new PHUIObjectBoxView()) $form_box = id(new PHUIObjectBoxView())
->setHeaderText(pht('Create New Project')) ->setHeaderText(pht('Create New Product'))
->setFormErrors($errors) ->setFormErrors($errors)
->setForm($form); ->setForm($form);
$crumbs = $this->buildApplicationCrumbs(); $crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('New Project')); $crumbs->addTextCrumb(pht('New Product'));
return $this->buildApplicationPage( return $this->buildApplicationPage(
array( array(
@ -116,7 +115,7 @@ final class ReleephProjectCreateController extends ReleephProjectController {
$form_box, $form_box,
), ),
array( array(
'title' => pht('Create New Project'), 'title' => pht('Create New Product'),
'device' => true, 'device' => true,
)); ));
} }

View file

@ -1,43 +1,61 @@
<?php <?php
final class ReleephProjectEditController extends ReleephProjectController { final class ReleephProductEditController extends ReleephProductController {
private $productID;
public function willProcessRequest(array $data) {
$this->productID = $data['projectID'];
}
public function processRequest() { public function processRequest() {
$request = $this->getRequest(); $request = $this->getRequest();
$viewer = $request->getUser();
$product = id(new ReleephProjectQuery())
->setViewer($viewer)
->withIDs(array($this->productID))
->requireCapabilities(
array(
PhabricatorPolicyCapability::CAN_VIEW,
PhabricatorPolicyCapability::CAN_EDIT,
))
->executeOne();
if (!$product) {
return new Aphront404Response();
}
$this->setProduct($product);
$e_name = true; $e_name = true;
$e_trunk_branch = true; $e_trunk_branch = true;
$e_branch_template = false; $e_branch_template = false;
$errors = array(); $errors = array();
$project_name = $request->getStr('name', $product_name = $request->getStr('name', $product->getName());
$this->getReleephProject()->getName());
$trunk_branch = $request->getStr('trunkBranch', $trunk_branch = $request->getStr('trunkBranch', $product->getTrunkBranch());
$this->getReleephProject()->getTrunkBranch());
$branch_template = $request->getStr('branchTemplate'); $branch_template = $request->getStr('branchTemplate');
if ($branch_template === null) { if ($branch_template === null) {
$branch_template = $branch_template = $product->getDetail('branchTemplate');
$this->getReleephProject()->getDetail('branchTemplate');
} }
$pick_failure_instructions = $request->getStr('pickFailureInstructions', $pick_failure_instructions = $request->getStr('pickFailureInstructions',
$this->getReleephProject()->getDetail('pick_failure_instructions')); $product->getDetail('pick_failure_instructions'));
$test_paths = $request->getStr('testPaths'); $test_paths = $request->getStr('testPaths');
if ($test_paths !== null) { if ($test_paths !== null) {
$test_paths = array_filter(explode("\n", $test_paths)); $test_paths = array_filter(explode("\n", $test_paths));
} else { } else {
$test_paths = $this->getReleephProject()->getDetail('testPaths', array()); $test_paths = $product->getDetail('testPaths', array());
} }
$arc_project_id = $this->getReleephProject()->getArcanistProjectID(); $arc_project_id = $product->getArcanistProjectID();
if ($request->isFormPost()) { if ($request->isFormPost()) {
$pusher_phids = $request->getArr('pushers'); $pusher_phids = $request->getArr('pushers');
if (!$project_name) { if (!$product_name) {
$e_name = pht('Required'); $e_name = pht('Required');
$errors[] = $errors[] =
pht('Your releeph project should have a simple descriptive name'); pht('Your releeph product should have a simple descriptive name.');
} }
if (!$trunk_branch) { if (!$trunk_branch) {
@ -46,14 +64,14 @@ final class ReleephProjectEditController extends ReleephProjectController {
pht('You must specify which branch you will be picking from.'); pht('You must specify which branch you will be picking from.');
} }
$other_releeph_projects = id(new ReleephProject()) $other_releeph_products = id(new ReleephProject())
->loadAllWhere('id <> %d', $this->getReleephProject()->getID()); ->loadAllWhere('id != %d', $product->getID());
$other_releeph_project_names = mpull($other_releeph_projects, $other_releeph_product_names = mpull($other_releeph_products,
'getName', 'getID'); 'getName', 'getID');
if (in_array($project_name, $other_releeph_project_names)) { if (in_array($product_name, $other_releeph_product_names)) {
$errors[] = pht("Releeph project name %s is already taken", $errors[] = pht("Releeph product name %s is already taken",
$project_name); $product_name);
} }
foreach ($test_paths as $test_path) { foreach ($test_paths as $test_path) {
@ -65,7 +83,7 @@ final class ReleephProjectEditController extends ReleephProjectController {
} }
} }
$project = $this->getReleephProject() $product
->setTrunkBranch($trunk_branch) ->setTrunkBranch($trunk_branch)
->setDetail('pushers', $pusher_phids) ->setDetail('pushers', $pusher_phids)
->setDetail('pick_failure_instructions', $pick_failure_instructions) ->setDetail('pick_failure_instructions', $pick_failure_instructions)
@ -78,7 +96,7 @@ final class ReleephProjectEditController extends ReleephProjectController {
if ($branch_template) { if ($branch_template) {
list($branch_name, $template_errors) = id(new ReleephBranchTemplate()) list($branch_name, $template_errors) = id(new ReleephBranchTemplate())
->setCommitHandle($fake_commit_handle) ->setCommitHandle($fake_commit_handle)
->setReleephProjectName($project_name) ->setReleephProjectName($product_name)
->interpolate($branch_template); ->interpolate($branch_template);
if ($template_errors) { if ($template_errors) {
@ -90,29 +108,15 @@ final class ReleephProjectEditController extends ReleephProjectController {
} }
if (!$errors) { if (!$errors) {
$project->save(); $product->save();
return id(new AphrontRedirectResponse()) return id(new AphrontRedirectResponse())->setURI($product->getURI());
->setURI('/releeph/project/');
} }
} }
$error_view = null;
if ($errors) {
$error_view = new AphrontErrorView();
$error_view->setErrors($errors);
}
$projects = mpull(
id(new PhabricatorProject())->loadAll(),
'getName',
'getID');
$projects[0] = '-'; // no project associated, that's ok
$pusher_phids = $request->getArr( $pusher_phids = $request->getArr(
'pushers', 'pushers',
$this->getReleephProject()->getDetail('pushers', array())); $product->getDetail('pushers', array()));
$handles = id(new PhabricatorHandleQuery()) $handles = id(new PhabricatorHandleQuery())
->setViewer($request->getUser()) ->setViewer($request->getUser())
@ -121,33 +125,32 @@ final class ReleephProjectEditController extends ReleephProjectController {
$pusher_handles = array_select_keys($handles, $pusher_phids); $pusher_handles = array_select_keys($handles, $pusher_phids);
$basic_inset = id(new AphrontFormInsetView()) $form = id(new AphrontFormView())
->setTitle(pht('Basics')) ->setUser($request->getUser())
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel(pht('Name')) ->setLabel(pht('Name'))
->setName('name') ->setName('name')
->setValue($project_name) ->setValue($product_name)
->setError($e_name) ->setError($e_name)
->setCaption(pht('A name like "Thrift" but not "Thrift releases".'))) ->setCaption(pht('A name like "Thrift" but not "Thrift releases".')))
->appendChild( ->appendChild(
id(new AphrontFormStaticControl()) id(new AphrontFormStaticControl())
->setLabel(pht('Repository')) ->setLabel(pht('Repository'))
->setValue( ->setValue(
$this $product
->getReleephProject() ->loadPhabricatorRepository()
->loadPhabricatorRepository() ->getName()))
->getName()))
->appendChild( ->appendChild(
id(new AphrontFormStaticControl()) id(new AphrontFormStaticControl())
->setLabel(pht('Arc Project')) ->setLabel(pht('Arc Project'))
->setValue( ->setValue(
$this->getReleephProject()->loadArcanistProject()->getName())) $product->loadArcanistProject()->getName()))
->appendChild( ->appendChild(
id(new AphrontFormStaticControl()) id(new AphrontFormStaticControl())
->setLabel(pht('Releeph Project PHID')) ->setLabel(pht('Releeph Project PHID'))
->setValue( ->setValue(
$this->getReleephProject()->getPHID())) $product->getPHID()))
->appendChild( ->appendChild(
id(new AphrontFormTextControl()) id(new AphrontFormTextControl())
->setLabel(pht('Trunk')) ->setLabel(pht('Trunk'))
@ -172,29 +175,10 @@ final class ReleephProjectEditController extends ReleephProjectController {
'in this project. One string per line. '. 'in this project. One string per line. '.
'Examples: \'__tests__\', \'/javatests/\'...'))); 'Examples: \'__tests__\', \'/javatests/\'...')));
$pushers_inset = id(new AphrontFormInsetView())
->setTitle(pht('Pushers'))
->appendChild(
pht('Pushers are allowed to approve Releeph requests to be committed. '.
'to this project\'s branches. If you leave this blank then anyone '.
'is allowed to approve requests.'))
->appendChild(
id(new AphrontFormTokenizerControl())
->setLabel(pht('Pushers'))
->setName('pushers')
->setDatasource('/typeahead/common/users/')
->setValue($pusher_handles));
// Build the Template inset
$help_markup = PhabricatorMarkupEngine::renderOneObject(
id(new PhabricatorMarkupOneOff())->setContent($this->getBranchHelpText()),
'default',
$request->getUser());
$branch_template_input = id(new AphrontFormTextControl()) $branch_template_input = id(new AphrontFormTextControl())
->setName('branchTemplate') ->setName('branchTemplate')
->setValue($branch_template) ->setValue($branch_template)
->setLabel('Template') ->setLabel('Branch Template')
->setError($e_branch_template) ->setError($e_branch_template)
->setCaption( ->setCaption(
pht("Leave this blank to use your installation's default.")); pht("Leave this blank to use your installation's default."));
@ -204,22 +188,18 @@ final class ReleephProjectEditController extends ReleephProjectController {
->addControl('template', $branch_template_input) ->addControl('template', $branch_template_input)
->addStatic('arcProjectID', $arc_project_id) ->addStatic('arcProjectID', $arc_project_id)
->addStatic('isSymbolic', false) ->addStatic('isSymbolic', false)
->addStatic('projectName', $this->getReleephProject()->getName()); ->addStatic('projectName', $product->getName());
$template_inset = id(new AphrontFormInsetView()) $form
->setTitle(pht('Branch Cutting'))
->appendChild( ->appendChild(
pht('Provide a pattern for creating new branches.')) id(new AphrontFormTokenizerControl())
->setLabel(pht('Pushers'))
->setName('pushers')
->setDatasource('/typeahead/common/users/')
->setValue($pusher_handles))
->appendChild($branch_template_input) ->appendChild($branch_template_input)
->appendChild($branch_template_preview) ->appendChild($branch_template_preview)
->appendChild($help_markup); ->appendRemarkupInstructions($this->getBranchHelpText());
// Build the form
$form = id(new AphrontFormView())
->setUser($request->getUser())
->appendChild($basic_inset)
->appendChild($pushers_inset)
->appendChild($template_inset);
$form $form
->appendChild( ->appendChild(
@ -227,14 +207,23 @@ final class ReleephProjectEditController extends ReleephProjectController {
->addCancelButton('/releeph/project/') ->addCancelButton('/releeph/project/')
->setValue(pht('Save'))); ->setValue(pht('Save')));
$panel = id(new AphrontPanelView()) $box = id(new PHUIObjectBoxView())
->setHeader(pht('Edit Releeph Project')) ->setHeaderText(pht('Edit Releeph Product'))
->appendChild($form) ->setFormErrors($errors)
->setWidth(AphrontPanelView::WIDTH_FORM); ->appendChild($form);
$crumbs = $this->buildApplicationCrumbs();
$crumbs->addTextCrumb(pht('Edit Product'));
return $this->buildStandardPageResponse( return $this->buildStandardPageResponse(
array($error_view, $panel), array(
array('title' => pht('Edit Releeph Project'))); $crumbs,
$box,
),
array(
'title' => pht('Edit Releeph Product'),
'device' => true,
));
} }
private function getBranchHelpText() { private function getBranchHelpText() {
@ -244,7 +233,7 @@ final class ReleephProjectEditController extends ReleephProjectController {
| Code | Meaning | Code | Meaning
| ----- | ------- | ----- | -------
| `%P` | The name of your project, with spaces changed to "-". | `%P` | The name of your product, with spaces changed to "-".
| `%p` | Like %P, but all lowercase. | `%p` | Like %P, but all lowercase.
| `%Y` | The four digit year associated with the branch date. | `%Y` | The four digit year associated with the branch date.
| `%m` | The two digit month. | `%m` | The two digit month.
@ -263,7 +252,7 @@ Use a directory to separate your release branches from other branches:
releases/%Y-%M-%d-%v releases/%Y-%M-%d-%v
=> releases/2012-30-16-rHERGE32cd512a52b7 => releases/2012-30-16-rHERGE32cd512a52b7
Include a second hierarchy if you share your repository with other projects: Include a second hierarchy if you share your repository with other products:
lang=none lang=none
releases/%P/%p-release-%Y%m%d-%V releases/%P/%p-release-%Y%m%d-%V