Skip to content
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

Add new "references" attribute to saved objects for relationships #28199

Merged
merged 65 commits into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
3c21c65
Add new references attribute to saved objects
mikecote Jan 7, 2019
1cc774e
Add dual support for dashboard export API
mikecote Jan 8, 2019
e7ff9d3
Use new relationships API supporting legacy relationships extraction
mikecote Jan 8, 2019
bf3b9fb
Code cleanup
mikecote Jan 9, 2019
49344fb
Fix style and CI error
mikecote Jan 9, 2019
3d43ab4
Add missing spaces test for findRelationships
mikecote Jan 9, 2019
d2ba949
Merge branch 'master' of github.com:mikecote/kibana into add-references
mikecote Jan 10, 2019
09c76e4
Merge branch 'master' of github.com:mikecote/kibana into add-references
mikecote Jan 10, 2019
f29a572
Convert collect_references_deep to typescript
mikecote Jan 10, 2019
76877a9
Add missing trailing commas
mikecote Jan 10, 2019
89318e4
Merge branch 'master' of github.com:mikecote/kibana into add-references
mikecote Jan 10, 2019
b54d17d
Fix broken test by making saved object API consistently return refere…
mikecote Jan 10, 2019
3e5e89b
Fix broken api integration tests
mikecote Jan 10, 2019
9deb6a8
Add comment about the two TS types for saved object
mikecote Jan 11, 2019
aadb163
Only return title from the attributes returned in findRelationships
mikecote Jan 11, 2019
8c8b63f
Fix broken test
mikecote Jan 11, 2019
d7a6e85
Add missing security tests
mikecote Jan 21, 2019
32c8153
Merge branch 'master' of github.com:mikecote/kibana into add-references
mikecote Jan 21, 2019
61d5096
Drop filterTypes support
mikecote Jan 21, 2019
4eba4d8
Merge branch 'master' of github.com:mikecote/kibana into add-references
mikecote Jan 22, 2019
0d971d6
Implement references to search, dashboard, visualization, graph
mikecote Jan 22, 2019
3fdaa5c
Add index pattern migration to dashboards
mikecote Jan 22, 2019
0dfa760
Add references mapping to dashboard mppings.json
mikecote Jan 22, 2019
5e02996
Remove findRelationships from repository and into it's own function /…
mikecote Jan 23, 2019
aabc917
Apply PR feedback pt1
mikecote Jan 23, 2019
87ee26d
Merge branch 'master' of github.com:mikecote/kibana into add-references
mikecote Jan 23, 2019
830c528
Fix some failing tests
mikecote Jan 23, 2019
5f328bb
Remove error throwing in migrations
mikecote Jan 23, 2019
fd3085e
Add references to edit saved object screen
mikecote Jan 23, 2019
7264bc7
Pass types to findRelationships
mikecote Jan 23, 2019
a2caa10
Merge branch 'master' of github.com:elastic/kibana into pr/28199
Jan 23, 2019
5f8b3b9
[ftr] restore snapshots from master, rely on migrations to add refere…
Jan 23, 2019
2e26652
[security] remove `find_relationships` action
Jan 23, 2019
acb991e
Merge branch 'master' of github.com:elastic/kibana into pr/28199
Jan 24, 2019
9bcfd57
remove data set modifications
Jan 23, 2019
4c9e0bf
[security/savedObjectsClient] remove _getAuthorizedTypes method
Jan 23, 2019
a2941c6
fix security & spaces tests to consider references and migrationVersion
mikecote Jan 24, 2019
b4ef670
Add space id prefixes to es_archiver/saved_objects/spaces/data.json
mikecote Jan 24, 2019
d2c68be
Merge branch 'master' of github.com:mikecote/kibana into add-references
mikecote Jan 24, 2019
ddc0496
Rename referenced attributes to have a suffix of RefName
mikecote Jan 24, 2019
5e8989f
Merge branch 'master' of github.com:elastic/kibana into add-references
mikecote Jan 24, 2019
b8d1f7f
Fix length check in scenario references doesn't exist
mikecote Jan 24, 2019
489b0e5
Add test for inject references to not be called when references array…
mikecote Jan 24, 2019
07eae56
Merge branch 'master' of github.com:elastic/kibana into add-references
mikecote Jan 25, 2019
304a31f
some code cleanup
mikecote Jan 25, 2019
0a8f5b1
Make migrations run on machine learning data files, fix rollup filter…
mikecote Jan 25, 2019
371fdfd
fix broken test
mikecote Jan 25, 2019
4a59408
Fix collector.js to include references in elasticsearch response
mikecote Jan 25, 2019
c379ab7
code cleanup pt2
mikecote Jan 25, 2019
a379ff1
add some more tests
mikecote Jan 25, 2019
5cd9518
Merge branch 'master' of github.com:elastic/kibana into add-references
mikecote Jan 25, 2019
71501d2
fix broken tests
mikecote Jan 25, 2019
876cb3f
updated documentation on referencedBy option for saved object client …
mikecote Jan 25, 2019
4ff0d12
Merge branch 'master' of github.com:elastic/kibana into add-references
mikecote Jan 28, 2019
882753f
Move visualization migrations into kibana plugin
mikecote Jan 28, 2019
dee9ce2
Update docs with better description on references
mikecote Jan 28, 2019
d22399a
Merge with master
mikecote Jan 29, 2019
14a2f55
Merge branch 'master' of github.com:elastic/kibana into add-references
mikecote Jan 29, 2019
1122c92
Merge w/ master
mikecote Jan 30, 2019
6babefe
Apply PR feedback
mikecote Jan 30, 2019
8924666
Merge with master
mikecote Jan 30, 2019
d3f11ed
Fix merge
mikecote Jan 30, 2019
6a313f4
fix tests I broke adressing PR feedback
mikecote Jan 30, 2019
c36c728
Merge with master
mikecote Jan 30, 2019
9ff87bd
PR feedback pt2
mikecote Jan 30, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ exports[`Relationships should render dashboards normally 1`] = `
type="row"
>
<React.Fragment
key="visualizations"
key="visualization"
>
<EuiDescriptionListTitle
style={
Expand Down Expand Up @@ -248,7 +248,7 @@ exports[`Relationships should render searches normally 1`] = `
type="row"
>
<React.Fragment
key="indexPatterns"
key="index-pattern"
>
<EuiDescriptionListTitle
style={
Expand Down Expand Up @@ -315,7 +315,7 @@ exports[`Relationships should render searches normally 1`] = `
/>
</React.Fragment>
<React.Fragment
key="visualizations"
key="visualization"
>
<EuiDescriptionListTitle
style={
Expand Down Expand Up @@ -427,7 +427,7 @@ exports[`Relationships should render visualizations normally 1`] = `
type="row"
>
<React.Fragment
key="dashboards"
key="dashboard"
>
<EuiDescriptionListTitle
style={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ describe('Relationships', () => {
it('should render searches normally', async () => {
const props = {
getRelationships: jest.fn().mockImplementation(() => ({
indexPatterns: [
'index-pattern': [
{
id: '1',
}
],
visualizations: [
visualization: [
{
id: '2',
}
Expand Down Expand Up @@ -123,7 +123,7 @@ describe('Relationships', () => {
it('should render visualizations normally', async () => {
const props = {
getRelationships: jest.fn().mockImplementation(() => ({
dashboards: [
dashboard: [
{
id: '1',
},
Expand Down Expand Up @@ -161,7 +161,7 @@ describe('Relationships', () => {
it('should render dashboards normally', async () => {
const props = {
getRelationships: jest.fn().mockImplementation(() => ({
visualizations: [
visualization: [
{
id: '1',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class RelationshipsUI extends Component {
/>);
break;
case 'search':
if (type === 'visualizations') {
if (type === 'visualization') {
calloutText = (<FormattedMessage
id="kbn.management.objects.objectsTable.relationships.search.visualizations.calloutText"
defaultMessage="Here are some visualizations that use this saved search. If
Expand All @@ -168,22 +168,44 @@ class RelationshipsUI extends Component {
}
break;
case 'visualization':
calloutText = (<FormattedMessage
id="kbn.management.objects.objectsTable.relationships.visualization.calloutText"
defaultMessage="Here are some dashboards which contain this visualization. If
you delete this visualization, these dashboards will no longer
show them."
/>);
if (type === 'index-pattern') {
calloutColor = 'success';
calloutTitle = (<FormattedMessage
id="kbn.management.objects.objectsTable.relationships.visualization.indexPattern.calloutTitle"
defaultMessage="Index Pattern"
/>);
calloutText = (<FormattedMessage
id="kbn.management.objects.objectsTable.relationships.visualization.indexPattern.calloutText"
defaultMessage="Here is the index pattern tied to this visualization."
/>);
} else if (type === 'search') {
calloutColor = 'success';
calloutTitle = (<FormattedMessage
id="kbn.management.objects.objectsTable.relationships.visualization.search.calloutTitle"
defaultMessage="Saved Search"
/>);
calloutText = (<FormattedMessage
id="kbn.management.objects.objectsTable.relationships.visualization.search.calloutText"
defaultMessage="Here is the saved search tied to this visualization."
/>);
} else {
calloutText = (<FormattedMessage
id="kbn.management.objects.objectsTable.relationships.visualization.calloutText"
defaultMessage="Here are some dashboards which contain this visualization. If
you delete this visualization, these dashboards will no longer
show them."
/>);
}
break;
case 'index-pattern':
if (type === 'visualizations') {
if (type === 'visualization') {
calloutText = (<FormattedMessage
id="kbn.management.objects.objectsTable.relationships.indexPattern.visualizations.calloutText"
defaultMessage="Here are some visualizations that use this index pattern. If
you delete this index pattern, these visualizations will not
longer work properly."
/>);
} else if (type === 'searches') {
} else if (type === 'search') {
calloutText = (<FormattedMessage
id="kbn.management.objects.objectsTable.relationships.indexPattern.searches.calloutText"
defaultMessage="Here are some saved searches that use this index pattern. If
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,10 @@ async function importIndexPattern(doc, indexPatterns, overwriteAll) {
}

async function importDocument(obj, doc, overwriteAll) {
await obj.applyESResp(doc);
await obj.applyESResp({
references: doc._references || [],
...doc
});
return await obj.save({ confirmOverwrite: !overwriteAll });
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export async function retrieveAndExportDocs(objs, savedObjectsClient) {
_type: obj.type,
_source: obj.attributes,
_migrationVersion: obj.migrationVersion,
_references: obj.references,
};
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,17 @@ describe('findRelationships', () => {
],
})
};
const result = await findRelationships(
const result = await findRelationships({
type,
id,
size,
savedObjectsClient
);
expect(result).to.eql({
visualizations: [
{ id: '1', title: 'Foo' },
{ id: '2', title: 'Bar' },
{ id: '3', title: 'FooBar' },
],
});
expect(result).to.eql([
{ id: '1', title: 'Foo', type: 'visualization' },
{ id: '2', title: 'Bar', type: 'visualization' },
{ id: '3', title: 'FooBar', type: 'visualization' },
]);
});

it('should find relationships for visualizations', async () => {
Expand Down Expand Up @@ -116,18 +114,16 @@ describe('findRelationships', () => {
})
};

const result = await findRelationships(
const result = await findRelationships({
type,
id,
size,
savedObjectsClient
);
expect(result).to.eql({
dashboards: [
{ id: '1', title: 'My Dashboard' },
{ id: '2', title: 'Your Dashboard' },
],
});
expect(result).to.eql([
{ id: '1', title: 'My Dashboard', type: 'dashboard' },
{ id: '2', title: 'Your Dashboard', type: 'dashboard' },
]);
});

it('should find relationships for saved searches', async () => {
Expand Down Expand Up @@ -181,20 +177,18 @@ describe('findRelationships', () => {
})
};

const result = await findRelationships(
const result = await findRelationships({
type,
id,
size,
savedObjectsClient
);
expect(result).to.eql({
visualizations: [
{ id: '1', title: 'Foo' },
{ id: '2', title: 'Bar' },
{ id: '3', title: 'FooBar' },
],
indexPatterns: [{ id: 'index-pattern:1', title: 'My Index Pattern' }],
});
expect(result).to.eql([
{ id: '1', title: 'Foo', type: 'visualization' },
{ id: '2', title: 'Bar', type: 'visualization' },
{ id: '3', title: 'FooBar', type: 'visualization' },
{ id: 'index-pattern:1', type: 'index-pattern', title: 'My Index Pattern' },
]);
});

it('should find relationships for index patterns', async () => {
Expand Down Expand Up @@ -288,21 +282,23 @@ describe('findRelationships', () => {
}
};

const result = await findRelationships(
const result = await findRelationships({
type,
id,
size,
savedObjectsClient
);
expect(result).to.eql({
visualizations: [{ id: '1', title: 'Foo' }, { id: '2', title: 'Bar' }],
searches: [{ id: '1', title: 'Foo' }, { id: '2', title: 'Bar' }],
});
expect(result).to.eql([
{ id: '1', type: 'visualization', title: 'Foo' },
{ id: '2', type: 'visualization', title: 'Bar' },
{ id: '1', type: 'search', title: 'Foo' },
{ id: '2', type: 'search', title: 'Bar' },
]);
});

it('should return an empty object for invalid types', async () => {
const type = 'invalid';
const result = await findRelationships(type);
const result = await findRelationships({ type });
expect(result).to.eql({});
});
});

This file was deleted.

Loading