1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2025-01-09 22:31:03 +01:00

Make UX improvements to diff create screen

Summary: Minor tweaks for consistency, and raise a friendlier error if the user doesn't upload anything.

Test Plan:
{F48686}
{F48685}

Reviewers: chad

Reviewed By: chad

CC: aran

Differential Revision: https://secure.phabricator.com/D6360
This commit is contained in:
epriestley 2013-07-03 10:32:02 -07:00
parent 29658db32e
commit ebfa7e2c95

View file

@ -6,6 +6,9 @@ final class DifferentialDiffCreateController extends DifferentialController {
$request = $this->getRequest(); $request = $this->getRequest();
$errors = array();
$e_diff = null;
$e_file = null;
if ($request->isFormPost()) { if ($request->isFormPost()) {
$diff = null; $diff = null;
@ -15,16 +18,26 @@ final class DifferentialDiffCreateController extends DifferentialController {
$diff = $request->getStr('diff'); $diff = $request->getStr('diff');
} }
$call = new ConduitCall( if (!strlen($diff)) {
'differential.createrawdiff', $errors[] = pht(
array( "You can not create an empty diff. Copy/paste a diff, or upload a ".
'diff' => $diff, "diff file.");
)); $e_diff = pht('Required');
$call->setUser($request->getUser()); $e_file = pht('Required');
$result = $call->execute(); }
$path = id(new PhutilURI($result['uri']))->getPath(); if (!$errors) {
return id(new AphrontRedirectResponse())->setURI($path); $call = new ConduitCall(
'differential.createrawdiff',
array(
'diff' => $diff,
));
$call->setUser($request->getUser());
$result = $call->execute();
$path = id(new PhutilURI($result['uri']))->getPath();
return id(new AphrontRedirectResponse())->setURI($path);
}
} }
$form = new AphrontFormView(); $form = new AphrontFormView();
@ -38,41 +51,52 @@ final class DifferentialDiffCreateController extends DifferentialController {
'target' => '_blank', 'target' => '_blank',
), ),
'Arcanist'); 'Arcanist');
$cancel_uri = $this->getApplicationURI();
$form $form
->setAction('/differential/diff/create/') ->setAction('/differential/diff/create/')
->setEncType('multipart/form-data') ->setEncType('multipart/form-data')
->setUser($request->getUser()) ->setUser($request->getUser())
->appendChild(hsprintf( ->appendInstructions(
'<p class="aphront-form-instructions">%s</p>',
pht( pht(
'The best way to create a Differential diff is by using %s, but you '. 'The best way to create a Differential diff is by using %s, but you '.
'can also just paste a diff (e.g., from %s or %s) into this box '. 'can also just paste a diff (for example, from %s, %s or %s) into '.
'or upload it as a file if you really want.', 'this box, or upload a diff file.',
$arcanist_link, $arcanist_link,
phutil_tag('tt', array(), 'svn diff'), phutil_tag('tt', array(), 'svn diff'),
phutil_tag('tt', array(), 'git diff')))) phutil_tag('tt', array(), 'git diff'),
phutil_tag('tt', array(), 'hg diff')))
->appendChild( ->appendChild(
id(new AphrontFormTextAreaControl()) id(new AphrontFormTextAreaControl())
->setLabel(pht('Raw Diff')) ->setLabel(pht('Raw Diff'))
->setName('diff') ->setName('diff')
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)) ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
->setError($e_diff))
->appendChild( ->appendChild(
id(new AphrontFormFileControl()) id(new AphrontFormFileControl())
->setLabel(pht('Raw Diff from file')) ->setLabel(pht('Raw Diff From File'))
->setName('diff-file')) ->setName('diff-file')
->setError($e_file))
->appendChild( ->appendChild(
id(new AphrontFormSubmitControl()) id(new AphrontFormSubmitControl())
->setValue(pht("Create Diff \xC2\xBB"))); ->addCancelButton($cancel_uri)
->setValue(pht("Create Diff")));
$crumbs = $this->buildApplicationCrumbs(); $crumbs = $this->buildApplicationCrumbs();
$crumbs->addCrumb( $crumbs->addCrumb(
id(new PhabricatorCrumbView()) id(new PhabricatorCrumbView())
->setName(pht('Create Diff')) ->setName(pht('Create Diff')));
->setHref('/differential/diff/create/'));
if ($errors) {
$errors = id(new AphrontErrorView())
->setErrors($errors);
}
return $this->buildApplicationPage( return $this->buildApplicationPage(
array( array(
$crumbs, $crumbs,
$errors,
$form $form
), ),
array( array(