Skip to content

Commit

Permalink
Revert "Rename action from insertTimeline to attachTimeline"
Browse files Browse the repository at this point in the history
This reverts commit 5e0db78.
  • Loading branch information
cnasikas committed Nov 30, 2020
1 parent ff53a8a commit b49be2d
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { APP_ID } from '../../../../common/constants';
import { SecurityPageName } from '../../../app/types';
import { useKibana } from '../../../common/lib/kibana';
import { getCaseDetailsUrl, getCreateCaseUrl } from '../../../common/components/link_to';
import { setAttachTimeline } from '../../../timelines/store/timeline/actions';
import { setInsertTimeline } from '../../../timelines/store/timeline/actions';
import { timelineSelectors } from '../../../timelines/store/timeline';

import { AllCasesModal } from './all_cases_modal';
Expand Down Expand Up @@ -51,7 +51,7 @@ export const useAllCasesModal = ({
});

dispatch(
setAttachTimeline({
setInsertTimeline({
graphEventId: timeline.graphEventId ?? '',
timelineId,
timelineSavedObjectId: timeline.savedObjectId ?? '',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import { getTimelineUrl, useFormatUrl } from '../../../common/components/link_to
import { useShallowEqualSelector } from '../../../common/hooks/use_selector';
import { timelineSelectors, timelineActions } from '../../../timelines/store/timeline';
import { SecurityPageName } from '../../../app/types';
import { setAttachTimeline } from '../../../timelines/store/timeline/actions';
import { setInsertTimeline } from '../../../timelines/store/timeline/actions';

interface UseInsertTimelineReturn {
handleOnTimelineAttached: (title: string, id: string | null, graphEventId?: string) => void;
handleOnTimelineChange: (title: string, id: string | null, graphEventId?: string) => void;
}

export const useInsertTimeline = (
Expand All @@ -25,9 +25,9 @@ export const useInsertTimeline = (
const dispatch = useDispatch();
const { formatUrl } = useFormatUrl(SecurityPageName.timelines);

const attachTimeline = useShallowEqualSelector(timelineSelectors.selectAttachTimeline);
const insertTimeline = useShallowEqualSelector(timelineSelectors.selectInsertTimeline);

const handleOnTimelineAttached = useCallback(
const handleOnTimelineChange = useCallback(
(title: string, id: string | null, graphEventId?: string) => {
const url = formatUrl(getTimelineUrl(id ?? '', graphEventId), {
absolute: true,
Expand All @@ -46,18 +46,18 @@ export const useInsertTimeline = (
);

useEffect(() => {
if (attachTimeline != null && value != null) {
dispatch(timelineActions.showTimeline({ id: attachTimeline.timelineId, show: false }));
handleOnTimelineAttached(
attachTimeline.timelineTitle,
attachTimeline.timelineSavedObjectId,
attachTimeline.graphEventId
if (insertTimeline != null && value != null) {
dispatch(timelineActions.showTimeline({ id: insertTimeline.timelineId, show: false }));
handleOnTimelineChange(
insertTimeline.timelineTitle,
insertTimeline.timelineSavedObjectId,
insertTimeline.graphEventId
);
dispatch(setAttachTimeline(null));
dispatch(setInsertTimeline(null));
}
}, [attachTimeline, dispatch, handleOnTimelineAttached, value]);
}, [insertTimeline, dispatch, handleOnTimelineChange, value]);

return {
handleOnTimelineAttached,
handleOnTimelineChange,
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export const mockGlobalState: State = {
status: TimelineStatus.active,
},
},
attachTimeline: null,
insertTimeline: null,
},
sourcerer: {
...initialSourcererState,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ import {
StyledStar,
} from './styles';
import * as i18n from './translations';
import { setAttachTimeline, showTimeline, TimelineInput } from '../../../store/timeline/actions';
import { setInsertTimeline, showTimeline, TimelineInput } from '../../../store/timeline/actions';
import { useCreateTimelineButton } from './use_create_timeline';

export const historyToolTip = 'The chronological history of actions related to this timeline';
Expand Down Expand Up @@ -111,7 +111,7 @@ export const StarIcon = React.memo<{
// TODO: 2 error is: Elements with the 'button' interactive role must be focusable
// TODO: Investigate this error
// eslint-disable-next-line
<div role="button" onClick={handleClick}>
<div role="button" onClick={handleClick}>
{isFavorite ? (
<EuiToolTip data-test-subj="timeline-favorite-filled-star-tool-tip" content={i18n.FAVORITE}>
<StyledStar data-test-subj="timeline-favorite-filled-star" type="starFilled" size="l" />
Expand Down Expand Up @@ -299,7 +299,7 @@ export const NewCase = React.memo<NewCaseProps>(
path: getCreateCaseUrl(),
}).then(() =>
dispatch(
setAttachTimeline({
setInsertTimeline({
graphEventId,
timelineId,
timelineSavedObjectId: savedObjectId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import '../../../../common/mock/match_media';
import { createStore, State } from '../../../../common/store';
import { useThrottledResizeObserver } from '../../../../common/components/utils';
import { Properties, showDescriptionThreshold, showNotesThreshold } from '.';
import { setAttachTimeline } from '../../../store/timeline/actions';
import { setInsertTimeline } from '../../../store/timeline/actions';
export { nextTick } from '@kbn/test/jest';
import { waitFor } from '@testing-library/react';

Expand Down Expand Up @@ -375,7 +375,7 @@ describe('Properties', () => {
await waitFor(() => {
expect(mockNavigateToApp).toBeCalledWith('securitySolution:case', { path: '/create' });
expect(mockDispatch).toBeCalledWith(
setAttachTimeline({
setInsertTimeline({
timelineId: defaultProps.timelineId,
timelineSavedObjectId: '1',
timelineTitle: 'coolness',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
TimelineTypeLiteral,
RowRendererId,
} from '../../../../common/types/timeline';
import { AttachTimeline } from './types';
import { InsertTimeline } from './types';

const actionCreator = actionCreatorFactory('x-pack/security_solution/local/timeline');

Expand Down Expand Up @@ -116,7 +116,7 @@ export const addTimeline = actionCreator<{
savedTimeline?: boolean;
}>('ADD_TIMELINE');

export const setAttachTimeline = actionCreator<AttachTimeline | null>('SET_ATTACH_TIMELINE');
export const setInsertTimeline = actionCreator<InsertTimeline | null>('SET_INSERT_TIMELINE');

export const startTimelineSaving = actionCreator<{
id: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
setEventsLoading,
setExcludedRowRendererIds,
setFilters,
setAttachTimeline,
setInsertTimeline,
setKqlFilterQueryDraft,
setSavedQueryId,
setSelected,
Expand Down Expand Up @@ -112,7 +112,7 @@ export const initialTimelineState: TimelineState = {
newTimelineModel: null,
},
showCallOutUnauthorizedMsg: false,
attachTimeline: null,
insertTimeline: null,
};

/** The reducer for all timeline actions */
Expand Down Expand Up @@ -505,9 +505,9 @@ export const timelineReducer = reducerWithInitialState(initialTimelineState)
timelineById: state.timelineById,
}),
}))
.case(setAttachTimeline, (state, attachTimeline) => ({
.case(setInsertTimeline, (state, insertTimeline) => ({
...state,
attachTimeline,
insertTimeline,
}))
.case(updateIndexNames, (state, { id, indexNames }) => ({
...state,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { isFromKueryExpressionValid } from '../../../common/lib/keury';
import { State } from '../../../common/store/types';

import { TimelineModel } from './model';
import { AutoSavedWarningMsg, AttachTimeline, TimelineById } from './types';
import { AutoSavedWarningMsg, InsertTimeline, TimelineById } from './types';

const selectTimelineById = (state: State): TimelineById => state.timeline.timelineById;

Expand All @@ -22,8 +22,8 @@ const selectCallOutUnauthorizedMsg = (state: State): boolean =>
export const selectTimeline = (state: State, timelineId: string): TimelineModel =>
state.timeline.timelineById[timelineId];

export const selectAttachTimeline = (state: State): AttachTimeline | null =>
state.timeline.attachTimeline;
export const selectInsertTimeline = (state: State): InsertTimeline | null =>
state.timeline.insertTimeline;

export const autoSaveMsgSelector = createSelector(selectAutoSaveMsg, (autoSaveMsg) => autoSaveMsg);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface TimelineById {
[id: string]: TimelineModel;
}

export interface AttachTimeline {
export interface InsertTimeline {
graphEventId?: string;
timelineId: string;
timelineSavedObjectId: string | null;
Expand All @@ -38,7 +38,7 @@ export interface TimelineState {
timelineById: TimelineById;
autoSavedWarningMsg: AutoSavedWarningMsg;
showCallOutUnauthorizedMsg: boolean;
attachTimeline: AttachTimeline | null;
insertTimeline: InsertTimeline | null;
}

export interface ActionTimeline extends Action<string> {
Expand Down

0 comments on commit b49be2d

Please sign in to comment.