Skip to content

Commit

Permalink
Merge branch 'master' into improve-telemetry-test
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Aug 19, 2020
2 parents 9d163d8 + cebcc3a commit 7b34a4e
Show file tree
Hide file tree
Showing 215 changed files with 5,000 additions and 2,404 deletions.
2 changes: 1 addition & 1 deletion .ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# NOTE: This Dockerfile is ONLY used to run certain tasks in CI. It is not used to run Kibana or as a distributable.
# If you're looking for the Kibana Docker image distributable, please see: src/dev/build/tasks/os_packages/docker_generator/templates/dockerfile.template.ts

ARG NODE_VERSION=10.21.0
ARG NODE_VERSION=10.22.0

FROM node:${NODE_VERSION} AS base

Expand Down
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.21.0
10.22.0
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10.21.0
10.22.0
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ export interface RouteConfigOptions<Method extends RouteMethod>
| [authRequired](./kibana-plugin-core-server.routeconfigoptions.authrequired.md) | <code>boolean &#124; 'optional'</code> | Defines authentication mode for a route: - true. A user has to have valid credentials to access a resource - false. A user can access a resource without any credentials. - 'optional'. A user can access a resource if has valid credentials or no credentials at all. Can be useful when we grant access to a resource but want to identify a user if possible.<!-- -->Defaults to <code>true</code> if an auth mechanism is registered. |
| [body](./kibana-plugin-core-server.routeconfigoptions.body.md) | <code>Method extends 'get' &#124; 'options' ? undefined : RouteConfigOptionsBody</code> | Additional body options [RouteConfigOptionsBody](./kibana-plugin-core-server.routeconfigoptionsbody.md)<!-- -->. |
| [tags](./kibana-plugin-core-server.routeconfigoptions.tags.md) | <code>readonly string[]</code> | Additional metadata tag strings to attach to the route. |
| [timeout](./kibana-plugin-core-server.routeconfigoptions.timeout.md) | <code>number</code> | Timeouts for processing durations. Response timeout is in milliseconds. Default value: 2 minutes |
| [timeout](./kibana-plugin-core-server.routeconfigoptions.timeout.md) | <code>{</code><br/><code> payload?: Method extends 'get' &#124; 'options' ? undefined : number;</code><br/><code> idleSocket?: number;</code><br/><code> }</code> | Defines per-route timeouts. |
| [xsrfRequired](./kibana-plugin-core-server.routeconfigoptions.xsrfrequired.md) | <code>Method extends 'get' ? never : boolean</code> | Defines xsrf protection requirements for a route: - true. Requires an incoming POST/PUT/DELETE request to contain <code>kbn-xsrf</code> header. - false. Disables xsrf protection.<!-- -->Set to true by default |

Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

## RouteConfigOptions.timeout property

Timeouts for processing durations. Response timeout is in milliseconds. Default value: 2 minutes
Defines per-route timeouts.

<b>Signature:</b>

```typescript
timeout?: number;
timeout?: {
payload?: Method extends 'get' | 'options' ? undefined : number;
idleSocket?: number;
};
```
2 changes: 1 addition & 1 deletion docs/settings/reporting-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ control the capturing process.
| Specify how long to allow the Reporting browser to wait for the "Loading..." screen
to dismiss and find the initial data for the Kibana page. If the time is
exceeded, a page screenshot is captured showing the current state, and the download link shows a warning message.
Defaults to `30000` (30 seconds).
Defaults to `60000` (1 minute).

| `xpack.reporting.capture.timeouts.waitForElements`
| Specify how long to allow the Reporting browser to wait for all visualization
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { i18n } from '@kbn/i18n';
import { createAction, IncompatibleActionError } from '../../../../src/plugins/ui_actions/public';
import { BookEmbeddable, BOOK_EMBEDDABLE } from './book_embeddable';
import { ViewMode, isReferenceOrValueEmbeddable } from '../../../../src/plugins/embeddable/public';
import { DASHBOARD_CONTAINER_TYPE } from '../../../../src/plugins/dashboard/public';

interface ActionContext {
embeddable: BookEmbeddable;
Expand All @@ -41,6 +42,8 @@ export const createAddBookToLibraryAction = () =>
return (
embeddable.type === BOOK_EMBEDDABLE &&
embeddable.getInput().viewMode === ViewMode.EDIT &&
embeddable.getRoot().isContainer &&
embeddable.getRoot().type !== DASHBOARD_CONTAINER_TYPE &&
isReferenceOrValueEmbeddable(embeddable) &&
!embeddable.inputIsRefType(embeddable.getInput())
);
Expand Down
8 changes: 7 additions & 1 deletion examples/embeddable_examples/public/book/book_embeddable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
EmbeddableOutput,
SavedObjectEmbeddableInput,
ReferenceOrValueEmbeddable,
Container,
} from '../../../../src/plugins/embeddable/public';
import { BookSavedObjectAttributes } from '../../common';
import { BookEmbeddableComponent } from './book_component';
Expand Down Expand Up @@ -103,7 +104,12 @@ export class BookEmbeddable extends Embeddable<BookEmbeddableInput, BookEmbeddab
};

