Skip to content

Commit

Permalink
Merge branch 'main' into 183710-fix-prefill-filters
Browse files Browse the repository at this point in the history
  • Loading branch information
maryam-saeidi committed May 21, 2024
2 parents 221905d + 6e851a8 commit d231a25
Show file tree
Hide file tree
Showing 205 changed files with 4,990 additions and 1,875 deletions.
4 changes: 3 additions & 1 deletion docs/settings/reporting-settings.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ reports, you might need to change the following settings.
If capturing a report fails for any reason, {kib} will re-queue the report job for retry, as many times as this setting. Defaults to `3`.

`xpack.reporting.queue.indexInterval`::
How often the index that stores reporting jobs rolls over to a new index. Valid values are `year`, `month`, `week`, `day`, and `hour`. Defaults to `week`.
deprecated:[8.15.0,This setting has no effect.] How often Reporting creates a new index to store report jobs and file contents.
Valid values are `year`, `month`, `week`, `day`, and `hour`. Defaults to `week`.
*NOTE*: This setting exists for backwards compatibility, but is unused. Use the built-in ILM policy provided for the reporting plugin to customize the rollover of Reporting data.

[[xpack-reportingQueue-pollEnabled]] `xpack.reporting.queue.pollEnabled` ::
When `true`, enables the {kib} instance to poll {es} for pending jobs and claim them for
Expand Down
7 changes: 3 additions & 4 deletions docs/user/reporting/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@ NOTE: When you create a dashboard report that includes a data table or saved sea

. To view and manage reports, open the main menu, then click *Stack Management > Reporting*.

NOTE: Reports are stored in {es} and managed by the `kibana-reporting` {ilm}
({ilm-init}) policy. By default, the policy stores reports forever. To learn
more about {ilm-init} policies, refer to the {es}
{ref}/index-lifecycle-management.html[{ilm-init} documentation].
NOTE: In "stateful" deployments, reports are stored in {es} and managed by the `kibana-reporting` {ilm}
({ilm-init}) policy. By default, the policy stores reports forever. To learn more about {ilm-init} policies, refer
to the {es} {ref}/index-lifecycle-management.html[{ilm-init} documentation].

[float]
[[csv-limitations]]
Expand Down
2 changes: 1 addition & 1 deletion docs/user/reporting/script-example.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ An example response for a successfully queued report:
---------------------------------------------------------

<1> The relative path on the {kib} host for downloading the report.
<2> (Not included in the example) Internal representation of the reporting job, as found in the `.reporting-*` index.
<2> (Not included in the example) Internal representation of the reporting job, as found in the `.reporting-*` storage.
21 changes: 7 additions & 14 deletions examples/embeddable_examples/public/app/render_examples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,14 @@ import { SEARCH_EMBEDDABLE_ID } from '../react_embeddables/search/constants';
import type { SearchApi, SearchSerializedState } from '../react_embeddables/search/types';

