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);
|
|
|
|
|
2011-06-10 00:28:29 +02:00
|
|
|
$project = new PhabricatorProject();
|
|
|
|
$project->setAuthorPHID($user->getPHID());
|
2013-10-07 02:13:51 +02:00
|
|
|
$project->attachMemberPHIDs(array());
|
2011-06-10 00:28:29 +02:00
|
|
|
$profile = new PhabricatorProjectProfile();
|
|
|
|
|
|
|
|
$e_name = true;
|
|
|
|
$errors = array();
|
|
|
|
if ($request->isFormPost()) {
|
|
|
|
|
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
|
|
|
try {
|
2012-01-24 16:11:37 +01:00
|
|
|
$xactions = array();
|
2012-08-08 03:02:05 +02:00
|
|
|
|
2012-01-24 16:11:37 +01:00
|
|
|
$xaction = new PhabricatorProjectTransaction();
|
|
|
|
$xaction->setTransactionType(
|
|
|
|
PhabricatorProjectTransactionType::TYPE_NAME);
|
|
|
|
$xaction->setNewValue($request->getStr('name'));
|
|
|
|
$xactions[] = $xaction;
|
|
|
|
|
2012-08-08 03:02:05 +02:00
|
|
|
$xaction = new PhabricatorProjectTransaction();
|
|
|
|
$xaction->setTransactionType(
|
|
|
|
PhabricatorProjectTransactionType::TYPE_MEMBERS);
|
|
|
|
$xaction->setNewValue(array($user->getPHID()));
|
|
|
|
$xactions[] = $xaction;
|
|
|
|
|
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
|
|
|
$editor = new PhabricatorProjectEditor($project);
|
2012-10-10 19:18:23 +02:00
|
|
|
$editor->setActor($user);
|
2012-01-24 16:11:37 +01:00
|
|
|
$editor->applyTransactions($xactions);
|
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
|
|
|
} catch (PhabricatorProjectNameCollisionException $ex) {
|
|
|
|
$e_name = 'Not Unique';
|
|
|
|
$errors[] = $ex->getMessage();
|
|
|
|
}
|
|
|
|
|
2011-06-10 00:28:29 +02:00
|
|
|
$profile->setBlurb($request->getStr('blurb'));
|
|
|
|
|
|
|
|
if (!$errors) {
|
|
|
|
$project->save();
|
|
|
|
$profile->setProjectPHID($project->getPHID());
|
|
|
|
$profile->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();
|
2013-02-13 18:22:14 +01:00
|
|
|
$error_view->setTitle(pht('Form Errors'));
|
2011-06-10 00:28:29 +02:00
|
|
|
$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())
|
|
|
|
->setError($e_name))
|
|
|
|
->appendChild(
|
|
|
|
id(new AphrontFormTextAreaControl())
|
2013-02-13 18:22:14 +01:00
|
|
|
->setLabel(pht('Blurb'))
|
2011-06-10 00:28:29 +02:00
|
|
|
->setName('blurb')
|
|
|
|
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_SHORT)
|
|
|
|
->setValue($profile->getBlurb()));
|
|
|
|
|
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());
|
|
|
|
$crumbs->addCrumb(
|
|
|
|
id(new PhabricatorCrumbView())
|
|
|
|
->setName(pht('Create Project'))
|
2013-02-19 22:33:10 +01:00
|
|
|
->setHref($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'))
|
|
|
|
->setFormError($error_view)
|
|
|
|
->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
|
|
|
}
|
|
|
|
}
|