"Paste" application tweaks

Summary:
Tweaks to the paste app:

  - I realized that unlike all the other apps, it makes more sense for the
default view of this one to be "create paste" instead of "list pastes" since
when you access the application directly you are most often wanting to share
something. Swap list out of the default slot and make edit the default.
  - Make the textarea bigger (usability).
  - Allow you to copy an existing paste.
  - Implement 'raw view'.
  - Tweak/adjust list view (usability, formatting).
  - Tweak page titles.

Test Plan:
Created, copied, and listed pastes. Viewed raw paste. Created an invalid paste.
Tried to create a copy of a nonexistant paste.

Reviewed By: codeblock
Reviewers: codeblock, jungejason, aran, tuomaspelkonen
CC: aran, epriestley, codeblock
Differential Revision: 456
This commit is contained in:
epriestley
2011-06-13 19:12:30 -07:00
parent c87886c750
commit 555464c4a7
9 changed files with 70 additions and 36 deletions

View File

@@ -27,6 +27,7 @@ class PhabricatorPasteCreateController extends PhabricatorPasteController {
$error_view = null;
$e_text = true;
$paste_text = null;
if ($request->isFormPost()) {
$errors = array();
$title = $request->getStr('title');
@@ -59,6 +60,19 @@ class PhabricatorPasteCreateController extends PhabricatorPasteController {
$error_view->setErrors($errors);
$error_view->setTitle('A problem has occurred!');
}
} else {
$copy = $request->getInt('copy');
if ($copy) {
$copy_paste = id(new PhabricatorPaste())->load($copy);
if ($copy_paste) {
$title = nonempty($copy_paste->getTitle(), 'P'.$copy_paste->getID());
$paste->setTitle('Copy of '.$title);
$copy_file = id(new PhabricatorFile())->loadOneWhere(
'phid = %s',
$copy_paste->getFilePHID());
$paste_text = $copy_file->loadFileData();
}
}
}
$form = new AphrontFormView();
@@ -74,6 +88,8 @@ class PhabricatorPasteCreateController extends PhabricatorPasteController {
id(new AphrontFormTextAreaControl())
->setLabel('Text')
->setError($e_text)
->setValue($paste_text)
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL)
->setName('text'))
->appendChild(
id(new AphrontFormSubmitControl())