1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 00:42:41 +01:00

Make it less confusing to create root-level Phriction doc

Summary: Without an existing root document, Phriction shows a nice little "fake" document as the landing page, which has its own nice "Edit this document" button. When showing that page, don't also render the standard "New Document" breadcrumb in the top right. That button always prompts first for a slug name, which is silly when the root document doesn't exist (because the slug name is required to be '').

Test Plan: Loaded Phriction with and without a root document.

Reviewers: epriestley

Reviewed By: epriestley

Subscribers: Korvin

Differential Revision: https://secure.phabricator.com/D19863
This commit is contained in:
Austin McKinley 2018-12-10 13:40:37 -08:00
parent 00a7071e2d
commit da4341cf8b
2 changed files with 19 additions and 8 deletions

View file

@ -2,6 +2,14 @@
abstract class PhrictionController extends PhabricatorController {
private $showingWelcomeDocument = false;
public function setShowingWelcomeDocument($show_welcome) {
$this->showingWelcomeDocument = $show_welcome;
return $this;
}
public function buildSideNavView($for_app = false) {
$user = $this->getRequest()->getUser();
@ -37,12 +45,14 @@ abstract class PhrictionController extends PhabricatorController {
->setIcon('fa-home'));
}
$crumbs->addAction(
id(new PHUIListItemView())
->setName(pht('New Document'))
->setHref('/phriction/new/?slug='.$this->getDocumentSlug())
->setWorkflow(true)
->setIcon('fa-plus-square'));
if (!$this->showingWelcomeDocument) {
$crumbs->addAction(
id(new PHUIListItemView())
->setName(pht('New Document'))
->setHref('/phriction/new/?slug='.$this->getDocumentSlug())
->setWorkflow(true)
->setIcon('fa-plus-square'));
}
return $crumbs;
}

View file

@ -9,6 +9,7 @@ final class PhrictionDocumentController
return true;
}
public function handleRequest(AphrontRequest $request) {
$viewer = $request->getViewer();
$this->slug = $request->getURIData('slug');
@ -35,15 +36,15 @@ final class PhrictionDocumentController
->needContent(true)
->executeOne();
if (!$document) {
$document = PhrictionDocument::initializeNewDocument($viewer, $slug);
if ($slug == '/') {
$title = pht('Welcome to Phriction');
$subtitle = pht('Phriction is a simple and easy to use wiki for '.
'keeping track of documents and their changes.');
$page_title = pht('Welcome');
$create_text = pht('Edit this Document');
$this->setShowingWelcomeDocument(true);
} else {
$title = pht('No Document Here');