mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-28 08:20:57 +01:00
Add "Reveal Entire File" option to Diffusion
Summary: Clicks all the "Show All" links for you at the touch of a button. Test Plan: - Used "reveal entire file" on revealable files. - Opened on already-visible files, got "entire file shown". - Used other menu options. - Used normal "show more" links. Reviewers: btrahan, jungejason Reviewed By: btrahan CC: aran, epriestley, btrahan Maniphest Tasks: T497 Differential Revision: https://secure.phabricator.com/D1331
This commit is contained in:
parent
e5c0bfc8e3
commit
3c9551e96d
6 changed files with 100 additions and 38 deletions
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2011 Facebook, Inc.
|
* Copyright 2012 Facebook, Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -1313,6 +1313,7 @@ class DifferentialChangesetParser {
|
||||||
'mustcapture' => true,
|
'mustcapture' => true,
|
||||||
'sigil' => 'show-more',
|
'sigil' => 'show-more',
|
||||||
'meta' => array(
|
'meta' => array(
|
||||||
|
'type' => 'all',
|
||||||
'ref' => $reference,
|
'ref' => $reference,
|
||||||
'range' => "{$top}-{$len}/{$top}-{$len}",
|
'range' => "{$top}-{$len}/{$top}-{$len}",
|
||||||
),
|
),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright 2011 Facebook, Inc.
|
* Copyright 2012 Facebook, Inc.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -22,6 +22,7 @@ class DifferentialChangesetDetailView extends AphrontView {
|
||||||
private $buttons = array();
|
private $buttons = array();
|
||||||
private $revisionID;
|
private $revisionID;
|
||||||
private $symbolIndex;
|
private $symbolIndex;
|
||||||
|
private $id;
|
||||||
|
|
||||||
public function setChangeset($changeset) {
|
public function setChangeset($changeset) {
|
||||||
$this->changeset = $changeset;
|
$this->changeset = $changeset;
|
||||||
|
@ -43,6 +44,13 @@ class DifferentialChangesetDetailView extends AphrontView {
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getID() {
|
||||||
|
if (!$this->id) {
|
||||||
|
$this->id = celerity_generate_unique_node_id();
|
||||||
|
}
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
public function render() {
|
public function render() {
|
||||||
require_celerity_resource('differential-changeset-view-css');
|
require_celerity_resource('differential-changeset-view-css');
|
||||||
require_celerity_resource('syntax-highlighting-css');
|
require_celerity_resource('syntax-highlighting-css');
|
||||||
|
@ -67,7 +75,7 @@ class DifferentialChangesetDetailView extends AphrontView {
|
||||||
'</div>';
|
'</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = celerity_generate_unique_node_id();
|
$id = $this->getID();
|
||||||
|
|
||||||
if ($this->symbolIndex) {
|
if ($this->symbolIndex) {
|
||||||
Javelin::initBehavior(
|
Javelin::initBehavior(
|
||||||
|
|
|
@ -101,6 +101,8 @@ class DifferentialChangesetListView extends AphrontView {
|
||||||
|
|
||||||
$ref = $this->references[$key];
|
$ref = $this->references[$key];
|
||||||
|
|
||||||
|
$detail = new DifferentialChangesetDetailView();
|
||||||
|
|
||||||
$detail_button = null;
|
$detail_button = null;
|
||||||
if ($this->standaloneViews) {
|
if ($this->standaloneViews) {
|
||||||
$detail_uri = new PhutilURI($this->renderURI);
|
$detail_uri = new PhutilURI($this->renderURI);
|
||||||
|
@ -125,6 +127,7 @@ class DifferentialChangesetListView extends AphrontView {
|
||||||
'leftURI' => (string)$detail_uri->alter('view', 'old'),
|
'leftURI' => (string)$detail_uri->alter('view', 'old'),
|
||||||
'rightURI' => (string)$detail_uri->alter('view', 'new'),
|
'rightURI' => (string)$detail_uri->alter('view', 'new'),
|
||||||
'diffusionURI' => $diffusion_uri,
|
'diffusionURI' => $diffusion_uri,
|
||||||
|
'containerID' => $detail->getID(),
|
||||||
),
|
),
|
||||||
'href' => $detail_uri,
|
'href' => $detail_uri,
|
||||||
'target' => '_blank',
|
'target' => '_blank',
|
||||||
|
@ -133,12 +136,12 @@ class DifferentialChangesetListView extends AphrontView {
|
||||||
"View Options \xE2\x96\xBC");
|
"View Options \xE2\x96\xBC");
|
||||||
}
|
}
|
||||||
|
|
||||||
$uniq_id = celerity_generate_unique_node_id();
|
|
||||||
|
|
||||||
$detail = new DifferentialChangesetDetailView();
|
|
||||||
$detail->setChangeset($changeset);
|
$detail->setChangeset($changeset);
|
||||||
$detail->addButton($detail_button);
|
$detail->addButton($detail_button);
|
||||||
$detail->setSymbolIndex(idx($this->symbolIndexes, $key));
|
$detail->setSymbolIndex(idx($this->symbolIndexes, $key));
|
||||||
|
|
||||||
|
$uniq_id = celerity_generate_unique_node_id();
|
||||||
$detail->appendChild(
|
$detail->appendChild(
|
||||||
phutil_render_tag(
|
phutil_render_tag(
|
||||||
'div',
|
'div',
|
||||||
|
|
|
@ -8,19 +8,19 @@
|
||||||
JX.install('PhabricatorMenuItem', {
|
JX.install('PhabricatorMenuItem', {
|
||||||
|
|
||||||
construct : function(name, action) {
|
construct : function(name, action) {
|
||||||
this._name = name;
|
this.setName(name);
|
||||||
this._action = action;
|
this._action = action;
|
||||||
},
|
},
|
||||||
|
|
||||||
members : {
|
members : {
|
||||||
_name : null,
|
|
||||||
_action : null,
|
_action : null,
|
||||||
|
|
||||||
render : function() {
|
render : function() {
|
||||||
if (this.getDisabled()) {
|
if (this.getDisabled()) {
|
||||||
return JX.$N('span', this._name);
|
return JX.$N('span', this.getName());
|
||||||
} else {
|
} else {
|
||||||
return JX.$N('a', { href : '#', meta : { item : this } }, this._name);
|
var attrs = { href : '#', meta : { item : this } };
|
||||||
|
return JX.$N('a', attrs, this.getName());
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ JX.install('PhabricatorMenuItem', {
|
||||||
},
|
},
|
||||||
|
|
||||||
properties : {
|
properties : {
|
||||||
|
name : '',
|
||||||
disabled : false
|
disabled : false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,33 +10,70 @@
|
||||||
|
|
||||||
JX.behavior('differential-dropdown-menus', function(config) {
|
JX.behavior('differential-dropdown-menus', function(config) {
|
||||||
|
|
||||||
var buttons = JX.DOM.scry(window.document, 'a', 'differential-view-options');
|
function build_menu(button, data) {
|
||||||
|
|
||||||
for (var ii = 0; ii < buttons.length; ii++) {
|
function show_more() {
|
||||||
var data = JX.Stratcom.getData(buttons[ii]);
|
var container = JX.$(data.containerID);
|
||||||
|
var nodes = JX.DOM.scry(container, 'tr', 'context-target');
|
||||||
|
for (var ii = 0; ii < nodes.length; ii++) {
|
||||||
|
var show = JX.DOM.scry(nodes[ii], 'a', 'show-more');
|
||||||
|
for (var jj = 0; jj < show.length; jj++) {
|
||||||
|
if (JX.Stratcom.getData(show[jj]).type != 'all') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
var event_data = {
|
||||||
|
context : nodes[ii],
|
||||||
|
show : show[jj]
|
||||||
|
};
|
||||||
|
JX.Stratcom.invoke('differential-reveal-context', null, event_data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var diffusion_item = new JX.PhabricatorMenuItem(
|
function link_to(name, uri) {
|
||||||
'Browse in Diffusion',
|
var item = new JX.PhabricatorMenuItem(
|
||||||
JX.bind(null, window.open, data.diffusionURI))
|
name,
|
||||||
|
JX.bind(null, window.open, uri));
|
||||||
|
item.setDisabled(!uri);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
var reveal_item = new JX.PhabricatorMenuItem('', show_more);
|
||||||
|
|
||||||
|
var diffusion_item = link_to('Browse in Diffusion', data.diffusionURI);
|
||||||
if (!data.diffusionURI) {
|
if (!data.diffusionURI) {
|
||||||
diffusion_item.setDisabled(true);
|
diffusion_item.setDisabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
new JX.PhabricatorDropdownMenu(buttons[ii])
|
var menu = new JX.PhabricatorDropdownMenu(buttons[ii])
|
||||||
|
.addItem(reveal_item)
|
||||||
.addItem(diffusion_item)
|
.addItem(diffusion_item)
|
||||||
.addItem(
|
.addItem(link_to('View Standalone', data.detailURI))
|
||||||
new JX.PhabricatorMenuItem(
|
.addItem(link_to('Show Raw File (Left)', data.leftURI))
|
||||||
'View Standalone',
|
.addItem(link_to('Show Raw File (Right)', data.rightURI));
|
||||||
JX.bind(null, window.open, data.detailURI)))
|
|
||||||
.addItem(
|
menu.listen(
|
||||||
new JX.PhabricatorMenuItem(
|
'open',
|
||||||
'Show Raw File (Left)',
|
function() {
|
||||||
JX.bind(null, window.open, data.leftURI)))
|
|
||||||
.addItem(
|
// When the user opens the menu, check if there are any "Show More"
|
||||||
new JX.PhabricatorMenuItem(
|
// links in the changeset body. If there aren't, disable the "Show
|
||||||
'Show Raw File (Right)',
|
// Entire File" menu item since it won't change anything.
|
||||||
JX.bind(null, window.open, data.rightURI)));
|
|
||||||
|
var nodes = JX.DOM.scry(JX.$(data.containerID), 'a', 'show-more');
|
||||||
|
if (nodes.length) {
|
||||||
|
reveal_item.setDisabled(false);
|
||||||
|
reveal_item.setName('Show Entire File');
|
||||||
|
} else {
|
||||||
|
reveal_item.setDisabled(true);
|
||||||
|
reveal_item.setName('Entire File Shown');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var buttons = JX.DOM.scry(window.document, 'a', 'differential-view-options');
|
||||||
|
for (var ii = 0; ii < buttons.length; ii++) {
|
||||||
|
build_menu(buttons[ii], JX.Stratcom.getData(buttons[ii]));
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,28 +9,40 @@
|
||||||
|
|
||||||
JX.behavior('differential-show-more', function(config) {
|
JX.behavior('differential-show-more', function(config) {
|
||||||
|
|
||||||
function onresponse(origin, response) {
|
function onresponse(context, response) {
|
||||||
var div = JX.$N('div', {}, JX.$H(response));
|
var div = JX.$N('div', {}, JX.$H(response));
|
||||||
var anchor = origin.getNode('context-target');
|
var root = context.parentNode;
|
||||||
var root = anchor.parentNode;
|
copyRows(root, div, context);
|
||||||
copyRows(root, div, anchor);
|
root.removeChild(context);
|
||||||
root.removeChild(anchor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JX.Stratcom.listen(
|
JX.Stratcom.listen(
|
||||||
'click',
|
'click',
|
||||||
'show-more',
|
'show-more',
|
||||||
function(e) {
|
function(e) {
|
||||||
var context = e.getNodes()['context-target'];
|
var event_data = {
|
||||||
|
context : e.getNodes()['context-target'],
|
||||||
|
show : e.getNodes()['show-more']
|
||||||
|
};
|
||||||
|
|
||||||
|
JX.Stratcom.invoke('differential-reveal-context', null, event_data);
|
||||||
|
e.kill();
|
||||||
|
});
|
||||||
|
|
||||||
|
JX.Stratcom.listen(
|
||||||
|
'differential-reveal-context',
|
||||||
|
null,
|
||||||
|
function(e) {
|
||||||
|
var context = e.getData().context;
|
||||||
|
var data = JX.Stratcom.getData(e.getData().show);
|
||||||
|
|
||||||
var container = JX.DOM.find(context, 'td');
|
var container = JX.DOM.find(context, 'td');
|
||||||
JX.DOM.setContent(container, 'Loading...');
|
JX.DOM.setContent(container, 'Loading...');
|
||||||
JX.DOM.alterClass(context, 'differential-show-more-loading', true);
|
JX.DOM.alterClass(context, 'differential-show-more-loading', true);
|
||||||
var data = e.getNodeData('show-more');
|
|
||||||
data['whitespace'] = config.whitespace;
|
data['whitespace'] = config.whitespace;
|
||||||
new JX.Workflow(config.uri, data)
|
new JX.Workflow(config.uri, data)
|
||||||
.setHandler(JX.bind(null, onresponse, e))
|
.setHandler(JX.bind(null, onresponse, context))
|
||||||
.start();
|
.start();
|
||||||
e.kill();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue