Skip to content

Commit

Permalink
Merge branch 'main' into task/olm-4724-action-log-users-filter
Browse files Browse the repository at this point in the history
  • Loading branch information
ashokaditya committed Sep 20, 2022
2 parents 835c6c3 + c92f2b9 commit 42d6576
Show file tree
Hide file tree
Showing 135 changed files with 4,014 additions and 1,365 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ x-pack/examples/files_example @elastic/kibana-app-services
/x-pack/plugins/licensing/ @elastic/kibana-core
/x-pack/plugins/global_search/ @elastic/kibana-core
/x-pack/plugins/cloud/ @elastic/kibana-core
/x-pack/plugins/cloud_integrations/ @elastic/kibana-core
/x-pack/plugins/saved_objects_tagging/ @elastic/kibana-core
/x-pack/test/saved_objects_field_count/ @elastic/kibana-core
/x-pack/test/saved_object_tagging/ @elastic/kibana-core
Expand Down
4 changes: 4 additions & 0 deletions docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,10 @@ The plugin exposes the static DefaultEditorController class to consume.
|The cloud plugin adds Cloud-specific features to Kibana.
|{kib-repo}blob/{branch}/x-pack/plugins/cloud_integrations/cloud_experiments/README.mdx[cloudExperiments]
|The Cloud Experiments Service provides the necessary APIs to implement A/B testing scenarios, fetching the variations in configuration and reporting back metrics to track conversion rates of the experiments.
|{kib-repo}blob/{branch}/x-pack/plugins/cloud_security_posture/README.md[cloudSecurityPosture]
|Cloud Posture automates the identification and remediation of risks across cloud infrastructures
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,8 @@
"jsonwebtoken": "^8.3.0",
"jsts": "^1.6.2",
"kea": "^2.4.2",
"launchdarkly-js-client-sdk": "^2.22.1",
"launchdarkly-node-server-sdk": "^6.4.2",
"load-json-file": "^6.2.0",
"lodash": "^4.17.21",
"lru-cache": "^4.1.5",
Expand Down Expand Up @@ -591,6 +593,7 @@
"redux-saga": "^1.1.3",
"redux-thunk": "^2.4.1",
"redux-thunks": "^1.0.0",
"remark-gfm": "1.0.0",
"remark-parse": "^8.0.3",
"remark-stringify": "^8.0.3",
"require-in-the-middle": "^5.2.0",
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pageLoadAssetSize:
cases: 144442
charts: 55000
cloud: 21076
cloudExperiments: 59358
cloudSecurityPosture: 19109
console: 46091
controls: 40000
Expand Down
1 change: 1 addition & 0 deletions src/dev/typescript/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export const PROJECTS = [
'src/plugins/chart_expressions/*/tsconfig.json',
'src/plugins/vis_types/*/tsconfig.json',
'x-pack/plugins/*/tsconfig.json',
'x-pack/plugins/cloud_integrations/*/tsconfig.json',
'examples/*/tsconfig.json',
'x-pack/examples/*/tsconfig.json',
'test/analytics/fixtures/plugins/*/tsconfig.json',
Expand Down
26 changes: 16 additions & 10 deletions src/plugins/data/common/search/search_source/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,26 @@ export const searchSourceCommonMock: jest.Mocked<ISearchStartSearchSource> = {
extract: jest.fn(),
};

export const createSearchSourceMock = (fields?: SearchSourceFields, response?: any) =>
export const createSearchSourceMock = (
fields?: SearchSourceFields,
response?: any,
search?: jest.Mock
) =>
new SearchSource(fields, {
aggs: {
createAggConfigs: jest.fn(),
} as unknown as SearchSourceDependencies['aggs'],
getConfig: uiSettingsServiceMock.createStartContract().get,
search: jest.fn().mockReturnValue(
of(
response ?? {
rawResponse: { hits: { hits: [], total: 0 } },
isPartial: false,
isRunning: false,
}
)
),
search:
search ||
jest.fn().mockReturnValue(
of(
response ?? {
rawResponse: { hits: { hits: [], total: 0 } },
isPartial: false,
isRunning: false,
}
)
),
onResponse: jest.fn().mockImplementation((req, res) => res),
});
1 change: 1 addition & 0 deletions src/plugins/discover/public/__mocks__/data_views.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const dataViewsMock = {
getIdsWithTitle: jest.fn(() => {
return Promise.resolve([dataViewMock, dataViewComplexMock, dataViewWithTimefieldMock]);
}),
createFilter: jest.fn(),
create: jest.fn(),
clearInstanceCache: jest.fn(),
} as unknown as jest.Mocked<DataViewsContract>;
1 change: 1 addition & 0 deletions src/plugins/discover/public/__mocks__/services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,5 @@ export const discoverServiceMock = {
expressions: expressionsPlugin,
savedObjectsTagging: {},
dataViews: dataViewsMock,
timefilter: { createFilter: jest.fn() },
} as unknown as DiscoverServices;
12 changes: 9 additions & 3 deletions src/plugins/discover/public/application/discover_router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ import { DiscoverMainRoute } from './main';
import { NotFoundRoute } from './not_found';
import { DiscoverServices } from '../build_services';
import { ViewAlertRoute } from './view_alert';
import { HistoryLocationState } from '../locator';

export const discoverRouter = (services: DiscoverServices, history: History, isDev: boolean) => (
export const discoverRouter = (
services: DiscoverServices,
history: History,
isDev: boolean,
historyLocationState?: HistoryLocationState
) => (
<KibanaContextProvider services={services}>
<EuiErrorBoundary>
<Router history={history} data-test-subj="discover-react-router">
Expand All @@ -39,10 +45,10 @@ export const discoverRouter = (services: DiscoverServices, history: History, isD
<ViewAlertRoute />
</Route>
<Route path="/view/:id">
<DiscoverMainRoute isDev={isDev} />
<DiscoverMainRoute isDev={isDev} historyLocationState={historyLocationState} />
</Route>
<Route path="/" exact>
<DiscoverMainRoute isDev={isDev} />
<DiscoverMainRoute isDev={isDev} historyLocationState={historyLocationState} />
</Route>
<NotFoundRoute />
</Switch>
Expand Down
10 changes: 8 additions & 2 deletions src/plugins/discover/public/application/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ import { i18n } from '@kbn/i18n';
import { toMountPoint, wrapWithTheme } from '@kbn/kibana-react-plugin/public';
import { discoverRouter } from './discover_router';
import { DiscoverServices } from '../build_services';
import { HistoryLocationState } from '../locator';

export const renderApp = (element: HTMLElement, services: DiscoverServices, isDev: boolean) => {
export const renderApp = (
element: HTMLElement,
services: DiscoverServices,
isDev: boolean,
historyLocationState?: HistoryLocationState
) => {
const { history: getHistory, capabilities, chrome, data, core } = services;

const history = getHistory();
Expand All @@ -26,7 +32,7 @@ export const renderApp = (element: HTMLElement, services: DiscoverServices, isDe
});
}
const unmount = toMountPoint(
wrapWithTheme(discoverRouter(services, history, isDev), core.theme.theme$)
wrapWithTheme(discoverRouter(services, history, isDev, historyLocationState), core.theme.theme$)
)(element);

return () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import { DiscoverError } from '../../components/common/error_alert';
import { useDiscoverServices } from '../../hooks/use_discover_services';
import { getUrlTracker } from '../../kibana_services';
import { restoreStateFromSavedSearch } from '../../services/saved_searches/restore_from_saved_search';
import { HistoryLocationState } from '../../locator';

const DiscoverMainAppMemoized = memo(DiscoverMainApp);

Expand All @@ -38,6 +39,7 @@ interface DiscoverLandingParams {

interface Props {
isDev: boolean;
historyLocationState?: HistoryLocationState;
}

export function DiscoverMainRoute(props: Props) {
Expand Down Expand Up @@ -93,7 +95,12 @@ export function DiscoverMainRoute(props: Props) {

const { appStateContainer } = getState({ history, savedSearch: nextSavedSearch, services });
const { index } = appStateContainer.getState();
const ip = await loadDataView(data.dataViews, config, index);
const ip = await loadDataView(
data.dataViews,
config,
index,
props.historyLocationState?.dataViewSpec
);

const ipList = ip.list;
const dataViewData = resolveDataView(ip, nextSavedSearch.searchSource, toastNotifications);
Expand All @@ -105,7 +112,15 @@ export function DiscoverMainRoute(props: Props) {
setError(e);
}
},
[config, data.dataViews, history, isDev, toastNotifications, services]
[
config,
data.dataViews,
history,
isDev,
props.historyLocationState?.dataViewSpec,
toastNotifications,
services,
]
);

const loadSavedSearch = useCallback(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@
*/

import { i18n } from '@kbn/i18n';
import type { DataView, DataViewListItem, DataViewsContract } from '@kbn/data-views-plugin/public';
import type {
DataView,
DataViewListItem,
DataViewsContract,
DataViewSpec,
} from '@kbn/data-views-plugin/public';
import type { ISearchSource } from '@kbn/data-plugin/public';
import type { IUiSettingsClient, ToastsStart } from '@kbn/core/public';
interface DataViewData {
Expand Down Expand Up @@ -75,12 +80,33 @@ export function getDataViewId(
export async function loadDataView(
dataViews: DataViewsContract,
config: IUiSettingsClient,
id?: string
id?: string,
dataViewSpec?: DataViewSpec
): Promise<DataViewData> {
const dataViewList = await dataViews.getIdsWithTitle();
let fetchId: string | undefined = id;

/**
* Handle redirect with data view spec provided via history location state
*/
if (dataViewSpec) {
const isPersisted = dataViewList.find(({ id: currentId }) => currentId === dataViewSpec.id);
if (!isPersisted) {
const createdAdHocDataView = await dataViews.create(dataViewSpec);
return {
list: dataViewList || [],
loaded: createdAdHocDataView,
stateVal: createdAdHocDataView.id,
stateValFound: true,
};
}
// reassign fetchId in case of persisted data view spec provided
fetchId = dataViewSpec.id!;
}

// try to fetch adhoc data view first
try {
const fetchedDataView = id ? await dataViews.get(id) : undefined;
const fetchedDataView = fetchId ? await dataViews.get(fetchId) : undefined;
if (fetchedDataView && !fetchedDataView.isPersisted()) {
return {
list: dataViewList || [],
Expand All @@ -95,12 +121,13 @@ export async function loadDataView(
// eslint-disable-next-line no-empty
} catch (e) {}

const actualId = getDataViewId(id, dataViewList, config.get('defaultIndex'));
// fetch persisted data view
const actualId = getDataViewId(fetchId, dataViewList, config.get('defaultIndex'));
return {
list: dataViewList || [],
loaded: await dataViews.get(actualId),
stateVal: id,
stateValFound: !!id && actualId === id,
stateVal: fetchId,
stateValFound: !!fetchId && actualId === fetchId,
};
}

Expand Down
Loading

0 comments on commit 42d6576

Please sign in to comment.