Skip to content

Commit

Permalink
Revert "[RAM] Add rule on click handler to global rule event log list" (
Browse files Browse the repository at this point in the history
#165332)

Reverts #165179

because of this PR #165115, we do
not need these changes anymore. Let's remove it to avoid confusion on
the props
  • Loading branch information
XavierM authored Aug 31, 2023
1 parent 083a10a commit 5ae86ee
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ export interface EventLogDataGrid {
onChangeItemsPerPage: (pageSize: number) => void;
onChangePage: (pageIndex: number) => void;
onFlyoutOpen?: (runLog: IExecutionLog) => void;
onRuleNameClick?: (ruleId: string) => void;
setVisibleColumns: (visibleColumns: string[]) => void;
setSortingColumns: (sortingColumns: EuiDataGridSorting['columns']) => void;
}
Expand Down Expand Up @@ -168,7 +167,6 @@ export const EventLogDataGrid = (props: EventLogDataGrid) => {
onChangeItemsPerPage,
onChangePage,
onFlyoutOpen,
onRuleNameClick,
} = props;

const { euiTheme } = useEuiTheme();
Expand Down Expand Up @@ -345,7 +343,6 @@ export const EventLogDataGrid = (props: EventLogDataGrid) => {
ruleId={ruleId}
spaceIds={spaceIds}
useExecutionStatus={isRuleUsingExecutionStatus}
onRuleNameClick={onRuleNameClick}
/>
</EuiFlexItem>
</EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,22 +147,4 @@ describe('rule_event_log_list_cell_renderer', () => {

window.location = savedLocation;
});

it('calls onRuleNameClick if the function is provided', () => {
const onRuleNameClick = jest.fn();

const wrapper1 = shallow(
<EventLogListCellRenderer
columnId="rule_name"
value="Rule"
ruleId="1"
spaceIds={['space1']}
onRuleNameClick={onRuleNameClick}
/>
);

wrapper1.find(EuiLink).simulate('click');

expect(onRuleNameClick).toHaveBeenCalledWith('1');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ interface EventLogListCellRendererProps {
ruleId?: string;
spaceIds?: string[];
useExecutionStatus?: boolean;
onRuleNameClick?: (ruleId: string) => void;
}

export const EventLogListCellRenderer = (props: EventLogListCellRendererProps) => {
Expand All @@ -48,7 +47,6 @@ export const EventLogListCellRenderer = (props: EventLogListCellRendererProps) =
ruleId,
spaceIds,
useExecutionStatus = true,
onRuleNameClick,
} = props;
const spacesData = useSpacesData();
const { http } = useKibana().services;
Expand Down Expand Up @@ -86,21 +84,15 @@ export const EventLogListCellRenderer = (props: EventLogListCellRendererProps) =
return ruleRoute;
}, [ruleId, ruleOnDifferentSpace, history, activeSpace, http, spaceIds]);

const onRuleNameClickInternal = useCallback(() => {
if (!ruleId) {
return;
}
if (onRuleNameClick) {
onRuleNameClick(ruleId);
return;
}
const onClickRuleName = useCallback(() => {
if (!ruleId) return;
if (ruleOnDifferentSpace) {
const newUrl = window.location.href.replace(window.location.pathname, ruleNamePathname);
window.open(newUrl, '_blank');
return;
}
history.push(ruleNamePathname);
}, [ruleNamePathname, history, ruleOnDifferentSpace, ruleId, onRuleNameClick]);
}, [ruleNamePathname, history, ruleOnDifferentSpace, ruleId]);

if (typeof value === 'undefined') {
return null;
Expand All @@ -121,7 +113,7 @@ export const EventLogListCellRenderer = (props: EventLogListCellRendererProps) =

if (columnId === 'rule_name' && ruleId) {
return (
<EuiLink onClick={onRuleNameClickInternal} data-href={ruleNamePathname}>
<EuiLink onClick={onClickRuleName} data-href={ruleNamePathname}>
{value}
</EuiLink>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export interface GlobalRuleEventLogListProps {
setHeaderActions?: RuleEventLogListCommonProps['setHeaderActions'];
localStorageKey?: RuleEventLogListCommonProps['localStorageKey'];
filteredRuleTypes?: RuleEventLogListCommonProps['filteredRuleTypes'];
onRuleNameClick?: RuleEventLogListCommonProps['onRuleNameClick'];
}

const GLOBAL_EVENT_LOG_LIST_STORAGE_KEY =
Expand All @@ -32,7 +31,7 @@ const REFRESH_TOKEN = {
};

export const GlobalRuleEventLogList = (props: GlobalRuleEventLogListProps) => {
const { setHeaderActions, localStorageKey, filteredRuleTypes, onRuleNameClick } = props;
const { setHeaderActions, localStorageKey, filteredRuleTypes } = props;
const { spaces } = useKibana().services;

// eslint-disable-next-line react-hooks/exhaustive-deps
Expand All @@ -52,7 +51,6 @@ export const GlobalRuleEventLogList = (props: GlobalRuleEventLogListProps) => {
localStorageKey={localStorageKey || GLOBAL_EVENT_LOG_LIST_STORAGE_KEY}
filteredRuleTypes={filteredRuleTypes}
setHeaderActions={setHeaderActions}
onRuleNameClick={onRuleNameClick}
/>
</SpacesContextWrapper>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ export interface RuleEventLogListCommonProps {
hasAllSpaceSwitch?: boolean;
filteredRuleTypes?: string[];
setHeaderActions?: (components?: React.ReactNode[]) => void;
onRuleNameClick?: (ruleId: string) => void;
}

export type RuleEventLogListTableProps<T extends RuleEventLogListOptions = 'default'> =
Expand All @@ -117,7 +116,6 @@ export const RuleEventLogListTable = <T extends RuleEventLogListOptions>(
hasAllSpaceSwitch = false,
setHeaderActions,
filteredRuleTypes,
onRuleNameClick,
} = props;

const { uiSettings, notifications } = useKibana().services;
Expand Down Expand Up @@ -629,7 +627,6 @@ export const RuleEventLogListTable = <T extends RuleEventLogListOptions>(
onChangeItemsPerPage={onChangeItemsPerPage}
onChangePage={onChangePage}
onFlyoutOpen={onFlyoutOpen}
onRuleNameClick={onRuleNameClick}
setVisibleColumns={setVisibleColumns}
setSortingColumns={setSortingColumns}
/>
Expand Down

0 comments on commit 5ae86ee

Please sign in to comment.