Skip to content

Commit cceed90

Browse files
committed
Merge branch 'master' of github.com:elastic/kibana into issue-65127-multiple-group-bys
2 parents 9da1a27 + 28623ad commit cceed90

11 files changed

Lines changed: 119 additions & 66 deletions

File tree

src/plugins/data/public/index_patterns/index_patterns/index_pattern.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,13 @@ export class IndexPattern implements IIndexPattern {
299299
}
300300

301301
async popularizeField(fieldName: string, unit = 1) {
302+
/**
303+
* This function is just used by Discover and it's high likely to be removed in the near future
304+
* It doesn't use the save function to skip the error message that's displayed when
305+
* a user adds several columns in a higher frequency that the changes can be persisted to ES
306+
* resulting in 409 errors
307+
*/
308+
if (!this.id) return;
302309
const field = this.fields.getByName(fieldName);
303310
if (!field) {
304311
return;
@@ -308,7 +315,15 @@ export class IndexPattern implements IIndexPattern {
308315
return;
309316
}
310317
field.count = count;
311-
await this.save();
318+
319+
try {
320+
const res = await this.savedObjectsClient.update(type, this.id, this.prepBody(), {
321+
version: this.version,
322+
});
323+
this.version = res._version;
324+
} catch (e) {
325+
// no need for an error message here
326+
}
312327
}
313328

314329
getNonScriptedFields() {

x-pack/plugins/lens/public/app_plugin/app.test.tsx

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ describe('Lens App', () => {
104104
storage: Storage;
105105
docId?: string;
106106
docStorage: SavedObjectStore;
107-
redirectTo: (id?: string, returnToOrigin?: boolean, newlyCreated?: boolean) => void;
107+
redirectTo: (
108+
id?: string,
109+
returnToOrigin?: boolean,
110+
originatingApp?: string | undefined,
111+
newlyCreated?: boolean
112+
) => void;
108113
originatingApp: string | undefined;
109114
}> {
110115
return ({
@@ -140,7 +145,14 @@ describe('Lens App', () => {
140145
load: jest.fn(),
141146
save: jest.fn(),
142147
},
143-
redirectTo: jest.fn((id?: string, returnToOrigin?: boolean, newlyCreated?: boolean) => {}),
148+
redirectTo: jest.fn(
149+
(
150+
id?: string,
151+
returnToOrigin?: boolean,
152+
originatingApp?: string | undefined,
153+
newlyCreated?: boolean
154+
) => {}
155+
),
144156
} as unknown) as jest.Mocked<{
145157
navigation: typeof navigationStartMock;
146158
editorFrame: EditorFrameInstance;
@@ -149,7 +161,12 @@ describe('Lens App', () => {
149161
storage: Storage;
150162
docId?: string;
151163
docStorage: SavedObjectStore;
152-
redirectTo: (id?: string, returnToOrigin?: boolean, newlyCreated?: boolean) => void;
164+
redirectTo: (
165+
id?: string,
166+
returnToOrigin?: boolean,
167+
originatingApp?: string | undefined,
168+
newlyCreated?: boolean
169+
) => void;
153170
originatingApp: string | undefined;
154171
}>;
155172
}
@@ -348,7 +365,12 @@ describe('Lens App', () => {
348365
storage: Storage;
349366
docId?: string;
350367
docStorage: SavedObjectStore;
351-
redirectTo: (id?: string, returnToOrigin?: boolean, newlyCreated?: boolean) => void;
368+
redirectTo: (
369+
id?: string,
370+
returnToOrigin?: boolean,
371+
originatingApp?: string | undefined,
372+
newlyCreated?: boolean
373+
) => void;
352374
originatingApp: string | undefined;
353375
}>;
354376

@@ -521,7 +543,7 @@ describe('Lens App', () => {
521543
expression: 'kibana 3',
522544
});
523545

524-
expect(args.redirectTo).toHaveBeenCalledWith('aaa', undefined, true);
546+
expect(args.redirectTo).toHaveBeenCalledWith('aaa', undefined, undefined, true);
525547

526548
inst.setProps({ docId: 'aaa' });
527549

@@ -541,7 +563,7 @@ describe('Lens App', () => {
541563
expression: 'kibana 3',
542564
});
543565

544-
expect(args.redirectTo).toHaveBeenCalledWith('aaa', undefined, true);
566+
expect(args.redirectTo).toHaveBeenCalledWith('aaa', undefined, undefined, true);
545567

546568
inst.setProps({ docId: 'aaa' });
547569

@@ -609,7 +631,7 @@ describe('Lens App', () => {
609631
title: 'hello there',
610632
});
611633

612-
expect(args.redirectTo).toHaveBeenCalledWith('aaa', true, true);
634+
expect(args.redirectTo).toHaveBeenCalledWith('aaa', true, undefined, true);
613635
});
614636

615637
it('saves app filters and does not save pinned filters', async () => {
@@ -677,7 +699,12 @@ describe('Lens App', () => {
677699
storage: Storage;
678700
docId?: string;
679701
docStorage: SavedObjectStore;
680-
redirectTo: (id?: string, returnToOrigin?: boolean, newlyCreated?: boolean) => void;
702+
redirectTo: (
703+
id?: string,
704+
returnToOrigin?: boolean,
705+
originatingApp?: string | undefined,
706+
newlyCreated?: boolean
707+
) => void;
681708
}>;
682709

683710
beforeEach(() => {

x-pack/plugins/lens/public/app_plugin/app.tsx

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ interface State {
3333
isLoading: boolean;
3434
isSaveModalVisible: boolean;
3535
indexPatternsForTopNav: IndexPatternInstance[];
36+
originatingApp: string | undefined;
3637
persistedDoc?: Document;
3738
lastKnownDoc?: Document;
3839

@@ -54,7 +55,7 @@ export function App({
5455
docId,
5556
docStorage,
5657
redirectTo,
57-
originatingApp,
58+
originatingAppFromUrl,
5859
navigation,
5960
}: {
6061
editorFrame: EditorFrameInstance;
@@ -64,8 +65,13 @@ export function App({
6465
storage: IStorageWrapper;
6566
docId?: string;
6667
docStorage: SavedObjectStore;
67-
redirectTo: (id?: string, returnToOrigin?: boolean, newlyCreated?: boolean) => void;
68-
originatingApp?: string | undefined;
68+
redirectTo: (
69+
id?: string,
70+
returnToOrigin?: boolean,
71+
originatingApp?: string | undefined,
72+
newlyCreated?: boolean
73+
) => void;
74+
originatingAppFromUrl?: string | undefined;
6975
}) {
7076
const language =
7177
storage.get('kibana.userQueryLanguage') || core.uiSettings.get('search:queryLanguage');
@@ -77,6 +83,7 @@ export function App({
7783
isSaveModalVisible: false,
7884
indexPatternsForTopNav: [],
7985
query: { query: '', language },
86+
originatingApp: originatingAppFromUrl,
8087
dateRange: {
8188
fromDate: currentRange.from,
8289
toDate: currentRange.to,
@@ -229,7 +236,7 @@ export function App({
229236
lastKnownDoc: newDoc,
230237
}));
231238
if (docId !== id || saveProps.returnToOrigin) {
232-
redirectTo(id, saveProps.returnToOrigin, newlyCreated);
239+
redirectTo(id, saveProps.returnToOrigin, state.originatingApp, newlyCreated);
233240
}
234241
})
235242
.catch(e => {
@@ -269,7 +276,7 @@ export function App({
269276
<div className="lnsApp__header">
270277
<TopNavMenu
271278
config={[
272-
...(!!originatingApp && lastKnownDoc?.id
279+
...(!!state.originatingApp && lastKnownDoc?.id
273280
? [
274281
{
275282
label: i18n.translate('xpack.lens.app.saveAndReturn', {
@@ -294,14 +301,14 @@ export function App({
294301
: []),
295302
{
296303
label:
297-
lastKnownDoc?.id && !!originatingApp
304+
lastKnownDoc?.id && !!state.originatingApp
298305
? i18n.translate('xpack.lens.app.saveAs', {
299306
defaultMessage: 'Save as',
300307
})
301308
: i18n.translate('xpack.lens.app.save', {
302309
defaultMessage: 'Save',
303310
}),
304-
emphasize: !originatingApp || !lastKnownDoc?.id,
311+
emphasize: !state.originatingApp || !lastKnownDoc?.id,
305312
run: () => {
306313
if (isSaveable && lastKnownDoc) {
307314
setState(s => ({ ...s, isSaveModalVisible: true }));
@@ -422,7 +429,7 @@ export function App({
422429
</div>
423430
{lastKnownDoc && state.isSaveModalVisible && (
424431
<SavedObjectSaveModalOrigin
425-
originatingApp={originatingApp}
432+
originatingApp={state.originatingApp}
426433
onSave={props => runSave(props)}
427434
onClose={() => setState(s => ({ ...s, isSaveModalVisible: false }))}
428435
documentInfo={{

x-pack/plugins/lens/public/app_plugin/mounter.tsx

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,11 @@ export async function mountApp(
4747
);
4848
const redirectTo = (
4949
routeProps: RouteComponentProps<{ id?: string }>,
50-
originatingApp: string,
5150
id?: string,
5251
returnToOrigin?: boolean,
52+
originatingApp?: string,
5353
newlyCreated?: boolean
5454
) => {
55-
if (!!originatingApp && !returnToOrigin) {
56-
removeQueryParam(routeProps.history, 'embeddableOriginatingApp');
57-
}
58-
5955
if (!id) {
6056
routeProps.history.push('/');
6157
} else if (!originatingApp) {
@@ -78,7 +74,10 @@ export async function mountApp(
7874
const renderEditor = (routeProps: RouteComponentProps<{ id?: string }>) => {
7975
trackUiEvent('loaded');
8076
const urlParams = parse(routeProps.location.search) as Record<string, string>;
81-
const originatingApp = urlParams.embeddableOriginatingApp;
77+
const originatingAppFromUrl = urlParams.embeddableOriginatingApp;
78+
if (urlParams.embeddableOriginatingApp) {
79+
removeQueryParam(routeProps.history, 'embeddableOriginatingApp');
80+
}
8281

8382
return (
8483
<App
@@ -89,10 +88,10 @@ export async function mountApp(
8988
storage={new Storage(localStorage)}
9089
docId={routeProps.match.params.id}
9190
docStorage={new SavedObjectIndexStore(savedObjectsClient)}
92-
redirectTo={(id, returnToOrigin, newlyCreated) =>
93-
redirectTo(routeProps, originatingApp, id, returnToOrigin, newlyCreated)
91+
redirectTo={(id, returnToOrigin, originatingApp, newlyCreated) =>
92+
redirectTo(routeProps, id, returnToOrigin, originatingApp, newlyCreated)
9493
}
95-
originatingApp={originatingApp}
94+
originatingAppFromUrl={originatingAppFromUrl}
9695
/>
9796
);
9897
};

x-pack/plugins/uptime/server/lib/alerts/tls.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,10 @@ import { updateState } from './common';
1212
import { ACTION_GROUP_DEFINITIONS, DYNAMIC_SETTINGS_DEFAULTS } from '../../../common/constants';
1313
import { Cert, CertResult } from '../../../common/runtime_types';
1414
import { commonStateTranslations, tlsTranslations } from './translations';
15+
import { DEFAULT_FROM, DEFAULT_TO } from '../../rest_api/certs/certs';
1516

1617
const { TLS } = ACTION_GROUP_DEFINITIONS;
1718

18-
const DEFAULT_FROM = 'now-1d';
19-
const DEFAULT_TO = 'now';
20-
const DEFAULT_INDEX = 0;
2119
const DEFAULT_SIZE = 20;
2220

2321
interface TlsAlertState {
@@ -113,7 +111,7 @@ export const tlsAlertFactory: UptimeAlertTypeFactory = (_server, libs) => ({
113111
dynamicSettings,
114112
from: DEFAULT_FROM,
115113
to: DEFAULT_TO,
116-
index: DEFAULT_INDEX,
114+
index: 0,
117115
size: DEFAULT_SIZE,
118116
notValidAfter: `now+${dynamicSettings?.certExpirationThreshold ??
119117
DYNAMIC_SETTINGS_DEFAULTS.certExpirationThreshold}d`,

x-pack/plugins/uptime/server/lib/requests/__tests__/get_certs.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ describe('getCerts', () => {
180180
},
181181
Object {
182182
"range": Object {
183-
"@timestamp": Object {
183+
"monitor.timespan": Object {
184184
"gte": "now-2d",
185185
"lte": "now+1h",
186186
},

x-pack/plugins/uptime/server/lib/requests/get_certs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const getCerts: UMElasticsearchQueryFn<GetCertsParams, CertResult> = asyn
5151
},
5252
{
5353
range: {
54-
'@timestamp': {
54+
'monitor.timespan': {
5555
gte: from,
5656
lte: to,
5757
},

x-pack/plugins/uptime/server/rest_api/certs/certs.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import { API_URLS } from '../../../common/constants';
99
import { UMServerLibs } from '../../lib/lib';
1010
import { UMRestApiRouteFactory } from '../types';
1111

12-
const DEFAULT_INDEX = 0;
12+
export const DEFAULT_FROM = 'now-5m';
13+
export const DEFAULT_TO = 'now';
14+
1315
const DEFAULT_SIZE = 25;
14-
const DEFAULT_FROM = 'now-1d';
15-
const DEFAULT_TO = 'now';
1616
const DEFAULT_SORT = 'not_after';
1717
const DEFAULT_DIRECTION = 'asc';
1818

@@ -31,7 +31,7 @@ export const createGetCertsRoute: UMRestApiRouteFactory = (libs: UMServerLibs) =
3131
}),
3232
},
3333
handler: async ({ callES, dynamicSettings }, _context, request, response): Promise<any> => {
34-
const index = request.query?.index ?? DEFAULT_INDEX;
34+
const index = request.query?.index ?? 0;
3535
const size = request.query?.size ?? DEFAULT_SIZE;
3636
const from = request.query?.from ?? DEFAULT_FROM;
3737
const to = request.query?.to ?? DEFAULT_TO;

x-pack/test/api_integration/apis/uptime/rest/helper/make_ping.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const makePing = async (
1818
refresh: boolean = true,
1919
tls: boolean | TlsProps = false
2020
) => {
21+
const timestamp = new Date();
2122
const baseDoc: any = {
2223
tcp: {
2324
rtt: {
@@ -40,7 +41,7 @@ export const makePing = async (
4041
ephemeral_id: '0d9a8dc6-f604-49e3-86a0-d8f9d6f2cbad',
4142
version: '8.0.0',
4243
},
43-
'@timestamp': new Date().toISOString(),
44+
'@timestamp': timestamp.toISOString(),
4445
resolve: {
4546
rtt: {
4647
us: 350,
@@ -88,6 +89,10 @@ export const makePing = async (
8889
check_group: uuid.v4(),
8990
type: 'http',
9091
status: 'up',
92+
timespan: {
93+
gte: timestamp.toISOString(),
94+
lt: new Date(timestamp.getTime() + 5000).toISOString,
95+
},
9196
},
9297
event: {
9398
dataset: 'uptime',

x-pack/test/api_integration/apis/uptime/rest/helper/make_tls.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const makeTls = ({ valid = true, commonName = '*.elastic.co', expiry, sha
3939
server: {
4040
x509: {
4141
not_before: '2020-03-01T00:00:00.000Z',
42-
not_after: '2020-05-30T12:00:00.000Z',
42+
not_after: expiryDate,
4343
issuer: {
4444
distinguished_name:
4545
'CN=DigiCert SHA2 High Assurance Server CA,OU=www.digicert.com,O=DigiCert Inc,C=US',

0 commit comments

Comments
 (0)