1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-22 14:52: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

@ -24,7 +24,7 @@ return array(
'phabricator.csrf-key' => '0b7ec0592e0a2829d8b71df2fa269b2c6172eca3',
'phabricator.version' => 'UNSTABLE',
@ -42,13 +42,13 @@ return array(
// DarkConsole is a administrative debugging/profiling tool built into
// Phabricator. You can leave it disabled unless you're developing against
// Phabricator.
// Determines whether or not DarkConsole is available. DarkConsole exposes
// some data like queries and stack traces, so you should be careful about
// turning it on in production (although users can not normally see it, even
// if the deployment configuration enables it).
'darkconsole.enabled' => true,
// Always enable DarkConsole, even for logged out users. This potentially
// exposes sensitive information to users, so make sure untrusted users can
// not access an install running in this mode. You should definitely leave

View file

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

View file

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

View file

@ -43,7 +43,7 @@ abstract class AphrontApplicationConfiguration {
final public function getConsole() {
return $this->console;
}
final public function setConsole($console) {
$this->console = $console;
}

View file

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

View file

@ -38,7 +38,7 @@ class DarkConsoleController extends PhabricatorController {
$user->save();
return new AphrontAjaxResponse();
}
if (PhabricatorEnv::getEnvConfig('darkconsole.enabled')) {
$user->setConsoleEnabled(!$user->getConsoleEnabled());
$user->save();
@ -48,7 +48,7 @@ class DarkConsoleController extends PhabricatorController {
return id(new AphrontRedirectResponse())->setURI('/');
}
}
}
}

View file

@ -7,7 +7,11 @@
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', 'infrastructure/env');
phutil_require_module('phutil', 'utils');
phutil_require_source('DarkConsoleController.php');

View file

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

View file

@ -70,7 +70,13 @@ class AphrontRequest {
final public function getStr($name, $default = null) {
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 {
return $default;
}

View file

@ -27,7 +27,7 @@ class AphrontRedirectResponse extends AphrontResponse {
$this->uri = $uri;
return $this;
}
public function getURI() {
return $this->uri;
}

View file

@ -46,7 +46,7 @@ abstract class PhabricatorController extends AphrontController {
}
$request->setUser($user);
if (PhabricatorEnv::getEnvConfig('darkconsole.enabled')) {
if ($user->getConsoleEnabled() ||
PhabricatorEnv::getEnvConfig('darkconsole.always-on')) {

View file

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

View file

@ -29,6 +29,18 @@ abstract class DifferentialController extends PhabricatorController {
$page->setTitle(idx($data, 'title'));
$page->setGlyph("\xE2\x9A\x99");
$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();
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,
array(
'title' => 'Differential Home',
'tab' => 'revisions',
));
}

View file

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

View file

@ -173,12 +173,12 @@ class PhabricatorStandardPageView extends AphrontPageView {
'</form>';
}
}
$foot_links = array();
$version = PhabricatorEnv::getEnvConfig('phabricator.version');
$foot_links[] = phutil_escape_html('Phabricator '.$version);
if (PhabricatorEnv::getEnvConfig('darkconsole.enabled') &&
!PhabricatorEnv::getEnvConfig('darkconsole.always-on')) {
if ($console) {
@ -201,7 +201,7 @@ class PhabricatorStandardPageView extends AphrontPageView {
$foot_links[] = $link;
}
$foot_links = implode(' &middot; ', $foot_links);
return
($console ? '<darkconsole />' : null).

View file

@ -7,7 +7,9 @@
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/markup');
phutil_require_module('phabricator', 'view/page/base');
phutil_require_module('phutil', 'markup');

View file

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

View file

@ -53,6 +53,6 @@
.phabricator-page-foot {
text-align: right;
padding: .5em 1em;
font-size: 11px;
font-size: 11px;
color: #f3f3f3;
}
}