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 all 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 @@ -56,8 +56,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
5 changes: 3 additions & 2 deletions 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 @@ -44,7 +46,6 @@ export interface SearchSessionSavedObjectAttributes {
*/
idMapping: Record<string, SearchSessionRequestInfo>;
}

export interface SearchSessionRequestInfo {
/**
* ID of the async search request
Expand Down
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 @@ -15,6 +15,12 @@ export const configSchema = schema.object({
inMemTimeout: schema.duration({ defaultValue: '1m' }),
maxUpdateRetries: schema.number({ defaultValue: 3 }),
defaultExpiration: schema.duration({ defaultValue: '7d' }),
management: schema.object({
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.sessions.enabled) {
const { management: sessionsMgmtConfig } = this.config.search.sessions;
registerSearchSessionsMgmt(core, sessionsMgmtConfig, { management });
}
}

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

if (this.initializerContext.config.get().search.sessions.enabled) {
if (this.config.search.sessions.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,
application,
} = 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, this.config, {
notifications,
urls: share.urlGenerators,
application,
});

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,89 @@
/*
* 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 { EuiConfirmModal, EuiOverlayMask } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import React, { useState } from 'react';
import { SearchSessionsMgmtAPI } from '../../lib/api';
import { TableText } from '../';
import { OnActionComplete } from './types';

interface CancelButtonProps {
id: string;
name: string;
api: SearchSessionsMgmtAPI;
onActionComplete: OnActionComplete;
}

const CancelConfirm = ({
onConfirmDismiss,
...props
}: CancelButtonProps & { onConfirmDismiss: () => void }) => {
const { id, name, api, onActionComplete } = props;
const [isLoading, setIsLoading] = useState(false);

const title = i18n.translate('xpack.data.mgmt.searchSessions.cancelModal.title', {
defaultMessage: 'Cancel search session',
});
const confirm = i18n.translate('xpack.data.mgmt.searchSessions.cancelModal.cancelButton', {
defaultMessage: 'Cancel',
});
const cancel = i18n.translate('xpack.data.mgmt.searchSessions.cancelModal.dontCancelButton', {
defaultMessage: 'Dismiss',
});
const message = i18n.translate('xpack.data.mgmt.searchSessions.cancelModal.message', {
defaultMessage: `Canceling the search session \'{name}\' will expire any cached results, so that quick restore will no longer be available. You will still be able to re-run it, using the reload action.`,
values: {
name,
},
});

return (
<EuiOverlayMask>
<EuiConfirmModal
title={title}
onCancel={onConfirmDismiss}
onConfirm={async () => {
setIsLoading(true);
await api.sendCancel(id);
onActionComplete();
}}
confirmButtonText={confirm}
confirmButtonDisabled={isLoading}
cancelButtonText={cancel}
defaultFocusedButton="confirm"
buttonColor="danger"
>
{message}
</EuiConfirmModal>
</EuiOverlayMask>
);
};

export const CancelButton = (props: CancelButtonProps) => {
const [showConfirm, setShowConfirm] = useState(false);

const onClick = () => {
setShowConfirm(true);
};

const onConfirmDismiss = () => {
setShowConfirm(false);
};

return (
<>
<TableText onClick={onClick}>
<FormattedMessage
id="xpack.data.mgmt.searchSessions.actionCancel"
defaultMessage="Cancel"
/>
</TableText>
{showConfirm ? <CancelConfirm {...props} onConfirmDismiss={onConfirmDismiss} /> : null}
</>
);
};
Loading