2011-06-10 00:28:29 +02:00
|
|
|
<?php
|
|
|
|
|
2012-03-10 00:46:25 +01:00
|
|
|
final class PhabricatorProjectCreateController
|
2011-06-10 00:28:29 +02:00
|
|
|
extends PhabricatorProjectController {
|
|
|
|
|
|
|
|
|
|
|
|
public function processRequest() {
|
|
|
|
|
|
|
|
$request = $this->getRequest();
|
|
|
|
$user = $request->getUser();
|
|
|
|
|
2013-10-10 13:29:07 +02:00
|
|
|
$this->requireApplicationCapability(
|
|
|
|
ProjectCapabilityCreateProjects::CAPABILITY);
|
|
|
|
|
2014-02-10 23:30:17 +01:00
|
|
|
$project = PhabricatorProject::initializeNewProject($user);
|
2011-06-10 00:28:29 +02:00
|
|
|
|
|
|
|
$e_name = true;
|
|
|
|
$errors = array();
|
|
|
|
if ($request->isFormPost()) {
|
2014-02-10 23:30:17 +01:00
|
|
|
$xactions = array();
|
2011-06-10 00:28:29 +02:00
|
|
|
|
2014-02-10 23:30:17 +01:00
|
|
|
$xactions[] = id(new PhabricatorProjectTransaction())
|
|
|
|
->setTransactionType(PhabricatorProjectTransaction::TYPE_NAME)
|
|
|
|
->setNewValue($request->getStr('name'));
|
|
|
|
|
|
|
|
$xactions[] = id(new PhabricatorProjectTransaction())
|
|
|
|
->setTransactionType(PhabricatorTransactions::TYPE_EDGE)
|
|
|
|
->setMetadataValue('edge:type', PhabricatorEdgeConfig::TYPE_PROJ_MEMBER)
|
|
|
|
->setNewValue(
|
|
|
|
array(
|
|
|
|
'+' => array($user->getPHID() => $user->getPHID()),
|
|
|
|
));
|
|
|
|
|
|
|
|
$editor = id(new PhabricatorProjectTransactionEditor())
|
|
|
|
->setActor($user)
|
|
|
|
->setContinueOnNoEffect(true)
|
|
|
|
->setContentSourceFromRequest($request)
|
|
|
|
->applyTransactions($project, $xactions);
|
|
|
|
|
|
|
|
// TODO: Deal with name collision exceptions more gracefully.
|
Provide wiki pages for projects
Summary:
Provide tighter integration between Projects and Phriction. Partly, I have most
of a rewrite for the Projects homepage ready but it's not currently possible to
publish feed stories about a project so all the feeds are empty/boring. This
partly makes them more useful and partly just provides a tool integration point.
- When you create a project, all the wiki pages in projects/<project_name>/*
are associated with it.
- Publish updates to those pages as being related to the project so they'll
show up in project feeds.
- Show a project link on those pages.
This is very "convention over configuration" but I think it's the right
approach. We could provide some sort of, like, "@project=derp" tag to let you
associated arbitrary pages to projects later, but just letting you move pages is
probably far better.
Test Plan:
- Ran upgrade scripts against stupidly named projects ("der", " der", " der
", "der (2)", " der (2) (2)", etc). Ended up with uniquely named projects.
- Ran unit tests.
- Created /projects/ wiki documents and made sure they displayed correctly.
- Verified feed stories publish as project-related.
- Edited projects, including perfomring a name-colliding edit.
- Created projects, including performing a name-colliding create.
Reviewers: btrahan, jungejason
Reviewed By: btrahan
CC: aran, epriestley, btrahan
Maniphest Tasks: T681
Differential Revision: 1231
2011-12-17 20:58:55 +01:00
|
|
|
|
2011-06-10 00:28:29 +02:00
|
|
|
if (!$errors) {
|
|
|
|
$project->save();
|
|
|
|
|
2011-06-26 17:37:47 +02:00
|
|
|
if ($request->isAjax()) {
|
|
|
|
return id(new AphrontAjaxResponse())
|
|
|
|
->setContent(array(
|
|
|
|
'phid' => $project->getPHID(),
|
|
|
|
'name' => $project->getName(),
|
|
|
|
));
|
|
|
|
} else {
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
|
|
->setURI('/project/view/'.$project->getID().'/');
|
|
|
|
}
|
2011-06-10 00:28:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$error_view = null;
|
|
|
|
if ($errors) {
|
|
|
|
$error_view = new AphrontErrorView();
|
|
|
|
$error_view->setErrors($errors);
|
|
|
|
}
|
|
|
|
|
2011-06-26 17:37:47 +02:00
|
|
|
if ($request->isAjax()) {
|
2013-08-26 20:53:11 +02:00
|
|
|
$form = new PHUIFormLayoutView();
|
2011-06-26 17:37:47 +02:00
|
|
|
} else {
|
|
|
|
$form = new AphrontFormView();
|
|
|
|
$form->setUser($user);
|
|
|
|
}
|
|
|
|
|
|
|
|
$form
|
2011-06-10 00:28:29 +02:00
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextControl())
|
2013-02-13 18:22:14 +01:00
|
|
|
->setLabel(pht('Name'))
|
2011-06-10 00:28:29 +02:00
|
|
|
->setName('name')
|
|
|
|
->setValue($project->getName())
|
2014-02-10 23:31:57 +01:00
|
|
|
->setError($e_name));
|
2011-06-10 00:28:29 +02:00
|
|
|
|
2011-06-26 17:37:47 +02:00
|
|
|
if ($request->isAjax()) {
|
|
|
|
$dialog = id(new AphrontDialogView())
|
|
|
|
->setUser($user)
|
|
|
|
->setWidth(AphrontDialogView::WIDTH_FORM)
|
2013-02-13 18:22:14 +01:00
|
|
|
->setTitle(pht('Create a New Project'))
|
2011-06-26 17:37:47 +02:00
|
|
|
->appendChild($error_view)
|
|
|
|
->appendChild($form)
|
2013-02-13 18:22:14 +01:00
|
|
|
->addSubmitButton(pht('Create Project'))
|
2011-06-26 17:37:47 +02:00
|
|
|
->addCancelButton('/project/');
|
|
|
|
|
|
|
|
return id(new AphrontDialogResponse())->setDialog($dialog);
|
|
|
|
} else {
|
|
|
|
$form
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormSubmitControl())
|
2013-02-13 18:22:14 +01:00
|
|
|
->setValue(pht('Create'))
|
2011-06-26 17:37:47 +02:00
|
|
|
->addCancelButton('/project/'));
|
|
|
|
|
2013-02-13 18:22:14 +01:00
|
|
|
$crumbs = $this->buildApplicationCrumbs($this->buildSideNavView());
|
2013-12-19 02:47:34 +01:00
|
|
|
$crumbs->addTextCrumb(
|
|
|
|
pht('Create Project'),
|
|
|
|
$this->getApplicationURI().'create/');
|
2013-02-13 18:22:14 +01:00
|
|
|
|
2013-09-25 20:23:29 +02:00
|
|
|
$form_box = id(new PHUIObjectBoxView())
|
2013-08-26 20:53:11 +02:00
|
|
|
->setHeaderText(pht('Create New Project'))
|
2014-01-10 18:17:37 +01:00
|
|
|
->setFormErrors($errors)
|
2013-08-26 20:53:11 +02:00
|
|
|
->setForm($form);
|
|
|
|
|
2013-02-13 18:22:14 +01:00
|
|
|
return $this->buildApplicationPage(
|
2011-06-26 17:37:47 +02:00
|
|
|
array(
|
2013-02-13 18:22:14 +01:00
|
|
|
$crumbs,
|
2013-08-26 20:53:11 +02:00
|
|
|
$form_box,
|
2011-06-26 17:37:47 +02:00
|
|
|
),
|
|
|
|
array(
|
2013-02-13 18:22:14 +01:00
|
|
|
'title' => pht('Create New Project'),
|
Update form styles, implement in many places
Summary:
This creates a common form look and feel across the site. I spent a bit of time working out a number of kinks in our various renderings. Some things:
- Font Styles are correctly applied for form elements now.
- Everything lines up!
- Selects are larger, easier to read, interact.
- Inputs have been squared.
- Consistant CSS applied glow (try it!)
- Improved Mobile Responsiveness
- CSS applied to all form elements, not just Aphront
- Many other minor tweaks.
I tried to hit as many high profile forms as possible in an effort to increase consistency. Stopped for now and will follow up after this lands. I know Evan is not a super fan of the glow, but after working with it for a week, it's way cleaner and responsive than the OS controls. Give it a try.
Test Plan: Tested many applications, forms, mobile and tablet.
Reviewers: epriestley, btrahan
Reviewed By: epriestley
CC: aran, Korvin
Differential Revision: https://secure.phabricator.com/D5860
2013-05-07 23:07:06 +02:00
|
|
|
'device' => true,
|
2011-06-26 17:37:47 +02:00
|
|
|
));
|
|
|
|
}
|
2011-06-10 00:28:29 +02:00
|
|
|
}
|
|
|
|
}
|