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

Differential lazyweb diff create workflow.

This commit is contained in:
epriestley 2011-02-05 12:20:18 -08:00
parent addfe3aa79
commit de2a9c634c
21 changed files with 166 additions and 34 deletions

View file

@ -27,7 +27,7 @@ celerity_register_resource_map(array(
), ),
'aphront-form-view-css' => 'aphront-form-view-css' =>
array( array(
'uri' => '/res/785ac1c6/rsrc/css/aphront/form-view.css', 'uri' => '/res/0ea02f2f/rsrc/css/aphront/form-view.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(
@ -91,7 +91,7 @@ celerity_register_resource_map(array(
), ),
'phabricator-standard-page-view' => 'phabricator-standard-page-view' =>
array( array(
'uri' => '/res/c7dedb5f/rsrc/css/application/base/standard-page-view.css', 'uri' => '/res/4ebe4b10/rsrc/css/application/base/standard-page-view.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(
@ -398,7 +398,7 @@ celerity_register_resource_map(array(
), array ( ), array (
'packages' => 'packages' =>
array ( array (
'554bfa09' => '89ccb170' =>
array ( array (
'name' => 'core.pkg.css', 'name' => 'core.pkg.css',
'symbols' => 'symbols' =>
@ -417,7 +417,7 @@ celerity_register_resource_map(array(
11 => 'phabricator-remarkup-css', 11 => 'phabricator-remarkup-css',
12 => 'syntax-highlighting-css', 12 => 'syntax-highlighting-css',
), ),
'uri' => '/res/pkg/554bfa09/core.pkg.css', 'uri' => '/res/pkg/89ccb170/core.pkg.css',
'type' => 'css', 'type' => 'css',
), ),
'4b8af7b5' => '4b8af7b5' =>
@ -454,19 +454,19 @@ celerity_register_resource_map(array(
), ),
'reverse' => 'reverse' =>
array ( array (
'phabricator-core-css' => '554bfa09', 'phabricator-core-css' => '89ccb170',
'phabricator-core-buttons-css' => '554bfa09', 'phabricator-core-buttons-css' => '89ccb170',
'phabricator-standard-page-view' => '554bfa09', 'phabricator-standard-page-view' => '89ccb170',
'aphront-dialog-view-css' => '554bfa09', 'aphront-dialog-view-css' => '89ccb170',
'aphront-form-view-css' => '554bfa09', 'aphront-form-view-css' => '89ccb170',
'aphront-panel-view-css' => '554bfa09', 'aphront-panel-view-css' => '89ccb170',
'aphront-side-nav-view-css' => '554bfa09', 'aphront-side-nav-view-css' => '89ccb170',
'aphront-table-view-css' => '554bfa09', 'aphront-table-view-css' => '89ccb170',
'aphront-tokenizer-control-css' => '554bfa09', 'aphront-tokenizer-control-css' => '89ccb170',
'aphront-typeahead-control-css' => '554bfa09', 'aphront-typeahead-control-css' => '89ccb170',
'phabricator-directory-css' => '554bfa09', 'phabricator-directory-css' => '89ccb170',
'phabricator-remarkup-css' => '554bfa09', 'phabricator-remarkup-css' => '89ccb170',
'syntax-highlighting-css' => '554bfa09', 'syntax-highlighting-css' => '89ccb170',
'differential-core-view-css' => '4b8af7b5', 'differential-core-view-css' => '4b8af7b5',
'differential-changeset-view-css' => '4b8af7b5', 'differential-changeset-view-css' => '4b8af7b5',
'differential-revision-detail-css' => '4b8af7b5', 'differential-revision-detail-css' => '4b8af7b5',

View file

@ -98,6 +98,7 @@ phutil_register_library_map(array(
'DifferentialDAO' => 'applications/differential/storage/base', 'DifferentialDAO' => 'applications/differential/storage/base',
'DifferentialDiff' => 'applications/differential/storage/diff', 'DifferentialDiff' => 'applications/differential/storage/diff',
'DifferentialDiffContentMail' => 'applications/differential/mail/diffcontent', 'DifferentialDiffContentMail' => 'applications/differential/mail/diffcontent',
'DifferentialDiffCreateController' => 'applications/differential/controller/diffcreate',
'DifferentialDiffProperty' => 'applications/differential/storage/diffproperty', 'DifferentialDiffProperty' => 'applications/differential/storage/diffproperty',
'DifferentialDiffTableOfContentsView' => 'applications/differential/view/difftableofcontents', 'DifferentialDiffTableOfContentsView' => 'applications/differential/view/difftableofcontents',
'DifferentialDiffViewController' => 'applications/differential/controller/diffview', 'DifferentialDiffViewController' => 'applications/differential/controller/diffview',
@ -286,6 +287,7 @@ phutil_register_library_map(array(
'DifferentialDAO' => 'PhabricatorLiskDAO', 'DifferentialDAO' => 'PhabricatorLiskDAO',
'DifferentialDiff' => 'DifferentialDAO', 'DifferentialDiff' => 'DifferentialDAO',
'DifferentialDiffContentMail' => 'DifferentialMail', 'DifferentialDiffContentMail' => 'DifferentialMail',
'DifferentialDiffCreateController' => 'DifferentialController',
'DifferentialDiffProperty' => 'DifferentialDAO', 'DifferentialDiffProperty' => 'DifferentialDAO',
'DifferentialDiffTableOfContentsView' => 'AphrontView', 'DifferentialDiffTableOfContentsView' => 'AphrontView',
'DifferentialDiffViewController' => 'DifferentialController', 'DifferentialDiffViewController' => 'DifferentialController',

View file

@ -6,7 +6,6 @@
phutil_require_module('phabricator', 'aphront/console/core');
phutil_require_module('phabricator', 'aphront/mapper'); phutil_require_module('phabricator', 'aphront/mapper');
phutil_require_module('phutil', 'symbols'); phutil_require_module('phutil', 'symbols');

View file

@ -7,7 +7,11 @@
phutil_require_module('phabricator', 'aphront/response/ajax'); phutil_require_module('phabricator', 'aphront/response/ajax');
phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/base/controller/base'); phutil_require_module('phabricator', 'applications/base/controller/base');
phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phutil', 'utils');
phutil_require_source('DarkConsoleController.php'); phutil_require_source('DarkConsoleController.php');

View file

@ -82,7 +82,10 @@ class AphrontDefaultApplicationConfiguration
'/differential/' => array( '/differential/' => array(
'$' => 'DifferentialRevisionListController', '$' => 'DifferentialRevisionListController',
'filter/(?<filter>\w+)/$' => 'DifferentialRevisionListController', 'filter/(?<filter>\w+)/$' => 'DifferentialRevisionListController',
'diff/(?<id>\d+)/$' => 'DifferentialDiffViewController', 'diff/' => array(
'(?<id>\d+)/$' => 'DifferentialDiffViewController',
'create/$' => 'DifferentialDiffCreateController',
),
'changeset/$' => 'DifferentialChangesetViewController', 'changeset/$' => 'DifferentialChangesetViewController',
'revision/edit/(?:(?<id>\d+)/)?$' 'revision/edit/(?:(?<id>\d+)/)?$'
=> 'DifferentialRevisionEditController', => 'DifferentialRevisionEditController',

View file

@ -70,7 +70,13 @@ class AphrontRequest {
final public function getStr($name, $default = null) { final public function getStr($name, $default = null) {
if (isset($this->requestData[$name])) { if (isset($this->requestData[$name])) {
return (string)$this->requestData[$name]; $str = (string)$this->requestData[$name];
// Normalize newline craziness.
$str = str_replace(
array("\r\n", "\r"),
array("\n", "\n"),
$str);
return $str;
} else { } else {
return $default; return $default;
} }

View file

@ -6,10 +6,12 @@
phutil_require_module('phabricator', 'aphront/console/core');
phutil_require_module('phabricator', 'aphront/controller'); phutil_require_module('phabricator', 'aphront/controller');
phutil_require_module('phabricator', 'aphront/exception/redirect'); phutil_require_module('phabricator', 'aphront/exception/redirect');
phutil_require_module('phabricator', 'aphront/response/webpage'); phutil_require_module('phabricator', 'aphront/response/webpage');
phutil_require_module('phabricator', 'applications/people/storage/user'); phutil_require_module('phabricator', 'applications/people/storage/user');
phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phabricator', 'storage/queryfx'); phutil_require_module('phabricator', 'storage/queryfx');
phutil_require_module('phabricator', 'view/page/standard'); phutil_require_module('phabricator', 'view/page/standard');

View file

@ -29,6 +29,18 @@ abstract class DifferentialController extends PhabricatorController {
$page->setTitle(idx($data, 'title')); $page->setTitle(idx($data, 'title'));
$page->setGlyph("\xE2\x9A\x99"); $page->setGlyph("\xE2\x9A\x99");
$page->appendChild($view); $page->appendChild($view);
$page->setTabs(
array(
'revisions' => array(
'name' => 'Revisions',
'href' => '/differential/',
),
'create' => array(
'name' => 'Create Diff',
'href' => '/differential/diff/create/',
),
),
idx($data, 'tab'));
$response = new AphrontWebpageResponse(); $response = new AphrontWebpageResponse();
return $response->setContent($page->render()); return $response->setContent($page->render());

View file

@ -0,0 +1,73 @@
<?php
/*
* Copyright 2011 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
class DifferentialDiffCreateController extends DifferentialController {
public function processRequest() {
$request = $this->getRequest();
if ($request->isFormPost()) {
$parser = new ArcanistDiffParser();
$diff = $request->getStr('diff');
$changes = $parser->parseDiff($diff);
$diff = DifferentialDiff::newFromRawChanges($changes);
$diff->setLintStatus(DifferentialLintStatus::LINT_SKIP);
$diff->setUnitStatus(DifferentialLintStatus::LINT_SKIP);
$diff->setAuthorPHID($request->getUser()->getPHID());
$diff->setCreationMethod('web');
$diff->save();
return id(new AphrontRedirectResponse())
->setURI('/differential/diff/'.$diff->getID().'/');
}
$form = new AphrontFormView();
$form
->setAction('/differential/diff/create/')
->setUser($request->getUser())
->appendChild(
'<p class="aphront-form-instructions">The best way to create a '.
'Differential diff is by using <strong>Arcanist</strong>, but you '.
'can also just paste a diff (e.g., from <tt>svn diff</tt> or '.
'<tt>git diff</tt>) into this box if you really want.</p>')
->appendChild(
id(new AphrontFormTextAreaControl())
->setLabel('Raw Diff')
->setName('diff')
->setHeight(AphrontFormTextAreaControl::HEIGHT_VERY_TALL))
->appendChild(
id(new AphrontFormSubmitControl())
->setValue("Create Diff \xC2\xBB"));
$panel = new AphrontPanelView();
$panel->setHeader('Create New Diff');
$panel->appendChild($form);
$panel->setWidth(AphrontPanelView::WIDTH_FORM);
return $this->buildStandardPageResponse(
$panel,
array(
'title' => 'Create Diff',
'tab' => 'create',
));
}
}

View file

@ -0,0 +1,22 @@
<?php
/**
* This file is automatically generated. Lint this module to rebuild it.
* @generated
*/
phutil_require_module('arcanist', 'parser/diff');
phutil_require_module('phabricator', 'aphront/response/redirect');
phutil_require_module('phabricator', 'applications/differential/constants/lintstatus');
phutil_require_module('phabricator', 'applications/differential/controller/base');
phutil_require_module('phabricator', 'applications/differential/storage/diff');
phutil_require_module('phabricator', 'view/form/base');
phutil_require_module('phabricator', 'view/form/control/submit');
phutil_require_module('phabricator', 'view/layout/panel');
phutil_require_module('phutil', 'utils');
phutil_require_source('DifferentialDiffCreateController.php');

View file

@ -172,6 +172,7 @@ class DifferentialRevisionListController extends DifferentialController {
$side_nav, $side_nav,
array( array(
'title' => 'Differential Home', 'title' => 'Differential Home',
'tab' => 'revisions',
)); ));
} }

View file

@ -20,6 +20,7 @@ class AphrontFormTextAreaControl extends AphrontFormControl {
const HEIGHT_VERY_SHORT = 'very-short'; const HEIGHT_VERY_SHORT = 'very-short';
const HEIGHT_SHORT = 'short'; const HEIGHT_SHORT = 'short';
const HEIGHT_VERY_TALL = 'very-tall';
private $height; private $height;
@ -38,6 +39,7 @@ class AphrontFormTextAreaControl extends AphrontFormControl {
switch ($this->height) { switch ($this->height) {
case self::HEIGHT_VERY_SHORT: case self::HEIGHT_VERY_SHORT:
case self::HEIGHT_SHORT: case self::HEIGHT_SHORT:
case self::HEIGHT_VERY_TALL:
$height_class = 'aphront-textarea-'.$this->height; $height_class = 'aphront-textarea-'.$this->height;
break; break;
} }

View file

@ -7,7 +7,9 @@
phutil_require_module('phabricator', 'infrastructure/celerity/api'); phutil_require_module('phabricator', 'infrastructure/celerity/api');
phutil_require_module('phabricator', 'infrastructure/env');
phutil_require_module('phabricator', 'infrastructure/javelin/api'); phutil_require_module('phabricator', 'infrastructure/javelin/api');
phutil_require_module('phabricator', 'infrastructure/javelin/markup');
phutil_require_module('phabricator', 'view/page/base'); phutil_require_module('phabricator', 'view/page/base');
phutil_require_module('phutil', 'markup'); phutil_require_module('phutil', 'markup');

View file

@ -57,6 +57,10 @@
height: 3em; height: 3em;
} }
.aphront-form-control-textarea textarea.aphront-textarea-very-tall {
height: 24em;
}
.aphront-form-control-select .aphront-form-input { .aphront-form-control-select .aphront-form-input {
padding-top: 2px; padding-top: 2px;
} }