Skip to content

Commit

Permalink
Merge branch '7.12' into backport/7.12/pr-92081
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Feb 25, 2021
2 parents 65114a0 + 20beb97 commit ec8e0cd
Show file tree
Hide file tree
Showing 17 changed files with 276 additions and 133 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@
"**/cross-fetch/node-fetch": "^2.6.1",
"**/deepmerge": "^4.2.2",
"**/fast-deep-equal": "^3.1.1",
"**/graphql-toolkit/lodash": "^4.17.15",
"**/graphql-toolkit/lodash": "^4.17.21",
"**/hoist-non-react-statics": "^3.3.2",
"**/isomorphic-fetch/node-fetch": "^2.6.1",
"**/istanbul-instrumenter-loader/schema-utils": "1.0.0",
"**/load-grunt-config/lodash": "^4.17.20",
"**/load-grunt-config/lodash": "^4.17.21",
"**/minimist": "^1.2.5",
"**/node-jose/node-forge": "^0.10.0",
"**/prismjs": "1.22.0",
Expand Down Expand Up @@ -231,7 +231,7 @@
"json-stringify-safe": "5.0.1",
"jsonwebtoken": "^8.5.1",
"load-json-file": "^6.2.0",
"lodash": "^4.17.20",
"lodash": "^4.17.21",
"lru-cache": "^4.1.5",
"markdown-it": "^10.0.0",
"md5": "^2.1.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ describe('getSearchDsl', () => {
mappings,
opts.type,
opts.sortField,
opts.sortOrder,
opts.pit
opts.sortOrder
);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export function getSearchDsl(
hasReferenceOperator,
kueryNode,
}),
...getSortingParams(mappings, type, sortField, sortOrder, pit),
...getSortingParams(mappings, type, sortField, sortOrder),
...(pit ? getPitParams(pit) : {}),
...(searchAfter ? { search_after: searchAfter } : {}),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,6 @@ describe('searchDsl/getSortParams', () => {
],
});
});
it('appends tiebreaker when PIT is provided', () => {
expect(getSortingParams(MAPPINGS, 'saved', 'title', undefined, { id: 'abc' }).sort).toEqual(
expect.arrayContaining([{ _shard_doc: 'asc' }])
);
});
});
describe('sortField is simple root property with multiple types', () => {
it('returns correct params', () => {
Expand All @@ -98,11 +93,6 @@ describe('searchDsl/getSortParams', () => {
],
});
});
it('appends tiebreaker when PIT is provided', () => {
expect(
getSortingParams(MAPPINGS, ['saved', 'pending'], 'type', undefined, { id: 'abc' }).sort
).toEqual(expect.arrayContaining([{ _shard_doc: 'asc' }]));
});
});
describe('sortField is simple non-root property with multiple types', () => {
it('returns correct params', () => {
Expand All @@ -124,11 +114,6 @@ describe('searchDsl/getSortParams', () => {
],
});
});
it('appends tiebreaker when PIT is provided', () => {
expect(
getSortingParams(MAPPINGS, 'saved', 'title.raw', undefined, { id: 'abc' }).sort
).toEqual(expect.arrayContaining([{ _shard_doc: 'asc' }]));
});
});
describe('sortField is multi-field with single type as array', () => {
it('returns correct params', () => {
Expand All @@ -143,11 +128,6 @@ describe('searchDsl/getSortParams', () => {
],
});
});
it('appends tiebreaker when PIT is provided', () => {
expect(
getSortingParams(MAPPINGS, ['saved'], 'title.raw', undefined, { id: 'abc' }).sort
).toEqual(expect.arrayContaining([{ _shard_doc: 'asc' }]));
});
});
describe('sortField is root multi-field with multiple types', () => {
it('returns correct params', () => {
Expand All @@ -162,12 +142,6 @@ describe('searchDsl/getSortParams', () => {
],
});
});
it('appends tiebreaker when PIT is provided', () => {
expect(
getSortingParams(MAPPINGS, ['saved', 'pending'], 'type.raw', undefined, { id: 'abc' })
.sort
).toEqual(expect.arrayContaining([{ _shard_doc: 'asc' }]));
});
});
describe('sortField is not-root multi-field with multiple types', () => {
it('returns correct params', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,14 @@

import Boom from '@hapi/boom';
import { getProperty, IndexMapping } from '../../../mappings';
import { SavedObjectsPitParams } from '../../../types';

// TODO: The plan is for ES to automatically add this tiebreaker when
// using PIT. We should remove this logic once that is resolved.
// https://github.com/elastic/elasticsearch/issues/56828
const ES_PROVIDED_TIEBREAKER = { _shard_doc: 'asc' };

const TOP_LEVEL_FIELDS = ['_id', '_score'];

export function getSortingParams(
mappings: IndexMapping,
type: string | string[],
sortField?: string,
sortOrder?: string,
pit?: SavedObjectsPitParams
sortOrder?: string
) {
if (!sortField) {
return {};
Expand All @@ -38,7 +31,6 @@ export function getSortingParams(
order: sortOrder,
},
},
...(pit ? [ES_PROVIDED_TIEBREAKER] : []),
],
};
}
Expand All @@ -59,7 +51,6 @@ export function getSortingParams(
unmapped_type: rootField.type,
},
},
...(pit ? [ES_PROVIDED_TIEBREAKER] : []),
],
};
}
Expand All @@ -84,7 +75,6 @@ export function getSortingParams(
unmapped_type: field.type,
},
},
...(pit ? [ES_PROVIDED_TIEBREAKER] : []),
],
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export function isFieldFiltered(
const scriptedOrMissing =
!filterState.missing ||
field.type === '_source' ||
field.type === 'unknown_selected' ||
field.scripted ||
fieldCounts[field.name] > 0;
const needle = filterState.name ? filterState.name.toLowerCase() : '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,20 @@ describe('group_fields', function () {
]);
});