getInputAsValueType = async (): Promise<BookByValueInput> => {
return this.attributeService.getInputAsValueType(this.input);
const input =
this.getRoot() && (this.getRoot() as Container).getInput().panels[this.id].explicitInput
? ((this.getRoot() as Container).getInput().panels[this.id]
.explicitInput as BookEmbeddableInput)
: this.input;
return this.attributeService.getInputAsValueType(input);
};

getInputAsRefType = async (): Promise<BookByReferenceInput> => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { i18n } from '@kbn/i18n';
import { createAction, IncompatibleActionError } from '../../../../src/plugins/ui_actions/public';
import { BookEmbeddable, BOOK_EMBEDDABLE } from './book_embeddable';
import { ViewMode, isReferenceOrValueEmbeddable } from '../../../../src/plugins/embeddable/public';
import { DASHBOARD_CONTAINER_TYPE } from '../../../../src/plugins/dashboard/public';

interface ActionContext {
embeddable: BookEmbeddable;
Expand All @@ -41,6 +42,8 @@ export const createUnlinkBookFromLibraryAction = () =>
return (
embeddable.type === BOOK_EMBEDDABLE &&
embeddable.getInput().viewMode === ViewMode.EDIT &&
embeddable.getRoot().isContainer &&
embeddable.getRoot().type !== DASHBOARD_CONTAINER_TYPE &&
isReferenceOrValueEmbeddable(embeddable) &&
embeddable.inputIsRefType(embeddable.getInput())
);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@
"zlib": "^1.0.5"
},
"engines": {
"node": "10.21.0",
"node": "10.22.0",
"yarn": "^1.21.1"
}
}
13 changes: 13 additions & 0 deletions packages/kbn-monaco/src/xjson/grammar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@ export enum AnnoTypes {
warning = 'warning',
}

export type Parser = ReturnType<typeof createParser>;

export interface Annotation {
name?: string;
type: AnnoTypes;
text: string;
at: number;
}

export interface ParseResult {
annotations: Annotation[];
}

/* eslint-disable */

