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

Initial client-side support for sharing saved-objects phase 1.5 #69399

Merged
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
b155c98
Change "Copy to space" action
jportner Mar 31, 2020
282498e
Cleanup copy-to-space UI controls
jportner Mar 31, 2020
deb09ab
Add "Share to space" action
jportner May 19, 2020
ff61253
Allow `SavedObjectsManagementAction` to trigger a refresh on finish
jportner May 21, 2020
0677b83
Sort saved objects management table by `_id`
jportner May 26, 2020
1659bb4
Revert "Sort saved objects management table by `_id`"
jportner May 27, 2020
a509e36
Saved object management table: allow refresh of single object
jportner May 28, 2020
8f2241d
Change Share-to-space action
jportner May 29, 2020
20aae34
Add "Spaces" column to Saved Object Management table
jportner Jun 2, 2020
c574ff9
Update import conflict resolution for multi-namespace objects
jportner Jun 4, 2020
1c4ef45
Expose `FailedImport` from the Kibana Platform
jportner Jun 4, 2020
b51b91f
Refactor `summarizeCopyResult`
jportner Jun 4, 2020
c257b42
Change Saved Object Import APIs to return metadata
jportner Jun 9, 2020
04307ef
Return successful imports after processing import response
jportner Jun 9, 2020
70179f5
Reworked copy results
jportner Jun 10, 2020
9d9b177
Change the "Copy results" to use switches to control overwrite
jportner Jun 11, 2020
32d828e
Fix inaccurate import error count
jportner Jun 11, 2020
6b9dd67
Prevent resolveImportErrors from creating duplicate retries
jportner Jun 12, 2020
0ce208d
Change `idToOverwrite` to `destinationId`
jportner Jul 1, 2020
34f60d7
Change how resolveImportErrors checks for conflicts -- use retries
jportner Jul 1, 2020
f4886c6
Remove `blocking` field from `missing_references` errors
jportner Jul 2, 2020
02e7ff9
Fix resolveImportErrors integration tests
jportner Jul 2, 2020
dfde63a
Update Import and Copy dev docs
jportner Jul 8, 2020
59d3a2a
Add ambiguous conflict UI for copy to space
jportner Jul 14, 2020
8f6eb96
Add ambiguous conflict UI for import
jportner Jul 14, 2020
c4d6d2a
Add "Create a new copy" option UI for import
jportner Jul 16, 2020
664f252
Add "Create a new copy" option UI for copy to space
jportner Jul 16, 2020
16bef0b
Label changes
jportner Jul 16, 2020
91b4cb3
Change ambiguous conflict destinations - sort by `updatedAt`
jportner Jul 16, 2020
11017b3
Fix tooltip text size
jportner Jul 16, 2020
9f7842d
Add number badge to copy space result
jportner Jul 20, 2020
c1e26ff
Add "resolve all" option for dealing with copy-to-space conflicts
jportner Jul 20, 2020
7997902
Disable actions based on object's `namespaceType`
jportner Jul 21, 2020
b222f1b
Add `ignoreMissingReferences` option for retries
jportner Jul 21, 2020
9fb291f
Fix client-side import error resolutions
jportner Jul 22, 2020
1485789
Return missing_references and conflict errors for same objects
jportner Jul 22, 2020
f828bc8
Add optional `overwrite` attribute to import/copy results
jportner Jul 22, 2020
5a84572
Overhaul copy-to-space summary counts and icons
jportner Jul 23, 2020
e08f229
Hide "Shared spaces" column if no shared types are registered
jportner Jul 23, 2020
7a74a6a
Revert "Hide "Shared spaces" column if no shared types are registered"
jportner Aug 10, 2020
407b10f
Address the rest of 1st round of review comments
jportner Jul 23, 2020
dc10ba1
Minor UI tweaks
jportner Jul 30, 2020
12037fd
Add new import summary
jportner Aug 11, 2020
91932d1
Update Copy flyout based on review feedback
jportner Aug 12, 2020
7a8cddf
Update Import flyout based on review feedback
jportner Aug 12, 2020
8f2082c
Prevent users from copying to spaces where an object already exists
jportner Aug 13, 2020
92ea812
Address 2nd round of review comments
jportner Aug 13, 2020
1b34a2d
Rename CSS class for consistency
jportner Aug 13, 2020
d885e64
Tweak import and copy flyout options
jportner Aug 14, 2020
2350e2f
Changes for platform team review feedbck
jportner Aug 19, 2020
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
Prev Previous commit
Next Next commit
Sort saved objects management table by _id
After updating the `namespaces` for a saved object, the table data
needs to be refreshed. Unfortunately, after searching again, the
sort order of the documents changes. By using `_id` to sort, we can
avoid the issue of sort order changing.

