Skip to content

Commit

Permalink
Merge branch 'master' of github.com:elastic/kibana into fix/console/p…
Browse files Browse the repository at this point in the history
…age-offset-floating-tooltip

* 'master' of github.com:elastic/kibana:
  [Maps] refactor isPointsOnly, isLinesOnly, and isPolygonsOnly to make synchronous (#54067)
  Fix icon path in tutorial introduction (#49684)
  [State Management] State containers improvements (#54436)
  Fix floating tools rendering logic (#54505)
  Handle another double quote special case (#54474)
  [Home][Tutorial] Add data UI for IBM MQ Filebeat module (#54238)
  fix(package): upgrade transitive dependency elliptic to v6.5.2 (#54476)
  [Graph] Fix various a11y issues (#54097)

# Conflicts:
#	src/legacy/core_plugins/console/public/np_ready/application/models/legacy_core_editor/legacy_core_editor.ts
  • Loading branch information
jloleysens committed Jan 13, 2020
2 parents 718a975 + 14df4c0 commit f35a535
Show file tree
Hide file tree
Showing 56 changed files with 765 additions and 862 deletions.
17 changes: 7 additions & 10 deletions examples/state_containers_examples/public/todo.tsx
Expand Up @@ -41,6 +41,7 @@ import {
PureTransition,
syncStates,
getStateFromKbnUrl,
BaseState,
} from '../../../src/plugins/kibana_utils/public';
import { useUrlTracker } from '../../../src/plugins/kibana_react/public';
import {
Expand Down Expand Up @@ -79,7 +80,7 @@ const TodoApp: React.FC<TodoAppProps> = ({ filter }) => {
const { setText } = GlobalStateHelpers.useTransitions();
const { text } = GlobalStateHelpers.useState();
const { edit: editTodo, delete: deleteTodo, add: addTodo } = useTransitions();
const todos = useState();
const todos = useState().todos;
const filteredTodos = todos.filter(todo => {
if (!filter) return true;
if (filter === 'completed') return todo.completed;
Expand Down Expand Up @@ -306,22 +307,18 @@ export const TodoAppPage: React.FC<{
);
};

function withDefaultState<State>(
function withDefaultState<State extends BaseState>(
stateContainer: BaseStateContainer<State>,
// eslint-disable-next-line no-shadow
defaultState: State
): INullableBaseStateContainer<State> {
return {
...stateContainer,
set: (state: State | null) => {
if (Array.isArray(defaultState)) {
stateContainer.set(state || defaultState);
} else {
stateContainer.set({
...defaultState,
...state,
});
}
stateContainer.set({
...defaultState,
...state,
});
},
};
}
2 changes: 2 additions & 0 deletions package.json
Expand Up @@ -166,6 +166,7 @@
"custom-event-polyfill": "^0.3.0",
"d3": "3.5.17",
"d3-cloud": "1.2.5",
"deep-freeze-strict": "^1.1.1",
"deepmerge": "^4.2.2",
"del": "^5.1.0",
"elastic-apm-node": "^3.2.0",
Expand Down Expand Up @@ -314,6 +315,7 @@
"@types/classnames": "^2.2.9",
"@types/d3": "^3.5.43",
"@types/dedent": "^0.7.0",
"@types/deep-freeze-strict": "^1.1.0",
"@types/delete-empty": "^2.0.0",
"@types/elasticsearch": "^5.0.33",
"@types/enzyme": "^3.9.0",
Expand Down
8 changes: 8 additions & 0 deletions renovate.json5
Expand Up @@ -210,6 +210,14 @@
'@types/dedent',
],
},
{
groupSlug: 'deep-freeze-strict',
groupName: 'deep-freeze-strict related packages',
packageNames: [
'deep-freeze-strict',
'@types/deep-freeze-strict',
],
},
{
groupSlug: 'delete-empty',
groupName: 'delete-empty related packages',
Expand Down
Expand Up @@ -164,7 +164,7 @@ function EditorUI() {

mappings.retrieveAutoCompleteInfo();

const unsubscribeResizer = subscribeResizeChecker(editorRef.current!, editor.getCoreEditor());
const unsubscribeResizer = subscribeResizeChecker(editorRef.current!, editor);
setupAutosave();

return () => {
Expand Down
Expand Up @@ -22,8 +22,15 @@ export function subscribeResizeChecker(el: HTMLElement, ...editors: any[]) {
const checker = new ResizeChecker(el);
checker.on('resize', () =>
editors.forEach(e => {
e.resize();
if (e.updateActionsBar) e.updateActionsBar();
if (e.getCoreEditor) {
e.getCoreEditor().resize();
} else {
e.resize();
}

if (e.updateActionsBar) {
e.updateActionsBar();
}
})
);
return () => checker.destroy();
Expand Down
Expand Up @@ -297,32 +297,32 @@ export class LegacyCoreEditor implements CoreEditor {
// pageY is relative to page, so subtract the offset
// from pageY to get the new top value
const offsetFromPage = $(this.editor.container).offset()!.top;
const startRow = range.start.lineNumber - 1;
const startLine = range.start.lineNumber;
const startColumn = range.start.column;
const firstLine = this.getLineValue(startRow);
const firstLine = this.getLineValue(startLine);
const maxLineLength = this.getWrapLimit() - 5;
const isWrapping = firstLine.length > maxLineLength;
const getScreenCoords = (row: number) =>
this.editor.renderer.textToScreenCoordinates(row, startColumn).pageY -
const getScreenCoords = (line: number) =>
this.editor.renderer.textToScreenCoordinates(line - 1, startColumn).pageY -
offsetFromPage +
(window.pageYOffset || 0);
const topOfReq = getScreenCoords(startRow);
const topOfReq = getScreenCoords(startLine);

if (topOfReq >= 0) {
let offset = 0;
if (isWrapping) {
// Try get the line height of the text area in pixels.
const textArea = $(this.editor.container.querySelector('textArea')!);
const hasRoomOnNextLine = this.getLineValue(startRow + 1).length < maxLineLength;
const hasRoomOnNextLine = this.getLineValue(startLine).length < maxLineLength;
if (textArea && hasRoomOnNextLine) {
// Line height + the number of wraps we have on a line.
offset += this.getLineValue(startRow).length * textArea.height()!;
offset += this.getLineValue(startLine).length * textArea.height()!;
} else {
if (startRow > 0) {
this.setActionsBar(getScreenCoords(startRow - 1));
if (startLine > 1) {
this.setActionsBar(getScreenCoords(startLine - 1));
return;
}
this.setActionsBar(getScreenCoords(startRow + 1));
this.setActionsBar(getScreenCoords(startLine + 1));
return;
}
}
Expand Down
Expand Up @@ -24,7 +24,7 @@ export default function(editor: any) {
const resize = editor.resize;

const throttledResize = throttle(() => {
resize.call(editor);
resize.call(editor, false);

// Keep current top line in view when resizing to avoid losing user context
const userRow = get(throttledResize, 'topRow', 0);
Expand Down
Expand Up @@ -52,3 +52,33 @@ Correctly handle new lines in triple quotes
SELECT * FROM "TABLE"
"""
}
==========
Single quotes escaped special case, start and end
-------------------------------------
{
"query": "\"test\""
}
-------------------------------------
{
"query": "\"test\""
}
==========
Single quotes escaped special case, start
-------------------------------------
{
"query": "\"test"
}
-------------------------------------
{
"query": "\"test"
}
==========
Single quotes escaped special case, end
-------------------------------------
{
"query": "test\""
}
-------------------------------------
{
"query": "test\""
}
14 changes: 14 additions & 0 deletions src/legacy/core_plugins/console/public/np_ready/lib/utils/utils.ts
Expand Up @@ -84,6 +84,20 @@ export function expandLiteralStrings(data: string) {
// Expand to triple quotes if there are _any_ slashes
if (string.match(/\\./)) {
const firstDoubleQuoteIdx = string.indexOf('"');
const lastDoubleQuoteIdx = string.lastIndexOf('"');

// Handle a special case where we may have a value like "\"test\"". We don't
// want to expand this to """"test"""" - so we terminate before processing the string
// further if we detect this either at the start or end of the double quote section.

if (string[firstDoubleQuoteIdx + 1] === '\\' && string[firstDoubleQuoteIdx + 2] === '"') {
return string;
}

if (string[lastDoubleQuoteIdx - 1] === '"' && string[lastDoubleQuoteIdx - 2] === '\\') {
return string;
}

const colonAndAnySpacing = string.slice(0, firstDoubleQuoteIdx);
const rawStringifiedValue = string.slice(firstDoubleQuoteIdx, string.length);
// Remove one level of JSON stringification
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f35a535

Please sign in to comment.