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

[8.11] [Security Solution] Adds feature flag to enable/disable ESQL in timeline (#174029) #174112

Merged
merged 4 commits into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ export const allowedExperimentalValues = Object.freeze({
* Enables Protection Updates tab in the Endpoint Policy Details page
*/
protectionUpdatesEnabled: true,

/*
* Disables discover esql tab within timeline
*
*/
timelineEsqlTabDisabled: false,
});

type ExperimentalConfigKeys = Array<keyof ExperimentalFeatures>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
} from '../../timelines/store/timeline/actions';
import { useDiscoverInTimelineContext } from '../../common/components/discover_in_timeline/use_discover_in_timeline_context';
import { useShowTimeline } from '../../common/utils/timeline/use_show_timeline';
import { useIsExperimentalFeatureEnabled } from '../../common/hooks/use_experimental_features';

export interface SendToTimelineButtonProps {
asEmptyButton: boolean;
Expand All @@ -60,6 +61,8 @@ export const SendToTimelineButton: React.FunctionComponent<SendToTimelineButtonP
const [isTimelineBottomBarVisible] = useShowTimeline();
const { discoverStateContainer } = useDiscoverInTimelineContext();

const isEsqlTabInTimelineDisabled = useIsExperimentalFeatureEnabled('timelineEsqlTabDisabled');

const getDataViewsSelector = useMemo(
() => sourcererSelectors.getSourcererDataViewsSelector(),
[]
Expand Down Expand Up @@ -226,6 +229,13 @@ export const SendToTimelineButton: React.FunctionComponent<SendToTimelineButtonP
: ACTION_CANNOT_INVESTIGATE_IN_TIMELINE;
const isDisabled = !isTimelineBottomBarVisible;

if (
(dataProviders?.[0]?.queryType === 'esql' || dataProviders?.[0]?.queryType === 'sql') &&
isEsqlTabInTimelineDisabled
) {
return null;
}

return asEmptyButton ? (
<EuiButtonEmpty
aria-label={toolTipText}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { useCallback } from 'react';

import { useDispatch } from 'react-redux';

import { TimelineTabs } from '../../../../common/types';
import { useInitializeUrlParam } from '../../utils/global_query_string';
import {
dispatchUpdateTimeline,
Expand All @@ -17,15 +18,21 @@ import {
import type { TimelineUrl } from '../../../timelines/store/timeline/model';
import { timelineActions } from '../../../timelines/store/timeline';
import { URL_PARAM_KEY } from '../use_url_state';
import { useIsExperimentalFeatureEnabled } from '../use_experimental_features';

export const useInitTimelineFromUrlParam = () => {
const dispatch = useDispatch();

const isEsqlTabDisabled = useIsExperimentalFeatureEnabled('timelineEsqlTabDisabled');

const onInitialize = useCallback(
(initialState: TimelineUrl | null) => {
if (initialState != null) {
queryTimelineById({
activeTimelineTab: initialState.activeTab,
activeTimelineTab:
initialState.activeTab === TimelineTabs.esql && isEsqlTabDisabled
? TimelineTabs.query
: initialState.activeTab,
duplicate: false,
graphEventId: initialState.graphEventId,
timelineId: initialState.id,
Expand All @@ -37,7 +44,7 @@ export const useInitTimelineFromUrlParam = () => {
});
}
},
[dispatch]
[dispatch, isEsqlTabDisabled]
);

useInitializeUrlParam(URL_PARAM_KEY.timeline, onInitialize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { useDispatch } from 'react-redux';
import styled from 'styled-components';

import { FormattedMessage } from '@kbn/i18n-react';
import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features';
import { useKibana } from '../../../../common/lib/kibana';
import { useAssistantTelemetry } from '../../../../assistant/use_assistant_telemetry';
import { useConversationStore } from '../../../../assistant/use_conversation_store';
import { useAssistantAvailability } from '../../../../assistant/use_assistant_availability';
Expand Down Expand Up @@ -132,6 +134,7 @@ const ActiveTimelineTab = memo<ActiveTimelineTabProps>(
setConversationId,
showTimeline,
}) => {
const isEsqlSettingEnabled = useKibana().services.configSettings.ESQLEnabled;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@logeekal, based on the note in #173640, I think we need to remove all occurrences of isEsqlSettingEnabled.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@spong, Conditional render should same as here without isEsqlSettingEnabled. Does that make sense?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const { hasAssistantPrivilege } = useAssistantAvailability();
const getTab = useCallback(
(tab: TimelineTabs) => {
Expand Down Expand Up @@ -179,12 +182,14 @@ const ActiveTimelineTab = memo<ActiveTimelineTabProps>(
timelineId={timelineId}
/>
</HideShowContainer>
<HideShowContainer
$isVisible={TimelineTabs.esql === activeTimelineTab}
data-test-subj={`timeline-tab-content-${TimelineTabs.esql}`}
>
<EsqlTab timelineId={timelineId} />
</HideShowContainer>
{showTimeline && isEsqlSettingEnabled && activeTimelineTab === TimelineTabs.esql && (
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this conditional goes away entirely as well since not already in 8.11?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This conditional is now the same as https://github.com/elastic/kibana/pull/173640/files#diff-c9eb10e636b9cedb21368945df018d08cb60b87ccf469be22cbab0abd7ae5ed3R182, which should merge first and be an empty change here.

<HideShowContainer
$isVisible={true}
data-test-subj={`timeline-tab-content-${TimelineTabs.esql}`}
>
<EsqlTab timelineId={timelineId} />
</HideShowContainer>
)}
<HideShowContainer
$isVisible={TimelineTabs.pinned === activeTimelineTab}
data-test-subj={`timeline-tab-content-${TimelineTabs.pinned}`}
Expand Down Expand Up @@ -281,6 +286,8 @@ const TabsContentComponent: React.FC<BasicTimelineTab> = ({
sessionViewConfig,
timelineDescription,
}) => {
const isEsqlTabInTimelineDisabled = useIsExperimentalFeatureEnabled('timelineEsqlTabDisabled');
const isEsqlSettingEnabled = useKibana().services.configSettings.ESQLEnabled;
spong marked this conversation as resolved.
Show resolved Hide resolved
const { hasAssistantPrivilege } = useAssistantAvailability();
const dispatch = useDispatch();
const getActiveTab = useMemo(() => getActiveTabSelector(), []);
Expand Down Expand Up @@ -394,26 +401,28 @@ const TabsContentComponent: React.FC<BasicTimelineTab> = ({
<span>{i18n.QUERY_TAB}</span>
{showTimeline && <TimelineEventsCountBadge />}
</StyledEuiTab>
<StyledEuiTab
data-test-subj={`timelineTabs-${TimelineTabs.esql}`}
onClick={setEsqlAsActiveTab}
isSelected={activeTab === TimelineTabs.esql}
disabled={false}
key={TimelineTabs.esql}
>
<span>{i18n.DISCOVER_ESQL_IN_TIMELINE_TAB}</span>
<StyledEuiBetaBadge
label={DISCOVER_ESQL_IN_TIMELINE_TECHNICAL_PREVIEW}
size="s"
iconType="beaker"
tooltipContent={
<FormattedMessage
id="xpack.securitySolution.timeline.tabs.discoverEsqlInTimeline.technicalPreviewTooltip"
defaultMessage="This functionality is in technical preview and may be changed or removed completely in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features."
/>
}
/>
</StyledEuiTab>
{!isEsqlTabInTimelineDisabled && isEsqlSettingEnabled && (
<StyledEuiTab
data-test-subj={`timelineTabs-${TimelineTabs.esql}`}
onClick={setEsqlAsActiveTab}
isSelected={activeTab === TimelineTabs.esql}
disabled={false}
key={TimelineTabs.esql}
>
<span>{i18n.DISCOVER_ESQL_IN_TIMELINE_TAB}</span>
<StyledEuiBetaBadge
label={DISCOVER_ESQL_IN_TIMELINE_TECHNICAL_PREVIEW}
size="s"
iconType="beaker"
tooltipContent={
<FormattedMessage
id="xpack.securitySolution.timeline.tabs.discoverEsqlInTimeline.technicalPreviewTooltip"
defaultMessage="This functionality is in technical preview and may be changed or removed completely in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features."
/>
}
/>
</StyledEuiTab>
)}
{timelineType === TimelineType.default && (
<StyledEuiTab
data-test-subj={`timelineTabs-${TimelineTabs.eql}`}
Expand Down