Skip to content

Commit

Permalink
Add app id prop for navigateToApp
Browse files Browse the repository at this point in the history
  • Loading branch information
kqualters-elastic committed Dec 13, 2021
1 parent b30e71d commit eb2ec6b
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 10 deletions.
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';
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
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

0 comments on commit eb2ec6b

Please sign in to comment.