export const RenderExamples = () => {
const initialState = useMemo(() => {
return {
rawState: {
timeRange: undefined,
},
references: [],
};
// only run onMount
}, []);

const parentApi = useMemo(() => {
return {
reload$: new Subject<void>(),
getSerializedStateForChild: () => ({
rawState: {
timeRange: undefined,
},
}),
timeRange$: new BehaviorSubject<TimeRange>({
from: 'now-24h',
to: 'now',
Expand Down Expand Up @@ -85,8 +80,7 @@ export const RenderExamples = () => {
<EuiCodeBlock language="jsx" fontSize="m" paddingSize="m">
{`<ReactEmbeddableRenderer<State, Api>
type={SEARCH_EMBEDDABLE_ID}
state={initialState}
parentApi={parentApi}
getParentApi={() => parentApi}
onApiAvailable={(newApi) => {
setApi(newApi);
}}
Expand All @@ -107,8 +101,7 @@ export const RenderExamples = () => {
<ReactEmbeddableRenderer<SearchSerializedState, SearchApi>
key={hidePanelChrome ? 'hideChrome' : 'showChrome'}
type={SEARCH_EMBEDDABLE_ID}
state={initialState}
parentApi={parentApi}
getParentApi={() => parentApi}
onApiAvailable={(newApi) => {
setApi(newApi);
}}
Expand Down
14 changes: 13 additions & 1 deletion examples/embeddable_examples/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ import { DATA_TABLE_ID } from './react_embeddables/data_table/constants';
import { registerCreateDataTableAction } from './react_embeddables/data_table/create_data_table_action';
import { EUI_MARKDOWN_ID } from './react_embeddables/eui_markdown/constants';
import { registerCreateEuiMarkdownAction } from './react_embeddables/eui_markdown/create_eui_markdown_action';
import { registerCreateFieldListAction } from './react_embeddables/field_list/create_field_list_action';
import { FIELD_LIST_ID } from './react_embeddables/field_list/constants';
import { registerCreateFieldListAction } from './react_embeddables/field_list/create_field_list_action';
import { registerFieldListPanelPlacementSetting } from './react_embeddables/field_list/register_field_list_embeddable';
import { SAVED_BOOK_ID } from './react_embeddables/saved_book/constants';
import { registerCreateSavedBookAction } from './react_embeddables/saved_book/create_saved_book_action';
import { registerAddSearchPanelAction } from './react_embeddables/search/register_add_search_panel_action';
import { registerSearchEmbeddable } from './react_embeddables/search/register_search_embeddable';

Expand Down Expand Up @@ -73,6 +75,14 @@ export class EmbeddableExamplesPlugin implements Plugin<void, void, SetupDeps, S
return getDataTableFactory(coreStart, deps);
});

embeddable.registerReactEmbeddableFactory(SAVED_BOOK_ID, async () => {
const { getSavedBookEmbeddableFactory } = await import(
'./react_embeddables/saved_book/saved_book_react_embeddable'
);
const [coreStart] = await startServicesPromise;
return getSavedBookEmbeddableFactory(coreStart);
});

registerSearchEmbeddable(
embeddable,
new Promise((resolve) => startServicesPromise.then(([_, startDeps]) => resolve(startDeps)))
Expand All @@ -88,6 +98,8 @@ export class EmbeddableExamplesPlugin implements Plugin<void, void, SetupDeps, S
registerAddSearchPanelAction(deps.uiActions);

registerCreateDataTableAction(deps.uiActions);

registerCreateSavedBookAction(deps.uiActions, core);
}

public stop() {}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { BehaviorSubject } from 'rxjs';
import { BookAttributes, BookAttributesManager } from './types';

export const defaultBookAttributes: BookAttributes = {
bookTitle: 'Pillars of the earth',
authorName: 'Ken follett',
numberOfPages: 973,
bookSynopsis:
'A spellbinding epic set in 12th-century England, The Pillars of the Earth tells the story of the struggle to build the greatest Gothic cathedral the world has known.',
};

export const stateManagerFromAttributes = (attributes: BookAttributes): BookAttributesManager => {
const bookTitle = new BehaviorSubject<string>(attributes.bookTitle);
const authorName = new BehaviorSubject<string>(attributes.authorName);
const numberOfPages = new BehaviorSubject<number>(attributes.numberOfPages);
const bookSynopsis = new BehaviorSubject<string | undefined>(attributes.bookSynopsis);

return {
bookTitle,
authorName,
numberOfPages,
bookSynopsis,
comparators: {
bookTitle: [bookTitle, (val) => bookTitle.next(val)],
authorName: [authorName, (val) => authorName.next(val)],
numberOfPages: [numberOfPages, (val) => numberOfPages.next(val)],
bookSynopsis: [bookSynopsis, (val) => bookSynopsis.next(val)],
},
};
};

export const serializeBookAttributes = (stateManager: BookAttributesManager): BookAttributes => ({
bookTitle: stateManager.bookTitle.value,
authorName: stateManager.authorName.value,
numberOfPages: stateManager.numberOfPages.value,
bookSynopsis: stateManager.bookSynopsis.value,
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export const SAVED_BOOK_ID = 'book';
export const ADD_SAVED_BOOK_ACTION_ID = 'create_saved_book';
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { CoreStart } from '@kbn/core/public';
import { i18n } from '@kbn/i18n';
import { apiIsPresentationContainer } from '@kbn/presentation-containers';
import { EmbeddableApiContext } from '@kbn/presentation-publishing';
import { IncompatibleActionError } from '@kbn/ui-actions-plugin/public';
import { UiActionsPublicStart } from '@kbn/ui-actions-plugin/public/plugin';
import { embeddableExamplesGrouping } from '../embeddable_examples_grouping';
import {
defaultBookAttributes,
serializeBookAttributes,
stateManagerFromAttributes,
} from './book_state';
import { ADD_SAVED_BOOK_ACTION_ID, SAVED_BOOK_ID } from './constants';
import { openSavedBookEditor } from './saved_book_editor';
import { saveBookAttributes } from './saved_book_library';
import {
BookByReferenceSerializedState,
BookByValueSerializedState,
BookSerializedState,
} from './types';

export const registerCreateSavedBookAction = (uiActions: UiActionsPublicStart, core: CoreStart) => {
uiActions.registerAction<EmbeddableApiContext>({
id: ADD_SAVED_BOOK_ACTION_ID,
getIconType: () => 'folderClosed',
grouping: [embeddableExamplesGrouping],
isCompatible: async ({ embeddable }) => {
return apiIsPresentationContainer(embeddable);
},
execute: async ({ embeddable }) => {
if (!apiIsPresentationContainer(embeddable)) throw new IncompatibleActionError();
const newPanelStateManager = stateManagerFromAttributes(defaultBookAttributes);

const { addToLibrary } = await openSavedBookEditor(newPanelStateManager, true, core, {
parentApi: embeddable,
});

const initialState: BookSerializedState = await (async () => {
// if we're adding this to the library, we only need to return the by reference state.
if (addToLibrary) {
const savedBookId = await saveBookAttributes(
undefined,
serializeBookAttributes(newPanelStateManager)
);
return { savedBookId } as BookByReferenceSerializedState;
}
return {
attributes: serializeBookAttributes(newPanelStateManager),
} as BookByValueSerializedState;
})();

embeddable.addNewPanel<BookSerializedState>({
panelType: SAVED_BOOK_ID,
initialState,
});
},
getDisplayName: () =>
i18n.translate('embeddableExamples.savedbook.addBookAction.displayName', {
defaultMessage: 'Book',
}),
});
uiActions.attachAction('ADD_PANEL_TRIGGER', ADD_SAVED_BOOK_ACTION_ID);
};
Loading

0 comments on commit d231a25

Please sign in to comment.