-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…78579) * adding alert to service page * sending on alert per service environment and transaction type * addressing PR comment * addressing PR comment Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: Elastic Machine <[email protected]>
- Loading branch information
1 parent
f2c87e0
commit 9b3e54e
Showing
19 changed files
with
1,419 additions
and
119 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
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
61 changes: 61 additions & 0 deletions
61
x-pack/plugins/apm/public/components/alerting/fields.test.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,61 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import React from 'react'; | ||
import { ServiceField, TransactionTypeField } from './fields'; | ||
import { act, fireEvent, render } from '@testing-library/react'; | ||
import { expectTextsInDocument } from '../../utils/testHelpers'; | ||
|
||
describe('alerting fields', () => { | ||
describe('Service Fiels', () => { | ||
it('renders with value', () => { | ||
const component = render(<ServiceField value="foo" />); | ||
expectTextsInDocument(component, ['foo']); | ||
}); | ||
it('renders with All when value is not defined', () => { | ||
const component = render(<ServiceField />); | ||
expectTextsInDocument(component, ['All']); | ||
}); | ||
}); | ||
describe('Transaction Type Field', () => { | ||
it('renders select field when multiple options available', () => { | ||
const options = [ | ||
{ text: 'Foo', value: 'foo' }, | ||
{ text: 'Bar', value: 'bar' }, | ||
]; | ||
const { getByText, getByTestId } = render( | ||
<TransactionTypeField currentValue="Foo" options={options} /> | ||
); | ||
|
||
act(() => { | ||
fireEvent.click(getByText('Foo')); | ||
}); | ||
|
||
const selectBar = getByTestId('transactionTypeField'); | ||
expect(selectBar instanceof HTMLSelectElement).toBeTruthy(); | ||
const selectOptions = (selectBar as HTMLSelectElement).options; | ||
expect(selectOptions.length).toEqual(2); | ||
expect( | ||
Object.values(selectOptions).map((option) => option.value) | ||
).toEqual(['foo', 'bar']); | ||
}); | ||
it('renders read-only field when single option available', () => { | ||
const options = [{ text: 'Bar', value: 'bar' }]; | ||
const component = render( | ||
<TransactionTypeField currentValue="Bar" options={options} /> | ||
); | ||
expectTextsInDocument(component, ['Bar']); | ||
}); | ||
it('renders read-only All option when no option available', () => { | ||
const component = render(<TransactionTypeField currentValue="" />); | ||
expectTextsInDocument(component, ['All']); | ||
}); | ||
|
||
it('renders current value when available', () => { | ||
const component = render(<TransactionTypeField currentValue="foo" />); | ||
expectTextsInDocument(component, ['foo']); | ||
}); | ||
}); | ||
}); |
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
32 changes: 32 additions & 0 deletions
32
x-pack/plugins/apm/public/components/alerting/get_alert_capabilities.ts
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,32 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { Capabilities } from 'kibana/public'; | ||
import { ApmPluginSetupDeps } from '../../plugin'; | ||
|
||
export const getAlertingCapabilities = ( | ||
plugins: ApmPluginSetupDeps, | ||
capabilities: Capabilities | ||
) => { | ||
const canReadAlerts = !!capabilities.apm['alerting:show']; | ||
const canSaveAlerts = !!capabilities.apm['alerting:save']; | ||
const isAlertingPluginEnabled = 'alerts' in plugins; | ||
const isAlertingAvailable = | ||
isAlertingPluginEnabled && (canReadAlerts || canSaveAlerts); | ||
const isMlPluginEnabled = 'ml' in plugins; | ||
const canReadAnomalies = !!( | ||
isMlPluginEnabled && | ||
capabilities.ml.canAccessML && | ||
capabilities.ml.canGetJobs | ||
); | ||
|
||
return { | ||
isAlertingAvailable, | ||
canReadAlerts, | ||
canSaveAlerts, | ||
canReadAnomalies, | ||
}; | ||
}; |
Oops, something went wrong.