it('should filter fields by a given name', function () {
const fieldFilterState = { ...getDefaultFieldFilter(), ...{ name: 'curr' } };

const actual1 = groupFields(
fields as IndexPatternField[],
['customer_birth_date', 'currency', 'unknown'],
5,
fieldCounts,
fieldFilterState,
false
);
expect(actual1.selected.map((field) => field.name)).toEqual(['currency']);
});

it('excludes unmapped fields if showUnmappedFields set to false', function () {
const fieldFilterState = getDefaultFieldFilter();
const fieldsWithUnmappedField = [...fields];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,18 @@ export function groupFields(
}
}
}
// add columns, that are not part of the index pattern, to be removeable
// add selected columns, that are not part of the index pattern, to be removeable
for (const column of columns) {
if (!result.selected.find((field) => field.name === column)) {
result.selected.push({ name: column, displayName: column } as IndexPatternField);
const tmpField = {
name: column,
displayName: column,
type: 'unknown_selected',
} as IndexPatternField;
if (
!result.selected.find((field) => field.name === column) &&
isFieldFiltered(tmpField, fieldFilterState, fieldCounts)
) {
result.selected.push(tmpField);
}
}
result.selected.sort((a, b) => {
Expand Down
9 changes: 4 additions & 5 deletions src/plugins/embeddable/README.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@ There is also an example of rendering dashboard container outside of dashboard a

=== Docs

link:./docs/README.md[Embeddable docs, guides & caveats]
link:https://github.com/elastic/kibana/blob/master/src/plugins/embeddable/docs/README.md[Embeddable docs, guides & caveats]

=== API docs

==== Server API
https://github.com/elastic/kibana/blob/master/docs/development/plugins/embeddable/server/kibana-plugin-plugins-embeddable-server.embeddablesetup.md[Server Setup contract]
https://github.com/elastic/kibana/blob/master/docs/development/plugins/embeddable/server/kibana-plugin-plugins-embeddable-server.embeddablestart.md[Server Start contract]

===== Browser API
https://github.com/elastic/kibana/blob/master/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddablesetup.md[Browser Setup contract]
https://github.com/elastic/kibana/blob/master/docs/development/plugins/embeddable/public/kibana-plugin-plugins-embeddable-public.embeddablestart.md[Browser Start contract]

==== Server API
https://github.com/elastic/kibana/blob/master/docs/development/plugins/embeddable/server/kibana-plugin-plugins-embeddable-server.embeddablesetup.md[Server Setup contract]

=== Testing

Run unit tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,29 @@ describe('<EditPolicy />', () => {
component.update();
});

test('serialization', async () => {
httpRequestsMockHelpers.setLoadPolicies([DEFAULT_POLICY]);
await act(async () => {
testBed = await setup();
});
const { component, actions } = testBed;
component.update();
await actions.delete.enablePhase();
await actions.setWaitForSnapshotPolicy('test');
await actions.savePolicy();
const latestRequest = server.requests[server.requests.length - 1];
const entirePolicy = JSON.parse(JSON.parse(latestRequest.requestBody).body);
expect(entirePolicy.phases.delete).toEqual({
min_age: '365d',
actions: {
delete: {},
wait_for_snapshot: {
policy: 'test',
},
},
});
});

test('wait for snapshot policy field should correctly display snapshot policy name', () => {
expect(testBed.find('snapshotPolicyCombobox').prop('data-currentvalue')).toEqual([
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ export const schema: FormSchema<FormInternal> = {
},
delete: {
min_age: {
defaultValue: '0',
defaultValue: '365',
validations: [
{
validator: minAgeValidator,
Expand Down
Loading

0 comments on commit ec8e0cd

Please sign in to comment.