export const createParser = () => {
Expand Down
8 changes: 5 additions & 3 deletions packages/kbn-monaco/src/xjson/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
* under the License.
*/

import { registerGrammarChecker } from './language';

/**
* This import registers the XJSON monaco language contribution
*/
import './language';
import { ID } from './constants';

export const XJsonLang = { registerGrammarChecker, ID };
export const XJsonLang = { ID };
45 changes: 27 additions & 18 deletions packages/kbn-monaco/src/xjson/language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,16 @@ const wps = new WorkerProxyService();
registerLexerRules(monaco);

// In future we will need to make this map languages to workers using "id" and/or "label" values
// that get passed in.
// that get passed in. Also this should not live inside the "xjson" dir directly. We can update this
// once we have another worker.
// @ts-ignore
window.MonacoEnvironment = {
getWorker: (id: any, label: any) => {
// In kibana we will probably build this once and then load with raw-loader
const blob = new Blob([workerSrc], { type: 'application/javascript' });
return new Worker(URL.createObjectURL(blob));
getWorker: (module: string, languageId: string) => {
if (languageId === ID) {
// In kibana we will probably build this once and then load with raw-loader
const blob = new Blob([workerSrc], { type: 'application/javascript' });
return new Worker(URL.createObjectURL(blob));
}
},
};

Expand All @@ -47,15 +50,19 @@ monaco.languages.onLanguage(ID, async () => {
});

const OWNER = 'XJSON_GRAMMAR_CHECKER';
export const registerGrammarChecker = (editor: monaco.editor.IEditor) => {

export const registerGrammarChecker = () => {
const allDisposables: monaco.IDisposable[] = [];

const updateAnnos = async () => {
const { annotations } = await wps.getAnnos();
const model = editor.getModel() as monaco.editor.ITextModel | null;
if (!model) {
const updateAnnotations = async (model: monaco.editor.IModel): Promise<void> => {
if (model.isDisposed()) {
return;
}
const parseResult = await wps.getAnnos(model.uri);
if (!parseResult) {
return;
}
const { annotations } = parseResult;
monaco.editor.setModelMarkers(
model,
OWNER,
Expand All @@ -74,19 +81,21 @@ export const registerGrammarChecker = (editor: monaco.editor.IEditor) => {
};

const onModelAdd = (model: monaco.editor.IModel) => {
allDisposables.push(
model.onDidChangeContent(async () => {
updateAnnos();
})
);
if (model.getModeId() === ID) {
allDisposables.push(
model.onDidChangeContent(async () => {
updateAnnotations(model);
})
);

updateAnnos();
updateAnnotations(model);
}
};

allDisposables.push(monaco.editor.onDidCreateModel(onModelAdd));
monaco.editor.getModels().forEach(onModelAdd);
return () => {
wps.stop();
allDisposables.forEach((d) => d.dispose());
};
};

registerGrammarChecker();
12 changes: 7 additions & 5 deletions packages/kbn-monaco/src/xjson/worker/xjson_worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,19 @@

/* eslint-disable-next-line @kbn/eslint/module_migration */
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
import { createParser } from '../grammar';
import { createParser, Parser, ParseResult } from '../grammar';

export class XJsonWorker {
constructor(private ctx: monaco.worker.IWorkerContext) {}
private parser: any;
private parser: Parser | undefined;

async parse() {
async parse(modelUri: string): Promise<ParseResult | undefined> {
if (!this.parser) {
this.parser = createParser();
}
const [model] = this.ctx.getMirrorModels();
return this.parser(model.getValue());
const model = this.ctx.getMirrorModels().find((m) => m.uri.toString() === modelUri);
if (model) {
return this.parser(model.getValue());
}
}
}
19 changes: 4 additions & 15 deletions packages/kbn-monaco/src/xjson/worker_proxy_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,32 +17,21 @@
* under the License.
*/

import { AnnoTypes } from './grammar';
import { ParseResult } from './grammar';
import { monaco } from '../monaco';
import { XJsonWorker } from './worker';
import { ID } from './constants';

export interface Annotation {
name?: string;
type: AnnoTypes;
text: string;
at: number;
}

export interface AnnotationsResponse {
annotations: Annotation[];
}

export class WorkerProxyService {
private worker: monaco.editor.MonacoWebWorker<XJsonWorker> | undefined;

public async getAnnos(): Promise<AnnotationsResponse> {
public async getAnnos(modelUri: monaco.Uri): Promise<ParseResult | undefined> {
if (!this.worker) {
throw new Error('Worker Proxy Service has not been setup!');
}
await this.worker.withSyncedResources(monaco.editor.getModels().map(({ uri }) => uri));
await this.worker.withSyncedResources([modelUri]);
const proxy = await this.worker.getProxy();
return proxy.parse();
return proxy.parse(modelUri.toString());
}

public setup() {
Expand Down
Loading

0 comments on commit 7b34a4e

Please sign in to comment.