mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* resolve merge conflicts * fix types * fix * fix test
This commit is contained in:
parent
7c50f90d4e
commit
2a5f75f8d2
4 changed files with 5 additions and 78 deletions
|
@ -22,7 +22,7 @@ import { Sort } from './sort';
|
|||
import { getDefaultControlColumn } from './control_columns';
|
||||
import { useMountAppended } from '../../../../common/utils/use_mount_appended';
|
||||
import { timelineActions } from '../../../store/timeline';
|
||||
import { ColumnHeaderOptions, TimelineTabs } from '../../../../../common/types/timeline';
|
||||
import { TimelineTabs } from '../../../../../common/types/timeline';
|
||||
import { defaultRowRenderers } from './renderers';
|
||||
|
||||
jest.mock('../../../../common/lib/kibana/hooks');
|
||||
|
@ -210,30 +210,7 @@ describe('Body', () => {
|
|||
});
|
||||
});
|
||||
}, 20000);
|
||||
|
||||
test('it dispatches the `REMOVE_COLUMN` action when there is a field removed from the custom fields', async () => {
|
||||
const customFieldId = 'my.custom.runtimeField';
|
||||
const extraFieldProps = {
|
||||
...props,
|
||||
columnHeaders: [
|
||||
...defaultHeaders,
|
||||
{ id: customFieldId, category: 'my' } as ColumnHeaderOptions,
|
||||
],
|
||||
};
|
||||
mount(
|
||||
<TestProviders>
|
||||
<BodyComponent {...extraFieldProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
expect(mockDispatch).toBeCalledTimes(1);
|
||||
expect(mockDispatch).toBeCalledWith({
|
||||
payload: { columnId: customFieldId, id: 'timeline-test' },
|
||||
type: 'x-pack/timelines/t-grid/REMOVE_COLUMN',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('action on event', () => {
|
||||
const addaNoteToEvent = (wrapper: ReturnType<typeof mount>, note: string) => {
|
||||
wrapper.find('[data-test-subj="add-note"]').first().find('button').simulate('click');
|
||||
|
|
|
@ -5,10 +5,10 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
import { noop, isEmpty } from 'lodash/fp';
|
||||
import { noop } from 'lodash/fp';
|
||||
import memoizeOne from 'memoize-one';
|
||||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { connect, ConnectedProps, useDispatch } from 'react-redux';
|
||||
import { connect, ConnectedProps } from 'react-redux';
|
||||
import deepEqual from 'fast-deep-equal';
|
||||
|
||||
import {
|
||||
|
@ -100,7 +100,6 @@ export const BodyComponent = React.memo<StatefulBodyProps>(
|
|||
leadingControlColumns = [],
|
||||
trailingControlColumns = [],
|
||||
}) => {
|
||||
const dispatch = useDispatch();
|
||||
const containerRef = useRef<HTMLDivElement | null>(null);
|
||||
const getManageTimeline = useMemo(() => timelineSelectors.getManageTimelineById(), []);
|
||||
const { queryFields, selectAll } = useDeepEqualSelector((state) =>
|
||||
|
@ -145,19 +144,6 @@ export const BodyComponent = React.memo<StatefulBodyProps>(
|
|||
}
|
||||
}, [isSelectAllChecked, onSelectAll, selectAll]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isEmpty(browserFields) && !isEmpty(columnHeaders)) {
|
||||
columnHeaders.forEach(({ id: columnId }) => {
|
||||
if (browserFields.base?.fields?.[columnId] == null) {
|
||||
const [category] = columnId.split('.');
|
||||
if (browserFields[category]?.fields?.[columnId] == null) {
|
||||
dispatch(timelineActions.removeColumn({ id, columnId }));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [browserFields, columnHeaders, dispatch, id]);
|
||||
|
||||
const enabledRowRenderers = useMemo(() => {
|
||||
if (
|
||||
excludedRowRendererIds &&
|
||||
|
|
|
@ -14,7 +14,7 @@ import { REMOVE_COLUMN } from './column_headers/translations';
|
|||
import { Direction } from '../../../../common/search_strategy';
|
||||
import { useMountAppended } from '../../utils/use_mount_appended';
|
||||
import { defaultHeaders, mockBrowserFields, mockTimelineData, TestProviders } from '../../../mock';
|
||||
import { ColumnHeaderOptions, TimelineTabs } from '../../../../common/types/timeline';
|
||||
import { TimelineTabs } from '../../../../common/types/timeline';
|
||||
import { TestCellRenderer } from '../../../mock/cell_renderer';
|
||||
import { mockGlobalState } from '../../../mock/global_state';
|
||||
import { EuiDataGridColumn } from '@elastic/eui';
|
||||
|
@ -335,26 +335,4 @@ describe('Body', () => {
|
|||
type: 'x-pack/timelines/t-grid/UPDATE_COLUMN_WIDTH',
|
||||
});
|
||||
});
|
||||
|
||||
test('it dispatches the `REMOVE_COLUMN` action when there is a field removed from the custom fields', async () => {
|
||||
const customFieldId = 'my.custom.runtimeField';
|
||||
const extraFieldProps = {
|
||||
...props,
|
||||
columnHeaders: [
|
||||
...defaultHeaders,
|
||||
{ id: customFieldId, category: 'my' } as ColumnHeaderOptions,
|
||||
],
|
||||
};
|
||||
render(
|
||||
<TestProviders>
|
||||
<BodyComponent {...extraFieldProps} />
|
||||
</TestProviders>
|
||||
);
|
||||
|
||||
expect(mockDispatch).toBeCalledTimes(1);
|
||||
expect(mockDispatch).toBeCalledWith({
|
||||
payload: { columnId: customFieldId, id: 'timeline-test' },
|
||||
type: 'x-pack/timelines/t-grid/REMOVE_COLUMN',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -17,7 +17,7 @@ import {
|
|||
EuiFlexItem,
|
||||
EuiProgress,
|
||||
} from '@elastic/eui';
|
||||
import { getOr, isEmpty } from 'lodash/fp';
|
||||
import { getOr } from 'lodash/fp';
|
||||
import memoizeOne from 'memoize-one';
|
||||
import React, {
|
||||
ComponentType,
|
||||
|
@ -395,20 +395,6 @@ export const BodyComponent = React.memo<StatefulBodyProps>(
|
|||
}
|
||||
}, [isSelectAllChecked, onSelectPage, selectAll]);
|
||||
|
||||
// Clean any removed custom field that may still be present in stored columnHeaders
|
||||
useEffect(() => {
|
||||
if (!isEmpty(browserFields) && !isEmpty(columnHeaders)) {
|
||||
columnHeaders.forEach(({ id: columnId }) => {
|
||||
if (browserFields.base?.fields?.[columnId] == null) {
|
||||
const [category] = columnId.split('.');
|
||||
if (browserFields[category]?.fields?.[columnId] == null) {
|
||||
dispatch(tGridActions.removeColumn({ id, columnId }));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [browserFields, columnHeaders, dispatch, id]);
|
||||
|
||||
const onAlertStatusActionSuccess = useMemo(() => {
|
||||
if (bulkActions && bulkActions !== true) {
|
||||
return bulkActions.onAlertStatusActionSuccess;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue