-
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
Co-authored-by: Clint Andrew Hall <[email protected]>
- Loading branch information
1 parent
dd68f7e
commit 0686bac
Showing
12 changed files
with
518 additions
and
6,309 deletions.
There are no files selected for viewing
1,861 changes: 20 additions & 1,841 deletions
1,861
src/plugins/custom_integrations/public/services/stub/fixtures/integrations.ts
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 initialType="recommended" onChange={action('onChange')} />; | ||
}; |
120 changes: 120 additions & 0 deletions
120
...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,120 @@ | ||
/* | ||
* 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 styled from 'styled-components'; | ||
|
||
import { i18n } from '@kbn/i18n'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { | ||
EuiPanel, | ||
EuiLink, | ||
EuiText, | ||
EuiForm, | ||
EuiRadioGroup, | ||
EuiSpacer, | ||
EuiIconTip, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
} from '@elastic/eui'; | ||
|
||
export type IntegrationPreferenceType = 'recommended' | 'beats' | 'agent'; | ||
|
||
interface Option { | ||
type: IntegrationPreferenceType; | ||
label: React.ReactNode; | ||
} | ||
|
||
export interface Props { | ||
initialType: IntegrationPreferenceType; | ||
onChange: (type: IntegrationPreferenceType) => 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}, show:" | ||
values={{ link }} | ||
/> | ||
); | ||
|
||
const recommendedTooltip = ( | ||
<FormattedMessage | ||
id="xpack.fleet.epm.integrationPreference.recommendedTooltip" | ||
defaultMessage="Generally available (GA) integrations are recommended over beta and experimental." | ||
/> | ||
); | ||
|
||
const Item = styled(EuiFlexItem)` | ||
padding-left: ${(props) => props.theme.eui.euiSizeXS}; | ||
`; | ||
|
||
const options: Option[] = [ | ||
{ | ||
type: 'recommended', | ||
label: ( | ||
<EuiFlexGroup alignItems="center" gutterSize="none"> | ||
<EuiFlexItem grow={false}> | ||
{i18n.translate('xpack.fleet.epm.integrationPreference.recommendedLabel', { | ||
defaultMessage: 'Recommended', | ||
})} | ||
</EuiFlexItem> | ||
<Item> | ||
<EuiIconTip content={recommendedTooltip} /> | ||
</Item> | ||
</EuiFlexGroup> | ||
), | ||
}, | ||
{ | ||
type: 'agent', | ||
label: i18n.translate('xpack.fleet.epm.integrationPreference.elasticAgentLabel', { | ||
defaultMessage: 'Elastic Agent only', | ||
}), | ||
}, | ||
{ | ||
type: 'beats', | ||
label: i18n.translate('xpack.fleet.epm.integrationPreference.beatsLabel', { | ||
defaultMessage: 'Beats only', | ||
}), | ||
}, | ||
]; | ||
|
||
export const IntegrationPreference = ({ initialType, onChange }: Props) => { | ||
const [idSelected, setIdSelected] = React.useState<IntegrationPreferenceType>(initialType); | ||
const radios = options.map((option) => ({ | ||
id: option.type, | ||
value: option.type, | ||
label: option.label, | ||
})); | ||
|
||
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 IntegrationPreferenceType); | ||
onChange(value as IntegrationPreferenceType); | ||
}} | ||
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
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
Oops, something went wrong.