-
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.
[fleet] Add Integration Preference selector
- Loading branch information
1 parent
aa559c9
commit e4e8c4c
Showing
5 changed files
with
146 additions
and
19 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
...blic/applications/integrations/sections/epm/components/integration_preference.stories.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,36 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
import type { Meta } from '@storybook/react'; | ||
|
||
import { action } from '@storybook/addon-actions'; | ||
|
||
import { IntegrationPreference as Component } from './integration_preference'; | ||
|
||
export default { | ||
title: 'Sections/EPM/Integration Preference', | ||
description: '', | ||
decorators: [ | ||
(storyFn, { globals }) => ( | ||
<div | ||
style={{ | ||
padding: 40, | ||
backgroundColor: | ||
globals.euiTheme === 'v8.dark' || globals.euiTheme === 'v7.dark' ? '#1D1E24' : '#FFF', | ||
width: 280, | ||
}} | ||
> | ||
{storyFn()} | ||
</div> | ||
), | ||
], | ||
} as Meta; | ||
|
||
export const IntegrationPreference = () => { | ||
return <Component onChange={action('onChange')} />; | ||
}; |
82 changes: 82 additions & 0 deletions
82
...fleet/public/applications/integrations/sections/epm/components/integration_preference.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,82 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { EuiPanel, EuiLink, EuiText, EuiForm, EuiRadioGroup, EuiSpacer } from '@elastic/eui'; | ||
|
||
import { SHIPPER_DISPLAY } from '../../../../../../../../../src/plugins/custom_integrations/common'; | ||
|
||
type Value = 'beats' | 'agent'; | ||
|
||
interface Option { | ||
value: Value; | ||
label: string; | ||
} | ||
|
||
export interface Props { | ||
onChange: (value: Value) => void; | ||
} | ||
|
||
const link = ( | ||
<EuiLink href="#"> | ||
<FormattedMessage | ||
id="xpack.fleet.epm.integrationPreference.titleLink" | ||
defaultMessage="Elastic Agent and Beats" | ||
/> | ||
</EuiLink> | ||
); | ||
|
||
const title = ( | ||
<FormattedMessage | ||
id="xpack.fleet.epm.integrationPreference.title" | ||
defaultMessage="When an integration is available for {link}, use:" | ||
values={{ link }} | ||
/> | ||
); | ||
|
||
export const IntegrationPreference = ({ onChange }: Props) => { | ||
const [idSelected, setIdSelected] = React.useState<Value>('agent'); | ||
|
||
const options: Option[] = [ | ||
{ | ||
value: 'agent', | ||
label: i18n.translate('xpack.fleet.epm.integrationPreference.elasticAgentLabel', { | ||
defaultMessage: 'Elastic Agent (recommended)', | ||
}), | ||
}, | ||
{ | ||
value: 'beats', | ||
label: SHIPPER_DISPLAY.beats, | ||
}, | ||
]; | ||
|
||
const radios = options.map((option) => ({ | ||
id: option.value, | ||
...option, | ||
})); | ||
|
||
return ( | ||
<EuiPanel hasShadow={false} paddingSize="none"> | ||
<EuiText size="s">{title}</EuiText> | ||
<EuiSpacer size="m" /> | ||
<EuiForm> | ||
<EuiRadioGroup | ||
options={radios} | ||
idSelected={idSelected} | ||
onChange={(id, value) => { | ||
setIdSelected(id as Value); | ||
onChange(value as Value); | ||
}} | ||
name="preference" | ||
/> | ||
</EuiForm> | ||
</EuiPanel> | ||
); | ||
}; |
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