-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unit tests for public components opensearch-project#383
[BUG] Detector Edit | Custom rule are not selected on update rules opensearch-project#406 Signed-off-by: Jovan Cvetkovic <[email protected]>
- Loading branch information
1 parent
67e02f2
commit e83a24f
Showing
35 changed files
with
1,170 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
public/pages/Ueba/components/RecentWidgets/RecentAggregators.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { EuiBasicTableColumn, EuiButton, EuiToolTip, EuiButtonIcon } from '@elastic/eui'; | ||
import { ROUTES } from '../../../../utils/constants'; | ||
import React, { useCallback, useContext, useEffect, useState } from 'react'; | ||
import { NotificationsStart } from 'opensearch-dashboards/public'; | ||
|
||
import { WidgetContainer } from '../../../Overview/components/Widgets/WidgetContainer'; | ||
import { TableWidget } from '../../../Overview/components/Widgets/TableWidget'; | ||
import { ServicesContext } from '../../../../services'; | ||
import { AggregatorItem } from '../../models/interfaces'; | ||
import { UebaViewModelActor } from '../../models/UebaViewModelActor'; | ||
import { BrowserServices } from '../../../../models/interfaces'; | ||
|
||
export interface AggregatorsProps { | ||
loading?: boolean; | ||
openFlyout: Function; | ||
services: BrowserServices; | ||
notifications: NotificationsStart; | ||
} | ||
|
||
export const RecentAggregators: React.FC<AggregatorsProps> = ({ | ||
loading = false, | ||
openFlyout, | ||
notifications, | ||
}) => { | ||
const services = useContext(ServicesContext); | ||
const uebaViewModelActor = services && new UebaViewModelActor(services, notifications); | ||
|
||
const [aggregatorItems, setAggregatorItems] = useState<AggregatorItem[]>([]); | ||
|
||
const actions = React.useMemo( | ||
() => [<EuiButton href={`#${ROUTES.UEBA_VIEW_AGGREGATORS}`}>View aggregators</EuiButton>], | ||
[] | ||
); | ||
|
||
const columns: EuiBasicTableColumn<AggregatorItem>[] = [ | ||
{ | ||
field: 'name', | ||
name: 'Name', | ||
sortable: true, | ||
align: 'left', | ||
}, | ||
{ | ||
field: 'description', | ||
name: 'Description', | ||
sortable: false, | ||
align: 'left', | ||
}, | ||
{ | ||
field: 'source_index', | ||
name: 'Source index', | ||
sortable: true, | ||
align: 'left', | ||
}, | ||
{ | ||
field: 'page_size', | ||
name: 'Page size', | ||
sortable: true, | ||
align: 'left', | ||
}, | ||
{ | ||
name: 'Details', | ||
sortable: false, | ||
actions: [ | ||
{ | ||
render: (aggregator: AggregatorItem) => ( | ||
<EuiToolTip content={'View details'}> | ||
<EuiButtonIcon | ||
aria-label={'View details'} | ||
data-test-subj={`view-details-icon`} | ||
iconType={'expand'} | ||
onClick={() => openFlyout(aggregator)} | ||
/> | ||
</EuiToolTip> | ||
), | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
const getAggregators = useCallback(async () => { | ||
const aggregators = await uebaViewModelActor?.getAggregators(); | ||
aggregators && setAggregatorItems(aggregators); | ||
}, [services]); | ||
|
||
useEffect(() => { | ||
getAggregators(); | ||
}, [getAggregators]); | ||
|
||
return ( | ||
<WidgetContainer title={'Recent aggregators'} actions={actions}> | ||
<TableWidget columns={columns} items={aggregatorItems} loading={loading} /> | ||
</WidgetContainer> | ||
); | ||
}; |
90 changes: 90 additions & 0 deletions
90
public/pages/Ueba/components/RecentWidgets/RecentInferences.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { EuiBasicTableColumn, EuiButton, EuiToolTip, EuiButtonIcon } from '@elastic/eui'; | ||
import { ROUTES } from '../../../../utils/constants'; | ||
import React, { useCallback, useContext, useEffect, useState } from 'react'; | ||
|
||
import { WidgetContainer } from '../../../Overview/components/Widgets/WidgetContainer'; | ||
import { TableWidget } from '../../../Overview/components/Widgets/TableWidget'; | ||
import { InferenceItem } from '../../models/interfaces'; | ||
import { ServicesContext } from '../../../../services'; | ||
|
||
export interface InferenceProps { | ||
loading?: boolean; | ||
openFlyout: Function; | ||
} | ||
|
||
export const RecentInferences: React.FC<InferenceProps> = ({ loading = false, openFlyout }) => { | ||
const services = useContext(ServicesContext); | ||
const [inferenceItems, setInferenceItems] = useState<InferenceItem[]>([]); | ||
|
||
const actions = React.useMemo( | ||
() => [<EuiButton href={`#${ROUTES.UEBA_VIEW_INFERENCES}`}>View inferences</EuiButton>], | ||
[] | ||
); | ||
|
||
const columns: EuiBasicTableColumn<InferenceItem>[] = [ | ||
{ | ||
field: 'name', | ||
name: 'Name', | ||
sortable: true, | ||
align: 'left', | ||
}, | ||
{ | ||
field: 'description', | ||
name: 'Description', | ||
sortable: false, | ||
align: 'left', | ||
}, | ||
{ | ||
field: 'type', | ||
name: 'Type', | ||
sortable: false, | ||
align: 'left', | ||
}, | ||
{ | ||
field: 'schedule', | ||
name: 'Schedule', | ||
sortable: false, | ||
align: 'left', | ||
}, | ||
{ | ||
name: 'Details', | ||
sortable: false, | ||
actions: [ | ||
{ | ||
render: (inference) => ( | ||
<EuiToolTip content={'View details'}> | ||
<EuiButtonIcon | ||
aria-label={'View details'} | ||
data-test-subj={`view-details-icon`} | ||
iconType={'expand'} | ||
onClick={() => openFlyout(inference)} | ||
/> | ||
</EuiToolTip> | ||
), | ||
}, | ||
], | ||
}, | ||
]; | ||
|
||
const getInferences = useCallback(async () => { | ||
const inferencesResponse = await services?.uebaService.getInferences(); | ||
if (inferencesResponse?.ok) { | ||
setInferenceItems(inferencesResponse?.response.hits.hits); | ||
} | ||
}, [services]); | ||
|
||
useEffect(() => { | ||
getInferences(); | ||
}, [getInferences]); | ||
|
||
return ( | ||
<WidgetContainer title={'Recent inference models'} actions={actions}> | ||
<TableWidget columns={columns} items={inferenceItems} loading={loading} /> | ||
</WidgetContainer> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React, { useState } from 'react'; | ||
import { EuiFlexItem } from '@elastic/eui'; | ||
|
||
import { ChartContainer } from '../../../../components/Charts/ChartContainer'; | ||
import { WidgetContainer } from '../../../Overview/components/Widgets/WidgetContainer'; | ||
export interface SummaryProps { | ||
loading: boolean; | ||
} | ||
export const Summary: React.FC<SummaryProps> = () => { | ||
const [loading, setLoading] = useState(true); | ||
return ( | ||
<WidgetContainer title="User entity behavior analytics" actions={[]}> | ||
<EuiFlexItem> | ||
<ChartContainer chartViewId={'ueba-view'} loading={loading} /> | ||
</EuiFlexItem> | ||
</WidgetContainer> | ||
); | ||
}; |
26 changes: 26 additions & 0 deletions
26
public/pages/Ueba/containers/CreateAggregator/CreateAggregator.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, { useContext, useEffect } from 'react'; | ||
|
||
import { NotificationsStart } from 'opensearch-dashboards/public'; | ||
import { BrowserServices } from '../../../../models/interfaces'; | ||
import { CoreServicesContext } from '../../../../components/core_services'; | ||
import { BREADCRUMBS } from '../../../../utils/constants'; | ||
import * as H from 'history'; | ||
|
||
export interface UebaProps { | ||
services: BrowserServices; | ||
notifications?: NotificationsStart; | ||
history: H.History; | ||
} | ||
|
||
export const CreateAggregator: React.FC<UebaProps> = (props) => { | ||
const context = useContext(CoreServicesContext); | ||
useEffect(() => { | ||
context?.chrome.setBreadcrumbs([ | ||
BREADCRUMBS.SECURITY_ANALYTICS, | ||
BREADCRUMBS.UEBA, | ||
BREADCRUMBS.UEBA_CREATE_AGGREGATOR, | ||
]); | ||
}); | ||
|
||
return <>Create aggregator</>; | ||
}; |
Empty file.
Oops, something went wrong.