Skip to content

Commit

Permalink
refactor: remove tab rendering and related tests from IndexCheckFlyou…
Browse files Browse the repository at this point in the history
…tComponent
  • Loading branch information
kapral18 committed Aug 21, 2024
1 parent 34bf5f5 commit ecb27b7
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,6 @@ describe('IndexCheckFlyout', () => {
);
});

it('should render tabs correctly, with latest check preselected', () => {
expect(screen.getByRole('tab', { name: 'Latest Check' })).toHaveAttribute(
'aria-selected',
'true'
);
expect(screen.getByRole('tab', { name: 'Latest Check' })).not.toBeDisabled();
expect(screen.getByRole('tab', { name: 'History' })).toHaveAttribute(
'aria-selected',
'false'
);
expect(screen.getByRole('tab', { name: 'History' })).toBeDisabled();
});

it('should render the correct index properties panel', () => {
expect(screen.getByTestId('indexStatsPanel')).toBeInTheDocument();
expect(screen.getByTestId('indexCheckFields')).toBeInTheDocument();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ import {
EuiFlyoutFooter,
EuiFlyoutHeader,
EuiSpacer,
EuiTab,
EuiTabs,
EuiText,
EuiTitle,
useGeneratedHtmlId,
} from '@elastic/eui';
import React, { useCallback, useEffect, useMemo, useState } from 'react';
import React, { useCallback, useEffect } from 'react';
import moment from 'moment';
import { useIndicesCheckContext } from '../../../contexts/indices_check_context';

Expand All @@ -32,7 +30,6 @@ import { IndexProperties } from '../../index_properties';
import { CHECK_NOW } from '../../summary_table/translations';
import { getIlmPhase } from '../helpers';
import { IndexResultBadge } from '../../index_result_badge';
import { HISTORY, LATEST_CHECK } from '../translations';
import { useCurrentWindowWidth } from '../../../use_current_window_width';

export interface Props {
Expand All @@ -44,18 +41,6 @@ export interface Props {
onClose: () => void;
}

const tabs = [
{
id: LATEST_CHECK,
name: LATEST_CHECK,
},
{
id: HISTORY,
name: HISTORY,
disabled: true,
},
];

export const IndexCheckFlyoutComponent: React.FC<Props> = ({
ilmExplain,
indexName,
Expand All @@ -73,7 +58,6 @@ export const IndexCheckFlyoutComponent: React.FC<Props> = ({
const isChecking = indexCheckState?.isChecking ?? false;
const partitionedFieldMetadata = indexCheckState?.partitionedFieldMetadata ?? null;
const indexResult = patternRollup?.results?.[indexName];
const [selectedTabId, setSelectedTabId] = useState(LATEST_CHECK);
const indexCheckFlyoutTitleId = useGeneratedHtmlId({
prefix: 'indexCheckFlyoutTitle',
});
Expand All @@ -97,21 +81,6 @@ export const IndexCheckFlyoutComponent: React.FC<Props> = ({
};
}, []);

const renderTabs = useMemo(
() =>
tabs.map((tab, index) => (
<EuiTab
onClick={() => setSelectedTabId(tab.id)}
isSelected={tab.id === selectedTabId}
key={index}
disabled={tab.disabled}
>
{tab.name}
</EuiTab>
)),
[selectedTabId]
);

return (
<div data-test-subj="indexCheckFlyout">
<EuiFlyout
Expand Down Expand Up @@ -139,8 +108,6 @@ export const IndexCheckFlyoutComponent: React.FC<Props> = ({
</EuiText>
</>
)}
<EuiSpacer />
<EuiTabs style={{ marginBottom: '-25px' }}>{renderTabs}</EuiTabs>
</EuiFlyoutHeader>
<EuiFlyoutBody>
<IndexProperties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,3 @@ export const LOADING_STATS = i18n.translate(
defaultMessage: 'Loading stats',
}
);

export const HISTORY = i18n.translate(
'securitySolutionPackages.ecsDataQualityDashboard.indexCheckFlyout.historyTab',
{
defaultMessage: 'History',
}
);

export const LATEST_CHECK = i18n.translate(
'securitySolutionPackages.ecsDataQualityDashboard.indexCheckFlyout.latestCheckTab',
{
defaultMessage: 'Latest Check',
}
);

0 comments on commit ecb27b7

Please sign in to comment.