Skip to content

Commit

Permalink
[Fleet] Warn user when they are sending data to stream managed by dif…
Browse files Browse the repository at this point in the history
…ferent integration (elastic#151075)

## Summary

Closes elastic#149427

Give the user a warning if they are sending data to a data stream that
isn't managed by the integration being added.

<img width="697" alt="Screenshot 2023-02-13 at 21 17 13"
src="https://user-images.githubusercontent.com/3315046/218576500-a0817207-451e-47c5-ba0b-d0faaddca1a4.png">
  • Loading branch information
hop-dev authored and justinkambic committed Feb 23, 2023
1 parent 182f841 commit 85bc6c2
Showing 1 changed file with 57 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
*/

import React, { useEffect, useState } from 'react';
import { EuiComboBox } from '@elastic/eui';
import { EuiComboBox, EuiIcon, EuiLink, EuiSpacer, EuiText, EuiToolTip } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import { FormattedMessage } from '@kbn/i18n-react';

import type { DataStream } from '../../../../../../../../../common/types';

interface SelectedDataset {
Expand Down Expand Up @@ -73,24 +75,59 @@ export const DatasetComboBox: React.FC<{
});
};
return (
<EuiComboBox
aria-label={i18n.translate('xpack.fleet.datasetCombo.ariaLabel', {
defaultMessage: 'Dataset combo box',
})}
placeholder={i18n.translate('xpack.fleet.datasetCombo.placeholder', {
defaultMessage: 'Select a dataset',
})}
singleSelection={{ asPlainText: true }}
options={datasetOptions}
selectedOptions={selectedOptions}
onCreateOption={onCreateOption}
onChange={onDatasetChange}
customOptionText={i18n.translate('xpack.fleet.datasetCombo.customOptionText', {
defaultMessage: 'Add {searchValue} as a custom option',
values: { searchValue: '{searchValue}' },
})}
isClearable={false}
isDisabled={isDisabled}
/>
<>
<EuiComboBox
aria-label={i18n.translate('xpack.fleet.datasetCombo.ariaLabel', {
defaultMessage: 'Dataset combo box',
})}
placeholder={i18n.translate('xpack.fleet.datasetCombo.placeholder', {
defaultMessage: 'Select a dataset',
})}
singleSelection={{ asPlainText: true }}
options={datasetOptions}
selectedOptions={selectedOptions}
onCreateOption={onCreateOption}
onChange={onDatasetChange}
customOptionText={i18n.translate('xpack.fleet.datasetCombo.customOptionText', {
defaultMessage: 'Add {searchValue} as a custom option',
values: { searchValue: '{searchValue}' },
})}
isClearable={false}
isDisabled={isDisabled}
/>
{valueAsOption && valueAsOption.value.package !== pkgName && (
<>
<EuiSpacer size="xs" />
<EuiText size="xs" color="warning">
<EuiIcon type="alert" />
&nbsp;
<FormattedMessage
id="xpack.fleet.datasetCombo.warning"
defaultMessage="This data stream is managed by the {package} integration, {learnMore}."
values={{
package: valueAsOption.value.package,
learnMore: (
<EuiToolTip
position="bottom"
content={
<FormattedMessage
id="xpack.fleet.datasetCombo.warningTooltip"
defaultMessage="The destination data stream may not be designed to receive data from this integration, check that the mappings and ingest pipelines are compatible before sending data."
/>
}
>
<EuiLink target="_blank">
{i18n.translate('xpack.fleet.datasetCombo.learnMoreLink', {
defaultMessage: 'learn more',
})}
</EuiLink>
</EuiToolTip>
),
}}
/>
</EuiText>
</>
)}
</>
);
};

0 comments on commit 85bc6c2

Please sign in to comment.