Skip to content

Commit

Permalink
Merge branch 'master' into reporting/client-np-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
elasticmachine authored Mar 17, 2020
2 parents 9c2ecb7 + 6a70d21 commit a603278
Show file tree
Hide file tree
Showing 512 changed files with 16,494 additions and 12,969 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

## SavedObject interface


<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

## SavedObject interface


<b>Signature:</b>

```typescript
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class HelloWorldEmbeddableFactory extends EmbeddableFactory {
* embeddables should check the UI Capabilities service to be sure of
* the right permissions.
*/
public isEditable() {
public async isEditable() {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import ReactDOM from 'react-dom';
import {
Container,
ContainerInput,
GetEmbeddableFactory,
EmbeddableStart,
} from '../../../../src/plugins/embeddable/public';
import { ListContainerComponent } from './list_container_component';

Expand All @@ -31,7 +31,10 @@ export class ListContainer extends Container<{}, ContainerInput> {
public readonly type = LIST_CONTAINER;
private node?: HTMLElement;

constructor(input: ContainerInput, getEmbeddableFactory: GetEmbeddableFactory) {
constructor(
input: ContainerInput,
getEmbeddableFactory: EmbeddableStart['getEmbeddableFactory']
) {
super(input, { embeddableLoaded: {} }, getEmbeddableFactory);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,30 @@
import { i18n } from '@kbn/i18n';
import {
EmbeddableFactory,
GetEmbeddableFactory,
ContainerInput,
EmbeddableStart,
} from '../../../../src/plugins/embeddable/public';
import { LIST_CONTAINER, ListContainer } from './list_container';

interface StartServices {
getEmbeddableFactory: EmbeddableStart['getEmbeddableFactory'];
}

export class ListContainerFactory extends EmbeddableFactory {
public readonly type = LIST_CONTAINER;
public readonly isContainerType = true;

constructor(private getEmbeddableFactory: GetEmbeddableFactory) {
constructor(private getStartServices: () => Promise<StartServices>) {
super();
}

public isEditable() {
public async isEditable() {
return true;
}

public async create(initialInput: ContainerInput) {
return new ListContainer(initialInput, this.getEmbeddableFactory);
const { getEmbeddableFactory } = await this.getStartServices();
return new ListContainer(initialInput, getEmbeddableFactory);
}

public getDisplayName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class MultiTaskTodoEmbeddableFactory extends EmbeddableFactory<
> {
public readonly type = MULTI_TASK_TODO_EMBEDDABLE;

public isEditable() {
public async isEditable() {
return true;
}

Expand Down
47 changes: 24 additions & 23 deletions examples/embeddable_examples/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,67 +17,68 @@
* under the License.
*/

import {
IEmbeddableSetup,
IEmbeddableStart,
EmbeddableFactory,
} from '../../../src/plugins/embeddable/public';
import { EmbeddableSetup, EmbeddableStart } from '../../../src/plugins/embeddable/public';
import { Plugin, CoreSetup, CoreStart } from '../../../src/core/public';
import { HelloWorldEmbeddableFactory, HELLO_WORLD_EMBEDDABLE } from './hello_world';
import { TODO_EMBEDDABLE, TodoEmbeddableFactory, TodoInput, TodoOutput } from './todo';
import {
MULTI_TASK_TODO_EMBEDDABLE,
MultiTaskTodoEmbeddableFactory,
MultiTaskTodoOutput,
MultiTaskTodoInput,
} from './multi_task_todo';
import { MULTI_TASK_TODO_EMBEDDABLE, MultiTaskTodoEmbeddableFactory } from './multi_task_todo';
import {
SEARCHABLE_LIST_CONTAINER,
SearchableListContainerFactory,
} from './searchable_list_container';
import { LIST_CONTAINER, ListContainerFactory } from './list_container';

interface EmbeddableExamplesSetupDependencies {
embeddable: IEmbeddableSetup;
embeddable: EmbeddableSetup;
}

interface EmbeddableExamplesStartDependencies {
embeddable: IEmbeddableStart;
embeddable: EmbeddableStart;
}

export class EmbeddableExamplesPlugin
implements
Plugin<void, void, EmbeddableExamplesSetupDependencies, EmbeddableExamplesStartDependencies> {
public setup(core: CoreSetup, deps: EmbeddableExamplesSetupDependencies) {
public setup(
core: CoreSetup<EmbeddableExamplesStartDependencies>,
deps: EmbeddableExamplesSetupDependencies
) {
deps.embeddable.registerEmbeddableFactory(
HELLO_WORLD_EMBEDDABLE,
new HelloWorldEmbeddableFactory()
);

deps.embeddable.registerEmbeddableFactory<
EmbeddableFactory<MultiTaskTodoInput, MultiTaskTodoOutput>
>(MULTI_TASK_TODO_EMBEDDABLE, new MultiTaskTodoEmbeddableFactory());
}
deps.embeddable.registerEmbeddableFactory(
MULTI_TASK_TODO_EMBEDDABLE,
new MultiTaskTodoEmbeddableFactory()
);

public start(core: CoreStart, deps: EmbeddableExamplesStartDependencies) {
// These are registered in the start method because `getEmbeddableFactory `
// is only available in start. We could reconsider this I think and make it
// available in both.
deps.embeddable.registerEmbeddableFactory(
SEARCHABLE_LIST_CONTAINER,
new SearchableListContainerFactory(deps.embeddable.getEmbeddableFactory)
new SearchableListContainerFactory(async () => ({
getEmbeddableFactory: (await core.getStartServices())[1].embeddable.getEmbeddableFactory,
}))
);

deps.embeddable.registerEmbeddableFactory(
LIST_CONTAINER,
new ListContainerFactory(deps.embeddable.getEmbeddableFactory)
new ListContainerFactory(async () => ({
getEmbeddableFactory: (await core.getStartServices())[1].embeddable.getEmbeddableFactory,
}))
);

deps.embeddable.registerEmbeddableFactory<EmbeddableFactory<TodoInput, TodoOutput>>(
deps.embeddable.registerEmbeddableFactory<TodoInput, TodoOutput>(
TODO_EMBEDDABLE,
new TodoEmbeddableFactory(core.overlays.openModal)
new TodoEmbeddableFactory(async () => ({
openModal: (await core.getStartServices())[0].overlays.openModal,
}))
);
}

public start(core: CoreStart, deps: EmbeddableExamplesStartDependencies) {}

public stop() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import ReactDOM from 'react-dom';
import {
Container,
ContainerInput,
GetEmbeddableFactory,
EmbeddableStart,
EmbeddableInput,
} from '../../../../src/plugins/embeddable/public';
import { SearchableListContainerComponent } from './searchable_list_container_component';
Expand All @@ -40,7 +40,10 @@ export class SearchableListContainer extends Container<ChildInput, SearchableCon
public readonly type = SEARCHABLE_LIST_CONTAINER;
private node?: HTMLElement;

constructor(input: SearchableContainerInput, getEmbeddableFactory: GetEmbeddableFactory) {
constructor(
input: SearchableContainerInput,
getEmbeddableFactory: EmbeddableStart['getEmbeddableFactory']
) {
super(input, { embeddableLoaded: {} }, getEmbeddableFactory);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,32 @@
*/

import { i18n } from '@kbn/i18n';
import { EmbeddableFactory, GetEmbeddableFactory } from '../../../../src/plugins/embeddable/public';
import { EmbeddableFactory, EmbeddableStart } from '../../../../src/plugins/embeddable/public';
import {
SEARCHABLE_LIST_CONTAINER,
SearchableListContainer,
SearchableContainerInput,
} from './searchable_list_container';

interface StartServices {
getEmbeddableFactory: EmbeddableStart['getEmbeddableFactory'];
}

export class SearchableListContainerFactory extends EmbeddableFactory {
public readonly type = SEARCHABLE_LIST_CONTAINER;
public readonly isContainerType = true;

constructor(private getEmbeddableFactory: GetEmbeddableFactory) {
constructor(private getStartServices: () => Promise<StartServices>) {
super();
}

public isEditable() {
public async isEditable() {
return true;
}

public async create(initialInput: SearchableContainerInput) {
return new SearchableListContainer(initialInput, this.getEmbeddableFactory);
const { getEmbeddableFactory } = await this.getStartServices();
return new SearchableListContainer(initialInput, getEmbeddableFactory);
}

public getDisplayName() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,22 @@ function TaskInput({ onSave }: { onSave: (task: string) => void }) {
);
}

interface StartServices {
openModal: OverlayStart['openModal'];
}

export class TodoEmbeddableFactory extends EmbeddableFactory<
TodoInput,
TodoOutput,
TodoEmbeddable
> {
public readonly type = TODO_EMBEDDABLE;

constructor(private openModal: OverlayStart['openModal']) {
constructor(private getStartServices: () => Promise<StartServices>) {
super();
}

public isEditable() {
public async isEditable() {
return true;
}

Expand All @@ -69,9 +73,10 @@ export class TodoEmbeddableFactory extends EmbeddableFactory<
* in this case, the task string.
*/
public async getExplicitInput() {
const { openModal } = await this.getStartServices();
return new Promise<{ task: string }>(resolve => {
const onSave = (task: string) => resolve({ task });
const overlay = this.openModal(
const overlay = openModal(
toMountPoint(
<TaskInput
onSave={(task: string) => {
Expand Down
4 changes: 2 additions & 2 deletions examples/embeddable_explorer/public/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { BrowserRouter as Router, Route, withRouter, RouteComponentProps } from

import { EuiPage, EuiPageSideBar, EuiSideNav } from '@elastic/eui';

import { IEmbeddableStart } from '../../../src/plugins/embeddable/public';
import { EmbeddableStart } from '../../../src/plugins/embeddable/public';
import { UiActionsStart } from '../../../src/plugins/ui_actions/public';
import { Start as InspectorStartContract } from '../../../src/plugins/inspector/public';
import {
Expand Down Expand Up @@ -74,7 +74,7 @@ const Nav = withRouter(({ history, navigateToApp, pages }: NavProps) => {
interface Props {
basename: string;
navigateToApp: CoreStart['application']['navigateToApp'];
embeddableApi: IEmbeddableStart;
embeddableApi: EmbeddableStart;
uiActionsApi: UiActionsStart;
overlays: OverlayStart;
notifications: CoreStart['notifications'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ import {
import { EuiSpacer } from '@elastic/eui';
import { OverlayStart, CoreStart, SavedObjectsStart, IUiSettingsClient } from 'kibana/public';
import {
GetEmbeddableFactory,
EmbeddablePanel,
IEmbeddableStart,
EmbeddableStart,
IEmbeddable,
} from '../../../src/plugins/embeddable/public';
import {
Expand All @@ -47,8 +46,8 @@ import { Start as InspectorStartContract } from '../../../src/plugins/inspector/
import { getSavedObjectFinder } from '../../../src/plugins/saved_objects/public';

interface Props {
getAllEmbeddableFactories: IEmbeddableStart['getEmbeddableFactories'];
getEmbeddableFactory: GetEmbeddableFactory;
getAllEmbeddableFactories: EmbeddableStart['getEmbeddableFactories'];
getEmbeddableFactory: EmbeddableStart['getEmbeddableFactory'];
uiActionsApi: UiActionsStart;
overlays: OverlayStart;
notifications: CoreStart['notifications'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ import {
EuiText,
} from '@elastic/eui';
import {
GetEmbeddableFactory,
EmbeddableStart,
EmbeddableFactoryRenderer,
EmbeddableRoot,
} from '../../../src/plugins/embeddable/public';
import { HelloWorldEmbeddable, HELLO_WORLD_EMBEDDABLE } from '../../embeddable_examples/public';

interface Props {
getEmbeddableFactory: GetEmbeddableFactory;
getEmbeddableFactory: EmbeddableStart['getEmbeddableFactory'];
}

export function HelloWorldEmbeddableExample({ getEmbeddableFactory }: Props) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,7 @@ import {
EuiText,
} from '@elastic/eui';
import { EuiSpacer } from '@elastic/eui';
import {
GetEmbeddableFactory,
EmbeddableFactoryRenderer,
} from '../../../src/plugins/embeddable/public';
import { EmbeddableFactoryRenderer, EmbeddableStart } from '../../../src/plugins/embeddable/public';
import {
HELLO_WORLD_EMBEDDABLE,
TODO_EMBEDDABLE,
Expand All @@ -42,7 +39,7 @@ import {
} from '../../embeddable_examples/public';

interface Props {
getEmbeddableFactory: GetEmbeddableFactory;
getEmbeddableFactory: EmbeddableStart['getEmbeddableFactory'];
}

export function ListContainerExample({ getEmbeddableFactory }: Props) {
Expand Down
4 changes: 2 additions & 2 deletions examples/embeddable_explorer/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@

import { Plugin, CoreSetup, AppMountParameters } from 'kibana/public';
import { UiActionsService } from '../../../src/plugins/ui_actions/public';
import { IEmbeddableStart } from '../../../src/plugins/embeddable/public';
import { EmbeddableStart } from '../../../src/plugins/embeddable/public';
import { Start as InspectorStart } from '../../../src/plugins/inspector/public';

interface StartDeps {
uiActions: UiActionsService;
embeddable: IEmbeddableStart;
embeddable: EmbeddableStart;
inspector: InspectorStart;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ import {
TODO_EMBEDDABLE,
TodoEmbeddableFactory,
} from '../../../examples/embeddable_examples/public/todo';
import { GetEmbeddableFactory, EmbeddableRoot } from '../../../src/plugins/embeddable/public';
import { EmbeddableStart, EmbeddableRoot } from '../../../src/plugins/embeddable/public';

interface Props {
getEmbeddableFactory: GetEmbeddableFactory;
getEmbeddableFactory: EmbeddableStart['getEmbeddableFactory'];
}

interface State {
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@
"@types/cheerio": "^0.22.10",
"@types/chromedriver": "^2.38.0",
"@types/classnames": "^2.2.9",
"@types/color": "^3.0.0",
"@types/d3": "^3.5.43",
"@types/dedent": "^0.7.0",
"@types/deep-freeze-strict": "^1.1.0",
Expand Down
Loading

0 comments on commit a603278

Please sign in to comment.