Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Security Solution] Add app id prop for navigateToApp #121139

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type { Filter } from '@kbn/es-query';
import { inputsModel, inputsSelectors, State } from '../../store';
import { inputsActions } from '../../store/actions';
import { ControlColumnProps, RowRenderer, TimelineId } from '../../../../common/types/timeline';
import { APP_UI_ID } from '../../../../common/constants';
import { timelineSelectors, timelineActions } from '../../../timelines/store/timeline';
import type { SubsetTimelineModel, TimelineModel } from '../../../timelines/store/timeline/model';
import { Status } from '../../../../common/detection_engine/schemas/common/schemas';
Expand Down Expand Up @@ -174,6 +175,7 @@ const StatefulEventsViewerComponent: React.FC<Props> = ({
<InspectButtonContainer>
{timelinesUi.getTGrid<'embedded'>({
additionalFilters,
appId: APP_UI_ID,
browserFields,
bulkActions,
columns,
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/timelines/public/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { Storage } from '../../../../../src/plugins/kibana_utils/public';
import type { DataPublicPluginStart } from '../../../../../src/plugins/data/public';
import { createStore } from '../store/t_grid';

import { TGrid as TGridComponent } from './tgrid';
import { TGrid as TGridComponent } from './t_grid';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did this not break the build before? 🤔

import type { TGridProps } from '../types';
import { DragDropContextWrapper } from './drag_and_drop';
import { initialTGridState } from '../store/t_grid/reducer';
Expand Down
11 changes: 6 additions & 5 deletions x-pack/plugins/timelines/public/components/rule_name/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,32 @@ import { useKibana } from '../../../../../../src/plugins/kibana_react/public';
interface RuleNameProps {
name: string;
id: string;
appId: string;
}

const appendSearch = (search?: string) =>
isEmpty(search) ? '' : `${search?.startsWith('?') ? search : `?${search}`}`;

const RuleNameComponents = ({ name, id }: RuleNameProps) => {
const RuleNameComponents = ({ name, id, appId }: RuleNameProps) => {
const { navigateToApp, getUrlForApp } = useKibana<CoreStart>().services.application;

const hrefRuleDetails = useMemo(
() =>
getUrlForApp('securitySolution', {
getUrlForApp(appId, {
deepLinkId: 'rules',
path: `/id/${id}${appendSearch(window.location.search)}`,
}),
[getUrlForApp, id]
[getUrlForApp, id, appId]
);
const goToRuleDetails = useCallback(
(ev) => {
ev.preventDefault();
navigateToApp('securitySolution', {
navigateToApp(appId, {
deepLinkId: 'rules',
path: `/id/${id}${appendSearch(window.location.search)}`,
});
},
[navigateToApp, id]
[navigateToApp, id, appId]
);
return (
// eslint-disable-next-line @elastic/eui/href-or-on-click
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ const StatefulAlertStatusBulkActions = lazy(
interface OwnProps {
activePage: number;
additionalControls?: React.ReactNode;
appId?: string;
browserFields: BrowserFields;
bulkActions?: BulkActionsProp;
createFieldComponent?: CreateFieldComponentType;
Expand Down Expand Up @@ -299,6 +300,7 @@ export const BodyComponent = React.memo<StatefulBodyProps>(
({
activePage,
additionalControls,
appId = '',
browserFields,
bulkActions = true,
clearSelected,
Expand Down Expand Up @@ -830,6 +832,7 @@ export const BodyComponent = React.memo<StatefulBodyProps>(
)}
{tableView === 'eventRenderedView' && (
<EventRenderedView
appId={appId}
alertToolbar={alertToolbar}
browserFields={browserFields}
events={data}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const StyledEuiBasicTable = styled(EuiBasicTable as BasicTableType)`

export interface EventRenderedViewProps {
alertToolbar: React.ReactNode;
appId: string;
browserFields: BrowserFields;
events: TimelineItem[];
leadingControlColumns: EuiDataGridControlColumn[];
Expand All @@ -87,6 +88,7 @@ export const PreferenceFormattedDate = React.memo(PreferenceFormattedDateCompone

const EventRenderedViewComponent = ({
alertToolbar,
appId,
browserFields,
events,
leadingControlColumns,
Expand Down Expand Up @@ -168,7 +170,7 @@ const EventRenderedViewComponent = ({
render: (name: unknown, item: TimelineItem) => {
const ruleName = get(item, `ecs.signal.rule.name`) ?? get(item, `ecs.${ALERT_RULE_NAME}`);
const ruleId = get(item, `ecs.signal.rule.id`) ?? get(item, `ecs.${ALERT_RULE_UUID}`);
return <RuleName name={ruleName} id={ruleId} />;
return <RuleName name={ruleName} id={ruleId} appId={appId} />;
},
},
{
Expand Down Expand Up @@ -209,7 +211,7 @@ const EventRenderedViewComponent = ({
width: '60%',
},
],
[ActionTitle, browserFields, events, leadingControlColumns, rowRenderers]
[ActionTitle, browserFields, events, leadingControlColumns, rowRenderers, appId]
);

const handleTableChange = useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

import React from 'react';

import type { TGridProps } from '../types';
import { TGridIntegrated, TGridIntegratedProps } from './t_grid/integrated';
import { TGridStandalone, TGridStandaloneProps } from './t_grid/standalone';
import type { TGridProps } from '../../types';
import { TGridIntegrated, TGridIntegratedProps } from './integrated';
import { TGridStandalone, TGridStandaloneProps } from './standalone';

export const TGrid = (props: TGridProps) => {
const { type, ...componentsProps } = props;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ const SECURITY_ALERTS_CONSUMERS = [AlertConsumers.SIEM];

export interface TGridIntegratedProps {
additionalFilters: React.ReactNode;
appId: string;
browserFields: BrowserFields;
bulkActions?: BulkActionsProp;
columns: ColumnHeaderOptions[];
Expand Down Expand Up @@ -138,6 +139,7 @@ export interface TGridIntegratedProps {

const TGridIntegratedComponent: React.FC<TGridIntegratedProps> = ({
additionalFilters,
appId,
browserFields,
bulkActions = true,
columns,
Expand Down Expand Up @@ -350,6 +352,7 @@ const TGridIntegratedComponent: React.FC<TGridIntegratedProps> = ({
<ScrollableFlexItem grow={1}>
<StatefulBody
activePage={pageInfo.activePage}
appId={appId}
browserFields={browserFields}
bulkActions={bulkActions}
createFieldComponent={createFieldComponent}
Expand Down
2 changes: 2 additions & 0 deletions x-pack/plugins/timelines/public/mock/t_grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const columnHeaders: ColumnHeaderOptions[] = [

export const tGridIntegratedProps: TGridIntegratedProps = {
additionalFilters: null,
appId: '',
browserFields: mockBrowserFields,
columns: columnHeaders,
dataProviders: mockDataProviders,
Expand Down Expand Up @@ -131,6 +132,7 @@ export const tGridIntegratedProps: TGridIntegratedProps = {

export const eventRenderedProps: EventRenderedViewProps = {
alertToolbar: <></>,
appId: '',
browserFields: mockBrowserFields,
events: mockTimelineData,
leadingControlColumns: [],
Expand Down