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

[Data/Search Sessions] Management UI #81707

Merged
merged 81 commits into from
Jan 20, 2021
Merged
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
58117ea
logging and error handling in session client routes
tsullivan Dec 17, 2020
eee4641
[Data] Background Search Session Management UI
tsullivan Dec 9, 2020
37a24eb
functional tests
tsullivan Dec 18, 2020
5f7a3c8
fix ci
tsullivan Dec 19, 2020
b791318
Merge branch 'master' into feature/data/management-ui
tsullivan Dec 19, 2020
5d1cdb0
new functional tests
tsullivan Dec 19, 2020
534ae52
fix fn tests
tsullivan Dec 20, 2020
5c6fd95
cleanups
tsullivan Dec 20, 2020
d374a6b
cleanup
tsullivan Dec 21, 2020
866bb06
restore test
tsullivan Dec 21, 2020
d1e4678
Merge branch 'master' into feature/data/management-ui
kibanamachine Dec 21, 2020
23fcdbc
Merge branch 'master' into feature/data/management-ui
tsullivan Dec 21, 2020
6d41c06
Merge branch 'master' into feature/data/management-ui
tsullivan Dec 22, 2020
bf87f84
Merge branch 'master' into feature/data/management-ui
tsullivan Dec 28, 2020
11a5f7a
configurable refresh and fetch timeout
tsullivan Dec 28, 2020
1644f2d
more tests
tsullivan Dec 29, 2020
b68c581
Merge branch 'master' into feature/data/management-ui
tsullivan Dec 29, 2020
858c232
feedback items
tsullivan Dec 29, 2020
d586d64
take expiresSoon field out of the interface
tsullivan Dec 29, 2020
8c91842
move helper to common
tsullivan Dec 29, 2020
f632a4c
remove bg sessions w/find and delete
tsullivan Dec 29, 2020
5dc31dd
add storybook
tsullivan Dec 30, 2020
5d0fe85
fix tests
tsullivan Dec 30, 2020
a38f1d6
storybook actions
tsullivan Dec 30, 2020
2b29591
Merge branch 'master' into feature/data/management-ui
tsullivan Dec 30, 2020
f3e1a9b
refactor expiration status calculation
tsullivan Dec 30, 2020
d967657
isViewable as calculated field
tsullivan Dec 30, 2020
4cc1b12
Merge branch 'master' into feature/data/management-ui
kibanamachine Jan 3, 2021
8ed2b4e
Merge branch 'master' into feature/data/management-ui
tsullivan Jan 4, 2021
e3f9113
refreshInterval 10s default
tsullivan Jan 4, 2021
36aa6b9
Merge branch 'feature/data/management-ui' of github.com:tsullivan/kib…
tsullivan Jan 4, 2021
0259e43
Merge branch 'master' into feature/data/management-ui
tsullivan Jan 7, 2021
d2ad3f3
list newest first
tsullivan Jan 7, 2021
3041960
"Type" => "App"
tsullivan Jan 7, 2021
6d3b66a
remove inline view action
tsullivan Jan 7, 2021
a4b415a
in-progress status tooltip shows expire date
tsullivan Jan 7, 2021
88ee034
move date_string to public
tsullivan Jan 7, 2021
660b467
fix tests
tsullivan Jan 7, 2021
25e13fc
Adds management to tsconfig refs
TinaHeiligers Jan 7, 2021
56044ba
removes preemptive script fix
TinaHeiligers Jan 7, 2021
4adb390
view action was removed
tsullivan Jan 7, 2021
0051eba
Merge branch 'master' into feature/data/management-ui
tsullivan Jan 7, 2021
1089170
rename the feature to Search Sessions
tsullivan Jan 7, 2021
e4cd13e
Update x-pack/plugins/data_enhanced/public/search/sessions_mgmt/compo…
tsullivan Jan 7, 2021
f6bd874
Update x-pack/plugins/data_enhanced/public/search/sessions_mgmt/compo…
tsullivan Jan 7, 2021
c46548e
add TODO
tsullivan Jan 7, 2021
7c2ac8b
use RedirectAppLinks
tsullivan Jan 7, 2021
88a8974
Merge branch 'master' of github.com:elastic/kibana into management_to…
TinaHeiligers Jan 10, 2021
a654f91
Merge remote-tracking branch 'elastic/master' into feature/data/manag…
tsullivan Jan 11, 2021
91bf1ae
Merge branch 'master' of github.com:elastic/kibana into pr/81707
Jan 11, 2021
69f66f2
Merge remote-tracking branch 'tinah/management_to_TS_project' into pr…
Jan 11, 2021
f59dc04
code review and react improvements
Jan 11, 2021
e23bb74
Merge branch 'master' of github.com:elastic/kibana into pr/81707
Jan 11, 2021
ce1062d
config
Jan 11, 2021
08ba096
Merge branch 'master' of github.com:elastic/kibana into pr/81707
Jan 12, 2021
c89eb43
fix test
Jan 12, 2021
2bc230d
Merge branch 'master' into feature/data/management-ui
kibanamachine Jan 12, 2021
fb58fcd
Merge branch 'master' of github.com:elastic/kibana into pr/81707
Jan 12, 2021
ca59197
Fix merge
Jan 12, 2021
b009bf4
Merge branch 'master' of github.com:elastic/kibana into pr/81707
Jan 13, 2021
5ac094e
Merge branch 'master' of github.com:elastic/kibana into pr/81707
Jan 13, 2021
ae5bcc0
Fix management test
Jan 13, 2021
3a38aad
@Dosant code review
Jan 13, 2021
c030ed1
code review
Jan 13, 2021
83d4a73
Deleteed story
Jan 13, 2021
863f2cc
Merge branch 'master' of github.com:elastic/kibana into pr/81707
Jan 13, 2021
5992e03
Merge branch 'master' into feature/data/management-ui
kibanamachine Jan 14, 2021
fc3121d
Merge branch 'master' of github.com:elastic/kibana into pr/81707
Jan 14, 2021
aad9f73
some more code review stuffs
Jan 14, 2021
34cd742
fix ts
Jan 14, 2021
9e7ac84
Merge branch 'master' of github.com:elastic/kibana into pr/81707
Jan 17, 2021
22eba85
Code review and cleanup
Jan 17, 2021
49a9433
Added functional tests for restoring, reloading and canceling a dashb…
Jan 17, 2021
706129c
Don't show expiration time for canceled, expired or errored sessions
Jan 17, 2021
b7d91ee
fix jest
Jan 18, 2021
6c409ce
Merge branch 'master' of github.com:elastic/kibana into pr/81707
Jan 18, 2021
ba11297
Moved UISession to public
Jan 18, 2021
a0c9a5e
Merge branch 'master' into feature/data/management-ui
kibanamachine Jan 19, 2021
0f54a66
Merge branch 'master' of github.com:elastic/kibana into pr/81707
Jan 20, 2021
cdf1af6
@tsullivan code review
Jan 20, 2021
56c39f8
Fixed import
Jan 20, 2021
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
4 changes: 2 additions & 2 deletions src/plugins/data/public/search/session/sessions_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ export class SessionsClient {
});
}

