From 4a8ce1699b9a7c7085117423f5492b88078aeb4b Mon Sep 17 00:00:00 2001 From: Bob Trahan Date: Fri, 9 Nov 2012 15:08:37 -0800 Subject: [PATCH] Create a "New Document" button in phriction Summary: gives user a dialogue and they can fill out what comes after /w/ Test Plan: made some new wiki docs. played with garbage data and edit scenarios as well as vanilla create -- good ish Reviewers: epriestley, chad Reviewed By: epriestley CC: aran, Korvin Maniphest Tasks: T1360 Differential Revision: https://secure.phabricator.com/D3946 --- src/__phutil_library_map__.php | 2 + .../PhabricatorApplicationPhriction.php | 1 + .../PhrictionDocumentController.php | 20 +++++++--- .../controller/PhrictionNewController.php | 38 +++++++++++++++++++ 4 files changed, 55 insertions(+), 6 deletions(-) create mode 100644 src/applications/phriction/controller/PhrictionNewController.php diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 47484d5de4..f58c93adf1 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -1217,6 +1217,7 @@ phutil_register_library_map(array( 'PhrictionEditController' => 'applications/phriction/controller/PhrictionEditController.php', 'PhrictionHistoryController' => 'applications/phriction/controller/PhrictionHistoryController.php', 'PhrictionListController' => 'applications/phriction/controller/PhrictionListController.php', + 'PhrictionNewController' => 'applications/phriction/controller/PhrictionNewController.php', 'PonderAddAnswerView' => 'applications/ponder/view/PonderAddAnswerView.php', 'PonderAddCommentView' => 'applications/ponder/view/PonderAddCommentView.php', 'PonderAnswer' => 'applications/ponder/storage/PonderAnswer.php', @@ -2395,6 +2396,7 @@ phutil_register_library_map(array( 'PhrictionEditController' => 'PhrictionController', 'PhrictionHistoryController' => 'PhrictionController', 'PhrictionListController' => 'PhrictionController', + 'PhrictionNewController' => 'PhrictionController', 'PonderAddAnswerView' => 'AphrontView', 'PonderAddCommentView' => 'AphrontView', 'PonderAnswer' => diff --git a/src/applications/phriction/application/PhabricatorApplicationPhriction.php b/src/applications/phriction/application/PhabricatorApplicationPhriction.php index c5bde16d41..5e6cb2251b 100644 --- a/src/applications/phriction/application/PhabricatorApplicationPhriction.php +++ b/src/applications/phriction/application/PhabricatorApplicationPhriction.php @@ -38,6 +38,7 @@ final class PhabricatorApplicationPhriction extends PhabricatorApplication { 'edit/(?:(?P[1-9]\d*)/)?' => 'PhrictionEditController', 'delete/(?P[1-9]\d*)/' => 'PhrictionDeleteController', + 'new/' => 'PhrictionNewController', 'preview/' => 'PhrictionDocumentPreviewController', 'diff/(?P[1-9]\d*)/' => 'PhrictionDiffController', diff --git a/src/applications/phriction/controller/PhrictionDocumentController.php b/src/applications/phriction/controller/PhrictionDocumentController.php index 427873e174..2ef3369d6a 100644 --- a/src/applications/phriction/controller/PhrictionDocumentController.php +++ b/src/applications/phriction/controller/PhrictionDocumentController.php @@ -159,24 +159,32 @@ final class PhrictionDocumentController '
'. $byline. $core_content. - '
'; + ''; + $create_button = javelin_render_tag( + 'a', + array( + 'href' => '/phriction/new/', + 'class' => 'button green', + 'sigil' => 'workflow', + ), + pht('New Document')); $edit_button = phutil_render_tag( 'a', array( - 'href' => '/phriction/edit/'.$document->getID().'/', + 'href' => '/phriction/edit/'.$document->getID().'/', 'class' => 'button', ), - 'Edit Document'); + pht('Edit Document')); $history_button = phutil_render_tag( 'a', array( - 'href' => PhrictionDocument::getSlugURI($slug, 'history'), + 'href' => PhrictionDocument::getSlugURI($slug, 'history'), 'class' => 'button grey', ), - 'View History'); + pht('View History')); // these float right so history_button which is right most goes first - $buttons = $history_button.$edit_button; + $buttons = $history_button.$edit_button.$create_button; } if ($version_note) { diff --git a/src/applications/phriction/controller/PhrictionNewController.php b/src/applications/phriction/controller/PhrictionNewController.php new file mode 100644 index 0000000000..90873e423c --- /dev/null +++ b/src/applications/phriction/controller/PhrictionNewController.php @@ -0,0 +1,38 @@ +getRequest(); + $user = $request->getUser(); + + if ($request->isFormPost()) { + $slug = PhabricatorSlug::normalize($request->getStr('slug')); + $uri = '/phriction/edit/?slug='.$slug; + return id(new AphrontRedirectResponse()) + ->setURI($uri); + } + + $view = id(new AphrontFormLayoutView()) + ->appendChild(id(new AphrontFormTextControl()) + ->setLabel('/w/') + ->setName('slug')); + + $dialog = id(new AphrontDialogView()) + ->setUser($user) + ->setTitle(pht('New Document')) + ->appendChild(phutil_render_tag('p', + array(), + pht('Create a new document at'))) + ->appendChild($view) + ->addSubmitButton(pht('Create')) + ->addCancelButton($request->getRequestURI()); + + return id(new AphrontDialogResponse())->setDialog($dialog); + } + +}