@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+44 -20
+44 -20
src/applications/differential/controller/DifferentialDiffCreateController.php
··· 6 6 7 7 $request = $this->getRequest(); 8 8 9 + $errors = array(); 10 + $e_diff = null; 11 + $e_file = null; 9 12 if ($request->isFormPost()) { 10 13 $diff = null; 11 14 ··· 15 18 $diff = $request->getStr('diff'); 16 19 } 17 20 18 - $call = new ConduitCall( 19 - 'differential.createrawdiff', 20 - array( 21 - 'diff' => $diff, 22 - )); 23 - $call->setUser($request->getUser()); 24 - $result = $call->execute(); 21 + if (!strlen($diff)) { 22 + $errors[] = pht( 23 + "You can not create an empty diff. Copy/paste a diff, or upload a ". 24 + "diff file."); 25 + $e_diff = pht('Required'); 26 + $e_file = pht('Required'); 27 + } 25 28 26 - $path = id(new PhutilURI($result['uri']))->getPath(); 27 - return id(new AphrontRedirectResponse())->setURI($path); 29 + if (!$errors) { 30 + $call = new ConduitCall( 31 + 'differential.createrawdiff', 32 + array( 33 + 'diff' => $diff, 34 + )); 35 + $call->setUser($request->getUser()); 36 + $result = $call->execute(); 37 + 38 + $path = id(new PhutilURI($result['uri']))->getPath(); 39 + return id(new AphrontRedirectResponse())->setURI($path); 40 + } 28 41 } 29 42 30 43 $form = new AphrontFormView(); ··· 38 51 'target' => '_blank', 39 52 ), 40 53 'Arcanist'); 54 + 55 + $cancel_uri = $this->getApplicationURI(); 56 + 41 57 $form 42 58 ->setAction('/differential/diff/create/') 43 59 ->setEncType('multipart/form-data') 44 60 ->setUser($request->getUser()) 45 - ->appendChild(hsprintf( 46 - '<p class="aphront-form-instructions">%s</p>', 61 + ->appendInstructions( 47 62 pht( 48 63 'The best way to create a Differential diff is by using %s, but you '. 49 - 'can also just paste a diff (e.g., from %s or %s) into this box '. 50 - 'or upload it as a file if you really want.', 64 + 'can also just paste a diff (for example, from %s, %s or %s) into '. 65 + 'this box, or upload a diff file.', 51 66 $arcanist_link, 52 67 phutil_tag('tt', array(), 'svn diff'), 53 - phutil_tag('tt', array(), 'git diff')))) 68 + phutil_tag('tt', array(), 'git diff'), 69 + phutil_tag('tt', array(), 'hg diff'))) 54 70 ->appendChild( 55 71 id(new AphrontFormTextAreaControl()) 56 72 ->setLabel(pht('Raw Diff')) 57 73 ->setName('diff') 58 - ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)) 74 + ->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL) 75 + ->setError($e_diff)) 59 76 ->appendChild( 60 77 id(new AphrontFormFileControl()) 61 - ->setLabel(pht('Raw Diff from file')) 62 - ->setName('diff-file')) 78 + ->setLabel(pht('Raw Diff From File')) 79 + ->setName('diff-file') 80 + ->setError($e_file)) 63 81 ->appendChild( 64 82 id(new AphrontFormSubmitControl()) 65 - ->setValue(pht("Create Diff \xC2\xBB"))); 83 + ->addCancelButton($cancel_uri) 84 + ->setValue(pht("Create Diff"))); 66 85 67 86 $crumbs = $this->buildApplicationCrumbs(); 68 87 $crumbs->addCrumb( 69 88 id(new PhabricatorCrumbView()) 70 - ->setName(pht('Create Diff')) 71 - ->setHref('/differential/diff/create/')); 89 + ->setName(pht('Create Diff'))); 90 + 91 + if ($errors) { 92 + $errors = id(new AphrontErrorView()) 93 + ->setErrors($errors); 94 + } 72 95 73 96 return $this->buildApplicationPage( 74 97 array( 75 98 $crumbs, 99 + $errors, 76 100 $form 77 101 ), 78 102 array(