To sort this way, we needed to change the search DSL to allow
sorting by multiple fields, as we already sort by `type`.
jportner committed Aug 19, 2020
commit 0677b830165135499da7901e43f172d94ff109d4
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ export interface SavedObjectsFindOptions
| [rootSearchFields](./kibana-plugin-core-public.savedobjectsfindoptions.rootsearchfields.md) | <code>string[]</code> | The fields to perform the parsed query against. Unlike the <code>searchFields</code> argument, these are expected to be root fields and will not be modified. If used in conjunction with <code>searchFields</code>, both are concatenated together. |
| [search](./kibana-plugin-core-public.savedobjectsfindoptions.search.md) | <code>string</code> | Search documents using the Elasticsearch Simple Query String syntax. See Elasticsearch Simple Query String <code>query</code> argument for more information |
| [searchFields](./kibana-plugin-core-public.savedobjectsfindoptions.searchfields.md) | <code>string[]</code> | The fields to perform the parsed query against. See Elasticsearch Simple Query String <code>fields</code> argument for more information |
| [sortField](./kibana-plugin-core-public.savedobjectsfindoptions.sortfield.md) | <code>string</code> | |
| [sortOrder](./kibana-plugin-core-public.savedobjectsfindoptions.sortorder.md) | <code>string</code> | |
| [sortField](./kibana-plugin-core-public.savedobjectsfindoptions.sortfield.md) | <code>string &#124; string[]</code> | |
| [sortOrder](./kibana-plugin-core-public.savedobjectsfindoptions.sortorder.md) | <code>string &#124; string[]</code> | |
| [type](./kibana-plugin-core-public.savedobjectsfindoptions.type.md) | <code>string &#124; string[]</code> | |

Original file line number Diff line number Diff line change
@@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
sortField?: string;
sortField?: string | string[];
```
Original file line number Diff line number Diff line change
@@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
sortOrder?: string;
sortOrder?: string | string[];
```
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ export interface SavedObjectsFindOptions
| [rootSearchFields](./kibana-plugin-core-server.savedobjectsfindoptions.rootsearchfields.md) | <code>string[]</code> | The fields to perform the parsed query against. Unlike the <code>searchFields</code> argument, these are expected to be root fields and will not be modified. If used in conjunction with <code>searchFields</code>, both are concatenated together. |
| [search](./kibana-plugin-core-server.savedobjectsfindoptions.search.md) | <code>string</code> | Search documents using the Elasticsearch Simple Query String syntax. See Elasticsearch Simple Query String <code>query</code> argument for more information |
| [searchFields](./kibana-plugin-core-server.savedobjectsfindoptions.searchfields.md) | <code>string[]</code> | The fields to perform the parsed query against. See Elasticsearch Simple Query String <code>fields</code> argument for more information |
| [sortField](./kibana-plugin-core-server.savedobjectsfindoptions.sortfield.md) | <code>string</code> | |
| [sortOrder](./kibana-plugin-core-server.savedobjectsfindoptions.sortorder.md) | <code>string</code> | |
| [sortField](./kibana-plugin-core-server.savedobjectsfindoptions.sortfield.md) | <code>string &#124; string[]</code> | |
| [sortOrder](./kibana-plugin-core-server.savedobjectsfindoptions.sortorder.md) | <code>string &#124; string[]</code> | |
| [type](./kibana-plugin-core-server.savedobjectsfindoptions.type.md) | <code>string &#124; string[]</code> | |

