Skip to content

Commit

Permalink
Add view mode
Browse files Browse the repository at this point in the history
  • Loading branch information
qn895 committed Nov 5, 2024
1 parent b3c356e commit bafff15
Showing 1 changed file with 6 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/

import React, { useMemo, useEffect, useState, type ReactElement, useCallback } from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiTab, EuiTabs, EuiToolTip, useEuiTheme } from '@elastic/eui';
import { EuiFlexGroup, EuiFlexItem, EuiTab, EuiTabs, useEuiTheme } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { css } from '@emotion/react';
import { isLegacyTableEnabled, SHOW_FIELD_STATISTICS } from '@kbn/discover-utils';
Expand Down Expand Up @@ -46,12 +46,6 @@ export const DocumentViewModeToggle = ({
() => isLegacyTableEnabled({ uiSettings, isEsqlMode }),
[uiSettings, isEsqlMode]
);
const state = stateContainer.appState.getState();
const fieldStatsWarningMsgForQuery = useMemo(() => {
return isEsqlMode
? dataVisualizerService?.getReasonIfFieldStatsUnavailableForQuery(state.query)
: undefined;
}, [state.query, dataVisualizerService, isEsqlMode]);

const [showPatternAnalysisTab, setShowPatternAnalysisTab] = useState<boolean | null>(null);
const showFieldStatisticsTab = useMemo(
Expand Down Expand Up @@ -171,17 +165,15 @@ export const DocumentViewModeToggle = ({

{showFieldStatisticsTab ? (
<EuiTab
disabled={isEsqlMode || fieldStatsWarningMsgForQuery !== undefined}
disabled={isEsqlMode}
isSelected={viewMode === VIEW_MODE.AGGREGATED_LEVEL}
onClick={() => setDiscoverViewMode(VIEW_MODE.AGGREGATED_LEVEL)}
data-test-subj="dscViewModeFieldStatsButton"
>
<EuiToolTip content={fieldStatsWarningMsgForQuery}>
<FormattedMessage
id="discover.viewModes.fieldStatistics.label"
defaultMessage="Field statistics"
/>
</EuiToolTip>
<FormattedMessage
id="discover.viewModes.fieldStatistics.label"
defaultMessage="Field statistics"
/>
</EuiTab>
) : null}
</EuiTabs>
Expand Down

0 comments on commit bafff15

Please sign in to comment.