1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-26 00:32:42 +01:00

Diff-of-diffs radio button logic.

This commit is contained in:
epriestley 2011-02-03 13:20:43 -08:00
parent c93dd9c090
commit 5fd28d35d9
7 changed files with 137 additions and 30 deletions

View file

@ -9,7 +9,7 @@
celerity_register_resource_map(array( celerity_register_resource_map(array(
'aphront-dark-console-css' => 'aphront-dark-console-css' =>
array( array(
'uri' => '/res/ac3fc983/rsrc/css/aphront/dark-console.css', 'uri' => '/res/056b0c12/rsrc/css/aphront/dark-console.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(
@ -63,7 +63,7 @@ celerity_register_resource_map(array(
), ),
'aphront-table-view-css' => 'aphront-table-view-css' =>
array( array(
'uri' => '/res/de3a1e4c/rsrc/css/aphront/table-view.css', 'uri' => '/res/6a70f0f0/rsrc/css/aphront/table-view.css',
'type' => 'css', 'type' => 'css',
'requires' => 'requires' =>
array( array(
@ -226,7 +226,7 @@ celerity_register_resource_map(array(
), ),
'javelin-behavior-dark-console' => 'javelin-behavior-dark-console' =>
array( array(
'uri' => '/res/35907b6e/rsrc/js/application/core/behavior-dark-console.js', 'uri' => '/res/020b0265/rsrc/js/application/core/behavior-dark-console.js',
'type' => 'js', 'type' => 'js',
'requires' => 'requires' =>
array( array(
@ -253,6 +253,16 @@ celerity_register_resource_map(array(
), ),
'disk' => '/rsrc/js/application/differential/behavior-comment-preview.js', 'disk' => '/rsrc/js/application/differential/behavior-comment-preview.js',
), ),
'javelin-behavior-differential-diff-radios' =>
array(
'uri' => '/res/ea6b0062/rsrc/js/application/differential/behavior-diff-radios.js',
'type' => 'js',
'requires' =>
array(
0 => 'javelin-lib-dev',
),
'disk' => '/rsrc/js/application/differential/behavior-diff-radios.js',
),
'javelin-behavior-differential-edit-inline-comments' => 'javelin-behavior-differential-edit-inline-comments' =>
array( array(
'uri' => '/res/74747b2e/rsrc/js/application/differential/behavior-edit-inline-comments.js', 'uri' => '/res/74747b2e/rsrc/js/application/differential/behavior-edit-inline-comments.js',
@ -358,7 +368,7 @@ celerity_register_resource_map(array(
), array ( ), array (
'packages' => 'packages' =>
array ( array (
'c5efa388' => '1a33af6b' =>
array ( array (
'name' => 'core.pkg.css', 'name' => 'core.pkg.css',
'symbols' => 'symbols' =>
@ -375,7 +385,7 @@ celerity_register_resource_map(array(
9 => 'aphront-typeahead-control-css', 9 => 'aphront-typeahead-control-css',
10 => 'phabricator-directory-css', 10 => 'phabricator-directory-css',
), ),
'uri' => '/res/pkg/c5efa388/core.pkg.css', 'uri' => '/res/pkg/1a33af6b/core.pkg.css',
'type' => 'css', 'type' => 'css',
), ),
'9d9c881c' => '9d9c881c' =>
@ -395,17 +405,17 @@ celerity_register_resource_map(array(
), ),
'reverse' => 'reverse' =>
array ( array (
'phabricator-core-css' => 'c5efa388', 'phabricator-core-css' => '1a33af6b',
'phabricator-core-buttons-css' => 'c5efa388', 'phabricator-core-buttons-css' => '1a33af6b',
'phabricator-standard-page-view' => 'c5efa388', 'phabricator-standard-page-view' => '1a33af6b',
'aphront-dialog-view-css' => 'c5efa388', 'aphront-dialog-view-css' => '1a33af6b',
'aphront-form-view-css' => 'c5efa388', 'aphront-form-view-css' => '1a33af6b',
'aphront-panel-view-css' => 'c5efa388', 'aphront-panel-view-css' => '1a33af6b',
'aphront-side-nav-view-css' => 'c5efa388', 'aphront-side-nav-view-css' => '1a33af6b',
'aphront-table-view-css' => 'c5efa388', 'aphront-table-view-css' => '1a33af6b',
'aphront-tokenizer-control-css' => 'c5efa388', 'aphront-tokenizer-control-css' => '1a33af6b',
'aphront-typeahead-control-css' => 'c5efa388', 'aphront-typeahead-control-css' => '1a33af6b',
'phabricator-directory-css' => 'c5efa388', 'phabricator-directory-css' => '1a33af6b',
'differential-core-view-css' => '9d9c881c', 'differential-core-view-css' => '9d9c881c',
'differential-changeset-view-css' => '9d9c881c', 'differential-changeset-view-css' => '9d9c881c',
'differential-revision-detail-css' => '9d9c881c', 'differential-revision-detail-css' => '9d9c881c',

View file

@ -37,6 +37,7 @@ class DifferentialRevisionViewController extends DifferentialController {
$diffs = $revision->loadDiffs(); $diffs = $revision->loadDiffs();
$diff_vs = null;
$target = end($diffs); $target = end($diffs);
$changesets = $target->loadChangesets(); $changesets = $target->loadChangesets();
@ -78,6 +79,8 @@ class DifferentialRevisionViewController extends DifferentialController {
$diff_history = new DifferentialRevisionUpdateHistoryView(); $diff_history = new DifferentialRevisionUpdateHistoryView();
$diff_history->setDiffs($diffs); $diff_history->setDiffs($diffs);
$diff_history->setSelectedVersusDiffID($diff_vs);
$diff_history->setSelectedDiffID($target->getID());
$toc_view = new DifferentialDiffTableOfContentsView(); $toc_view = new DifferentialDiffTableOfContentsView();
$toc_view->setChangesets($changesets); $toc_view->setChangesets($changesets);

View file

@ -637,7 +637,7 @@ class DifferentialChangesetParser {
Filesystem::writeFile($old_tmp, $changeset->makeOldFile()); Filesystem::writeFile($old_tmp, $changeset->makeOldFile());
Filesystem::writeFile($new_tmp, $changeset->makeNewFile()); Filesystem::writeFile($new_tmp, $changeset->makeNewFile());
list($err, $diff) = exec_manual( list($err, $diff) = exec_manual(
'diff -bw -U9999 %s %s', 'diff -bw -U65535 %s %s',
$old_tmp, $old_tmp,
$new_tmp); $new_tmp);
@ -663,7 +663,8 @@ EOSYNTHETIC;
$changes = id(new ArcanistDiffParser())->parseDiff($diff); $changes = id(new ArcanistDiffParser())->parseDiff($diff);
$diff = DifferentialDiff::newFromRawChanges($changes); $diff = DifferentialDiff::newFromRawChanges($changes);
$alt_changeset = reset($diff->getChangesets()); $changesets = $diff->getChangesets();
$alt_changeset = reset($changesets);
$this->subparser = new DifferentialChangesetParser(); $this->subparser = new DifferentialChangesetParser();
$this->subparser->setChangeset($alt_changeset); $this->subparser->setChangeset($alt_changeset);

View file

@ -19,12 +19,24 @@
final class DifferentialRevisionUpdateHistoryView extends AphrontView { final class DifferentialRevisionUpdateHistoryView extends AphrontView {
private $diffs = array(); private $diffs = array();
private $selectedVersusDiffID;
private $selectedDiffID;
public function setDiffs($diffs) { public function setDiffs($diffs) {
$this->diffs = $diffs; $this->diffs = $diffs;
return $this; return $this;
} }
public function setSelectedVersusDiffID($id) {
$this->selectedVersusDiffID = $id;
return $this;
}
public function setSelectedDiffID($id) {
$this->selectedDiffID = $id;
return $this;
}
public function render() { public function render() {
require_celerity_resource('differential-core-view-css'); require_celerity_resource('differential-core-view-css');
@ -35,8 +47,6 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView {
'name' => 'Base', 'name' => 'Base',
'id' => null, 'id' => null,
'desc' => 'Base', 'desc' => 'Base',
'old' => false,
'new' => false,
'age' => null, 'age' => null,
'lint' => null, 'lint' => null,
'unit' => null, 'unit' => null,
@ -49,14 +59,14 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView {
'name' => 'Diff '.(++$seq), 'name' => 'Diff '.(++$seq),
'id' => $diff->getID(), 'id' => $diff->getID(),
'desc' => 'TODO',//$diff->getDescription(), 'desc' => 'TODO',//$diff->getDescription(),
'old' => false,
'new' => false,
'age' => $diff->getDateCreated(), 'age' => $diff->getDateCreated(),
'lint' => $diff->getLintStatus(), 'lint' => $diff->getLintStatus(),
'unit' => $diff->getUnitStatus(), 'unit' => $diff->getUnitStatus(),
); );
} }
$max_id = $diff->getID();
$idx = 0; $idx = 0;
$rows = array(); $rows = array();
foreach ($data as $row) { foreach ($data as $row) {
@ -64,10 +74,56 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView {
$name = phutil_escape_html($row['name']); $name = phutil_escape_html($row['name']);
$id = phutil_escape_html($row['id']); $id = phutil_escape_html($row['id']);
$radios = array();
$lint = '*'; $lint = '*';
$unit = '*'; $unit = '*';
$old = '<input type="radio" name="old" />';
$new = '<input type="radio" name="new" />'; $old_class = null;
$new_class = null;
if ($max_id != $id) {
$uniq = celerity_generate_unique_node_id();
$old_checked = ($this->selectedVersusDiffID == $id);
$old = phutil_render_tag(
'input',
array(
'type' => 'radio',
'name' => 'vs',
'value' => '0',
'id' => $uniq,
'checked' => $old_checked ? 'checked' : null,
));
$radios[] = $uniq;
if ($old_checked) {
$old_class = " revhistory-old-now";
}
} else {
$old = null;
}
if ($id) {
$new_checked = ($this->selectedDiffID == $id);
$new = phutil_render_tag(
'input',
array(
'type' => 'radio',
'name' => 'id',
'value' => $id,
'checked' => $new_checked ? 'checked' : null,
));
if ($new_checked) {
$new_class = " revhistory-new-now";
}
} else {
$new = null;
}
Javelin::initBehavior(
'differential-diff-radios',
array(
'radios' => $radios,
));
$desc = 'TODO'; $desc = 'TODO';
$age = '-'; $age = '-';
@ -86,8 +142,8 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView {
'<td class="revhistory-age">'.$age.'</td>'. '<td class="revhistory-age">'.$age.'</td>'.
'<td class="revhistory-star">'.$lint.'</td>'. '<td class="revhistory-star">'.$lint.'</td>'.
'<td class="revhistory-star">'.$unit.'</td>'. '<td class="revhistory-star">'.$unit.'</td>'.
'<td class="revhistory-old">'.$old.'</td>'. '<td class="revhistory-old'.$old_class.'">'.$old.'</td>'.
'<td class="revhistory-new">'.$new.'</td>'. '<td class="revhistory-new'.$new_class.'">'.$new.'</td>'.
'</tr>'; '</tr>';
} }
@ -110,8 +166,7 @@ final class DifferentialRevisionUpdateHistoryView extends AphrontView {
'<tr>'. '<tr>'.
'<td colspan="8" class="diff-differ-submit">'. '<td colspan="8" class="diff-differ-submit">'.
'<label>Whitespace Changes: '.$select.'</label>'. '<label>Whitespace Changes: '.$select.'</label>'.
'<button class="disabled" '<button>Show Diff</button>'.
disabled="disabled">Show Diff</button>'.
'</td>'. '</td>'.
'</tr>'. '</tr>'.
'</table>'. '</table>'.

View file

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

View file

@ -1092,7 +1092,10 @@ abstract class LiskDAO {
if (count($args) !== 0) { if (count($args) !== 0) {
throw new Exception("Getter call should have zero args: {$method}"); throw new Exception("Getter call should have zero args: {$method}");
} }
return @$this->$property; if (isset($this->$property)) {
return $this->$property;
}
return null;
} }
if (!strncmp($method, 'set', 3)) { if (!strncmp($method, 'set', 3)) {

View file

@ -0,0 +1,34 @@
/**
* @provides javelin-behavior-differential-diff-radios
* @requires javelin-lib-dev
*/
JX.behavior('differential-diff-radios', function(config) {
JX.Stratcom.listen(
'click',
'new-radio',
function(e) {
var target = e.getTarget();
var adjust;
var node;
var reset = false;
for (var ii = 0; ii < config.radios.length; ii++) {
node = JX.$(config.radios[ii]);
if (node.value >= target.value) {
if (node.checked) {
node.checked = false;
reset = true;
}
node.disabled = 'disabled';
} else {
node.disabled = '';
if (!adjust || adjust.value < node.value) {
adjust = node;
}
}
}
if (reset && adjust) {
adjust.checked = 'checked';
}
});
});