'.replace(/>\s+/g, ">");
-
-var SearchBox = function(editor, range, showReplaceForm) {
- var div = dom.createElement("div");
- div.innerHTML = html;
- this.element = div.firstChild;
-
- this.$init();
- this.setEditor(editor);
-};
-
-(function() {
- this.setEditor = function(editor) {
- editor.searchBox = this;
- editor.container.appendChild(this.element);
- this.editor = editor;
- };
-
- this.$initElements = function(sb) {
- this.searchBox = sb.querySelector(".ace_search_form");
- this.replaceBox = sb.querySelector(".ace_replace_form");
- this.searchOptions = sb.querySelector(".ace_search_options");
- this.regExpOption = sb.querySelector("[action=toggleRegexpMode]");
- this.caseSensitiveOption = sb.querySelector("[action=toggleCaseSensitive]");
- this.wholeWordOption = sb.querySelector("[action=toggleWholeWords]");
- this.searchInput = this.searchBox.querySelector(".ace_search_field");
- this.replaceInput = this.replaceBox.querySelector(".ace_search_field");
- };
-
- this.$init = function() {
- var sb = this.element;
-
- this.$initElements(sb);
-
- var _this = this;
- event.addListener(sb, "mousedown", function(e) {
- setTimeout(function(){
- _this.activeInput.focus();
- }, 0);
- event.stopPropagation(e);
- });
- event.addListener(sb, "click", function(e) {
- var t = e.target || e.srcElement;
- var action = t.getAttribute("action");
- if (action && _this[action])
- _this[action]();
- else if (_this.$searchBarKb.commands[action])
- _this.$searchBarKb.commands[action].exec(_this);
- event.stopPropagation(e);
- });
-
- event.addCommandKeyListener(sb, function(e, hashId, keyCode) {
- var keyString = keyUtil.keyCodeToString(keyCode);
- var command = _this.$searchBarKb.findKeyCommand(hashId, keyString);
- if (command && command.exec) {
- command.exec(_this);
- event.stopEvent(e);
- }
- });
-
- this.$onChange = lang.delayedCall(function() {
- _this.find(false, false);
- });
-
- event.addListener(this.searchInput, "input", function() {
- _this.$onChange.schedule(20);
- });
- event.addListener(this.searchInput, "focus", function() {
- _this.activeInput = _this.searchInput;
- _this.searchInput.value && _this.highlight();
- });
- event.addListener(this.replaceInput, "focus", function() {
- _this.activeInput = _this.replaceInput;
- _this.searchInput.value && _this.highlight();
- });
- };
- this.$closeSearchBarKb = new HashHandler([{
- bindKey: "Esc",
- name: "closeSearchBar",
- exec: function(editor) {
- editor.searchBox.hide();
- }
- }]);
- this.$searchBarKb = new HashHandler();
- this.$searchBarKb.bindKeys({
- "Ctrl-f|Command-f|Ctrl-H|Command-Option-F": function(sb) {
- var isReplace = sb.isReplace = !sb.isReplace;
- sb.replaceBox.style.display = isReplace ? "" : "none";
- sb[isReplace ? "replaceInput" : "searchInput"].focus();
- },
- "Ctrl-G|Command-G": function(sb) {
- sb.findNext();
- },
- "Ctrl-Shift-G|Command-Shift-G": function(sb) {
- sb.findPrev();
- },
- "esc": function(sb) {
- setTimeout(function() { sb.hide();});
- },
- "Return": function(sb) {
- if (sb.activeInput == sb.replaceInput)
- sb.replace();
- sb.findNext();
- },
- "Shift-Return": function(sb) {
- if (sb.activeInput == sb.replaceInput)
- sb.replace();
- sb.findPrev();
- },
- "Tab": function(sb) {
- (sb.activeInput == sb.replaceInput ? sb.searchInput : sb.replaceInput).focus();
- }
- });
-
- this.$searchBarKb.addCommands([{
- name: "toggleRegexpMode",
- bindKey: {win: "Alt-R|Alt-/", mac: "Ctrl-Alt-R|Ctrl-Alt-/"},
- exec: function(sb) {
- sb.regExpOption.checked = !sb.regExpOption.checked;
- sb.$syncOptions();
- }
- }, {
- name: "toggleCaseSensitive",
- bindKey: {win: "Alt-C|Alt-I", mac: "Ctrl-Alt-R|Ctrl-Alt-I"},
- exec: function(sb) {
- sb.caseSensitiveOption.checked = !sb.caseSensitiveOption.checked;
- sb.$syncOptions();
- }
- }, {
- name: "toggleWholeWords",
- bindKey: {win: "Alt-B|Alt-W", mac: "Ctrl-Alt-B|Ctrl-Alt-W"},
- exec: function(sb) {
- sb.wholeWordOption.checked = !sb.wholeWordOption.checked;
- sb.$syncOptions();
- }
- }]);
-
- this.$syncOptions = function() {
- dom.setCssClass(this.regExpOption, "checked", this.regExpOption.checked);
- dom.setCssClass(this.wholeWordOption, "checked", this.wholeWordOption.checked);
- dom.setCssClass(this.caseSensitiveOption, "checked", this.caseSensitiveOption.checked);
- this.find(false, false);
- };
-
- this.highlight = function(re) {
- this.editor.session.highlight(re || this.editor.$search.$options.re);
- this.editor.renderer.updateBackMarkers()
- };
- this.find = function(skipCurrent, backwards) {
- var range = this.editor.find(this.searchInput.value, {
- skipCurrent: skipCurrent,
- backwards: backwards,
- wrap: true,
- regExp: this.regExpOption.checked,
- caseSensitive: this.caseSensitiveOption.checked,
- wholeWord: this.wholeWordOption.checked
- });
- var noMatch = !range && this.searchInput.value;
- dom.setCssClass(this.searchBox, "ace_nomatch", noMatch);
- this.editor._emit("findSearchBox", { match: !noMatch });
- this.highlight();
- };
- this.findNext = function() {
- this.find(true, false);
- };
- this.findPrev = function() {
- this.find(true, true);
- };
- this.replace = function() {
- if (!this.editor.getReadOnly())
- this.editor.replace(this.replaceInput.value);
- };
- this.replaceAndFindNext = function() {
- if (!this.editor.getReadOnly()) {
- this.editor.replace(this.replaceInput.value);
- this.findNext()
- }
- };
- this.replaceAll = function() {
- if (!this.editor.getReadOnly())
- this.editor.replaceAll(this.replaceInput.value);
- };
-
- this.hide = function() {
- this.element.style.display = "none";
- this.editor.keyBinding.removeKeyboardHandler(this.$closeSearchBarKb);
- this.editor.focus();
- };
- this.show = function(value, isReplace) {
- this.element.style.display = "";
- this.replaceBox.style.display = isReplace ? "" : "none";
-
- this.isReplace = isReplace;
-
- if (value)
- this.searchInput.value = value;
- this.searchInput.focus();
- this.searchInput.select();
-
- this.editor.keyBinding.addKeyboardHandler(this.$closeSearchBarKb);
- };
-
-}).call(SearchBox.prototype);
-
-exports.SearchBox = SearchBox;
-
-exports.Search = function(editor, isReplace) {
- var sb = editor.searchBox || new SearchBox(editor);
- sb.show(editor.session.getTextRange(), isReplace);
-};
-
-});
diff --git a/src/core_plugins/console/public/webpackShims/ace/mode-json.js b/src/core_plugins/console/public/webpackShims/ace/mode-json.js
deleted file mode 100644
index 06b39f90b23dfa..00000000000000
--- a/src/core_plugins/console/public/webpackShims/ace/mode-json.js
+++ /dev/null
@@ -1,625 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-consoleAce.define('ace/mode/json', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/json_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/mode/behaviour/cstyle', 'ace/mode/folding/cstyle', 'ace/worker/worker_client'], function(require, exports, module) {
-
-
-var oop = require("../lib/oop");
-var TextMode = require("./text").Mode;
-var Tokenizer = require("../tokenizer").Tokenizer;
-var HighlightRules = require("./json_highlight_rules").JsonHighlightRules;
-var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
-var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
-var CStyleFoldMode = require("./folding/cstyle").FoldMode;
-var WorkerClient = require("../worker/worker_client").WorkerClient;
-
-var Mode = function() {
- this.HighlightRules = HighlightRules;
- this.$outdent = new MatchingBraceOutdent();
- this.$behaviour = new CstyleBehaviour();
- this.foldingRules = new CStyleFoldMode();
-};
-oop.inherits(Mode, TextMode);
-
-(function() {
-
- this.getNextLineIndent = function(state, line, tab) {
- var indent = this.$getIndent(line);
-
- if (state == "start") {
- var match = line.match(/^.*[\{\(\[]\s*$/);
- if (match) {
- indent += tab;
- }
- }
-
- return indent;
- };
-
- this.checkOutdent = function(state, line, input) {
- return this.$outdent.checkOutdent(line, input);
- };
-
- this.autoOutdent = function(state, doc, row) {
- this.$outdent.autoOutdent(doc, row);
- };
-
- this.createWorker = function(session) {
- var worker = new WorkerClient(["ace"], "ace/mode/json_worker", "JsonWorker");
- worker.attachToDocument(session.getDocument());
-
- worker.on("error", function(e) {
- session.setAnnotations([e.data]);
- });
-
- worker.on("ok", function() {
- session.clearAnnotations();
- });
-
- return worker;
- };
-
-
- this.$id = "ace/mode/json";
-}).call(Mode.prototype);
-
-exports.Mode = Mode;
-});
-
-consoleAce.define('ace/mode/json_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
-
-
-var oop = require("../lib/oop");
-var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
-
-var JsonHighlightRules = function() {
- this.$rules = {
- "start" : [
- {
- token : "variable", // single line
- regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]\\s*(?=:)'
- }, {
- token : "string", // single line
- regex : '"',
- next : "string"
- }, {
- token : "constant.numeric", // hex
- regex : "0[xX][0-9a-fA-F]+\\b"
- }, {
- token : "constant.numeric", // float
- regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"
- }, {
- token : "constant.language.boolean",
- regex : "(?:true|false)\\b"
- }, {
- token : "invalid.illegal", // single quoted strings are not allowed
- regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
- }, {
- token : "invalid.illegal", // comments are not allowed
- regex : "\\/\\/.*$"
- }, {
- token : "paren.lparen",
- regex : "[[({]"
- }, {
- token : "paren.rparen",
- regex : "[\\])}]"
- }, {
- token : "text",
- regex : "\\s+"
- }
- ],
- "string" : [
- {
- token : "constant.language.escape",
- regex : /\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|["\\\/bfnrt])/
- }, {
- token : "string",
- regex : '[^"\\\\]+'
- }, {
- token : "string",
- regex : '"',
- next : "start"
- }, {
- token : "string",
- regex : "",
- next : "start"
- }
- ]
- };
-
-};
-
-oop.inherits(JsonHighlightRules, TextHighlightRules);
-
-exports.JsonHighlightRules = JsonHighlightRules;
-});
-
-consoleAce.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
-
-
-var Range = require("../range").Range;
-
-var MatchingBraceOutdent = function() {};
-
-(function() {
-
- this.checkOutdent = function(line, input) {
- if (! /^\s+$/.test(line))
- return false;
-
- return /^\s*\}/.test(input);
- };
-
- this.autoOutdent = function(doc, row) {
- var line = doc.getLine(row);
- var match = line.match(/^(\s*\})/);
-
- if (!match) return 0;
-
- var column = match[1].length;
- var openBracePos = doc.findMatchingBracket({row: row, column: column});
-
- if (!openBracePos || openBracePos.row == row) return 0;
-
- var indent = this.$getIndent(doc.getLine(openBracePos.row));
- doc.replace(new Range(row, 0, row, column-1), indent);
- };
-
- this.$getIndent = function(line) {
- return line.match(/^\s*/)[0];
- };
-
-}).call(MatchingBraceOutdent.prototype);
-
-exports.MatchingBraceOutdent = MatchingBraceOutdent;
-});
-
-consoleAce.define('ace/mode/behaviour/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/behaviour', 'ace/token_iterator', 'ace/lib/lang'], function(require, exports, module) {
-
-
-var oop = require("../../lib/oop");
-var Behaviour = require("../behaviour").Behaviour;
-var TokenIterator = require("../../token_iterator").TokenIterator;
-var lang = require("../../lib/lang");
-
-var SAFE_INSERT_IN_TOKENS =
- ["text", "paren.rparen", "punctuation.operator"];
-var SAFE_INSERT_BEFORE_TOKENS =
- ["text", "paren.rparen", "punctuation.operator", "comment"];
-
-
-var autoInsertedBrackets = 0;
-var autoInsertedRow = -1;
-var autoInsertedLineEnd = "";
-var maybeInsertedBrackets = 0;
-var maybeInsertedRow = -1;
-var maybeInsertedLineStart = "";
-var maybeInsertedLineEnd = "";
-
-var CstyleBehaviour = function () {
-
- CstyleBehaviour.isSaneInsertion = function(editor, session) {
- var cursor = editor.getCursorPosition();
- var iterator = new TokenIterator(session, cursor.row, cursor.column);
- if (!this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS)) {
- var iterator2 = new TokenIterator(session, cursor.row, cursor.column + 1);
- if (!this.$matchTokenType(iterator2.getCurrentToken() || "text", SAFE_INSERT_IN_TOKENS))
- return false;
- }
- iterator.stepForward();
- return iterator.getCurrentTokenRow() !== cursor.row ||
- this.$matchTokenType(iterator.getCurrentToken() || "text", SAFE_INSERT_BEFORE_TOKENS);
- };
-
- CstyleBehaviour.$matchTokenType = function(token, types) {
- return types.indexOf(token.type || token) > -1;
- };
-
- CstyleBehaviour.recordAutoInsert = function(editor, session, bracket) {
- var cursor = editor.getCursorPosition();
- var line = session.doc.getLine(cursor.row);
- if (!this.isAutoInsertedClosing(cursor, line, autoInsertedLineEnd[0]))
- autoInsertedBrackets = 0;
- autoInsertedRow = cursor.row;
- autoInsertedLineEnd = bracket + line.substr(cursor.column);
- autoInsertedBrackets++;
- };
-
- CstyleBehaviour.recordMaybeInsert = function(editor, session, bracket) {
- var cursor = editor.getCursorPosition();
- var line = session.doc.getLine(cursor.row);
- if (!this.isMaybeInsertedClosing(cursor, line))
- maybeInsertedBrackets = 0;
- maybeInsertedRow = cursor.row;
- maybeInsertedLineStart = line.substr(0, cursor.column) + bracket;
- maybeInsertedLineEnd = line.substr(cursor.column);
- maybeInsertedBrackets++;
- };
-
- CstyleBehaviour.isAutoInsertedClosing = function(cursor, line, bracket) {
- return autoInsertedBrackets > 0 &&
- cursor.row === autoInsertedRow &&
- bracket === autoInsertedLineEnd[0] &&
- line.substr(cursor.column) === autoInsertedLineEnd;
- };
-
- CstyleBehaviour.isMaybeInsertedClosing = function(cursor, line) {
- return maybeInsertedBrackets > 0 &&
- cursor.row === maybeInsertedRow &&
- line.substr(cursor.column) === maybeInsertedLineEnd &&
- line.substr(0, cursor.column) == maybeInsertedLineStart;
- };
-
- CstyleBehaviour.popAutoInsertedClosing = function() {
- autoInsertedLineEnd = autoInsertedLineEnd.substr(1);
- autoInsertedBrackets--;
- };
-
- CstyleBehaviour.clearMaybeInsertedClosing = function() {
- maybeInsertedBrackets = 0;
- maybeInsertedRow = -1;
- };
-
- this.add("braces", "insertion", function (state, action, editor, session, text) {
- var cursor = editor.getCursorPosition();
- var line = session.doc.getLine(cursor.row);
- if (text == '{') {
- var selection = editor.getSelectionRange();
- var selected = session.doc.getTextRange(selection);
- if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
- return {
- text: '{' + selected + '}',
- selection: false
- };
- } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
- if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
- CstyleBehaviour.recordAutoInsert(editor, session, "}");
- return {
- text: '{}',
- selection: [1, 1]
- };
- } else {
- CstyleBehaviour.recordMaybeInsert(editor, session, "{");
- return {
- text: '{',
- selection: [1, 1]
- };
- }
- }
- } else if (text == '}') {
- var rightChar = line.substring(cursor.column, cursor.column + 1);
- if (rightChar == '}') {
- var matching = session.$findOpeningBracket('}', {column: cursor.column + 1, row: cursor.row});
- if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
- CstyleBehaviour.popAutoInsertedClosing();
- return {
- text: '',
- selection: [1, 1]
- };
- }
- }
- } else if (text == "\n" || text == "\r\n") {
- var closing = "";
- if (CstyleBehaviour.isMaybeInsertedClosing(cursor, line)) {
- closing = lang.stringRepeat("}", maybeInsertedBrackets);
- CstyleBehaviour.clearMaybeInsertedClosing();
- }
- var rightChar = line.substring(cursor.column, cursor.column + 1);
- if (rightChar === '}') {
- var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
- if (!openBracePos)
- return null;
- var next_indent = this.$getIndent(session.getLine(openBracePos.row));
- } else if (closing) {
- var next_indent = this.$getIndent(line);
- } else {
- return;
- }
- var indent = next_indent + session.getTabString();
-
- return {
- text: '\n' + indent + '\n' + next_indent + closing,
- selection: [1, indent.length, 1, indent.length]
- };
- } else {
- CstyleBehaviour.clearMaybeInsertedClosing();
- }
- });
-
- this.add("braces", "deletion", function (state, action, editor, session, range) {
- var selected = session.doc.getTextRange(range);
- if (!range.isMultiLine() && selected == '{') {
- var line = session.doc.getLine(range.start.row);
- var rightChar = line.substring(range.end.column, range.end.column + 1);
- if (rightChar == '}') {
- range.end.column++;
- return range;
- } else {
- maybeInsertedBrackets--;
- }
- }
- });
-
- this.add("parens", "insertion", function (state, action, editor, session, text) {
- if (text == '(') {
- var selection = editor.getSelectionRange();
- var selected = session.doc.getTextRange(selection);
- if (selected !== "" && editor.getWrapBehavioursEnabled()) {
- return {
- text: '(' + selected + ')',
- selection: false
- };
- } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
- CstyleBehaviour.recordAutoInsert(editor, session, ")");
- return {
- text: '()',
- selection: [1, 1]
- };
- }
- } else if (text == ')') {
- var cursor = editor.getCursorPosition();
- var line = session.doc.getLine(cursor.row);
- var rightChar = line.substring(cursor.column, cursor.column + 1);
- if (rightChar == ')') {
- var matching = session.$findOpeningBracket(')', {column: cursor.column + 1, row: cursor.row});
- if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
- CstyleBehaviour.popAutoInsertedClosing();
- return {
- text: '',
- selection: [1, 1]
- };
- }
- }
- }
- });
-
- this.add("parens", "deletion", function (state, action, editor, session, range) {
- var selected = session.doc.getTextRange(range);
- if (!range.isMultiLine() && selected == '(') {
- var line = session.doc.getLine(range.start.row);
- var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
- if (rightChar == ')') {
- range.end.column++;
- return range;
- }
- }
- });
-
- this.add("brackets", "insertion", function (state, action, editor, session, text) {
- if (text == '[') {
- var selection = editor.getSelectionRange();
- var selected = session.doc.getTextRange(selection);
- if (selected !== "" && editor.getWrapBehavioursEnabled()) {
- return {
- text: '[' + selected + ']',
- selection: false
- };
- } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
- CstyleBehaviour.recordAutoInsert(editor, session, "]");
- return {
- text: '[]',
- selection: [1, 1]
- };
- }
- } else if (text == ']') {
- var cursor = editor.getCursorPosition();
- var line = session.doc.getLine(cursor.row);
- var rightChar = line.substring(cursor.column, cursor.column + 1);
- if (rightChar == ']') {
- var matching = session.$findOpeningBracket(']', {column: cursor.column + 1, row: cursor.row});
- if (matching !== null && CstyleBehaviour.isAutoInsertedClosing(cursor, line, text)) {
- CstyleBehaviour.popAutoInsertedClosing();
- return {
- text: '',
- selection: [1, 1]
- };
- }
- }
- }
- });
-
- this.add("brackets", "deletion", function (state, action, editor, session, range) {
- var selected = session.doc.getTextRange(range);
- if (!range.isMultiLine() && selected == '[') {
- var line = session.doc.getLine(range.start.row);
- var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
- if (rightChar == ']') {
- range.end.column++;
- return range;
- }
- }
- });
-
- this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
- if (text == '"' || text == "'") {
- var quote = text;
- var selection = editor.getSelectionRange();
- var selected = session.doc.getTextRange(selection);
- if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
- return {
- text: quote + selected + quote,
- selection: false
- };
- } else {
- var cursor = editor.getCursorPosition();
- var line = session.doc.getLine(cursor.row);
- var leftChar = line.substring(cursor.column-1, cursor.column);
- if (leftChar == '\\') {
- return null;
- }
- var tokens = session.getTokens(selection.start.row);
- var col = 0, token;
- var quotepos = -1; // Track whether we're inside an open quote.
-
- for (var x = 0; x < tokens.length; x++) {
- token = tokens[x];
- if (token.type == "string") {
- quotepos = -1;
- } else if (quotepos < 0) {
- quotepos = token.value.indexOf(quote);
- }
- if ((token.value.length + col) > selection.start.column) {
- break;
- }
- col += tokens[x].value.length;
- }
- if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
- if (!CstyleBehaviour.isSaneInsertion(editor, session))
- return;
- return {
- text: quote + quote,
- selection: [1,1]
- };
- } else if (token && token.type === "string") {
- var rightChar = line.substring(cursor.column, cursor.column + 1);
- if (rightChar == quote) {
- return {
- text: '',
- selection: [1, 1]
- };
- }
- }
- }
- }
- });
-
- this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
- var selected = session.doc.getTextRange(range);
- if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
- var line = session.doc.getLine(range.start.row);
- var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
- if (rightChar == selected) {
- range.end.column++;
- return range;
- }
- }
- });
-
-};
-
-oop.inherits(CstyleBehaviour, Behaviour);
-
-exports.CstyleBehaviour = CstyleBehaviour;
-});
-
-consoleAce.define('ace/mode/folding/cstyle', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/range', 'ace/mode/folding/fold_mode'], function(require, exports, module) {
-
-
-var oop = require("../../lib/oop");
-var Range = require("../../range").Range;
-var BaseFoldMode = require("./fold_mode").FoldMode;
-
-var FoldMode = exports.FoldMode = function(commentRegex) {
- if (commentRegex) {
- this.foldingStartMarker = new RegExp(
- this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
- );
- this.foldingStopMarker = new RegExp(
- this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
- );
- }
-};
-oop.inherits(FoldMode, BaseFoldMode);
-
-(function() {
-
- this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
- this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
-
- this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
- var line = session.getLine(row);
- var match = line.match(this.foldingStartMarker);
- if (match) {
- var i = match.index;
-
- if (match[1])
- return this.openingBracketBlock(session, match[1], row, i);
-
- var range = session.getCommentFoldRange(row, i + match[0].length, 1);
-
- if (range && !range.isMultiLine()) {
- if (forceMultiline) {
- range = this.getSectionRange(session, row);
- } else if (foldStyle != "all")
- range = null;
- }
-
- return range;
- }
-
- if (foldStyle === "markbegin")
- return;
-
- var match = line.match(this.foldingStopMarker);
- if (match) {
- var i = match.index + match[0].length;
-
- if (match[1])
- return this.closingBracketBlock(session, match[1], row, i);
-
- return session.getCommentFoldRange(row, i, -1);
- }
- };
-
- this.getSectionRange = function(session, row) {
- var line = session.getLine(row);
- var startIndent = line.search(/\S/);
- var startRow = row;
- var startColumn = line.length;
- row = row + 1;
- var endRow = row;
- var maxRow = session.getLength();
- while (++row < maxRow) {
- line = session.getLine(row);
- var indent = line.search(/\S/);
- if (indent === -1)
- continue;
- if (startIndent > indent)
- break;
- var subRange = this.getFoldWidgetRange(session, "all", row);
-
- if (subRange) {
- if (subRange.start.row <= startRow) {
- break;
- } else if (subRange.isMultiLine()) {
- row = subRange.end.row;
- } else if (startIndent == indent) {
- break;
- }
- }
- endRow = row;
- }
-
- return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
- };
-
-}).call(FoldMode.prototype);
-
-});
diff --git a/src/core_plugins/console/public/webpackShims/ace/mode-yaml.js b/src/core_plugins/console/public/webpackShims/ace/mode-yaml.js
deleted file mode 100644
index e517111c4d27bf..00000000000000
--- a/src/core_plugins/console/public/webpackShims/ace/mode-yaml.js
+++ /dev/null
@@ -1,290 +0,0 @@
-/* ***** BEGIN LICENSE BLOCK *****
- * Distributed under the BSD license:
- *
- * Copyright (c) 2010, Ajax.org B.V.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Ajax.org B.V. nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * ***** END LICENSE BLOCK ***** */
-
-consoleAce.define('ace/mode/yaml', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text', 'ace/tokenizer', 'ace/mode/yaml_highlight_rules', 'ace/mode/matching_brace_outdent', 'ace/mode/folding/coffee'], function(require, exports, module) {
-
-
-var oop = require("../lib/oop");
-var TextMode = require("./text").Mode;
-var Tokenizer = require("../tokenizer").Tokenizer;
-var YamlHighlightRules = require("./yaml_highlight_rules").YamlHighlightRules;
-var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
-var FoldMode = require("./folding/coffee").FoldMode;
-
-var Mode = function() {
- this.HighlightRules = YamlHighlightRules;
- this.$outdent = new MatchingBraceOutdent();
- this.foldingRules = new FoldMode();
-};
-oop.inherits(Mode, TextMode);
-
-(function() {
-
- this.lineCommentStart = "#";
-
- this.getNextLineIndent = function(state, line, tab) {
- var indent = this.$getIndent(line);
-
- if (state == "start") {
- var match = line.match(/^.*[\{\(\[]\s*$/);
- if (match) {
- indent += tab;
- }
- }
-
- return indent;
- };
-
- this.checkOutdent = function(state, line, input) {
- return this.$outdent.checkOutdent(line, input);
- };
-
- this.autoOutdent = function(state, doc, row) {
- this.$outdent.autoOutdent(doc, row);
- };
-
-
- this.$id = "ace/mode/yaml";
-}).call(Mode.prototype);
-
-exports.Mode = Mode;
-
-});
-
-consoleAce.define('ace/mode/yaml_highlight_rules', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/text_highlight_rules'], function(require, exports, module) {
-
-
-var oop = require("../lib/oop");
-var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
-
-var YamlHighlightRules = function() {
- this.$rules = {
- "start" : [
- {
- token : "comment",
- regex : "#.*$"
- }, {
- token : "list.markup",
- regex : /^(?:-{3}|\.{3})\s*(?=#|$)/
- }, {
- token : "list.markup",
- regex : /^\s*[\-?](?:$|\s)/
- }, {
- token: "constant",
- regex: "!![\\w//]+"
- }, {
- token: "constant.language",
- regex: "[&\\*][a-zA-Z0-9-_]+"
- }, {
- token: ["meta.tag", "keyword"],
- regex: /^(\s*\w.*?)(\:(?:\s+|$))/
- },{
- token: ["meta.tag", "keyword"],
- regex: /(\w+?)(\s*\:(?:\s+|$))/
- }, {
- token : "keyword.operator",
- regex : "<<\\w*:\\w*"
- }, {
- token : "keyword.operator",
- regex : "-\\s*(?=[{])"
- }, {
- token : "string", // single line
- regex : '["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]'
- }, {
- token : "string", // multi line string start
- regex : '[|>][-+\\d\\s]*$',
- next : "qqstring"
- }, {
- token : "string", // single quoted string
- regex : "['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"
- }, {
- token : "constant.numeric", // float
- regex : /[+\-]?[\d_]+(?:(?:\.[\d_]*)?(?:[eE][+\-]?[\d_]+)?)?\b/
- }, {
- token : "constant.numeric", // other number
- regex : /[+\-]?\.inf\b|NaN\b|0x[\dA-Fa-f_]+|0b[10_]+/
- }, {
- token : "constant.language.boolean",
- regex : "(?:true|false|TRUE|FALSE|True|False|yes|no)\\b"
- }, {
- token : "invalid.illegal", // comments are not allowed
- regex : "\\/\\/.*$"
- }, {
- token : "paren.lparen",
- regex : "[[({]"
- }, {
- token : "paren.rparen",
- regex : "[\\])}]"
- }
- ],
- "qqstring" : [
- {
- token : "string",
- regex : '(?=(?:(?:\\\\.)|(?:[^:]))*?:)',
- next : "start"
- }, {
- token : "string",
- regex : '.+'
- }
- ]};
-
-};
-
-oop.inherits(YamlHighlightRules, TextHighlightRules);
-
-exports.YamlHighlightRules = YamlHighlightRules;
-});
-
-consoleAce.define('ace/mode/matching_brace_outdent', ['require', 'exports', 'module' , 'ace/range'], function(require, exports, module) {
-
-
-var Range = require("../range").Range;
-
-var MatchingBraceOutdent = function() {};
-
-(function() {
-
- this.checkOutdent = function(line, input) {
- if (! /^\s+$/.test(line))
- return false;
-
- return /^\s*\}/.test(input);
- };
-
- this.autoOutdent = function(doc, row) {
- var line = doc.getLine(row);
- var match = line.match(/^(\s*\})/);
-
- if (!match) return 0;
-
- var column = match[1].length;
- var openBracePos = doc.findMatchingBracket({row: row, column: column});
-
- if (!openBracePos || openBracePos.row == row) return 0;
-
- var indent = this.$getIndent(doc.getLine(openBracePos.row));
- doc.replace(new Range(row, 0, row, column-1), indent);
- };
-
- this.$getIndent = function(line) {
- return line.match(/^\s*/)[0];
- };
-
-}).call(MatchingBraceOutdent.prototype);
-
-exports.MatchingBraceOutdent = MatchingBraceOutdent;
-});
-
-consoleAce.define('ace/mode/folding/coffee', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/mode/folding/fold_mode', 'ace/range'], function(require, exports, module) {
-
-
-var oop = require("../../lib/oop");
-var BaseFoldMode = require("./fold_mode").FoldMode;
-var Range = require("../../range").Range;
-
-var FoldMode = exports.FoldMode = function() {};
-oop.inherits(FoldMode, BaseFoldMode);
-
-(function() {
-
- this.getFoldWidgetRange = function(session, foldStyle, row) {
- var range = this.indentationBlock(session, row);
- if (range)
- return range;
-
- var re = /\S/;
- var line = session.getLine(row);
- var startLevel = line.search(re);
- if (startLevel == -1 || line[startLevel] != "#")
- return;
-
- var startColumn = line.length;
- var maxRow = session.getLength();
- var startRow = row;
- var endRow = row;
-
- while (++row < maxRow) {
- line = session.getLine(row);
- var level = line.search(re);
-
- if (level == -1)
- continue;
-
- if (line[level] != "#")
- break;
-
- endRow = row;
- }
-
- if (endRow > startRow) {
- var endColumn = session.getLine(endRow).length;
- return new Range(startRow, startColumn, endRow, endColumn);
- }
- };
- this.getFoldWidget = function(session, foldStyle, row) {
- var line = session.getLine(row);
- var indent = line.search(/\S/);
- var next = session.getLine(row + 1);
- var prev = session.getLine(row - 1);
- var prevIndent = prev.search(/\S/);
- var nextIndent = next.search(/\S/);
-
- if (indent == -1) {
- session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
- return "";
- }
- if (prevIndent == -1) {
- if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
- session.foldWidgets[row - 1] = "";
- session.foldWidgets[row + 1] = "";
- return "start";
- }
- } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
- if (session.getLine(row - 2).search(/\S/) == -1) {
- session.foldWidgets[row - 1] = "start";
- session.foldWidgets[row + 1] = "";
- return "";
- }
- }
-
- if (prevIndent!= -1 && prevIndent < indent)
- session.foldWidgets[row - 1] = "start";
- else
- session.foldWidgets[row - 1] = "";
-
- if (indent < nextIndent)
- return "start";
- else
- return "";
- };
-
-}).call(FoldMode.prototype);
-
-});
diff --git a/src/core_plugins/console/public/webpackShims/ace/worker-json.js b/src/core_plugins/console/public/webpackShims/ace/worker-json.js
deleted file mode 100644
index 508c852fd37c9b..00000000000000
--- a/src/core_plugins/console/public/webpackShims/ace/worker-json.js
+++ /dev/null
@@ -1,2289 +0,0 @@
-"no use strict";
-;(function(window) {
-if (typeof window.window != "undefined" && window.document) {
- return;
-}
-
-window.console = function() {
- var msgs = Array.prototype.slice.call(arguments, 0);
- postMessage({type: "log", data: msgs});
-};
-window.console.error =
-window.console.warn =
-window.console.log =
-window.console.trace = window.console;
-
-window.window = window;
-window.ace = window;
-
-window.onerror = function(message, file, line, col, err) {
- console.error("Worker " + err.stack);
-};
-
-window.normalizeModule = function(parentId, moduleName) {
- if (moduleName.indexOf("!") !== -1) {
- var chunks = moduleName.split("!");
- return window.normalizeModule(parentId, chunks[0]) + "!" + window.normalizeModule(parentId, chunks[1]);
- }
- if (moduleName.charAt(0) == ".") {
- var base = parentId.split("/").slice(0, -1).join("/");
- moduleName = (base ? base + "/" : "") + moduleName;
-
- while(moduleName.indexOf(".") !== -1 && previous != moduleName) {
- var previous = moduleName;
- moduleName = moduleName.replace(/^\.\//, "").replace(/\/\.\//, "/").replace(/[^\/]+\/\.\.\//, "");
- }
- }
-
- return moduleName;
-};
-
-window.require = function(parentId, id) {
- if (!id) {
- id = parentId
- parentId = null;
- }
- if (!id.charAt)
- throw new Error("worker.js require() accepts only (parentId, id) as arguments");
-
- id = window.normalizeModule(parentId, id);
-
- var module = window.require.modules[id];
- if (module) {
- if (!module.initialized) {
- module.initialized = true;
- module.exports = module.factory().exports;
- }
- return module.exports;
- }
-
- var chunks = id.split("/");
- if (!window.require.tlns)
- return console.log("unable to load " + id);
- chunks[0] = window.require.tlns[chunks[0]] || chunks[0];
- var path = chunks.join("/") + ".js";
-
- window.require.id = id;
- importScripts(path);
- return window.require(parentId, id);
-};
-window.require.modules = {};
-window.require.tlns = {};
-
-window.define = function(id, deps, factory) {
- if (arguments.length == 2) {
- factory = deps;
- if (typeof id != "string") {
- deps = id;
- id = window.require.id;
- }
- } else if (arguments.length == 1) {
- factory = id;
- deps = []
- id = window.require.id;
- }
-
- if (!deps.length)
- deps = ['require', 'exports', 'module']
-
- if (id.indexOf("text!") === 0)
- return;
-
- var req = function(childId) {
- return window.require(id, childId);
- };
-
- window.require.modules[id] = {
- exports: {},
- factory: function() {
- var module = this;
- var returnExports = factory.apply(this, deps.map(function(dep) {
- switch(dep) {
- case 'require': return req
- case 'exports': return module.exports
- case 'module': return module
- default: return req(dep)
- }
- }));
- if (returnExports)
- module.exports = returnExports;
- return module;
- }
- };
-};
-window.define.amd = {}
-
-window.initBaseUrls = function initBaseUrls(topLevelNamespaces) {
- require.tlns = topLevelNamespaces;
-}
-
-window.initSender = function initSender() {
-
- var EventEmitter = window.require("ace/lib/event_emitter").EventEmitter;
- var oop = window.require("ace/lib/oop");
-
- var Sender = function() {};
-
- (function() {
-
- oop.implement(this, EventEmitter);
-
- this.callback = function(data, callbackId) {
- postMessage({
- type: "call",
- id: callbackId,
- data: data
- });
- };
-
- this.emit = function(name, data) {
- postMessage({
- type: "event",
- name: name,
- data: data
- });
- };
-
- }).call(Sender.prototype);
-
- return new Sender();
-}
-
-window.main = null;
-window.sender = null;
-
-window.onmessage = function(e) {
- var msg = e.data;
- if (msg.command) {
- if (main[msg.command])
- main[msg.command].apply(main, msg.args);
- else
- throw new Error("Unknown command:" + msg.command);
- }
- else if (msg.init) {
- initBaseUrls(msg.tlns);
- require("ace/lib/es5-shim");
- sender = initSender();
- var clazz = require(msg.module)[msg.classname];
- main = new clazz(sender);
- }
- else if (msg.event && sender) {
- sender._emit(msg.event, msg.data);
- }
-};
-})(this);// https://github.com/kriskowal/es5-shim
-
-consoleAce.define('ace/lib/es5-shim', ['require', 'exports', 'module' ], function(require, exports, module) {
-
-function Empty() {}
-
-if (!Function.prototype.bind) {
- Function.prototype.bind = function bind(that) { // .length is 1
- var target = this;
- if (typeof target != "function") {
- throw new TypeError("Function.prototype.bind called on incompatible " + target);
- }
- var args = slice.call(arguments, 1); // for normal call
- var bound = function () {
-
- if (this instanceof bound) {
-
- var result = target.apply(
- this,
- args.concat(slice.call(arguments))
- );
- if (Object(result) === result) {
- return result;
- }
- return this;
-
- } else {
- return target.apply(
- that,
- args.concat(slice.call(arguments))
- );
-
- }
-
- };
- if(target.prototype) {
- Empty.prototype = target.prototype;
- bound.prototype = new Empty();
- Empty.prototype = null;
- }
- return bound;
- };
-}
-var call = Function.prototype.call;
-var prototypeOfArray = Array.prototype;
-var prototypeOfObject = Object.prototype;
-var slice = prototypeOfArray.slice;
-var _toString = call.bind(prototypeOfObject.toString);
-var owns = call.bind(prototypeOfObject.hasOwnProperty);
-var defineGetter;
-var defineSetter;
-var lookupGetter;
-var lookupSetter;
-var supportsAccessors;
-if ((supportsAccessors = owns(prototypeOfObject, "__defineGetter__"))) {
- defineGetter = call.bind(prototypeOfObject.__defineGetter__);
- defineSetter = call.bind(prototypeOfObject.__defineSetter__);
- lookupGetter = call.bind(prototypeOfObject.__lookupGetter__);
- lookupSetter = call.bind(prototypeOfObject.__lookupSetter__);
-}
-if ([1,2].splice(0).length != 2) {
- if(function() { // test IE < 9 to splice bug - see issue #138
- function makeArray(l) {
- var a = new Array(l+2);
- a[0] = a[1] = 0;
- return a;
- }
- var array = [], lengthBefore;
-
- array.splice.apply(array, makeArray(20));
- array.splice.apply(array, makeArray(26));
-
- lengthBefore = array.length; //46
- array.splice(5, 0, "XXX"); // add one element
-
- lengthBefore + 1 == array.length
-
- if (lengthBefore + 1 == array.length) {
- return true;// has right splice implementation without bugs
- }
- }()) {//IE 6/7
- var array_splice = Array.prototype.splice;
- Array.prototype.splice = function(start, deleteCount) {
- if (!arguments.length) {
- return [];
- } else {
- return array_splice.apply(this, [
- start === void 0 ? 0 : start,
- deleteCount === void 0 ? (this.length - start) : deleteCount
- ].concat(slice.call(arguments, 2)))
- }
- };
- } else {//IE8
- Array.prototype.splice = function(pos, removeCount){
- var length = this.length;
- if (pos > 0) {
- if (pos > length)
- pos = length;
- } else if (pos == void 0) {
- pos = 0;
- } else if (pos < 0) {
- pos = Math.max(length + pos, 0);
- }
-
- if (!(pos+removeCount < length))
- removeCount = length - pos;
-
- var removed = this.slice(pos, pos+removeCount);
- var insert = slice.call(arguments, 2);
- var add = insert.length;
- if (pos === length) {
- if (add) {
- this.push.apply(this, insert);
- }
- } else {
- var remove = Math.min(removeCount, length - pos);
- var tailOldPos = pos + remove;
- var tailNewPos = tailOldPos + add - remove;
- var tailCount = length - tailOldPos;
- var lengthAfterRemove = length - remove;
-
- if (tailNewPos < tailOldPos) { // case A
- for (var i = 0; i < tailCount; ++i) {
- this[tailNewPos+i] = this[tailOldPos+i];
- }
- } else if (tailNewPos > tailOldPos) { // case B
- for (i = tailCount; i--; ) {
- this[tailNewPos+i] = this[tailOldPos+i];
- }
- } // else, add == remove (nothing to do)
-
- if (add && pos === lengthAfterRemove) {
- this.length = lengthAfterRemove; // truncate array
- this.push.apply(this, insert);
- } else {
- this.length = lengthAfterRemove + add; // reserves space
- for (i = 0; i < add; ++i) {
- this[pos+i] = insert[i];
- }
- }
- }
- return removed;
- };
- }
-}
-if (!Array.isArray) {
- Array.isArray = function isArray(obj) {
- return _toString(obj) == "[object Array]";
- };
-}
-var boxedString = Object("a"),
- splitString = boxedString[0] != "a" || !(0 in boxedString);
-
-if (!Array.prototype.forEach) {
- Array.prototype.forEach = function forEach(fun /*, thisp*/) {
- var object = toObject(this),
- self = splitString && _toString(this) == "[object String]" ?
- this.split("") :
- object,
- thisp = arguments[1],
- i = -1,
- length = self.length >>> 0;
- if (_toString(fun) != "[object Function]") {
- throw new TypeError(); // TODO message
- }
-
- while (++i < length) {
- if (i in self) {
- fun.call(thisp, self[i], i, object);
- }
- }
- };
-}
-if (!Array.prototype.map) {
- Array.prototype.map = function map(fun /*, thisp*/) {
- var object = toObject(this),
- self = splitString && _toString(this) == "[object String]" ?
- this.split("") :
- object,
- length = self.length >>> 0,
- result = Array(length),
- thisp = arguments[1];
- if (_toString(fun) != "[object Function]") {
- throw new TypeError(fun + " is not a function");
- }
-
- for (var i = 0; i < length; i++) {
- if (i in self)
- result[i] = fun.call(thisp, self[i], i, object);
- }
- return result;
- };
-}
-if (!Array.prototype.filter) {
- Array.prototype.filter = function filter(fun /*, thisp */) {
- var object = toObject(this),
- self = splitString && _toString(this) == "[object String]" ?
- this.split("") :
- object,
- length = self.length >>> 0,
- result = [],
- value,
- thisp = arguments[1];
- if (_toString(fun) != "[object Function]") {
- throw new TypeError(fun + " is not a function");
- }
-
- for (var i = 0; i < length; i++) {
- if (i in self) {
- value = self[i];
- if (fun.call(thisp, value, i, object)) {
- result.push(value);
- }
- }
- }
- return result;
- };
-}
-if (!Array.prototype.every) {
- Array.prototype.every = function every(fun /*, thisp */) {
- var object = toObject(this),
- self = splitString && _toString(this) == "[object String]" ?
- this.split("") :
- object,
- length = self.length >>> 0,
- thisp = arguments[1];
- if (_toString(fun) != "[object Function]") {
- throw new TypeError(fun + " is not a function");
- }
-
- for (var i = 0; i < length; i++) {
- if (i in self && !fun.call(thisp, self[i], i, object)) {
- return false;
- }
- }
- return true;
- };
-}
-if (!Array.prototype.some) {
- Array.prototype.some = function some(fun /*, thisp */) {
- var object = toObject(this),
- self = splitString && _toString(this) == "[object String]" ?
- this.split("") :
- object,
- length = self.length >>> 0,
- thisp = arguments[1];
- if (_toString(fun) != "[object Function]") {
- throw new TypeError(fun + " is not a function");
- }
-
- for (var i = 0; i < length; i++) {
- if (i in self && fun.call(thisp, self[i], i, object)) {
- return true;
- }
- }
- return false;
- };
-}
-if (!Array.prototype.reduce) {
- Array.prototype.reduce = function reduce(fun /*, initial*/) {
- var object = toObject(this),
- self = splitString && _toString(this) == "[object String]" ?
- this.split("") :
- object,
- length = self.length >>> 0;
- if (_toString(fun) != "[object Function]") {
- throw new TypeError(fun + " is not a function");
- }
- if (!length && arguments.length == 1) {
- throw new TypeError("reduce of empty array with no initial value");
- }
-
- var i = 0;
- var result;
- if (arguments.length >= 2) {
- result = arguments[1];
- } else {
- do {
- if (i in self) {
- result = self[i++];
- break;
- }
- if (++i >= length) {
- throw new TypeError("reduce of empty array with no initial value");
- }
- } while (true);
- }
-
- for (; i < length; i++) {
- if (i in self) {
- result = fun.call(void 0, result, self[i], i, object);
- }
- }
-
- return result;
- };
-}
-if (!Array.prototype.reduceRight) {
- Array.prototype.reduceRight = function reduceRight(fun /*, initial*/) {
- var object = toObject(this),
- self = splitString && _toString(this) == "[object String]" ?
- this.split("") :
- object,
- length = self.length >>> 0;
- if (_toString(fun) != "[object Function]") {
- throw new TypeError(fun + " is not a function");
- }
- if (!length && arguments.length == 1) {
- throw new TypeError("reduceRight of empty array with no initial value");
- }
-
- var result, i = length - 1;
- if (arguments.length >= 2) {
- result = arguments[1];
- } else {
- do {
- if (i in self) {
- result = self[i--];
- break;
- }
- if (--i < 0) {
- throw new TypeError("reduceRight of empty array with no initial value");
- }
- } while (true);
- }
-
- do {
- if (i in this) {
- result = fun.call(void 0, result, self[i], i, object);
- }
- } while (i--);
-
- return result;
- };
-}
-if (!Array.prototype.indexOf || ([0, 1].indexOf(1, 2) != -1)) {
- Array.prototype.indexOf = function indexOf(sought /*, fromIndex */ ) {
- var self = splitString && _toString(this) == "[object String]" ?
- this.split("") :
- toObject(this),
- length = self.length >>> 0;
-
- if (!length) {
- return -1;
- }
-
- var i = 0;
- if (arguments.length > 1) {
- i = toInteger(arguments[1]);
- }
- i = i >= 0 ? i : Math.max(0, length + i);
- for (; i < length; i++) {
- if (i in self && self[i] === sought) {
- return i;
- }
- }
- return -1;
- };
-}
-if (!Array.prototype.lastIndexOf || ([0, 1].lastIndexOf(0, -3) != -1)) {
- Array.prototype.lastIndexOf = function lastIndexOf(sought /*, fromIndex */) {
- var self = splitString && _toString(this) == "[object String]" ?
- this.split("") :
- toObject(this),
- length = self.length >>> 0;
-
- if (!length) {
- return -1;
- }
- var i = length - 1;
- if (arguments.length > 1) {
- i = Math.min(i, toInteger(arguments[1]));
- }
- i = i >= 0 ? i : length - Math.abs(i);
- for (; i >= 0; i--) {
- if (i in self && sought === self[i]) {
- return i;
- }
- }
- return -1;
- };
-}
-if (!Object.getPrototypeOf) {
- Object.getPrototypeOf = function getPrototypeOf(object) {
- return object.__proto__ || (
- object.constructor ?
- object.constructor.prototype :
- prototypeOfObject
- );
- };
-}
-if (!Object.getOwnPropertyDescriptor) {
- var ERR_NON_OBJECT = "Object.getOwnPropertyDescriptor called on a " +
- "non-object: ";
- Object.getOwnPropertyDescriptor = function getOwnPropertyDescriptor(object, property) {
- if ((typeof object != "object" && typeof object != "function") || object === null)
- throw new TypeError(ERR_NON_OBJECT + object);
- if (!owns(object, property))
- return;
-
- var descriptor, getter, setter;
- descriptor = { enumerable: true, configurable: true };
- if (supportsAccessors) {
- var prototype = object.__proto__;
- object.__proto__ = prototypeOfObject;
-
- var getter = lookupGetter(object, property);
- var setter = lookupSetter(object, property);
- object.__proto__ = prototype;
-
- if (getter || setter) {
- if (getter) descriptor.get = getter;
- if (setter) descriptor.set = setter;
- return descriptor;
- }
- }
- descriptor.value = object[property];
- return descriptor;
- };
-}
-if (!Object.getOwnPropertyNames) {
- Object.getOwnPropertyNames = function getOwnPropertyNames(object) {
- return Object.keys(object);
- };
-}
-if (!Object.create) {
- var createEmpty;
- if (Object.prototype.__proto__ === null) {
- createEmpty = function () {
- return { "__proto__": null };
- };
- } else {
- createEmpty = function () {
- var empty = {};
- for (var i in empty)
- empty[i] = null;
- empty.constructor =
- empty.hasOwnProperty =
- empty.propertyIsEnumerable =
- empty.isPrototypeOf =
- empty.toLocaleString =
- empty.toString =
- empty.valueOf =
- empty.__proto__ = null;
- return empty;
- }
- }
-
- Object.create = function create(prototype, properties) {
- var object;
- if (prototype === null) {
- object = createEmpty();
- } else {
- if (typeof prototype != "object")
- throw new TypeError("typeof prototype["+(typeof prototype)+"] != 'object'");
- var Type = function () {};
- Type.prototype = prototype;
- object = new Type();
- object.__proto__ = prototype;
- }
- if (properties !== void 0)
- Object.defineProperties(object, properties);
- return object;
- };
-}
-
-function doesDefinePropertyWork(object) {
- try {
- Object.defineProperty(object, "sentinel", {});
- return "sentinel" in object;
- } catch (exception) {
- }
-}
-if (Object.defineProperty) {
- var definePropertyWorksOnObject = doesDefinePropertyWork({});
- var definePropertyWorksOnDom = typeof document == "undefined" ||
- doesDefinePropertyWork(document.createElement("div"));
- if (!definePropertyWorksOnObject || !definePropertyWorksOnDom) {
- var definePropertyFallback = Object.defineProperty;
- }
-}
-
-if (!Object.defineProperty || definePropertyFallback) {
- var ERR_NON_OBJECT_DESCRIPTOR = "Property description must be an object: ";
- var ERR_NON_OBJECT_TARGET = "Object.defineProperty called on non-object: "
- var ERR_ACCESSORS_NOT_SUPPORTED = "getters & setters can not be defined " +
- "on this javascript engine";
-
- Object.defineProperty = function defineProperty(object, property, descriptor) {
- if ((typeof object != "object" && typeof object != "function") || object === null)
- throw new TypeError(ERR_NON_OBJECT_TARGET + object);
- if ((typeof descriptor != "object" && typeof descriptor != "function") || descriptor === null)
- throw new TypeError(ERR_NON_OBJECT_DESCRIPTOR + descriptor);
- if (definePropertyFallback) {
- try {
- return definePropertyFallback.call(Object, object, property, descriptor);
- } catch (exception) {
- }
- }
- if (owns(descriptor, "value")) {
-
- if (supportsAccessors && (lookupGetter(object, property) ||
- lookupSetter(object, property)))
- {
- var prototype = object.__proto__;
- object.__proto__ = prototypeOfObject;
- delete object[property];
- object[property] = descriptor.value;
- object.__proto__ = prototype;
- } else {
- object[property] = descriptor.value;
- }
- } else {
- if (!supportsAccessors)
- throw new TypeError(ERR_ACCESSORS_NOT_SUPPORTED);
- if (owns(descriptor, "get"))
- defineGetter(object, property, descriptor.get);
- if (owns(descriptor, "set"))
- defineSetter(object, property, descriptor.set);
- }
-
- return object;
- };
-}
-if (!Object.defineProperties) {
- Object.defineProperties = function defineProperties(object, properties) {
- for (var property in properties) {
- if (owns(properties, property))
- Object.defineProperty(object, property, properties[property]);
- }
- return object;
- };
-}
-if (!Object.seal) {
- Object.seal = function seal(object) {
- return object;
- };
-}
-if (!Object.freeze) {
- Object.freeze = function freeze(object) {
- return object;
- };
-}
-try {
- Object.freeze(function () {});
-} catch (exception) {
- Object.freeze = (function freeze(freezeObject) {
- return function freeze(object) {
- if (typeof object == "function") {
- return object;
- } else {
- return freezeObject(object);
- }
- };
- })(Object.freeze);
-}
-if (!Object.preventExtensions) {
- Object.preventExtensions = function preventExtensions(object) {
- return object;
- };
-}
-if (!Object.isSealed) {
- Object.isSealed = function isSealed(object) {
- return false;
- };
-}
-if (!Object.isFrozen) {
- Object.isFrozen = function isFrozen(object) {
- return false;
- };
-}
-if (!Object.isExtensible) {
- Object.isExtensible = function isExtensible(object) {
- if (Object(object) === object) {
- throw new TypeError(); // TODO message
- }
- var name = '';
- while (owns(object, name)) {
- name += '?';
- }
- object[name] = true;
- var returnValue = owns(object, name);
- delete object[name];
- return returnValue;
- };
-}
-if (!Object.keys) {
- var hasDontEnumBug = true,
- dontEnums = [
- "toString",
- "toLocaleString",
- "valueOf",
- "hasOwnProperty",
- "isPrototypeOf",
- "propertyIsEnumerable",
- "constructor"
- ],
- dontEnumsLength = dontEnums.length;
-
- for (var key in {"toString": null}) {
- hasDontEnumBug = false;
- }
-
- Object.keys = function keys(object) {
-
- if (
- (typeof object != "object" && typeof object != "function") ||
- object === null
- ) {
- throw new TypeError("Object.keys called on a non-object");
- }
-
- var keys = [];
- for (var name in object) {
- if (owns(object, name)) {
- keys.push(name);
- }
- }
-
- if (hasDontEnumBug) {
- for (var i = 0, ii = dontEnumsLength; i < ii; i++) {
- var dontEnum = dontEnums[i];
- if (owns(object, dontEnum)) {
- keys.push(dontEnum);
- }
- }
- }
- return keys;
- };
-
-}
-if (!Date.now) {
- Date.now = function now() {
- return new Date().getTime();
- };
-}
-var ws = "\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003" +
- "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" +
- "\u2029\uFEFF";
-if (!String.prototype.trim || ws.trim()) {
- ws = "[" + ws + "]";
- var trimBeginRegexp = new RegExp("^" + ws + ws + "*"),
- trimEndRegexp = new RegExp(ws + ws + "*$");
- String.prototype.trim = function trim() {
- return String(this).replace(trimBeginRegexp, "").replace(trimEndRegexp, "");
- };
-}
-
-function toInteger(n) {
- n = +n;
- if (n !== n) { // isNaN
- n = 0;
- } else if (n !== 0 && n !== (1/0) && n !== -(1/0)) {
- n = (n > 0 || -1) * Math.floor(Math.abs(n));
- }
- return n;
-}
-
-function isPrimitive(input) {
- var type = typeof input;
- return (
- input === null ||
- type === "undefined" ||
- type === "boolean" ||
- type === "number" ||
- type === "string"
- );
-}
-
-function toPrimitive(input) {
- var val, valueOf, toString;
- if (isPrimitive(input)) {
- return input;
- }
- valueOf = input.valueOf;
- if (typeof valueOf === "function") {
- val = valueOf.call(input);
- if (isPrimitive(val)) {
- return val;
- }
- }
- toString = input.toString;
- if (typeof toString === "function") {
- val = toString.call(input);
- if (isPrimitive(val)) {
- return val;
- }
- }
- throw new TypeError();
-}
-var toObject = function (o) {
- if (o == null) { // this matches both null and undefined
- throw new TypeError("can't convert "+o+" to object");
- }
- return Object(o);
-};
-
-});
-
-consoleAce.define('ace/mode/json_worker', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/worker/mirror', 'ace/mode/json/json_parse'], function(require, exports, module) {
-
-
-var oop = require("../lib/oop");
-var Mirror = require("../worker/mirror").Mirror;
-var parse = require("./json/json_parse");
-
-var JsonWorker = exports.JsonWorker = function(sender) {
- Mirror.call(this, sender);
- this.setTimeout(200);
-};
-
-oop.inherits(JsonWorker, Mirror);
-
-(function() {
-
- this.onUpdate = function() {
- var value = this.doc.getValue();
-
- try {
- var result = parse(value);
- } catch (e) {
- var pos = this.doc.indexToPosition(e.at-1);
- this.sender.emit("error", {
- row: pos.row,
- column: pos.column,
- text: e.message,
- type: "error"
- });
- return;
- }
- this.sender.emit("ok");
- };
-
-}).call(JsonWorker.prototype);
-
-});
-
-consoleAce.define('ace/lib/oop', ['require', 'exports', 'module' ], function(require, exports, module) {
-
-
-exports.inherits = function(ctor, superCtor) {
- ctor.super_ = superCtor;
- ctor.prototype = Object.create(superCtor.prototype, {
- constructor: {
- value: ctor,
- enumerable: false,
- writable: true,
- configurable: true
- }
- });
-};
-
-exports.mixin = function(obj, mixin) {
- for (var key in mixin) {
- obj[key] = mixin[key];
- }
- return obj;
-};
-
-exports.implement = function(proto, mixin) {
- exports.mixin(proto, mixin);
-};
-
-});
-consoleAce.define('ace/worker/mirror', ['require', 'exports', 'module' , 'ace/document', 'ace/lib/lang'], function(require, exports, module) {
-
-
-var Document = require("../document").Document;
-var lang = require("../lib/lang");
-
-var Mirror = exports.Mirror = function(sender) {
- this.sender = sender;
- var doc = this.doc = new Document("");
-
- var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
-
- var _self = this;
- sender.on("change", function(e) {
- doc.applyDeltas(e.data);
- if (_self.$timeout)
- return deferredUpdate.schedule(_self.$timeout);
- _self.onUpdate();
- });
-};
-
-(function() {
-
- this.$timeout = 500;
-
- this.setTimeout = function(timeout) {
- this.$timeout = timeout;
- };
-
- this.setValue = function(value) {
- this.doc.setValue(value);
- this.deferredUpdate.schedule(this.$timeout);
- };
-
- this.getValue = function(callbackId) {
- this.sender.callback(this.doc.getValue(), callbackId);
- };
-
- this.onUpdate = function() {
- };
-
- this.isPending = function() {
- return this.deferredUpdate.isPending();
- };
-
-}).call(Mirror.prototype);
-
-});
-
-consoleAce.define('ace/document', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter', 'ace/range', 'ace/anchor'], function(require, exports, module) {
-
-
-var oop = require("./lib/oop");
-var EventEmitter = require("./lib/event_emitter").EventEmitter;
-var Range = require("./range").Range;
-var Anchor = require("./anchor").Anchor;
-
-var Document = function(text) {
- this.$lines = [];
- if (text.length == 0) {
- this.$lines = [""];
- } else if (Array.isArray(text)) {
- this._insertLines(0, text);
- } else {
- this.insert({row: 0, column:0}, text);
- }
-};
-
-(function() {
-
- oop.implement(this, EventEmitter);
- this.setValue = function(text) {
- var len = this.getLength();
- this.remove(new Range(0, 0, len, this.getLine(len-1).length));
- this.insert({row: 0, column:0}, text);
- };
- this.getValue = function() {
- return this.getAllLines().join(this.getNewLineCharacter());
- };
- this.createAnchor = function(row, column) {
- return new Anchor(this, row, column);
- };
- if ("aaa".split(/a/).length == 0)
- this.$split = function(text) {
- return text.replace(/\r\n|\r/g, "\n").split("\n");
- }
- else
- this.$split = function(text) {
- return text.split(/\r\n|\r|\n/);
- };
-
-
- this.$detectNewLine = function(text) {
- var match = text.match(/^.*?(\r\n|\r|\n)/m);
- this.$autoNewLine = match ? match[1] : "\n";
- };
- this.getNewLineCharacter = function() {
- switch (this.$newLineMode) {
- case "windows":
- return "\r\n";
- case "unix":
- return "\n";
- default:
- return this.$autoNewLine;
- }
- };
-
- this.$autoNewLine = "\n";
- this.$newLineMode = "auto";
- this.setNewLineMode = function(newLineMode) {
- if (this.$newLineMode === newLineMode)
- return;
-
- this.$newLineMode = newLineMode;
- };
- this.getNewLineMode = function() {
- return this.$newLineMode;
- };
- this.isNewLine = function(text) {
- return (text == "\r\n" || text == "\r" || text == "\n");
- };
- this.getLine = function(row) {
- return this.$lines[row] || "";
- };
- this.getLines = function(firstRow, lastRow) {
- return this.$lines.slice(firstRow, lastRow + 1);
- };
- this.getAllLines = function() {
- return this.getLines(0, this.getLength());
- };
- this.getLength = function() {
- return this.$lines.length;
- };
- this.getTextRange = function(range) {
- if (range.start.row == range.end.row) {
- return this.getLine(range.start.row)
- .substring(range.start.column, range.end.column);
- }
- var lines = this.getLines(range.start.row, range.end.row);
- lines[0] = (lines[0] || "").substring(range.start.column);
- var l = lines.length - 1;
- if (range.end.row - range.start.row == l)
- lines[l] = lines[l].substring(0, range.end.column);
- return lines.join(this.getNewLineCharacter());
- };
-
- this.$clipPosition = function(position) {
- var length = this.getLength();
- if (position.row >= length) {
- position.row = Math.max(0, length - 1);
- position.column = this.getLine(length-1).length;
- } else if (position.row < 0)
- position.row = 0;
- return position;
- };
- this.insert = function(position, text) {
- if (!text || text.length === 0)
- return position;
-
- position = this.$clipPosition(position);
- if (this.getLength() <= 1)
- this.$detectNewLine(text);
-
- var lines = this.$split(text);
- var firstLine = lines.splice(0, 1)[0];
- var lastLine = lines.length == 0 ? null : lines.splice(lines.length - 1, 1)[0];
-
- position = this.insertInLine(position, firstLine);
- if (lastLine !== null) {
- position = this.insertNewLine(position); // terminate first line
- position = this._insertLines(position.row, lines);
- position = this.insertInLine(position, lastLine || "");
- }
- return position;
- };
- this.insertLines = function(row, lines) {
- if (row >= this.getLength())
- return this.insert({row: row, column: 0}, "\n" + lines.join("\n"));
- return this._insertLines(Math.max(row, 0), lines);
- };
- this._insertLines = function(row, lines) {
- if (lines.length == 0)
- return {row: row, column: 0};
- if (lines.length > 0xFFFF) {
- var end = this._insertLines(row, lines.slice(0xFFFF));
- lines = lines.slice(0, 0xFFFF);
- }
-
- var args = [row, 0];
- args.push.apply(args, lines);
- this.$lines.splice.apply(this.$lines, args);
-
- var range = new Range(row, 0, row + lines.length, 0);
- var delta = {
- action: "insertLines",
- range: range,
- lines: lines
- };
- this._emit("change", { data: delta });
- return end || range.end;
- };
- this.insertNewLine = function(position) {
- position = this.$clipPosition(position);
- var line = this.$lines[position.row] || "";
-
- this.$lines[position.row] = line.substring(0, position.column);
- this.$lines.splice(position.row + 1, 0, line.substring(position.column, line.length));
-
- var end = {
- row : position.row + 1,
- column : 0
- };
-
- var delta = {
- action: "insertText",
- range: Range.fromPoints(position, end),
- text: this.getNewLineCharacter()
- };
- this._emit("change", { data: delta });
-
- return end;
- };
- this.insertInLine = function(position, text) {
- if (text.length == 0)
- return position;
-
- var line = this.$lines[position.row] || "";
-
- this.$lines[position.row] = line.substring(0, position.column) + text
- + line.substring(position.column);
-
- var end = {
- row : position.row,
- column : position.column + text.length
- };
-
- var delta = {
- action: "insertText",
- range: Range.fromPoints(position, end),
- text: text
- };
- this._emit("change", { data: delta });
-
- return end;
- };
- this.remove = function(range) {
- if (!range instanceof Range)
- range = Range.fromPoints(range.start, range.end);
- range.start = this.$clipPosition(range.start);
- range.end = this.$clipPosition(range.end);
-
- if (range.isEmpty())
- return range.start;
-
- var firstRow = range.start.row;
- var lastRow = range.end.row;
-
- if (range.isMultiLine()) {
- var firstFullRow = range.start.column == 0 ? firstRow : firstRow + 1;
- var lastFullRow = lastRow - 1;
-
- if (range.end.column > 0)
- this.removeInLine(lastRow, 0, range.end.column);
-
- if (lastFullRow >= firstFullRow)
- this._removeLines(firstFullRow, lastFullRow);
-
- if (firstFullRow != firstRow) {
- this.removeInLine(firstRow, range.start.column, this.getLine(firstRow).length);
- this.removeNewLine(range.start.row);
- }
- }
- else {
- this.removeInLine(firstRow, range.start.column, range.end.column);
- }
- return range.start;
- };
- this.removeInLine = function(row, startColumn, endColumn) {
- if (startColumn == endColumn)
- return;
-
- var range = new Range(row, startColumn, row, endColumn);
- var line = this.getLine(row);
- var removed = line.substring(startColumn, endColumn);
- var newLine = line.substring(0, startColumn) + line.substring(endColumn, line.length);
- this.$lines.splice(row, 1, newLine);
-
- var delta = {
- action: "removeText",
- range: range,
- text: removed
- };
- this._emit("change", { data: delta });
- return range.start;
- };
- this.removeLines = function(firstRow, lastRow) {
- if (firstRow < 0 || lastRow >= this.getLength())
- return this.remove(new Range(firstRow, 0, lastRow + 1, 0));
- return this._removeLines(firstRow, lastRow);
- };
-
- this._removeLines = function(firstRow, lastRow) {
- var range = new Range(firstRow, 0, lastRow + 1, 0);
- var removed = this.$lines.splice(firstRow, lastRow - firstRow + 1);
-
- var delta = {
- action: "removeLines",
- range: range,
- nl: this.getNewLineCharacter(),
- lines: removed
- };
- this._emit("change", { data: delta });
- return removed;
- };
- this.removeNewLine = function(row) {
- var firstLine = this.getLine(row);
- var secondLine = this.getLine(row+1);
-
- var range = new Range(row, firstLine.length, row+1, 0);
- var line = firstLine + secondLine;
-
- this.$lines.splice(row, 2, line);
-
- var delta = {
- action: "removeText",
- range: range,
- text: this.getNewLineCharacter()
- };
- this._emit("change", { data: delta });
- };
- this.replace = function(range, text) {
- if (!range instanceof Range)
- range = Range.fromPoints(range.start, range.end);
- if (text.length == 0 && range.isEmpty())
- return range.start;
- if (text == this.getTextRange(range))
- return range.end;
-
- this.remove(range);
- if (text) {
- var end = this.insert(range.start, text);
- }
- else {
- end = range.start;
- }
-
- return end;
- };
- this.applyDeltas = function(deltas) {
- for (var i=0; i=0; i--) {
- var delta = deltas[i];
-
- var range = Range.fromPoints(delta.range.start, delta.range.end);
-
- if (delta.action == "insertLines")
- this._removeLines(range.start.row, range.end.row - 1);
- else if (delta.action == "insertText")
- this.remove(range);
- else if (delta.action == "removeLines")
- this._insertLines(range.start.row, delta.lines);
- else if (delta.action == "removeText")
- this.insert(range.start, delta.text);
- }
- };
- this.indexToPosition = function(index, startRow) {
- var lines = this.$lines || this.getAllLines();
- var newlineLength = this.getNewLineCharacter().length;
- for (var i = startRow || 0, l = lines.length; i < l; i++) {
- index -= lines[i].length + newlineLength;
- if (index < 0)
- return {row: i, column: index + lines[i].length + newlineLength};
- }
- return {row: l-1, column: lines[l-1].length};
- };
- this.positionToIndex = function(pos, startRow) {
- var lines = this.$lines || this.getAllLines();
- var newlineLength = this.getNewLineCharacter().length;
- var index = 0;
- var row = Math.min(pos.row, lines.length);
- for (var i = startRow || 0; i < row; ++i)
- index += lines[i].length + newlineLength;
-
- return index + pos.column;
- };
-
-}).call(Document.prototype);
-
-exports.Document = Document;
-});
-
-consoleAce.define('ace/lib/event_emitter', ['require', 'exports', 'module' ], function(require, exports, module) {
-
-
-var EventEmitter = {};
-var stopPropagation = function() { this.propagationStopped = true; };
-var preventDefault = function() { this.defaultPrevented = true; };
-
-EventEmitter._emit =
-EventEmitter._dispatchEvent = function(eventName, e) {
- this._eventRegistry || (this._eventRegistry = {});
- this._defaultHandlers || (this._defaultHandlers = {});
-
- var listeners = this._eventRegistry[eventName] || [];
- var defaultHandler = this._defaultHandlers[eventName];
- if (!listeners.length && !defaultHandler)
- return;
-
- if (typeof e != "object" || !e)
- e = {};
-
- if (!e.type)
- e.type = eventName;
- if (!e.stopPropagation)
- e.stopPropagation = stopPropagation;
- if (!e.preventDefault)
- e.preventDefault = preventDefault;
-
- listeners = listeners.slice();
- for (var i=0; i [" + this.end.row + "/" + this.end.column + "]");
- };
-
- this.contains = function(row, column) {
- return this.compare(row, column) == 0;
- };
- this.compareRange = function(range) {
- var cmp,
- end = range.end,
- start = range.start;
-
- cmp = this.compare(end.row, end.column);
- if (cmp == 1) {
- cmp = this.compare(start.row, start.column);
- if (cmp == 1) {
- return 2;
- } else if (cmp == 0) {
- return 1;
- } else {
- return 0;
- }
- } else if (cmp == -1) {
- return -2;
- } else {
- cmp = this.compare(start.row, start.column);
- if (cmp == -1) {
- return -1;
- } else if (cmp == 1) {
- return 42;
- } else {
- return 0;
- }
- }
- };
- this.comparePoint = function(p) {
- return this.compare(p.row, p.column);
- };
- this.containsRange = function(range) {
- return this.comparePoint(range.start) == 0 && this.comparePoint(range.end) == 0;
- };
- this.intersects = function(range) {
- var cmp = this.compareRange(range);
- return (cmp == -1 || cmp == 0 || cmp == 1);
- };
- this.isEnd = function(row, column) {
- return this.end.row == row && this.end.column == column;
- };
- this.isStart = function(row, column) {
- return this.start.row == row && this.start.column == column;
- };
- this.setStart = function(row, column) {
- if (typeof row == "object") {
- this.start.column = row.column;
- this.start.row = row.row;
- } else {
- this.start.row = row;
- this.start.column = column;
- }
- };
- this.setEnd = function(row, column) {
- if (typeof row == "object") {
- this.end.column = row.column;
- this.end.row = row.row;
- } else {
- this.end.row = row;
- this.end.column = column;
- }
- };
- this.inside = function(row, column) {
- if (this.compare(row, column) == 0) {
- if (this.isEnd(row, column) || this.isStart(row, column)) {
- return false;
- } else {
- return true;
- }
- }
- return false;
- };
- this.insideStart = function(row, column) {
- if (this.compare(row, column) == 0) {
- if (this.isEnd(row, column)) {
- return false;
- } else {
- return true;
- }
- }
- return false;
- };
- this.insideEnd = function(row, column) {
- if (this.compare(row, column) == 0) {
- if (this.isStart(row, column)) {
- return false;
- } else {
- return true;
- }
- }
- return false;
- };
- this.compare = function(row, column) {
- if (!this.isMultiLine()) {
- if (row === this.start.row) {
- return column < this.start.column ? -1 : (column > this.end.column ? 1 : 0);
- };
- }
-
- if (row < this.start.row)
- return -1;
-
- if (row > this.end.row)
- return 1;
-
- if (this.start.row === row)
- return column >= this.start.column ? 0 : -1;
-
- if (this.end.row === row)
- return column <= this.end.column ? 0 : 1;
-
- return 0;
- };
- this.compareStart = function(row, column) {
- if (this.start.row == row && this.start.column == column) {
- return -1;
- } else {
- return this.compare(row, column);
- }
- };
- this.compareEnd = function(row, column) {
- if (this.end.row == row && this.end.column == column) {
- return 1;
- } else {
- return this.compare(row, column);
- }
- };
- this.compareInside = function(row, column) {
- if (this.end.row == row && this.end.column == column) {
- return 1;
- } else if (this.start.row == row && this.start.column == column) {
- return -1;
- } else {
- return this.compare(row, column);
- }
- };
- this.clipRows = function(firstRow, lastRow) {
- if (this.end.row > lastRow)
- var end = {row: lastRow + 1, column: 0};
- else if (this.end.row < firstRow)
- var end = {row: firstRow, column: 0};
-
- if (this.start.row > lastRow)
- var start = {row: lastRow + 1, column: 0};
- else if (this.start.row < firstRow)
- var start = {row: firstRow, column: 0};
-
- return Range.fromPoints(start || this.start, end || this.end);
- };
- this.extend = function(row, column) {
- var cmp = this.compare(row, column);
-
- if (cmp == 0)
- return this;
- else if (cmp == -1)
- var start = {row: row, column: column};
- else
- var end = {row: row, column: column};
-
- return Range.fromPoints(start || this.start, end || this.end);
- };
-
- this.isEmpty = function() {
- return (this.start.row === this.end.row && this.start.column === this.end.column);
- };
- this.isMultiLine = function() {
- return (this.start.row !== this.end.row);
- };
- this.clone = function() {
- return Range.fromPoints(this.start, this.end);
- };
- this.collapseRows = function() {
- if (this.end.column == 0)
- return new Range(this.start.row, 0, Math.max(this.start.row, this.end.row-1), 0)
- else
- return new Range(this.start.row, 0, this.end.row, 0)
- };
- this.toScreenRange = function(session) {
- var screenPosStart = session.documentToScreenPosition(this.start);
- var screenPosEnd = session.documentToScreenPosition(this.end);
-
- return new Range(
- screenPosStart.row, screenPosStart.column,
- screenPosEnd.row, screenPosEnd.column
- );
- };
- this.moveBy = function(row, column) {
- this.start.row += row;
- this.start.column += column;
- this.end.row += row;
- this.end.column += column;
- };
-
-}).call(Range.prototype);
-Range.fromPoints = function(start, end) {
- return new Range(start.row, start.column, end.row, end.column);
-};
-Range.comparePoints = comparePoints;
-
-Range.comparePoints = function(p1, p2) {
- return p1.row - p2.row || p1.column - p2.column;
-};
-
-
-exports.Range = Range;
-});
-
-consoleAce.define('ace/anchor', ['require', 'exports', 'module' , 'ace/lib/oop', 'ace/lib/event_emitter'], function(require, exports, module) {
-
-
-var oop = require("./lib/oop");
-var EventEmitter = require("./lib/event_emitter").EventEmitter;
-
-var Anchor = exports.Anchor = function(doc, row, column) {
- this.$onChange = this.onChange.bind(this);
- this.attach(doc);
-
- if (typeof column == "undefined")
- this.setPosition(row.row, row.column);
- else
- this.setPosition(row, column);
-};
-
-(function() {
-
- oop.implement(this, EventEmitter);
- this.getPosition = function() {
- return this.$clipPositionToDocument(this.row, this.column);
- };
- this.getDocument = function() {
- return this.document;
- };
- this.$insertRight = false;
- this.onChange = function(e) {
- var delta = e.data;
- var range = delta.range;
-
- if (range.start.row == range.end.row && range.start.row != this.row)
- return;
-
- if (range.start.row > this.row)
- return;
-
- if (range.start.row == this.row && range.start.column > this.column)
- return;
-
- var row = this.row;
- var column = this.column;
- var start = range.start;
- var end = range.end;
-
- if (delta.action === "insertText") {
- if (start.row === row && start.column <= column) {
- if (start.column === column && this.$insertRight) {
- } else if (start.row === end.row) {
- column += end.column - start.column;
- } else {
- column -= start.column;
- row += end.row - start.row;
- }
- } else if (start.row !== end.row && start.row < row) {
- row += end.row - start.row;
- }
- } else if (delta.action === "insertLines") {
- if (start.row <= row) {
- row += end.row - start.row;
- }
- } else if (delta.action === "removeText") {
- if (start.row === row && start.column < column) {
- if (end.column >= column)
- column = start.column;
- else
- column = Math.max(0, column - (end.column - start.column));
-
- } else if (start.row !== end.row && start.row < row) {
- if (end.row === row)
- column = Math.max(0, column - end.column) + start.column;
- row -= (end.row - start.row);
- } else if (end.row === row) {
- row -= end.row - start.row;
- column = Math.max(0, column - end.column) + start.column;
- }
- } else if (delta.action == "removeLines") {
- if (start.row <= row) {
- if (end.row <= row)
- row -= end.row - start.row;
- else {
- row = start.row;
- column = 0;
- }
- }
- }
-
- this.setPosition(row, column, true);
- };
- this.setPosition = function(row, column, noClip) {
- var pos;
- if (noClip) {
- pos = {
- row: row,
- column: column
- };
- } else {
- pos = this.$clipPositionToDocument(row, column);
- }
-
- if (this.row == pos.row && this.column == pos.column)
- return;
-
- var old = {
- row: this.row,
- column: this.column
- };
-
- this.row = pos.row;
- this.column = pos.column;
- this._emit("change", {
- old: old,
- value: pos
- });
- };
- this.detach = function() {
- this.document.removeEventListener("change", this.$onChange);
- };
- this.attach = function(doc) {
- this.document = doc || this.document;
- this.document.on("change", this.$onChange);
- };
- this.$clipPositionToDocument = function(row, column) {
- var pos = {};
-
- if (row >= this.document.getLength()) {
- pos.row = Math.max(0, this.document.getLength() - 1);
- pos.column = this.document.getLine(pos.row).length;
- }
- else if (row < 0) {
- pos.row = 0;
- pos.column = 0;
- }
- else {
- pos.row = row;
- pos.column = Math.min(this.document.getLine(pos.row).length, Math.max(0, column));
- }
-
- if (column < 0)
- pos.column = 0;
-
- return pos;
- };
-
-}).call(Anchor.prototype);
-
-});
-
-consoleAce.define('ace/lib/lang', ['require', 'exports', 'module' ], function(require, exports, module) {
-
-
-exports.stringReverse = function(string) {
- return string.split("").reverse().join("");
-};
-
-exports.stringRepeat = function (string, count) {
- var result = '';
- while (count > 0) {
- if (count & 1)
- result += string;
-
- if (count >>= 1)
- string += string;
- }
- return result;
-};
-
-var trimBeginRegexp = /^\s\s*/;
-var trimEndRegexp = /\s\s*$/;
-
-exports.stringTrimLeft = function (string) {
- return string.replace(trimBeginRegexp, '');
-};
-
-exports.stringTrimRight = function (string) {
- return string.replace(trimEndRegexp, '');
-};
-
-exports.copyObject = function(obj) {
- var copy = {};
- for (var key in obj) {
- copy[key] = obj[key];
- }
- return copy;
-};
-
-exports.copyArray = function(array){
- var copy = [];
- for (var i=0, l=array.length; i= '0' && ch <= '9') {
- string += ch;
- next();
- }
- if (ch === '.') {
- string += '.';
- while (next() && ch >= '0' && ch <= '9') {
- string += ch;
- }
- }
- if (ch === 'e' || ch === 'E') {
- string += ch;
- next();
- if (ch === '-' || ch === '+') {
- string += ch;
- next();
- }
- while (ch >= '0' && ch <= '9') {
- string += ch;
- next();
- }
- }
- number = +string;
- if (isNaN(number)) {
- error("Bad number");
- } else {
- return number;
- }
- },
-
- string = function () {
-
- var hex,
- i,
- string = '',
- uffff;
-
- if (ch === '"') {
- while (next()) {
- if (ch === '"') {
- next();
- return string;
- } else if (ch === '\\') {
- next();
- if (ch === 'u') {
- uffff = 0;
- for (i = 0; i < 4; i += 1) {
- hex = parseInt(next(), 16);
- if (!isFinite(hex)) {
- break;
- }
- uffff = uffff * 16 + hex;
- }
- string += String.fromCharCode(uffff);
- } else if (typeof escapee[ch] === 'string') {
- string += escapee[ch];
- } else {
- break;
- }
- } else {
- string += ch;
- }
- }
- }
- error("Bad string");
- },
-
- white = function () {
-
- while (ch && ch <= ' ') {
- next();
- }
- },
-
- word = function () {
-
- switch (ch) {
- case 't':
- next('t');
- next('r');
- next('u');
- next('e');
- return true;
- case 'f':
- next('f');
- next('a');
- next('l');
- next('s');
- next('e');
- return false;
- case 'n':
- next('n');
- next('u');
- next('l');
- next('l');
- return null;
- }
- error("Unexpected '" + ch + "'");
- },
-
- value, // Place holder for the value function.
-
- array = function () {
-
- var array = [];
-
- if (ch === '[') {
- next('[');
- white();
- if (ch === ']') {
- next(']');
- return array; // empty array
- }
- while (ch) {
- array.push(value());
- white();
- if (ch === ']') {
- next(']');
- return array;
- }
- next(',');
- white();
- }
- }
- error("Bad array");
- },
-
- object = function () {
-
- var key,
- object = {};
-
- if (ch === '{') {
- next('{');
- white();
- if (ch === '}') {
- next('}');
- return object; // empty object
- }
- while (ch) {
- key = string();
- white();
- next(':');
- if (Object.hasOwnProperty.call(object, key)) {
- error('Duplicate key "' + key + '"');
- }
- object[key] = value();
- white();
- if (ch === '}') {
- next('}');
- return object;
- }
- next(',');
- white();
- }
- }
- error("Bad object");
- };
-
- value = function () {
-
- white();
- switch (ch) {
- case '{':
- return object();
- case '[':
- return array();
- case '"':
- return string();
- case '-':
- return number();
- default:
- return ch >= '0' && ch <= '9' ? number() : word();
- }
- };
-
- return function (source, reviver) {
- var result;
-
- text = source;
- at = 0;
- ch = ' ';
- result = value();
- white();
- if (ch) {
- error("Syntax error");
- }
-
- return typeof reviver === 'function' ? function walk(holder, key) {
- var k, v, value = holder[key];
- if (value && typeof value === 'object') {
- for (k in value) {
- if (Object.hasOwnProperty.call(value, k)) {
- v = walk(value, k);
- if (v !== undefined) {
- value[k] = v;
- } else {
- delete value[k];
- }
- }
- }
- }
- return reviver.call(holder, key, value);
- }({'': result}, '') : result;
- };
-});
diff --git a/src/core_plugins/console/public/webpackShims/acequire.js b/src/core_plugins/console/public/webpackShims/acequire.js
deleted file mode 100644
index 05539287ede9cf..00000000000000
--- a/src/core_plugins/console/public/webpackShims/acequire.js
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = require('./ace').require;
diff --git a/src/core_plugins/console/server/__tests__/elasticsearch_proxy_config.js b/src/core_plugins/console/server/__tests__/elasticsearch_proxy_config.js
index 7bd963dd9f9540..3a721bb18dfac5 100644
--- a/src/core_plugins/console/server/__tests__/elasticsearch_proxy_config.js
+++ b/src/core_plugins/console/server/__tests__/elasticsearch_proxy_config.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import expect from 'expect.js';
import { getElasticsearchProxyConfig } from '../elasticsearch_proxy_config';
import https from 'https';
@@ -99,22 +118,22 @@ describe('plugins/console', function () {
expect(agent.options.ca).to.contain('test ca certificate\n');
});
- it(`sets cert and key when certificate and key paths are specified`, function () {
+ it(`doesn't set cert and key when certificate and key paths are specified`, function () {
setElasticsearchConfig('ssl.certificate', __dirname + '/fixtures/cert.crt');
setElasticsearchConfig('ssl.key', __dirname + '/fixtures/cert.key');
const { agent } = getElasticsearchProxyConfig(server);
- expect(agent.options.cert).to.be('test certificate\n');
- expect(agent.options.key).to.be('test key\n');
+ expect(agent.options.cert).to.be(undefined);
+ expect(agent.options.key).to.be(undefined);
});
- it(`sets passphrase when certificate, key and keyPassphrase are specified`, function () {
+ it(`doesn't set passphrase when certificate, key and keyPassphrase are specified`, function () {
setElasticsearchConfig('ssl.certificate', __dirname + '/fixtures/cert.crt');
setElasticsearchConfig('ssl.key', __dirname + '/fixtures/cert.key');
setElasticsearchConfig('ssl.keyPassphrase', 'secret');
const { agent } = getElasticsearchProxyConfig(server);
- expect(agent.options.passphrase).to.be('secret');
+ expect(agent.options.passphrase).to.be(undefined);
});
});
});
diff --git a/src/core_plugins/console/server/__tests__/proxy_config.js b/src/core_plugins/console/server/__tests__/proxy_config.js
index 9174d92e275d0e..79fbf444d07f18 100644
--- a/src/core_plugins/console/server/__tests__/proxy_config.js
+++ b/src/core_plugins/console/server/__tests__/proxy_config.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
/* eslint-env mocha */
import expect from 'expect.js';
@@ -18,9 +37,7 @@ const parsedLocalEs = parseUrl('https://localhost:5601/search');
describe('ProxyConfig', function () {
beforeEach(function () {
- sinon.stub(fs, 'readFileSync', function (path) {
- return { path };
- });
+ sinon.stub(fs, 'readFileSync').callsFake((path) => ({ path }));
});
afterEach(function () {
diff --git a/src/core_plugins/console/server/__tests__/proxy_config_collection.js b/src/core_plugins/console/server/__tests__/proxy_config_collection.js
index 2f4ecf222abd0c..6b9878f06952e2 100644
--- a/src/core_plugins/console/server/__tests__/proxy_config_collection.js
+++ b/src/core_plugins/console/server/__tests__/proxy_config_collection.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
/* eslint-env mocha */
import expect from 'expect.js';
@@ -9,7 +28,7 @@ import { ProxyConfigCollection } from '../proxy_config_collection';
describe('ProxyConfigCollection', function () {
beforeEach(function () {
- sinon.stub(fs, 'readFileSync', () => new Buffer(0));
+ sinon.stub(fs, 'readFileSync').callsFake(() => new Buffer(0));
});
afterEach(function () {
diff --git a/src/core_plugins/console/server/__tests__/proxy_route/body.js b/src/core_plugins/console/server/__tests__/proxy_route/body.js
index 6be331d38bada1..28ad08d72ab6af 100644
--- a/src/core_plugins/console/server/__tests__/proxy_route/body.js
+++ b/src/core_plugins/console/server/__tests__/proxy_route/body.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import sinon from 'sinon';
import Wreck from 'wreck';
import expect from 'expect.js';
@@ -8,14 +27,13 @@ import { createProxyRoute } from '../../';
import { createWreckResponseStub } from './stubs';
describe('Console Proxy Route', () => {
- const sandbox = sinon.sandbox.create();
+ const sandbox = sinon.createSandbox();
const teardowns = [];
let request;
beforeEach(() => {
- teardowns.push(() => sandbox.restore());
request = async (method, path, response) => {
- sandbox.stub(Wreck, 'request', createWreckResponseStub(response));
+ sandbox.stub(Wreck, 'request').callsFake(createWreckResponseStub(response));
const server = new Server();
@@ -37,6 +55,7 @@ describe('Console Proxy Route', () => {
});
afterEach(async () => {
+ sandbox.restore();
await Promise.all(teardowns.splice(0).map(fn => fn()));
});
diff --git a/src/core_plugins/console/server/__tests__/proxy_route/headers.js b/src/core_plugins/console/server/__tests__/proxy_route/headers.js
index 30cbcc6cb7c529..3bf32ce78871ad 100644
--- a/src/core_plugins/console/server/__tests__/proxy_route/headers.js
+++ b/src/core_plugins/console/server/__tests__/proxy_route/headers.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import { request } from 'http';
import sinon from 'sinon';
@@ -10,14 +29,12 @@ import { createProxyRoute } from '../../';
import { createWreckResponseStub } from './stubs';
describe('Console Proxy Route', () => {
- const sandbox = sinon.sandbox.create();
+ const sandbox = sinon.createSandbox();
const teardowns = [];
let setup;
beforeEach(() => {
- teardowns.push(() => sandbox.restore());
-
- sandbox.stub(Wreck, 'request', createWreckResponseStub());
+ sandbox.stub(Wreck, 'request').callsFake(createWreckResponseStub());
setup = () => {
const server = new Server();
@@ -34,6 +51,7 @@ describe('Console Proxy Route', () => {
});
afterEach(async () => {
+ sandbox.restore();
await Promise.all(teardowns.splice(0).map(fn => fn()));
});
diff --git a/src/core_plugins/console/server/__tests__/proxy_route/params.js b/src/core_plugins/console/server/__tests__/proxy_route/params.js
index dd95b85bf018a3..2fb13705559466 100644
--- a/src/core_plugins/console/server/__tests__/proxy_route/params.js
+++ b/src/core_plugins/console/server/__tests__/proxy_route/params.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import { Agent } from 'http';
import sinon from 'sinon';
@@ -10,14 +29,12 @@ import { createProxyRoute } from '../../';
import { createWreckResponseStub } from './stubs';
describe('Console Proxy Route', () => {
- const sandbox = sinon.sandbox.create();
+ const sandbox = sinon.createSandbox();
const teardowns = [];
let setup;
beforeEach(() => {
- teardowns.push(() => sandbox.restore());
-
- sandbox.stub(Wreck, 'request', createWreckResponseStub());
+ sandbox.stub(Wreck, 'request').callsFake(createWreckResponseStub());
setup = () => {
const server = new Server();
@@ -28,6 +45,7 @@ describe('Console Proxy Route', () => {
});
afterEach(async () => {
+ sandbox.restore();
await Promise.all(teardowns.splice(0).map(fn => fn()));
});
diff --git a/src/core_plugins/console/server/__tests__/proxy_route/query_string.js b/src/core_plugins/console/server/__tests__/proxy_route/query_string.js
index 1f0229e228e40a..9276ec3b5ef357 100644
--- a/src/core_plugins/console/server/__tests__/proxy_route/query_string.js
+++ b/src/core_plugins/console/server/__tests__/proxy_route/query_string.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import sinon from 'sinon';
import Wreck from 'wreck';
import expect from 'expect.js';
@@ -8,14 +27,12 @@ import { createProxyRoute } from '../../';
import { createWreckResponseStub } from './stubs';
describe('Console Proxy Route', () => {
- const sandbox = sinon.sandbox.create();
+ const sandbox = sinon.createSandbox();
const teardowns = [];
let request;
beforeEach(() => {
- teardowns.push(() => sandbox.restore());
-
- sandbox.stub(Wreck, 'request', createWreckResponseStub());
+ sandbox.stub(Wreck, 'request').callsFake(createWreckResponseStub());
request = async (method, path) => {
const server = new Server();
@@ -38,6 +55,7 @@ describe('Console Proxy Route', () => {
});
afterEach(async () => {
+ sandbox.restore();
await Promise.all(teardowns.splice(0).map(fn => fn()));
});
diff --git a/src/core_plugins/console/server/__tests__/proxy_route/stubs.js b/src/core_plugins/console/server/__tests__/proxy_route/stubs.js
index 9e250befe1826f..3318f7a4b27409 100644
--- a/src/core_plugins/console/server/__tests__/proxy_route/stubs.js
+++ b/src/core_plugins/console/server/__tests__/proxy_route/stubs.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import { Readable } from 'stream';
export function createWreckResponseStub(response) {
diff --git a/src/core_plugins/console/server/__tests__/wildcard_matcher.js b/src/core_plugins/console/server/__tests__/wildcard_matcher.js
index 2b758eeea33171..4eb0de4e5ebec4 100644
--- a/src/core_plugins/console/server/__tests__/wildcard_matcher.js
+++ b/src/core_plugins/console/server/__tests__/wildcard_matcher.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
/* eslint-env mocha */
import { WildcardMatcher } from '../wildcard_matcher';
diff --git a/src/core_plugins/console/server/elasticsearch_proxy_config.js b/src/core_plugins/console/server/elasticsearch_proxy_config.js
index 110cde0913a504..86fb37eb86eb7e 100644
--- a/src/core_plugins/console/server/elasticsearch_proxy_config.js
+++ b/src/core_plugins/console/server/elasticsearch_proxy_config.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import _ from 'lodash';
import { readFileSync } from 'fs';
import http from 'http';
@@ -36,13 +55,6 @@ const createAgent = (server) => {
agentOptions.ca = config.get('elasticsearch.ssl.certificateAuthorities').map(readFile);
}
- // Add client certificate and key if required by elasticsearch
- if (config.get('elasticsearch.ssl.certificate') && config.get('elasticsearch.ssl.key')) {
- agentOptions.cert = readFile(config.get('elasticsearch.ssl.certificate'));
- agentOptions.key = readFile(config.get('elasticsearch.ssl.key'));
- agentOptions.passphrase = config.get('elasticsearch.ssl.keyPassphrase');
- }
-
return new https.Agent(agentOptions);
};
diff --git a/src/core_plugins/console/server/index.js b/src/core_plugins/console/server/index.js
index 795c5541af16b1..15a8a5baf79dc0 100644
--- a/src/core_plugins/console/server/index.js
+++ b/src/core_plugins/console/server/index.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
export { ProxyConfigCollection } from './proxy_config_collection';
export { getElasticsearchProxyConfig } from './elasticsearch_proxy_config';
export { createProxyRoute } from './proxy_route';
diff --git a/src/core_plugins/console/server/proxy_config.js b/src/core_plugins/console/server/proxy_config.js
index 8cc6a4cd839bcd..98bc58f5f56c35 100644
--- a/src/core_plugins/console/server/proxy_config.js
+++ b/src/core_plugins/console/server/proxy_config.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import { values } from 'lodash';
import { format as formatUrl } from 'url';
import { Agent as HttpsAgent } from 'https';
diff --git a/src/core_plugins/console/server/proxy_config_collection.js b/src/core_plugins/console/server/proxy_config_collection.js
index 5d19034f46e583..e8bf52cc8b0855 100644
--- a/src/core_plugins/console/server/proxy_config_collection.js
+++ b/src/core_plugins/console/server/proxy_config_collection.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import { defaultsDeep } from 'lodash';
import { ProxyConfig } from './proxy_config';
diff --git a/src/core_plugins/console/server/proxy_route.js b/src/core_plugins/console/server/proxy_route.js
index 8c2201183979a0..cdae847f0e7023 100644
--- a/src/core_plugins/console/server/proxy_route.js
+++ b/src/core_plugins/console/server/proxy_route.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import Joi from 'joi';
import Boom from 'boom';
import Wreck from 'wreck';
diff --git a/src/core_plugins/console/server/wildcard_matcher.js b/src/core_plugins/console/server/wildcard_matcher.js
index b37d74f04246fc..208ae2fc73db51 100644
--- a/src/core_plugins/console/server/wildcard_matcher.js
+++ b/src/core_plugins/console/server/wildcard_matcher.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import { Minimatch } from 'minimatch';
export class WildcardMatcher {
diff --git a/src/core_plugins/dev_mode/index.js b/src/core_plugins/dev_mode/index.js
index b44a3c52d204ca..202301544fe895 100644
--- a/src/core_plugins/dev_mode/index.js
+++ b/src/core_plugins/dev_mode/index.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
export default (kibana) => {
return new kibana.Plugin({
id: 'dev_mode',
diff --git a/src/core_plugins/dev_mode/public/vis_debug_spy_panel.js b/src/core_plugins/dev_mode/public/vis_debug_spy_panel.js
index ece98bf0b0c7f4..8fb31cb0d0f714 100644
--- a/src/core_plugins/dev_mode/public/vis_debug_spy_panel.js
+++ b/src/core_plugins/dev_mode/public/vis_debug_spy_panel.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import visDebugSpyPanelTemplate from './vis_debug_spy_panel.html';
import { SpyModesRegistryProvider } from 'ui/registry/spy_modes';
diff --git a/src/core_plugins/elasticsearch/__tests__/index.js b/src/core_plugins/elasticsearch/__tests__/index.js
index 85273e23beee7e..d09e1db67a6662 100644
--- a/src/core_plugins/elasticsearch/__tests__/index.js
+++ b/src/core_plugins/elasticsearch/__tests__/index.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import { Deprecations } from '../../../deprecation';
import expect from 'expect.js';
import index from '../index';
diff --git a/src/core_plugins/elasticsearch/index.js b/src/core_plugins/elasticsearch/index.js
index 0829206579b138..87af4ace6a668b 100644
--- a/src/core_plugins/elasticsearch/index.js
+++ b/src/core_plugins/elasticsearch/index.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import { compact, get, has, set } from 'lodash';
import { unset } from '../../utils';
diff --git a/src/core_plugins/elasticsearch/lib/__tests__/cluster.js b/src/core_plugins/elasticsearch/lib/__tests__/cluster.js
index f06f9fb848a986..e0156fbe066c7d 100644
--- a/src/core_plugins/elasticsearch/lib/__tests__/cluster.js
+++ b/src/core_plugins/elasticsearch/lib/__tests__/cluster.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import expect from 'expect.js';
import { Cluster } from '../cluster';
import sinon from 'sinon';
diff --git a/src/core_plugins/elasticsearch/lib/__tests__/create_admin_cluster.js b/src/core_plugins/elasticsearch/lib/__tests__/create_admin_cluster.js
index d5dcc25bdbeed4..71d457a5b79738 100644
--- a/src/core_plugins/elasticsearch/lib/__tests__/create_admin_cluster.js
+++ b/src/core_plugins/elasticsearch/lib/__tests__/create_admin_cluster.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import expect from 'expect.js';
import sinon from 'sinon';
import { set, get, partial } from 'lodash';
diff --git a/src/core_plugins/elasticsearch/lib/__tests__/create_agent.js b/src/core_plugins/elasticsearch/lib/__tests__/create_agent.js
index 5425d61653a7d2..9f9d50d8433489 100644
--- a/src/core_plugins/elasticsearch/lib/__tests__/create_agent.js
+++ b/src/core_plugins/elasticsearch/lib/__tests__/create_agent.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import expect from 'expect.js';
import createAgent from '../create_agent';
import https from 'https';
diff --git a/src/core_plugins/elasticsearch/lib/__tests__/create_clusters.js b/src/core_plugins/elasticsearch/lib/__tests__/create_clusters.js
index 7f621057c27afa..ce9ebc739a6510 100644
--- a/src/core_plugins/elasticsearch/lib/__tests__/create_clusters.js
+++ b/src/core_plugins/elasticsearch/lib/__tests__/create_clusters.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import expect from 'expect.js';
import { createClusters } from '../create_clusters';
import sinon from 'sinon';
@@ -52,10 +71,10 @@ describe('plugins/elasticsearch', function () {
});
describe('server stop', () => {
- const sandbox = sinon.sandbox.create();
+ const sandbox = sinon.createSandbox();
beforeEach(() => {
- sandbox.stub(ClusterNS, 'Cluster', function () {
+ sandbox.stub(ClusterNS, 'Cluster').callsFake(function () {
this.stub = true;
this.close = sinon.stub();
});
diff --git a/src/core_plugins/elasticsearch/lib/__tests__/create_data_cluster.js b/src/core_plugins/elasticsearch/lib/__tests__/create_data_cluster.js
index eb30a72962f676..10a2e0dab5ab76 100644
--- a/src/core_plugins/elasticsearch/lib/__tests__/create_data_cluster.js
+++ b/src/core_plugins/elasticsearch/lib/__tests__/create_data_cluster.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import expect from 'expect.js';
import sinon from 'sinon';
import { set, get, partial } from 'lodash';
diff --git a/src/core_plugins/elasticsearch/lib/__tests__/create_proxy.js b/src/core_plugins/elasticsearch/lib/__tests__/create_proxy.js
index 0bbdf724b63756..74bf7c08e71ada 100644
--- a/src/core_plugins/elasticsearch/lib/__tests__/create_proxy.js
+++ b/src/core_plugins/elasticsearch/lib/__tests__/create_proxy.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import expect from 'expect.js';
import { createPath } from '../create_proxy';
diff --git a/src/core_plugins/elasticsearch/lib/__tests__/ensure_es_version.js b/src/core_plugins/elasticsearch/lib/__tests__/ensure_es_version.js
index b6828c35622617..2d554979ed9236 100644
--- a/src/core_plugins/elasticsearch/lib/__tests__/ensure_es_version.js
+++ b/src/core_plugins/elasticsearch/lib/__tests__/ensure_es_version.js
@@ -1,9 +1,28 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import _ from 'lodash';
import Promise from 'bluebird';
import sinon from 'sinon';
import expect from 'expect.js';
-import { esTestConfig } from '../../../../test_utils/es';
+import { esTestConfig } from '@kbn/test';
import { ensureEsVersion } from '../ensure_es_version';
describe('plugins/elasticsearch', () => {
diff --git a/src/core_plugins/elasticsearch/lib/__tests__/fixtures/mappings.js b/src/core_plugins/elasticsearch/lib/__tests__/fixtures/mappings.js
index 0c9cf770bef8c0..53125a5407e83b 100644
--- a/src/core_plugins/elasticsearch/lib/__tests__/fixtures/mappings.js
+++ b/src/core_plugins/elasticsearch/lib/__tests__/fixtures/mappings.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
export default {
'_default_': {
'dynamic': 'strict'
diff --git a/src/core_plugins/elasticsearch/lib/__tests__/health_check.js b/src/core_plugins/elasticsearch/lib/__tests__/health_check.js
index db96c1d63234e6..8b666e115a21c8 100644
--- a/src/core_plugins/elasticsearch/lib/__tests__/health_check.js
+++ b/src/core_plugins/elasticsearch/lib/__tests__/health_check.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import Promise from 'bluebird';
import sinon from 'sinon';
import expect from 'expect.js';
@@ -7,7 +26,7 @@ const NoConnections = require('elasticsearch').errors.NoConnections;
import mappings from './fixtures/mappings';
import healthCheck from '../health_check';
import kibanaVersion from '../kibana_version';
-import { esTestConfig } from '../../../../test_utils/es';
+import { esTestConfig } from '@kbn/test';
import * as patchKibanaIndexNS from '../patch_kibana_index';
const esPort = esTestConfig.getPort();
@@ -15,19 +34,18 @@ const esUrl = esTestConfig.getUrl();
describe('plugins/elasticsearch', () => {
describe('lib/health_check', function () {
- this.timeout(3000);
-
let health;
let plugin;
let cluster;
let server;
- const sandbox = sinon.sandbox.create();
+ const sandbox = sinon.createSandbox();
function getTimerCount() {
return Object.keys(sandbox.clock.timers || {}).length;
}
beforeEach(() => {
+ sandbox.useFakeTimers();
const COMPATIBLE_VERSION_NUMBER = '5.0.0';
// Stub the Kibana version instead of drawing from package.json.
@@ -90,8 +108,6 @@ describe('plugins/elasticsearch', () => {
afterEach(() => sandbox.restore());
it('should stop when cluster is shutdown', () => {
- sandbox.useFakeTimers();
-
// ensure that health.start() is responsible for the timer we are observing
expect(getTimerCount()).to.be(0);
health.start();
@@ -127,13 +143,19 @@ describe('plugins/elasticsearch', () => {
});
});
- it('should set the cluster red if the ping fails, then to green', function () {
+ it('should set the cluster red if the ping fails, then to green', async () => {
const ping = cluster.callWithInternalUser.withArgs('ping');
ping.onCall(0).returns(Promise.reject(new NoConnections()));
ping.onCall(1).returns(Promise.resolve());
- return health.run()
- .then(function () {
+ const healthRunPromise = health.run();
+
+ // Exhaust micro-task queue, to make sure that next health check is rescheduled.
+ await Promise.resolve();
+ sandbox.clock.runAll();
+
+ return healthRunPromise
+ .then(() => {
sinon.assert.calledOnce(plugin.status.yellow);
sinon.assert.calledWithExactly(plugin.status.yellow, 'Waiting for Elasticsearch');
@@ -157,7 +179,11 @@ describe('plugins/elasticsearch', () => {
setImmediate(handler);
});
- return health.waitUntilReady().then(function () {
+ const waitUntilReadyPromise = health.waitUntilReady();
+
+ sandbox.clock.runAll();
+
+ return waitUntilReadyPromise.then(function () {
sinon.assert.calledOnce(plugin.status.once);
});
});
diff --git a/src/core_plugins/elasticsearch/lib/__tests__/is_es_compatible_with_kibana.js b/src/core_plugins/elasticsearch/lib/__tests__/is_es_compatible_with_kibana.js
index d2c98858815b9b..5b7cfd372b1910 100644
--- a/src/core_plugins/elasticsearch/lib/__tests__/is_es_compatible_with_kibana.js
+++ b/src/core_plugins/elasticsearch/lib/__tests__/is_es_compatible_with_kibana.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import expect from 'expect.js';
import isEsCompatibleWithKibana from '../is_es_compatible_with_kibana';
diff --git a/src/core_plugins/elasticsearch/lib/__tests__/map_uri.js b/src/core_plugins/elasticsearch/lib/__tests__/map_uri.js
index 325a430c3f1334..1c203745880b44 100644
--- a/src/core_plugins/elasticsearch/lib/__tests__/map_uri.js
+++ b/src/core_plugins/elasticsearch/lib/__tests__/map_uri.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import expect from 'expect.js';
import mapUri from '../map_uri';
import { defaults } from 'lodash';
diff --git a/src/core_plugins/elasticsearch/lib/__tests__/parse_config.js b/src/core_plugins/elasticsearch/lib/__tests__/parse_config.js
index 3cc30d31fc25de..7c79c4887b880c 100644
--- a/src/core_plugins/elasticsearch/lib/__tests__/parse_config.js
+++ b/src/core_plugins/elasticsearch/lib/__tests__/parse_config.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import expect from 'expect.js';
import { parseConfig } from '../parse_config';
@@ -69,7 +88,7 @@ describe('plugins/elasticsearch', function () {
expect(config.ssl.ca).to.contain('test ca certificate\n');
});
- it(`sets cert and key when certificate and key paths are specified`, function () {
+ it(`by default sets cert and key when certificate and key paths are specified`, function () {
serverConfig.ssl.certificate = __dirname + '/fixtures/cert.crt';
serverConfig.ssl.key = __dirname + '/fixtures/cert.key';
@@ -78,7 +97,7 @@ describe('plugins/elasticsearch', function () {
expect(config.ssl.key).to.be('test key\n');
});
- it(`sets passphrase when certificate, key and keyPassphrase are specified`, function () {
+ it(`by default sets passphrase when certificate, key and keyPassphrase are specified`, function () {
serverConfig.ssl.certificate = __dirname + '/fixtures/cert.crt';
serverConfig.ssl.key = __dirname + '/fixtures/cert.key';
serverConfig.ssl.keyPassphrase = 'secret';
@@ -86,6 +105,24 @@ describe('plugins/elasticsearch', function () {
const config = parseConfig(serverConfig);
expect(config.ssl.passphrase).to.be('secret');
});
+
+ it(`doesn't set cert and key when ignoreCertAndKey is true`, function () {
+ serverConfig.ssl.certificate = __dirname + '/fixtures/cert.crt';
+ serverConfig.ssl.key = __dirname + '/fixtures/cert.key';
+
+ const config = parseConfig(serverConfig, { ignoreCertAndKey: true });
+ expect(config.ssl.cert).to.be(undefined);
+ expect(config.ssl.key).to.be(undefined);
+ });
+
+ it(`by default sets passphrase when ignoreCertAndKey is true`, function () {
+ serverConfig.ssl.certificate = __dirname + '/fixtures/cert.crt';
+ serverConfig.ssl.key = __dirname + '/fixtures/cert.key';
+ serverConfig.ssl.keyPassphrase = 'secret';
+
+ const config = parseConfig(serverConfig, { ignoreCertAndKey: true });
+ expect(config.ssl.passphrase).to.be(undefined);
+ });
});
});
});
diff --git a/src/core_plugins/elasticsearch/lib/__tests__/patch_kibana_index.js b/src/core_plugins/elasticsearch/lib/__tests__/patch_kibana_index.js
index 89e8338d7e6e38..97301c705be1b3 100644
--- a/src/core_plugins/elasticsearch/lib/__tests__/patch_kibana_index.js
+++ b/src/core_plugins/elasticsearch/lib/__tests__/patch_kibana_index.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import expect from 'expect.js';
import sinon from 'sinon';
import { times, cloneDeep, pick, partition } from 'lodash';
diff --git a/src/core_plugins/elasticsearch/lib/__tests__/set_headers.js b/src/core_plugins/elasticsearch/lib/__tests__/set_headers.js
index 2ee97b53d5474f..861e3b751a3811 100644
--- a/src/core_plugins/elasticsearch/lib/__tests__/set_headers.js
+++ b/src/core_plugins/elasticsearch/lib/__tests__/set_headers.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import expect from 'expect.js';
import setHeaders from '../set_headers';
diff --git a/src/core_plugins/elasticsearch/lib/client_logger.js b/src/core_plugins/elasticsearch/lib/client_logger.js
index dac94311f4bfcc..90079ddf918895 100644
--- a/src/core_plugins/elasticsearch/lib/client_logger.js
+++ b/src/core_plugins/elasticsearch/lib/client_logger.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
export function clientLogger(server) {
return class ElasticsearchClientLogging {
// additional tags to differentiate connection
diff --git a/src/core_plugins/elasticsearch/lib/cluster.js b/src/core_plugins/elasticsearch/lib/cluster.js
index 119e3f1ae4d460..52644e5a8b3e29 100644
--- a/src/core_plugins/elasticsearch/lib/cluster.js
+++ b/src/core_plugins/elasticsearch/lib/cluster.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import elasticsearch from 'elasticsearch';
import { get, set, isEmpty, cloneDeep, pick } from 'lodash';
import toPath from 'lodash/internal/toPath';
@@ -15,7 +34,7 @@ export class Cluster {
this._clients = new Set();
this._client = this.createClient();
- this._noAuthClient = this.createClient({ auth: false });
+ this._noAuthClient = this.createClient({ auth: false }, { ignoreCertAndKey: true });
return this;
}
@@ -53,13 +72,13 @@ export class Cluster {
this._clients.clear();
}
- createClient = configOverrides => {
+ createClient = (configOverrides, parseOptions) => {
const config = {
...this._getClientConfig(),
...configOverrides
};
- const client = new elasticsearch.Client(parseConfig(config));
+ const client = new elasticsearch.Client(parseConfig(config, parseOptions));
this._clients.add(client);
return client;
}
diff --git a/src/core_plugins/elasticsearch/lib/create_admin_cluster.js b/src/core_plugins/elasticsearch/lib/create_admin_cluster.js
index 177679f2cb6bd1..c3a46c2b157353 100644
--- a/src/core_plugins/elasticsearch/lib/create_admin_cluster.js
+++ b/src/core_plugins/elasticsearch/lib/create_admin_cluster.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import { clientLogger } from './client_logger';
export function createAdminCluster(server) {
diff --git a/src/core_plugins/elasticsearch/lib/create_agent.js b/src/core_plugins/elasticsearch/lib/create_agent.js
index 190a51670dd1f7..6bce56b27032b1 100644
--- a/src/core_plugins/elasticsearch/lib/create_agent.js
+++ b/src/core_plugins/elasticsearch/lib/create_agent.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import url from 'url';
import { get } from 'lodash';
import http from 'http';
@@ -10,5 +29,5 @@ export default function (config) {
if (!/^https/.test(target.protocol)) return new http.Agent();
- return new https.Agent(parseConfig(config).ssl);
+ return new https.Agent(parseConfig(config, { ignoreCertAndKey: true }).ssl);
}
diff --git a/src/core_plugins/elasticsearch/lib/create_clusters.js b/src/core_plugins/elasticsearch/lib/create_clusters.js
index 0a4a047ed6f458..e5a5c60b91612c 100644
--- a/src/core_plugins/elasticsearch/lib/create_clusters.js
+++ b/src/core_plugins/elasticsearch/lib/create_clusters.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import { Cluster } from './cluster';
export function createClusters(server) {
diff --git a/src/core_plugins/elasticsearch/lib/create_data_cluster.js b/src/core_plugins/elasticsearch/lib/create_data_cluster.js
index b2d4af4b603b74..c370d5b0f948aa 100644
--- a/src/core_plugins/elasticsearch/lib/create_data_cluster.js
+++ b/src/core_plugins/elasticsearch/lib/create_data_cluster.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import { clientLogger } from './client_logger';
export function createDataCluster(server) {
diff --git a/src/core_plugins/elasticsearch/lib/create_proxy.js b/src/core_plugins/elasticsearch/lib/create_proxy.js
index 3802312be7a826..64f5f94fe71b44 100644
--- a/src/core_plugins/elasticsearch/lib/create_proxy.js
+++ b/src/core_plugins/elasticsearch/lib/create_proxy.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import createAgent from './create_agent';
import mapUri from './map_uri';
import { assign } from 'lodash';
diff --git a/src/core_plugins/elasticsearch/lib/ensure_es_version.js b/src/core_plugins/elasticsearch/lib/ensure_es_version.js
index aa2fb3156fa52a..d0f0046fe44e89 100644
--- a/src/core_plugins/elasticsearch/lib/ensure_es_version.js
+++ b/src/core_plugins/elasticsearch/lib/ensure_es_version.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
/**
* ES and Kibana versions are locked, so Kibana should require that ES has the same version as
* that defined in Kibana's package.json.
diff --git a/src/core_plugins/elasticsearch/lib/filter_headers.js b/src/core_plugins/elasticsearch/lib/filter_headers.js
index 891306fd260c29..2361788cf0cb73 100644
--- a/src/core_plugins/elasticsearch/lib/filter_headers.js
+++ b/src/core_plugins/elasticsearch/lib/filter_headers.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import _ from 'lodash';
export default function (originalHeaders, headersToKeep) {
diff --git a/src/core_plugins/elasticsearch/lib/health_check.js b/src/core_plugins/elasticsearch/lib/health_check.js
index 8ac1ae3a19e8e7..63019da0c5385d 100644
--- a/src/core_plugins/elasticsearch/lib/health_check.js
+++ b/src/core_plugins/elasticsearch/lib/health_check.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import Promise from 'bluebird';
import elasticsearch from 'elasticsearch';
import kibanaVersion from './kibana_version';
diff --git a/src/core_plugins/elasticsearch/lib/is_es_compatible_with_kibana.js b/src/core_plugins/elasticsearch/lib/is_es_compatible_with_kibana.js
index 954e25033ee002..4afbd488d2946f 100644
--- a/src/core_plugins/elasticsearch/lib/is_es_compatible_with_kibana.js
+++ b/src/core_plugins/elasticsearch/lib/is_es_compatible_with_kibana.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
/**
* Let's weed out the ES versions that won't work with a given Kibana version.
* 1. Major version differences will never work together.
diff --git a/src/core_plugins/elasticsearch/lib/kibana_version.js b/src/core_plugins/elasticsearch/lib/kibana_version.js
index 6291319c6a5547..d3fa178fd70d8f 100644
--- a/src/core_plugins/elasticsearch/lib/kibana_version.js
+++ b/src/core_plugins/elasticsearch/lib/kibana_version.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import {
version as kibanaVersion,
} from '../../../../package.json';
diff --git a/src/core_plugins/elasticsearch/lib/map_uri.js b/src/core_plugins/elasticsearch/lib/map_uri.js
index 2007f594bcb61c..11c9b99c6da3b6 100644
--- a/src/core_plugins/elasticsearch/lib/map_uri.js
+++ b/src/core_plugins/elasticsearch/lib/map_uri.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import { defaults, omit, trimLeft, trimRight } from 'lodash';
import { parse as parseUrl, format as formatUrl } from 'url';
import filterHeaders from './filter_headers';
diff --git a/src/core_plugins/elasticsearch/lib/parse_config.js b/src/core_plugins/elasticsearch/lib/parse_config.js
index 50d22bb5825e08..cf792eea86cffa 100644
--- a/src/core_plugins/elasticsearch/lib/parse_config.js
+++ b/src/core_plugins/elasticsearch/lib/parse_config.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import util from 'util';
import url from 'url';
import { get, noop, size, pick } from 'lodash';
@@ -6,7 +25,7 @@ import Bluebird from 'bluebird';
const readFile = (file) => readFileSync(file, 'utf8');
-export function parseConfig(serverConfig = {}) {
+export function parseConfig(serverConfig = {}, { ignoreCertAndKey = false } = {}) {
const config = {
keepAlive: true,
...pick(serverConfig, [
@@ -56,7 +75,7 @@ export function parseConfig(serverConfig = {}) {
}
// Add client certificate and key if required by elasticsearch
- if (get(serverConfig, 'ssl.certificate') && get(serverConfig, 'ssl.key')) {
+ if (!ignoreCertAndKey && get(serverConfig, 'ssl.certificate') && get(serverConfig, 'ssl.key')) {
config.ssl.cert = readFile(serverConfig.ssl.certificate);
config.ssl.key = readFile(serverConfig.ssl.key);
config.ssl.passphrase = serverConfig.ssl.keyPassphrase;
diff --git a/src/core_plugins/elasticsearch/lib/patch_kibana_index.js b/src/core_plugins/elasticsearch/lib/patch_kibana_index.js
index c4d4e18398102b..8a86cb4714ac3a 100644
--- a/src/core_plugins/elasticsearch/lib/patch_kibana_index.js
+++ b/src/core_plugins/elasticsearch/lib/patch_kibana_index.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import {
getTypes,
getRootType,
diff --git a/src/core_plugins/elasticsearch/lib/set_headers.js b/src/core_plugins/elasticsearch/lib/set_headers.js
index 8d9afba712d27c..f50fa31b1dffcb 100644
--- a/src/core_plugins/elasticsearch/lib/set_headers.js
+++ b/src/core_plugins/elasticsearch/lib/set_headers.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import { isPlainObject } from 'lodash';
export default function setHeaders(originalHeaders, newHeaders) {
diff --git a/src/core_plugins/input_control_vis/index.js b/src/core_plugins/input_control_vis/index.js
index f7d56fced8ab42..8a172d0734e11e 100644
--- a/src/core_plugins/input_control_vis/index.js
+++ b/src/core_plugins/input_control_vis/index.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
export default function (kibana) {
return new kibana.Plugin({
uiExports: {
diff --git a/src/core_plugins/input_control_vis/public/components/editor/__snapshots__/controls_tab.test.js.snap b/src/core_plugins/input_control_vis/public/components/editor/__snapshots__/controls_tab.test.js.snap
index 0fdbcce8ef3b75..998bea146e05cd 100644
--- a/src/core_plugins/input_control_vis/public/components/editor/__snapshots__/controls_tab.test.js.snap
+++ b/src/core_plugins/input_control_vis/public/components/editor/__snapshots__/controls_tab.test.js.snap
@@ -81,6 +81,7 @@ exports[`renders ControlsTab 1`] = `
{
+ return Promise.resolve({
+ id: 'mockIndexPattern',
+ title: 'mockIndexPattern',
+ fields: [
+ { name: 'keywordField', type: 'string', aggregatable: true },
+ { name: 'textField', type: 'string', aggregatable: false },
+ { name: 'numberField', type: 'number', aggregatable: true }
+ ]
+ });
+};
diff --git a/src/core_plugins/input_control_vis/public/components/editor/__tests__/get_index_patterns_mock.js b/src/core_plugins/input_control_vis/public/components/editor/__tests__/get_index_patterns_mock.js
new file mode 100644
index 00000000000000..d4f668b5559160
--- /dev/null
+++ b/src/core_plugins/input_control_vis/public/components/editor/__tests__/get_index_patterns_mock.js
@@ -0,0 +1,35 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
+export const getIndexPatternsMock = () => {
+ return Promise.resolve([
+ {
+ id: 'indexPattern1',
+ attributes: {
+ title: 'indexPattern1'
+ }
+ },
+ {
+ id: 'indexPattern2',
+ attributes: {
+ title: 'indexPattern2'
+ }
+ }
+ ]);
+};
diff --git a/src/core_plugins/input_control_vis/public/components/editor/control_editor.js b/src/core_plugins/input_control_vis/public/components/editor/control_editor.js
index 8d755b7fc1e48a..7a7d3f7d24a068 100644
--- a/src/core_plugins/input_control_vis/public/components/editor/control_editor.js
+++ b/src/core_plugins/input_control_vis/public/components/editor/control_editor.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import './control_editor.less';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
@@ -99,18 +118,18 @@ export class ControlEditor extends Component {
return (
{
+ handleIndexPatternChange = (controlIndex, indexPatternId) => {
const updatedControl = this.props.scope.vis.params.controls[controlIndex];
- updatedControl.indexPattern = evt.value;
+ updatedControl.indexPattern = indexPatternId;
updatedControl.fieldName = '';
this.setVisParam('controls', setControl(this.props.scope.vis.params.controls, controlIndex, updatedControl));
}
- handleFieldNameChange = (controlIndex, evt) => {
+ handleFieldNameChange = (controlIndex, fieldName) => {
const updatedControl = this.props.scope.vis.params.controls[controlIndex];
- updatedControl.fieldName = evt.value;
+ updatedControl.fieldName = fieldName;
this.setVisParam('controls', setControl(this.props.scope.vis.params.controls, controlIndex, updatedControl));
}
diff --git a/src/core_plugins/input_control_vis/public/components/editor/controls_tab.test.js b/src/core_plugins/input_control_vis/public/components/editor/controls_tab.test.js
index 0cc5dc7120c91a..e12410c5cba0b5 100644
--- a/src/core_plugins/input_control_vis/public/components/editor/controls_tab.test.js
+++ b/src/core_plugins/input_control_vis/public/components/editor/controls_tab.test.js
@@ -1,7 +1,27 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import React from 'react';
import sinon from 'sinon';
import { mount, shallow } from 'enzyme';
import { findTestSubject } from '@elastic/eui/lib/test';
+import { getIndexPatternMock } from './__tests__/get_index_pattern_mock';
import {
ControlsTab,
} from './controls_tab';
@@ -21,14 +41,7 @@ const savedObjectsClientMock = {
}
};
const indexPatternsMock = {
- get: () => {
- return Promise.resolve({
- fields: [
- { name: 'keywordField', type: 'string', aggregatable: true },
- { name: 'numberField', type: 'number', aggregatable: true }
- ]
- });
- }
+ get: getIndexPatternMock
};
const scopeMock = {
vis: {
diff --git a/src/core_plugins/input_control_vis/public/components/editor/field_select.js b/src/core_plugins/input_control_vis/public/components/editor/field_select.js
index 182d0f58096c61..27cfef773197d6 100644
--- a/src/core_plugins/input_control_vis/public/components/editor/field_select.js
+++ b/src/core_plugins/input_control_vis/public/components/editor/field_select.js
@@ -1,60 +1,127 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import _ from 'lodash';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
-import Select from 'react-select';
import {
EuiFormRow,
+ EuiComboBox,
} from '@elastic/eui';
export class FieldSelect extends Component {
constructor(props) {
super(props);
- // not storing activeIndexPatternId in react state
- // 1) does not effect rendering
- // 2) requires synchronous modification to avoid race condition
- this.activeIndexPatternId = props.indexPatternId;
+ this._hasUnmounted = false;
this.state = {
- fields: []
+ isLoading: false,
+ fields: [],
+ indexPatternId: props.indexPatternId,
};
this.filterField = _.get(props, 'filterField', () => { return true; });
- this.loadFields(props.indexPatternId);
+ }
+
+ componentWillUnmount() {
+ this._hasUnmounted = true;
+ }
+
+ componentDidMount() {
+ this.loadFields(this.state.indexPatternId);
}
componentWillReceiveProps(nextProps) {
if (this.props.indexPatternId !== nextProps.indexPatternId) {
- this.activeIndexPatternId = nextProps.indexPatternId;
- this.setState({ fields: [] });
this.loadFields(nextProps.indexPatternId);
}
}
- async loadFields(indexPatternId) {
+ loadFields = (indexPatternId) => {
+ this.setState({
+ isLoading: true,
+ fields: [],
+ indexPatternId
+ }, this.debouncedLoad.bind(null, indexPatternId));
+ }
+
+ debouncedLoad = _.debounce(async (indexPatternId) => {
if (!indexPatternId || indexPatternId.length === 0) {
return;
}
- const indexPattern = await this.props.getIndexPattern(indexPatternId);
+ let indexPattern;
+ try {
+ indexPattern = await this.props.getIndexPattern(indexPatternId);
+ } catch (err) {
+ // index pattern no longer exists
+ return;
+ }
+
+ if (this._hasUnmounted) {
+ return;
+ }
// props.indexPatternId may be updated before getIndexPattern returns
// ignore response when fetched index pattern does not match active index pattern
- if (indexPattern.id !== this.activeIndexPatternId) {
+ if (indexPattern.id !== this.state.indexPatternId) {
return;
}
- const fields = indexPattern.fields
+ const fieldsByTypeMap = new Map();
+ const fields = [];
+ indexPattern.fields
.filter(this.filterField)
- .sort((a, b) => {
- if (a.name < b.name) return -1;
- if (a.name > b.name) return 1;
- return 0;
- })
- .map(function (field) {
- return { label: field.name, value: field.name };
+ .forEach(field => {
+ if (fieldsByTypeMap.has(field.type)) {
+ const fieldsList = fieldsByTypeMap.get(field.type);
+ fieldsList.push(field.name);
+ fieldsByTypeMap.set(field.type, fieldsList);
+ } else {
+ fieldsByTypeMap.set(field.type, [field.name]);
+ }
});
- this.setState({ fields: fields });
+
+ fieldsByTypeMap.forEach((fieldsList, fieldType) => {
+ fields.push({
+ label: fieldType,
+ options: fieldsList.sort().map(fieldName => {
+ return { value: fieldName, label: fieldName };
+ })
+ });
+ });
+
+ fields.sort((a, b) => {
+ if (a.label < b.label) return -1;
+ if (a.label > b.label) return 1;
+ return 0;
+ });
+
+ this.setState({
+ isLoading: false,
+ fields: fields
+ });
+ }, 300);
+
+ onChange = (selectedOptions) => {
+ this.props.onChange(_.get(selectedOptions, '0.value'));
}
render() {
@@ -63,19 +130,25 @@ export class FieldSelect extends Component {
}
const selectId = `fieldSelect-${this.props.controlIndex}`;
+
+ const selectedOptions = [];
+ if (this.props.fieldName) {
+ selectedOptions.push({ value: this.props.fieldName, label: this.props.fieldName });
+ }
+
return (
-
);
@@ -86,7 +159,7 @@ FieldSelect.propTypes = {
getIndexPattern: PropTypes.func.isRequired,
indexPatternId: PropTypes.string,
onChange: PropTypes.func.isRequired,
- value: PropTypes.string,
+ fieldName: PropTypes.string,
filterField: PropTypes.func,
controlIndex: PropTypes.number.isRequired,
};
diff --git a/src/core_plugins/input_control_vis/public/components/editor/index_pattern_select.js b/src/core_plugins/input_control_vis/public/components/editor/index_pattern_select.js
index 668ab56a2cf98f..c600c4097e11ec 100644
--- a/src/core_plugins/input_control_vis/public/components/editor/index_pattern_select.js
+++ b/src/core_plugins/input_control_vis/public/components/editor/index_pattern_select.js
@@ -1,45 +1,144 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
+import _ from 'lodash';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
-import Select from 'react-select';
import {
EuiFormRow,
+ EuiComboBox,
} from '@elastic/eui';
export class IndexPatternSelect extends Component {
constructor(props) {
super(props);
- this.loadOptions = this.loadOptions.bind(this);
+ this.state = {
+ isLoading: false,
+ options: [],
+ selectedIndexPattern: undefined,
+ };
+ }
+
+ componentWillMount() {
+ this._isMounted = true;
+ }
+
+ componentWillUnmount() {
+ this._isMounted = false;
+ this.debouncedFetch.cancel();
+ }
+
+ componentDidMount() {
+ this.fetchOptions();
+ this.fetchSelectedIndexPattern(this.props.indexPatternId);
+ }
+
+ componentWillReceiveProps(nextProps) {
+ if (nextProps.indexPatternId !== this.props.indexPatternId) {
+ this.fetchSelectedIndexPattern(nextProps.indexPatternId);
+ }
}
- loadOptions(input, callback) {
- this.props.getIndexPatterns(input).then((indexPatternSavedObjects) => {
+ fetchSelectedIndexPattern = async (indexPatternId) => {
+ if (!indexPatternId) {
+ this.setState({
+ selectedIndexPattern: undefined
+ });
+ return;
+ }
+
+ let indexPattern;
+ try {
+ indexPattern = await this.props.getIndexPattern(indexPatternId);
+ } catch (err) {
+ // index pattern no longer exists
+ return;
+ }
+
+ if (!this._isMounted) {
+ return;
+ }
+
+ this.setState({
+ selectedIndexPattern: {
+ value: indexPattern.id,
+ label: indexPattern.title,
+ }
+ });
+ }
+
+ debouncedFetch = _.debounce(async (searchValue) => {
+ const indexPatternSavedObjects = await this.props.getIndexPatterns(searchValue);
+
+ if (!this._isMounted) {
+ return;
+ }
+
+ // We need this check to handle the case where search results come back in a different
+ // order than they were sent out. Only load results for the most recent search.
+ if (searchValue === this.state.searchValue) {
const options = indexPatternSavedObjects.map((indexPatternSavedObject) => {
return {
label: indexPatternSavedObject.attributes.title,
value: indexPatternSavedObject.id
};
});
- callback(null, { options: options });
- });
+ this.setState({
+ isLoading: false,
+ options,
+ });
+ }
+ }, 300);
+
+ fetchOptions = (searchValue = '') => {
+ this.setState({
+ isLoading: true,
+ searchValue
+ }, this.debouncedFetch.bind(null, searchValue));
+ }
+
+ onChange = (selectedOptions) => {
+ this.props.onChange(_.get(selectedOptions, '0.value'));
}
render() {
const selectId = `indexPatternSelect-${this.props.controlIndex}`;
+ const selectedOptions = [];
+ if (this.state.selectedIndexPattern) {
+ selectedOptions.push(this.state.selectedIndexPattern);
+ }
return (
-
);
@@ -48,7 +147,8 @@ export class IndexPatternSelect extends Component {
IndexPatternSelect.propTypes = {
getIndexPatterns: PropTypes.func.isRequired,
+ getIndexPattern: PropTypes.func.isRequired,
onChange: PropTypes.func.isRequired,
- value: PropTypes.string,
+ indexPatternId: PropTypes.string,
controlIndex: PropTypes.number.isRequired,
};
diff --git a/src/core_plugins/input_control_vis/public/components/editor/list_control_editor.js b/src/core_plugins/input_control_vis/public/components/editor/list_control_editor.js
index 14c9f2726dfa75..654fd94defb515 100644
--- a/src/core_plugins/input_control_vis/public/components/editor/list_control_editor.js
+++ b/src/core_plugins/input_control_vis/public/components/editor/list_control_editor.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import PropTypes from 'prop-types';
import React from 'react';
import { IndexPatternSelect } from './index_pattern_select';
@@ -52,14 +71,15 @@ export function ListControlEditor(props) {
{
- return Promise.resolve([
- {
- id: 'indexPattern1',
- attributes: {
- title: 'indexPattern1'
- }
- },
- {
- id: 'indexPattern2',
- attributes: {
- title: 'indexPattern2'
- }
- }
- ]);
-};
-const getIndexPattern = () => {
- return Promise.resolve({
- fields: [
- { name: 'keywordField', type: 'string', aggregatable: true },
- { name: 'textField', type: 'string', aggregatable: false },
- { name: 'numberField', type: 'number', aggregatable: true }
- ]
- });
-};
const controlParams = {
id: '1',
indexPattern: 'indexPattern1',
@@ -58,8 +54,8 @@ beforeEach(() => {
test('renders ListControlEditor', () => {
const component = shallow( {
{ value: '2', text: 'fieldB' }
];
const component = shallow( {
test('handleCheckboxOptionChange - multiselect', () => {
const component = mount( {
test('handleNumberOptionChange - size', () => {
const component = mount( {
- return Promise.resolve([
- {
- id: 'indexPattern1',
- attributes: {
- title: 'indexPattern1'
- }
- },
- {
- id: 'indexPattern2',
- attributes: {
- title: 'indexPattern2'
- }
- }
- ]);
-};
-const getIndexPattern = () => {
- return Promise.resolve({
- fields: [
- { name: 'keywordField', type: 'string', aggregatable: true },
- { name: 'textField', type: 'string', aggregatable: false },
- { name: 'numberField', type: 'number', aggregatable: true }
- ]
- });
-};
const controlParams = {
id: '1',
indexPattern: 'indexPattern1',
@@ -55,8 +51,8 @@ beforeEach(() => {
test('renders RangeControlEditor', () => {
const component = shallow( {
test('handleNumberOptionChange - step', () => {
const component = mount( {
test('handleNumberOptionChange - decimalPlaces', () => {
const component = mount(
@@ -56,6 +50,7 @@ exports[`Apply and Cancel change btns enabled when there are changes 1`] = `
@@ -87,6 +83,7 @@ exports[`Apply and Cancel change btns enabled when there are changes 1`] = `
grow={false}
>
@@ -108,6 +105,7 @@ exports[`Apply and Cancel change btns enabled when there are changes 1`] = `
grow={false}
>
@@ -135,6 +133,7 @@ exports[`Clear btns enabled when there are values 1`] = `
@@ -184,6 +176,7 @@ exports[`Clear btns enabled when there are values 1`] = `
@@ -215,6 +209,7 @@ exports[`Clear btns enabled when there are values 1`] = `
grow={false}
>
@@ -236,6 +231,7 @@ exports[`Clear btns enabled when there are values 1`] = `
grow={false}
>
@@ -263,6 +259,7 @@ exports[`Renders list control 1`] = `
@@ -312,6 +302,7 @@ exports[`Renders list control 1`] = `
@@ -343,6 +335,7 @@ exports[`Renders list control 1`] = `
grow={false}
>
@@ -364,6 +357,7 @@ exports[`Renders list control 1`] = `
grow={false}
>
@@ -391,6 +385,7 @@ exports[`Renders range control 1`] = `
@@ -465,6 +462,7 @@ exports[`Renders range control 1`] = `
grow={false}
>
@@ -486,6 +484,7 @@ exports[`Renders range control 1`] = `
grow={false}
>
diff --git a/src/core_plugins/input_control_vis/public/components/vis/__snapshots__/list_control.test.js.snap b/src/core_plugins/input_control_vis/public/components/vis/__snapshots__/list_control.test.js.snap
index 2f7a39c8b5b0da..13844a1b6b47e6 100644
--- a/src/core_plugins/input_control_vis/public/components/vis/__snapshots__/list_control.test.js.snap
+++ b/src/core_plugins/input_control_vis/public/components/vis/__snapshots__/list_control.test.js.snap
@@ -2,98 +2,31 @@
exports[`renders ListControl 1`] = `
-
`;
diff --git a/src/core_plugins/input_control_vis/public/components/vis/__snapshots__/range_control.test.js.snap b/src/core_plugins/input_control_vis/public/components/vis/__snapshots__/range_control.test.js.snap
index cd61c334def618..24fd9d46902f47 100644
--- a/src/core_plugins/input_control_vis/public/components/vis/__snapshots__/range_control.test.js.snap
+++ b/src/core_plugins/input_control_vis/public/components/vis/__snapshots__/range_control.test.js.snap
@@ -2,31 +2,14 @@
exports[`renders RangeControl 1`] = `
+
{control}
);
@@ -32,5 +51,5 @@ FormRow.propTypes = {
id: PropTypes.string.isRequired,
children: PropTypes.node.isRequired,
controlIndex: PropTypes.number.isRequired,
- control: PropTypes.object.isRequired,
+ disableMsg: PropTypes.string,
};
diff --git a/src/core_plugins/input_control_vis/public/components/vis/form_row.test.js b/src/core_plugins/input_control_vis/public/components/vis/form_row.test.js
index cd1439dbbcbe84..aba942ad1bffc1 100644
--- a/src/core_plugins/input_control_vis/public/components/vis/form_row.test.js
+++ b/src/core_plugins/input_control_vis/public/components/vis/form_row.test.js
@@ -1,3 +1,22 @@
+/*
+ * Licensed to Elasticsearch B.V. under one or more contributor
+ * license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright
+ * ownership. Elasticsearch B.V. licenses this file to you 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.
+ */
+
import React from 'react';
import { shallow } from 'enzyme';
@@ -6,15 +25,10 @@ import {
} from './form_row';
test('renders enabled control', () => {
- const enabledControl = {
- id: 'mock-enabled-control',
- isEnabled: () => { return true; },
- };
const component = shallow(