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
123 lines
3.5 KiB
PHP
123 lines
3.5 KiB
PHP
<?php
|
|
|
|
final class PhabricatorRepositoryCreateController
|
|
extends PhabricatorRepositoryController {
|
|
|
|
public function processRequest() {
|
|
|
|
|
|
$request = $this->getRequest();
|
|
$user = $request->getUser();
|
|
|
|
$e_name = true;
|
|
$e_callsign = true;
|
|
|
|
$repository = new PhabricatorRepository();
|
|
|
|
$type_map = PhabricatorRepositoryType::getAllRepositoryTypes();
|
|
$errors = array();
|
|
|
|
if ($request->isFormPost()) {
|
|
|
|
$repository->setName($request->getStr('name'));
|
|
$repository->setCallsign($request->getStr('callsign'));
|
|
$repository->setVersionControlSystem($request->getStr('type'));
|
|
|
|
if (!strlen($repository->getName())) {
|
|
$e_name = 'Required';
|
|
$errors[] = 'Repository name is required.';
|
|
} else {
|
|
$e_name = null;
|
|
}
|
|
|
|
if (!strlen($repository->getCallsign())) {
|
|
$e_callsign = 'Required';
|
|
$errors[] = 'Callsign is required.';
|
|
} else if (!preg_match('/^[A-Z]+$/', $repository->getCallsign())) {
|
|
$e_callsign = 'Invalid';
|
|
$errors[] = 'Callsign must be ALL UPPERCASE LETTERS.';
|
|
} else {
|
|
$e_callsign = null;
|
|
}
|
|
|
|
if (empty($type_map[$repository->getVersionControlSystem()])) {
|
|
$errors[] = 'Invalid version control system.';
|
|
}
|
|
|
|
if (!$errors) {
|
|
try {
|
|
$repository->save();
|
|
|
|
return id(new AphrontRedirectResponse())
|
|
->setURI('/repository/edit/'.$repository->getID().'/');
|
|
|
|
} catch (AphrontQueryDuplicateKeyException $ex) {
|
|
$e_callsign = 'Duplicate';
|
|
$errors[] = 'Callsign must be unique. Another repository already '.
|
|
'uses that callsign.';
|
|
}
|
|
}
|
|
}
|
|
|
|
$error_view = null;
|
|
if ($errors) {
|
|
$error_view = new AphrontErrorView();
|
|
$error_view->setErrors($errors);
|
|
$error_view->setTitle('Form Errors');
|
|
}
|
|
|
|
|
|
$form = new AphrontFormView();
|
|
$form
|
|
->setUser($user)
|
|
->setAction('/repository/create/')
|
|
->setFlexible(true)
|
|
->appendChild(
|
|
id(new AphrontFormTextControl())
|
|
->setLabel('Name')
|
|
->setName('name')
|
|
->setValue($repository->getName())
|
|
->setError($e_name)
|
|
->setCaption('Human-readable repository name.'))
|
|
->appendChild(hsprintf(
|
|
'<p class="aphront-form-instructions">Select a "Callsign" — a '.
|
|
'short, uppercase string to identify revisions in this repository. If '.
|
|
'you choose "EX", revisions in this repository will be identified '.
|
|
'with the prefix "rEX".</p>'))
|
|
->appendChild(
|
|
id(new AphrontFormTextControl())
|
|
->setLabel('Callsign')
|
|
->setName('callsign')
|
|
->setValue($repository->getCallsign())
|
|
->setError($e_callsign)
|
|
->setCaption(
|
|
'Short, UPPERCASE identifier. Once set, it can not be changed.'))
|
|
->appendChild(
|
|
id(new AphrontFormSelectControl())
|
|
->setLabel('Type')
|
|
->setName('type')
|
|
->setOptions($type_map)
|
|
->setValue($repository->getVersionControlSystem()))
|
|
->appendChild(
|
|
id(new AphrontFormSubmitControl())
|
|
->setValue('Create Repository')
|
|
->addCancelButton('/repository/'));
|
|
|
|
$header = id(new PhabricatorHeaderView())
|
|
->setHeader(pht('Create Repository'));
|
|
|
|
return $this->buildApplicationPage(
|
|
array(
|
|
$error_view,
|
|
$header,
|
|
$form,
|
|
),
|
|
array(
|
|
'title' => pht('Create Repository'),
|
|
'device' => true,
|
|
'dust' => true,
|
|
));
|
|
}
|
|
|
|
}
|