-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use embeddable v2 #39126
Merged
stacey-gammon
merged 17 commits into
elastic:master
from
stacey-gammon:2019-06-17-use-embeddable-v2
Jul 12, 2019
Merged
Use embeddable v2 #39126
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
5b02da9
Final Embeddable API V2 PR
stacey-gammon cd05714
fix: import discover embeddable scss file
stacey-gammon f795efa
address code review comments
stacey-gammon fa11c17
Merge branch 'master' of github.com:elastic/kibana into 2019-06-17-us…
stacey-gammon 7d42540
Add a functional test that would have caught the bug... will look to …
stacey-gammon 3febe3c
Fix bug cause by async loading calls and changes to parent input whil…
stacey-gammon 6be0d89
Merge branch 'master' of github.com:elastic/kibana into 2019-06-17-us…
stacey-gammon 2478a8c
remove outdated readme in dashboard folder
stacey-gammon f26cada
need to always refresh dashboard container, not just when "dirty"
stacey-gammon 9556c70
Merge branch 'master' of github.com:elastic/kibana into 2019-06-17-us…
stacey-gammon b0fc507
add a wait, this issue started appearing right when I added this to t…
stacey-gammon a420da2
Remove test that kills kibana ci so it's not a blocker. jest test was…
stacey-gammon a8c2c94
fix issues when panel is added then removed before it completes loading
stacey-gammon 09ea5b2
fix logic error with maps embeddable and isLayerTOCOpen
stacey-gammon 5c7168a
Merge branch 'master' of github.com:elastic/kibana into 2019-06-17-us…
stacey-gammon 1baf731
Merge branch 'master' of github.com:elastic/kibana into 2019-06-17-us…
stacey-gammon 4129d16
Merge branch 'master' of github.com:elastic/kibana into 2019-06-17-us…
stacey-gammon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
142 changes: 142 additions & 0 deletions
142
src/legacy/core_plugins/embeddable_api/public/containers/explicit_input.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
/* | ||
* 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 '../ui_capabilities.test.mocks'; | ||
|
||
import { skip } from 'rxjs/operators'; | ||
import { | ||
CONTACT_CARD_EMBEDDABLE, | ||
HelloWorldContainer, | ||
FilterableContainer, | ||
FILTERABLE_EMBEDDABLE, | ||
FilterableEmbeddableFactory, | ||
ContactCardEmbeddable, | ||
SlowContactCardEmbeddableFactory, | ||
HELLO_WORLD_EMBEDDABLE_TYPE, | ||
HelloWorldEmbeddableFactory, | ||
} from '../test_samples/index'; | ||
import { isErrorEmbeddable, EmbeddableOutput, EmbeddableFactory } from '../embeddables'; | ||
import { | ||
FilterableEmbeddableInput, | ||
FilterableEmbeddable, | ||
} from '../test_samples/embeddables/filterable_embeddable'; | ||
import { Filter, FilterStateStore } from '@kbn/es-query'; | ||
|
||
jest.mock('ui/new_platform'); | ||
|
||
const embeddableFactories = new Map<string, EmbeddableFactory>(); | ||
embeddableFactories.set(FILTERABLE_EMBEDDABLE, new FilterableEmbeddableFactory()); | ||
embeddableFactories.set( | ||
CONTACT_CARD_EMBEDDABLE, | ||
new SlowContactCardEmbeddableFactory({ loadTickCount: 2 }) | ||
); | ||
embeddableFactories.set(HELLO_WORLD_EMBEDDABLE_TYPE, new HelloWorldEmbeddableFactory()); | ||
|
||
test('Explicit embeddable input mapped to undefined will default to inherited', async () => { | ||
const derivedFilter: Filter = { | ||
$state: { store: FilterStateStore.APP_STATE }, | ||
meta: { disabled: false, alias: 'name', negate: false }, | ||
query: { match: {} }, | ||
}; | ||
const container = new FilterableContainer( | ||
{ id: 'hello', panels: {}, filters: [derivedFilter] }, | ||
embeddableFactories | ||
); | ||
const embeddable = await container.addNewEmbeddable< | ||
FilterableEmbeddableInput, | ||
EmbeddableOutput, | ||
FilterableEmbeddable | ||
>(FILTERABLE_EMBEDDABLE, {}); | ||
|
||
if (isErrorEmbeddable(embeddable)) { | ||
throw new Error('Error adding embeddable'); | ||
} | ||
|
||
embeddable.updateInput({ filters: [] }); | ||
|
||
expect(container.getInputForChild<FilterableEmbeddableInput>(embeddable.id).filters).toEqual([]); | ||
|
||
embeddable.updateInput({ filters: undefined }); | ||
|
||
expect(container.getInputForChild<FilterableEmbeddableInput>(embeddable.id).filters).toEqual([ | ||
derivedFilter, | ||
]); | ||
}); | ||
|
||
test('Explicit embeddable input mapped to undefined with no inherited value will get passed to embeddable', async done => { | ||
const container = new HelloWorldContainer({ id: 'hello', panels: {} }, embeddableFactories); | ||
|
||
const embeddable = await container.addNewEmbeddable< | ||
FilterableEmbeddableInput, | ||
EmbeddableOutput, | ||
FilterableEmbeddable | ||
>(FILTERABLE_EMBEDDABLE, {}); | ||
|
||
if (isErrorEmbeddable(embeddable)) { | ||
throw new Error('Error adding embeddable'); | ||
} | ||
|
||
embeddable.updateInput({ filters: [] }); | ||
|
||
expect(container.getInputForChild<FilterableEmbeddableInput>(embeddable.id).filters).toEqual([]); | ||
|
||
const subscription = embeddable | ||
.getInput$() | ||
.pipe(skip(1)) | ||
.subscribe(() => { | ||
if (embeddable.getInput().filters === undefined) { | ||
subscription.unsubscribe(); | ||
done(); | ||
} | ||
}); | ||
|
||
embeddable.updateInput({ filters: undefined }); | ||
}); | ||
|
||
// The goal is to make sure that if the container input changes after `onPanelAdded` is called | ||
// but before the embeddable factory returns the embeddable, that the `inheritedChildInput` and | ||
// embeddable input comparisons won't cause explicit input to be set when it shouldn't. | ||
test('Explicit input tests in async situations', (done: () => void) => { | ||
const container = new HelloWorldContainer( | ||
{ | ||
id: 'hello', | ||
panels: { | ||
'123': { | ||
explicitInput: { firstName: 'Sam', id: '123' }, | ||
type: CONTACT_CARD_EMBEDDABLE, | ||
}, | ||
}, | ||
lastName: 'bar', | ||
}, | ||
embeddableFactories | ||
); | ||
|
||
container.updateInput({ lastName: 'lolol' }); | ||
|
||
const subscription = container.getOutput$().subscribe(() => { | ||
if (container.getOutput().embeddableLoaded['123']) { | ||
expect(container.getInput().panels['123'].explicitInput.lastName).toBeUndefined(); | ||
const embeddable = container.getChild<ContactCardEmbeddable>('123'); | ||
expect(embeddable).toBeDefined(); | ||
expect(embeddable.getInput().lastName).toBe('lolol'); | ||
subscription.unsubscribe(); | ||
done(); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change was necessary or the link actions that navigated the user to another page would result in the pop up menu still showing.