Backed out 2 changesets (bug 1264557) for Eslint failure. CLOSED TREE

Backed out changeset e17cd801b578 (bug 1264557)
Backed out changeset d3bf0a95e4e4 (bug 1264557)
This commit is contained in:
Csoregi Natalia 2018-05-10 13:48:13 +03:00
parent a08a710078
commit 33962019e1
7 changed files with 4 additions and 80 deletions

View File

@ -40,7 +40,6 @@ define(function(require, exports, module) {
PropTypes.bool,
PropTypes.number
]),
dataSize: PropTypes.number,
expandedNodes: PropTypes.instanceOf(Set),
searchFilter: PropTypes.string,
actions: PropTypes.object,
@ -137,7 +136,7 @@ define(function(require, exports, module) {
return (
div({className: "jsonPanelBox tab-panel-inner"},
JsonToolbar({actions: this.props.actions, dataSize: this.props.dataSize}),
JsonToolbar({actions: this.props.actions}),
div({className: "panelContent"},
content
)

View File

@ -15,9 +15,6 @@ define(function(require, exports, module) {
const { SearchBox } = createFactories(require("./SearchBox"));
const { Toolbar, ToolbarButton } = createFactories(require("./reps/Toolbar"));
/* 100kB file */
const EXPAND_THRESHOLD = 100 * 1024;
/**
* This template represents a toolbar within the 'JSON' panel.
*/
@ -25,7 +22,6 @@ define(function(require, exports, module) {
static get propTypes() {
return {
actions: PropTypes.object,
dataSize: PropTypes.number,
};
}
@ -33,8 +29,6 @@ define(function(require, exports, module) {
super(props);
this.onSave = this.onSave.bind(this);
this.onCopy = this.onCopy.bind(this);
this.onCollapse = this.onCollapse.bind(this);
this.onExpand = this.onExpand.bind(this);
}
// Commands
@ -47,14 +41,6 @@ define(function(require, exports, module) {
this.props.actions.onCopyJson();
}
onCollapse(event) {
this.props.actions.onCollapse();
}
onExpand(event) {
this.props.actions.onExpand();
}
render() {
return (
Toolbar({},
@ -64,13 +50,6 @@ define(function(require, exports, module) {
ToolbarButton({className: "btn copy", onClick: this.onCopy},
JSONView.Locale.$STR("jsonViewer.Copy")
),
ToolbarButton({className: "btn collapse", onClick: this.onCollapse},
JSONView.Locale.$STR("jsonViewer.CollapseAll")
),
this.props.dataSize > EXPAND_THRESHOLD ? undefined :
ToolbarButton({className: "btn expand", onClick: this.onExpand},
JSONView.Locale.$STR("jsonViewer.ExpandAll")
),
SearchBox({
actions: this.props.actions
})

View File

@ -68,8 +68,7 @@ define(function(require, exports, module) {
data: this.state.json,
expandedNodes: this.state.expandedNodes,
actions: this.props.actions,
searchFilter: this.state.searchFilter,
dataSize: this.state.jsonText.length
searchFilter: this.state.searchFilter
})
),
TabPanel({

View File

@ -23,8 +23,7 @@ define(function(require, exports, module) {
jsonPretty: null,
headers: JSONView.headers,
tabActive: 0,
prettified: false,
expandedNodes: new Set()
prettified: false
};
/**
@ -86,16 +85,6 @@ define(function(require, exports, module) {
input.prettified = !input.prettified;
},
onCollapse: function(data) {
input.expandedNodes.clear();
theApp.forceUpdate();
},
onExpand: function(data) {
input.expandedNodes = TreeViewClass.getExpandedNodes(input.json);
theApp.setState({expandedNodes: input.expandedNodes});
}
};
/**
@ -139,6 +128,7 @@ define(function(require, exports, module) {
if (document.readyState == "loading") {
// If the JSON has not been loaded yet, render the Raw Data tab first.
input.json = {};
input.expandedNodes = new Set();
input.tabActive = 1;
return new Promise(resolve => {
document.addEventListener("DOMContentLoaded", resolve, {once: true});

View File

@ -58,4 +58,3 @@ support-files =
[browser_jsonview_theme.js]
[browser_jsonview_url_linkification.js]
[browser_jsonview_valid_json.js]
[browser_jsonview_expand_collapse.js]

View File

@ -1,39 +0,0 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
const TEST_JSON_URL = URL_ROOT + "array_json.json";
const EXPAND_THRESHOLD = 100 * 1024;
add_task(async function() {
info("Test expand/collapse JSON started");
await addJsonViewTab(TEST_JSON_URL);
let browser = gBrowser.selectedBrowser, selector, countAfter, countBefore, json;
/* Initial sanity check */
countBefore = await getElementCount(".treeRow");
ok(countBefore == 6, "There must be six rows");
/* Test the "Collapse All" button */
selector = ".jsonPanelBox .toolbar button.collapse";
await BrowserTestUtils.synthesizeMouseAtCenter(selector, {}, browser);
countAfter = await getElementCount(".treeRow");
ok(countAfter == 3, "There must be three rows");
/* Test the "Expand All" button */
selector = ".jsonPanelBox .toolbar button.expand";
await BrowserTestUtils.synthesizeMouseAtCenter(selector, {}, browser);
countAfter = await getElementCount(".treeRow");
ok(countAfter == 6, "There must be six expanded rows");
/* Test big file handling */
json = JSON.stringify({data: Array(1e5).fill().map(x => "hoot"), status: "ok"});
ok(json.length > EXPAND_THRESHOLD, "The generated JSON must be larger than 100kB");
await addJsonViewTab("data:application/json," + json);
ok(document.querySelector(selector) == null, "The Expand All button must be gone");
});

View File

@ -32,9 +32,6 @@ jsonViewer.Copy=Copy
# LOCALIZATION NOTE (jsonViewer.ExpandAll): Label for expanding all nodes
jsonViewer.ExpandAll=Expand All
# LOCALIZATION NOTE (jsonViewer.CollapseAll): Label for collapsing all nodes
jsonViewer.CollapseAll=Collapse All
# LOCALIZATION NOTE (jsonViewer.PrettyPrint): Label for JSON
# pretty print action button.
jsonViewer.PrettyPrint=Pretty Print