Original file line number Diff line number Diff line change
@@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
sortField?: string;
sortField?: string | string[];
```
Original file line number Diff line number Diff line change
@@ -7,5 +7,5 @@
<b>Signature:</b>

```typescript
sortOrder?: string;
sortOrder?: string | string[];
```
4 changes: 2 additions & 2 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
@@ -1205,9 +1205,9 @@ export interface SavedObjectsFindOptions {
search?: string;
searchFields?: string[];
// (undocumented)
sortField?: string;
sortField?: string | string[];
// (undocumented)
sortOrder?: string;
sortOrder?: string | string[];
// (undocumented)
type: string | string[];
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -46,12 +46,17 @@ describe('getSearchDsl', () => {
});
}).toThrowError(/type must be specified/);
});
it('throws when sortOrder without sortField', () => {

it('throws when sortOrder is defined and sortField is undefined', () => {
expect(() => {
getSearchDsl(mappings, registry, {
type: 'foo',
sortOrder: 'desc',
});
getSearchDsl(mappings, registry, { type: 'foo', sortOrder: 'desc' });
}).toThrowError(/sortOrder requires a sortField/);
});

it('throws when sortOrder length is greater than sortField length', () => {
expect(() => {
const options = { type: 'foo', sortField: ['bar'], sortOrder: ['baz', 'qux'] };
getSearchDsl(mappings, registry, options);
}).toThrowError(/sortOrder requires a sortField/);
});
});
@@ -86,22 +91,30 @@ describe('getSearchDsl', () => {
});
});

it('passes (mappings, type, sortField, sortOrder) to getSortingParams', () => {
getSortingParams.mockReturnValue({});
const opts = {
type: 'foo',
sortField: 'bar',
sortOrder: 'baz',
};
describe('passes (mappings, type, sortField, sortOrder) to getSortingParams', () => {
it('with string type and undefined sortField/sortOrder', () => {
getSortingParams.mockReturnValue({});

getSearchDsl(mappings, registry, opts);
expect(getSortingParams).toHaveBeenCalledTimes(1);
expect(getSortingParams).toHaveBeenCalledWith(
mappings,
opts.type,
opts.sortField,
opts.sortOrder
);
getSearchDsl(mappings, registry, { type: 'foo' });
expect(getSortingParams).toHaveBeenCalledTimes(1);
expect(getSortingParams).toHaveBeenCalledWith(mappings, 'foo', [], []);
});

it('with strings', () => {
getSortingParams.mockReturnValue({});

getSearchDsl(mappings, registry, { type: 'foo', sortField: 'bar', sortOrder: 'baz' });
expect(getSortingParams).toHaveBeenCalledTimes(1);
expect(getSortingParams).toHaveBeenCalledWith(mappings, 'foo', ['bar'], ['baz']);
});

it('with string arrays', () => {
getSortingParams.mockReturnValue({});

getSearchDsl(mappings, registry, { type: ['foo'], sortField: ['bar'], sortOrder: ['baz'] });
expect(getSortingParams).toHaveBeenCalledTimes(1);
expect(getSortingParams).toHaveBeenCalledWith(mappings, ['foo'], ['bar'], ['baz']);
});
});

it('returns combination of getQueryParams and getSortingParams', () => {
Original file line number Diff line number Diff line change
@@ -32,8 +32,8 @@ interface GetSearchDslOptions {
defaultSearchOperator?: string;
searchFields?: string[];
rootSearchFields?: string[];
sortField?: string;
sortOrder?: string;
sortField?: string | string[];
sortOrder?: string | string[];
namespaces?: string[];
hasReference?: {
type: string;
@@ -64,7 +64,10 @@ export function getSearchDsl(
throw Boom.notAcceptable('type must be specified');
}

if (sortOrder && !sortField) {
const sortFields = sortField ? (Array.isArray(sortField) ? sortField : [sortField]) : [];
const sortOrders = sortOrder ? (Array.isArray(sortOrder) ? sortOrder : [sortOrder]) : [];

if (sortOrders.length > sortFields.length) {
throw Boom.notAcceptable('sortOrder requires a sortField');
}

@@ -81,6 +84,6 @@ export function getSearchDsl(
hasReference,
kueryNode,
}),
...getSortingParams(mappings, type, sortField, sortOrder),
...getSortingParams(mappings, type, sortFields, sortOrders),
};
}
Loading