Skip to content

Commit

Permalink
[Security Solution][THI] - remove obsolete timelineEsqlTabDisabled fe…
Browse files Browse the repository at this point in the history
…ature flag (#205175)

## Summary

This PR removes the `timelineEsqlTabDisabled` feature flag that was
introduced a long time ago and has been in `disabled: false` state for
many months.
I noticed that the line was moved in [this
PR](#176064) over 6 months ago but
the introduction of the feature precedes that.

No UI changes introduced!
  • Loading branch information
PhilippeOberti authored Jan 11, 2025
1 parent f833b18 commit 3d6f452
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,6 @@ export const allowedExperimentalValues = Object.freeze({
*/
jamfDataInAnalyzerEnabled: true,

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

/**
* Enables graph visualization in alerts flyout
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {
} from '../../timelines/store/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';
import { useSourcererDataView } from '../../sourcerer/containers';
import { useDiscoverState } from '../../timelines/components/timeline/tabs/esql/use_discover_state';

Expand Down Expand Up @@ -63,8 +62,6 @@ export const SendToTimelineButton: FC<PropsWithChildren<SendToTimelineButtonProp
const { dataViewId: timelineDataViewId } = useSourcererDataView(SourcererScopeName.timeline);
const { setDiscoverAppState } = useDiscoverState();

const isEsqlTabInTimelineDisabled = useIsExperimentalFeatureEnabled('timelineEsqlTabDisabled');

const signalIndexName = useSelector(sourcererSelectors.signalIndexName);
const defaultDataView = useSelector(sourcererSelectors.defaultDataView);

Expand Down Expand Up @@ -245,10 +242,7 @@ export const SendToTimelineButton: FC<PropsWithChildren<SendToTimelineButtonProp
: ACTION_CANNOT_INVESTIGATE_IN_TIMELINE;
const isDisabled = !isTimelineBottomBarVisible;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,14 @@ export const useEsqlAvailability = () => {
const { uiSettings } = useKibana().services;
const isEsqlAdvancedSettingEnabled = uiSettings?.get(ENABLE_ESQL);

const isTimelineEsqlFeatureFlagDisabled =
useIsExperimentalFeatureEnabled('timelineEsqlTabDisabled');

const isEsqlRuleTypeEnabled =
!useIsExperimentalFeatureEnabled('esqlRulesDisabled') && isEsqlAdvancedSettingEnabled;

return useMemo(
() => ({
isEsqlAdvancedSettingEnabled,
isEsqlRuleTypeEnabled,
isTimelineEsqlEnabledByFeatureFlag: !isTimelineEsqlFeatureFlagDisabled,
}),
[isEsqlAdvancedSettingEnabled, isTimelineEsqlFeatureFlagDisabled, isEsqlRuleTypeEnabled]
[isEsqlAdvancedSettingEnabled, isEsqlRuleTypeEnabled]
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,14 @@ import { safeDecode } from '@kbn/rison';
import { useSelector } from 'react-redux';

import type { State } from '../../store';
import { TimelineId, TimelineTabs } from '../../../../common/types';
import { TimelineId } from '../../../../common/types';
import { useInitializeUrlParam } from '../../utils/global_query_string';
import { useQueryTimelineById } from '../../../timelines/components/open_timeline/helpers';
import type { TimelineModel, TimelineUrl } from '../../../timelines/store/model';
import { selectTimelineById } from '../../../timelines/store/selectors';
import { URL_PARAM_KEY } from '../use_url_state';
import { useIsExperimentalFeatureEnabled } from '../use_experimental_features';

export const useInitTimelineFromUrlParam = () => {
const isEsqlTabDisabled = useIsExperimentalFeatureEnabled('timelineEsqlTabDisabled');

const queryTimelineById = useQueryTimelineById();
const activeTimeline = useSelector((state: State) =>
selectTimelineById(state, TimelineId.active)
Expand All @@ -30,10 +27,7 @@ export const useInitTimelineFromUrlParam = () => {
(initialState: TimelineUrl | null) => {
if (initialState != null) {
queryTimelineById({
activeTimelineTab:
initialState.activeTab === TimelineTabs.esql && isEsqlTabDisabled
? TimelineTabs.query
: initialState.activeTab,
activeTimelineTab: initialState.activeTab,
duplicate: false,
graphEventId: initialState.graphEventId,
timelineId: initialState.id,
Expand All @@ -42,7 +36,7 @@ export const useInitTimelineFromUrlParam = () => {
});
}
},
[isEsqlTabDisabled, queryTimelineById]
[queryTimelineById]
);

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jest.mock('react-router-dom', () => {
jest.mock('../../../../common/hooks/esql/use_esql_availability', () => ({
useEsqlAvailability: jest.fn().mockReturnValue({
isEsqlAdvancedSettingEnabled: true,
isTimelineEsqlEnabledByFeatureFlag: true,
}),
}));

Expand Down Expand Up @@ -73,22 +72,6 @@ describe('Timeline', () => {
it('should not show the esql tab when the advanced setting is disabled', async () => {
useEsqlAvailabilityMock.mockReturnValue({
isEsqlAdvancedSettingEnabled: false,
isTimelineEsqlEnabledByFeatureFlag: true,
});
render(
<TestProviders>
<TabsContent {...defaultProps} />
</TestProviders>
);

await waitFor(() => {
expect(screen.queryByTestId(esqlTabSubj)).toBeNull();
});
});
it('should not show the esql tab when the esql is disabled by feature flag', async () => {
useEsqlAvailabilityMock.mockReturnValue({
isEsqlAdvancedSettingEnabled: false,
isTimelineEsqlEnabledByFeatureFlag: false,
});
render(
<TestProviders>
Expand All @@ -113,7 +96,6 @@ describe('Timeline', () => {
it('should show the esql tab when the advanced setting is disabled', async () => {
useEsqlAvailabilityMock.mockReturnValue({
isESQLTabInTimelineEnabled: false,
isTimelineEsqlEnabledByFeatureFlag: true,
});

render(
Expand All @@ -126,23 +108,6 @@ describe('Timeline', () => {
expect(screen.queryByTestId(esqlTabSubj)).toBeVisible();
});
});

it('should not show the esql tab when the esql is disabled by the feature flag', async () => {
useEsqlAvailabilityMock.mockReturnValue({
isESQLTabInTimelineEnabled: true,
isTimelineEsqlEnabledByFeatureFlag: false,
});

render(
<TestProviders store={mockStore}>
<TabsContent {...defaultProps} />
</TestProviders>
);

await waitFor(() => {
expect(screen.queryByTestId(esqlTabSubj)).toBeNull();
});
});
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,14 @@ const ActiveTimelineTab = memo<ActiveTimelineTabProps>(
timelineType,
showTimeline,
}) => {
const { isTimelineEsqlEnabledByFeatureFlag, isEsqlAdvancedSettingEnabled } =
useEsqlAvailability();
const { isEsqlAdvancedSettingEnabled } = useEsqlAvailability();
const timelineESQLSavedSearch = useShallowEqualSelector((state) =>
selectTimelineESQLSavedSearchId(state, timelineId)
);
const shouldShowESQLTab = useMemo(() => {
// disabling esql feature from feature flag should unequivocally hide the tab
// irrespective of the fact that the advanced setting is enabled or
// not or existing esql query is present or not
if (!isTimelineEsqlEnabledByFeatureFlag) {
return false;
}
return isEsqlAdvancedSettingEnabled || timelineESQLSavedSearch != null;
}, [isEsqlAdvancedSettingEnabled, isTimelineEsqlEnabledByFeatureFlag, timelineESQLSavedSearch]);
const shouldShowESQLTab = useMemo(
() => isEsqlAdvancedSettingEnabled || timelineESQLSavedSearch != null,
[isEsqlAdvancedSettingEnabled, timelineESQLSavedSearch]
);
const getTab = useCallback(
(tab: TimelineTabs) => {
switch (tab) {
Expand Down Expand Up @@ -246,8 +240,7 @@ const TabsContentComponent: React.FC<BasicTimelineTab> = ({
const getAppNotes = useMemo(() => getNotesSelector(), []);
const getTimelineNoteIds = useMemo(() => getNoteIdsSelector(), []);
const getTimelinePinnedEventNotes = useMemo(() => getEventIdToNoteIdsSelector(), []);
const { isEsqlAdvancedSettingEnabled, isTimelineEsqlEnabledByFeatureFlag } =
useEsqlAvailability();
const { isEsqlAdvancedSettingEnabled } = useEsqlAvailability();

const timelineESQLSavedSearch = useShallowEqualSelector((state) =>
selectTimelineESQLSavedSearchId(state, timelineId)
Expand All @@ -263,15 +256,10 @@ const TabsContentComponent: React.FC<BasicTimelineTab> = ({

const activeTab = useShallowEqualSelector((state) => getActiveTab(state, timelineId));
const showTimeline = useShallowEqualSelector((state) => getShowTimeline(state, timelineId));
const shouldShowESQLTab = useMemo(() => {
// disabling esql feature from feature flag should unequivocally hide the tab
// irrespective of the fact that the advanced setting is enabled or
// not or existing esql query is present or not
if (!isTimelineEsqlEnabledByFeatureFlag) {
return false;
}
return isEsqlAdvancedSettingEnabled || timelineESQLSavedSearch != null;
}, [isEsqlAdvancedSettingEnabled, isTimelineEsqlEnabledByFeatureFlag, timelineESQLSavedSearch]);
const shouldShowESQLTab = useMemo(
() => isEsqlAdvancedSettingEnabled || timelineESQLSavedSearch != null,
[isEsqlAdvancedSettingEnabled, timelineESQLSavedSearch]
);

const numberOfPinnedEvents = useShallowEqualSelector((state) =>
getNumberOfPinnedEvents(state, timelineId)
Expand Down

0 comments on commit 3d6f452

Please sign in to comment.