public find(options: SavedObjectsFindOptions): Promise<SavedObjectsFindResponse> {
return this.http!.post(`/internal/session`, {
public find(options: Omit<SavedObjectsFindOptions, 'type'>): Promise<SavedObjectsFindResponse> {
return this.http!.post(`/internal/session/_find`, {
body: JSON.stringify(options),
});
}
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/data_enhanced/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export {
EqlSearchStrategyResponse,
IAsyncSearchOptions,
pollSearch,
SearchSessionSavedObject,
SearchSessionSavedObjectAttributes,
SearchSessionStatus,
SearchSessionRequestInfo,
Expand Down
8 changes: 7 additions & 1 deletion x-pack/plugins/data_enhanced/common/search/session/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SearchSessionStatus } from './';

export interface SearchSessionSavedObjectAttributes {
/**
* User-facing session name to be displayed in session management
Expand All @@ -24,7 +26,7 @@ export interface SearchSessionSavedObjectAttributes {
/**
* status
*/
status: string;
status: SearchSessionStatus;
/**
* urlGeneratorId
*/
Expand All @@ -45,6 +47,10 @@ export interface SearchSessionSavedObjectAttributes {
idMapping: Record<string, SearchSessionRequestInfo>;
}

export interface SearchSessionSavedObject {
lizozom marked this conversation as resolved.
Show resolved Hide resolved
id: string;
attributes: SearchSessionSavedObjectAttributes;
}
export interface SearchSessionRequestInfo {
/**
* ID of the async search request
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { SearchSessionStatus } from '../';

export enum ACTION {
EXTEND = 'extend',
CANCEL = 'cancel',
DELETE = 'delete',
lizozom marked this conversation as resolved.
Show resolved Hide resolved
}

export const DATE_STRING_FORMAT = 'D MMM, YYYY, HH:mm:ss';

export { SearchSessionStatus as STATUS };
23 changes: 23 additions & 0 deletions x-pack/plugins/data_enhanced/common/search/sessions_mgmt/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { ACTION, STATUS } from './constants';

export interface UISession {
id: string;
name: string;
appId: string;
created: string;
expires: string | null;
status: STATUS;
actions?: ACTION[];
isRestorable: boolean;
lizozom marked this conversation as resolved.
Show resolved Hide resolved
url: string;
}

export type ActionComplete = (result: UISession[]) => void;

export * from './constants';
6 changes: 6 additions & 0 deletions x-pack/plugins/data_enhanced/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ export const configSchema = schema.object({
search: schema.object({
sendToBackground: schema.object({
enabled: schema.boolean({ defaultValue: false }),
sessionsManagement: schema.object({
lizozom marked this conversation as resolved.
Show resolved Hide resolved
maxSessions: schema.number({ defaultValue: 10000 }),
refreshInterval: schema.duration({ defaultValue: '10s' }),
refreshTimeout: schema.duration({ defaultValue: '1m' }),
expiresSoonWarning: schema.duration({ defaultValue: '1d' }),
}),
}),
}),
});
Expand Down
11 changes: 2 additions & 9 deletions x-pack/plugins/data_enhanced/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,8 @@
"id": "dataEnhanced",
"version": "8.0.0",
"kibanaVersion": "kibana",
"configPath": [
"xpack", "data_enhanced"
],
"requiredPlugins": [
"bfetch",
"data",
"features",
"taskManager"
],
"configPath": ["xpack", "data_enhanced"],
"requiredPlugins": ["bfetch", "data", "features", "management", "share", "taskManager"],
"optionalPlugins": ["kibanaUtils", "usageCollection"],
"server": true,
"ui": true,
Expand Down
16 changes: 14 additions & 2 deletions x-pack/plugins/data_enhanced/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,25 @@ import React from 'react';
import { CoreSetup, CoreStart, Plugin, PluginInitializerContext } from 'src/core/public';
import { DataPublicPluginSetup, DataPublicPluginStart } from '../../../../src/plugins/data/public';
import { BfetchPublicSetup } from '../../../../src/plugins/bfetch/public';
import { ManagementSetup } from '../../../../src/plugins/management/public';
import { SharePluginStart } from '../../../../src/plugins/share/public';

import { setAutocompleteService } from './services';
import { setupKqlQuerySuggestionProvider, KUERY_LANGUAGE_NAME } from './autocomplete';
import { EnhancedSearchInterceptor } from './search/search_interceptor';
import { registerSearchSessionsMgmt } from './search/sessions_mgmt';
import { toMountPoint } from '../../../../src/plugins/kibana_react/public';
import { createConnectedSearchSessionIndicator } from './search';
import { ConfigSchema } from '../config';

export interface DataEnhancedSetupDependencies {
bfetch: BfetchPublicSetup;
data: DataPublicPluginSetup;
management: ManagementSetup;
}
export interface DataEnhancedStartDependencies {
data: DataPublicPluginStart;
share: SharePluginStart;
}

export type DataEnhancedSetup = ReturnType<DataEnhancedPlugin['setup']>;
Expand All @@ -30,12 +35,13 @@ export type DataEnhancedStart = ReturnType<DataEnhancedPlugin['start']>;
export class DataEnhancedPlugin
implements Plugin<void, void, DataEnhancedSetupDependencies, DataEnhancedStartDependencies> {
private enhancedSearchInterceptor!: EnhancedSearchInterceptor;
private config!: ConfigSchema;

constructor(private initializerContext: PluginInitializerContext<ConfigSchema>) {}

public setup(
core: CoreSetup<DataEnhancedStartDependencies>,
{ bfetch, data }: DataEnhancedSetupDependencies
{ bfetch, data, management }: DataEnhancedSetupDependencies
) {
data.autocomplete.addQuerySuggestionProvider(
KUERY_LANGUAGE_NAME,
Expand All @@ -57,12 +63,18 @@ export class DataEnhancedPlugin
searchInterceptor: this.enhancedSearchInterceptor,
},
});

this.config = this.initializerContext.config.get<ConfigSchema>();
if (this.config.search.sendToBackground.enabled) {
const { sessionsManagement: sessionsMgmtConfig } = this.config.search.sendToBackground;
registerSearchSessionsMgmt(core, sessionsMgmtConfig, { management });
}
}

public start(core: CoreStart, plugins: DataEnhancedStartDependencies) {
setAutocompleteService(plugins.data.autocomplete);

if (this.initializerContext.config.get().search.sendToBackground.enabled) {
if (this.config.search.sendToBackground.enabled) {
core.chrome.setBreadcrumbsAppendExtension({
content: toMountPoint(
React.createElement(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React, { ReactNode } from 'react';
import { IntlProvider } from 'react-intl';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { UrlGeneratorsStart } from '../../../../../../../src/plugins/share/public/url_generators';

export function LocaleWrapper({ children }: { children?: ReactNode }) {
return <IntlProvider locale="en">{children}</IntlProvider>;
}

export const mockUrls = ({
getUrlGenerator: (id: string) => ({ createUrl: () => `hello-cool-${id}-url` }),
} as unknown) as UrlGeneratorsStart;
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { CoreSetup } from 'kibana/public';
import type { ManagementAppMountParams } from 'src/plugins/management/public';
import type {
AppDependencies,
IManagementSectionsPluginsSetup,
IManagementSectionsPluginsStart,
SessionsMgmtConfigSchema,
} from '../';
import { APP } from '../';
import { SearchSessionsMgmtAPI } from '../lib/api';
import { AsyncSearchIntroDocumentation } from '../lib/documentation';
import { renderApp } from './render';

export class SearchSessionsMgmtApp {
constructor(
private coreSetup: CoreSetup<IManagementSectionsPluginsStart>,
private config: SessionsMgmtConfigSchema,
private params: ManagementAppMountParams,
private pluginsSetup: IManagementSectionsPluginsSetup
) {}

public async mountManagementSection() {
const { coreSetup, params, pluginsSetup } = this;
const [coreStart, pluginsStart] = await coreSetup.getStartServices();

const {
chrome: { docTitle },
http,
docLinks,
i18n,
notifications,
uiSettings,
} = coreStart;
const { data, share } = pluginsStart;

const pluginName = APP.getI18nName();
docTitle.change(pluginName);
params.setBreadcrumbs([{ text: pluginName }]);

const { sessionsClient } = data.search;
const api = new SearchSessionsMgmtAPI(
sessionsClient,
share.urlGenerators,
notifications,
this.config
);

const documentation = new AsyncSearchIntroDocumentation(docLinks);
tsullivan marked this conversation as resolved.
Show resolved Hide resolved

const dependencies: AppDependencies = {
plugins: pluginsSetup,
config: this.config,
documentation,
core: coreStart,
api,
http,
i18n,
uiSettings,
share,
};

const { element } = params;
const unmountAppCb = renderApp(element, dependencies);

return () => {
docTitle.reset();
unmountAppCb();
};
}
}

export { renderApp };
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import { AppDependencies } from '../';
import { createKibanaReactContext } from '../../../../../../../src/plugins/kibana_react/public';
import { SearchSessionsMgmtMain } from '../components/main';

export const renderApp = (
elem: HTMLElement | null,
{ i18n, uiSettings, ...homeDeps }: AppDependencies
) => {
if (!elem) {
return () => undefined;
}

const { Context: I18nContext } = i18n;
// uiSettings is required by the listing table to format dates in the timezone from Settings
const { Provider: KibanaReactContextProvider } = createKibanaReactContext({
uiSettings,
});

render(
<I18nContext>
<KibanaReactContextProvider>
<SearchSessionsMgmtMain {...homeDeps} timezone={uiSettings.get('dateFormat:tz')} />
</KibanaReactContextProvider>
</I18nContext>,
elem
);

return () => {
unmountComponentAtNode(elem);
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import { i18n } from '@kbn/i18n';
import React from 'react';
import { IClickActionDescriptor } from '../';
import { ACTION, ActionComplete, UISession } from '../../../../../common/search/sessions_mgmt';
import extendSessionIcon from '../../icons/extend_session.svg';
lizozom marked this conversation as resolved.
Show resolved Hide resolved
import { SearchSessionsMgmtAPI } from '../../lib/api';
import { DeleteButton } from '../delete_button';

export const getAction = (
api: SearchSessionsMgmtAPI,
actionType: string,
{ id }: UISession,
actionComplete: ActionComplete
): IClickActionDescriptor | null => {
switch (actionType) {
case ACTION.CANCEL:
return {
iconType: 'crossInACircleFilled',
textColor: 'default',
label: i18n.translate('xpack.data.mgmt.searchSessions.actionCancel', {
defaultMessage: 'Cancel',
}),
};

case ACTION.DELETE:
return {
iconType: 'trash',
textColor: 'danger',
label: <DeleteButton api={api} id={id} actionComplete={actionComplete} />,
};

case ACTION.EXTEND:
return {
iconType: extendSessionIcon,
textColor: 'default',
label: i18n.translate('xpack.data.mgmt.searchSessions.actionExtend', {
defaultMessage: 'Extend',
}),
};

default:
// eslint-disable-next-line no-console
console.error(`Unknown action: ${actionType}`);
}

// Unknown action: do not show

return null;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

export { PopoverActionsMenu } from './popover_actions';
Loading