Skip to content

Commit

Permalink
add warning for kafka type option
Browse files Browse the repository at this point in the history
  • Loading branch information
szwarckonrad committed Aug 10, 2023
1 parent 48b7acf commit 6bdc7d7
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 19 deletions.
2 changes: 2 additions & 0 deletions x-pack/plugins/fleet/cypress/screens/fleet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ export const SETTINGS_OUTPUTS = {
NAME_INPUT: 'settingsOutputsFlyout.nameInput',
TYPE_INPUT: 'settingsOutputsFlyout.typeInput',
ADD_HOST_ROW_BTN: 'fleetServerHosts.multiRowInput.addRowButton',
WARNING_KAFKA_CALLOUT: 'settingsOutputsFlyout.kafkaOutputTypeCallout',
WARNING_ELASTICSEARCH_CALLOUT: 'settingsOutputsFlyout.elasticsearchOutputTypeCallout',
};

export const getSpecificSelectorId = (selector: string, id: number) => {
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/fleet/cypress/screens/fleet_outputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const selectKafkaOutput = () => {
visit('/app/fleet/settings');
cy.getBySel(SETTINGS_OUTPUTS.ADD_BTN).click();
cy.getBySel(SETTINGS_OUTPUTS.TYPE_INPUT).select('kafka');
cy.getBySel(SETTINGS_OUTPUTS.WARNING_KAFKA_CALLOUT);
cy.getBySel(SETTINGS_OUTPUTS_KAFKA.AUTHENTICATION_USERNAME_PASSWORD_OPTION).click();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ export const EditOutputFlyout: React.FunctionComponent<EditOutputFlyoutProps> =
[proxies]
);

const isESOutput = inputs.typeInput.value === outputType.Elasticsearch;
const { kafkaOutput: isKafkaOutputEnabled } = ExperimentalFeaturesService.get();

const OUTPUT_TYPE_OPTIONS = [
Expand Down Expand Up @@ -249,6 +248,43 @@ export const EditOutputFlyout: React.FunctionComponent<EditOutputFlyoutProps> =
}
};

const renderTypeSpecificWarning = () => {
const isESOutput = inputs.typeInput.value === outputType.Elasticsearch;
const isKafkaOutput = inputs.typeInput.value === outputType.Kafka;
if (!isKafkaOutput && !isESOutput) {
return null;
}

const generateWarningMessage = () => {
switch (inputs.typeInput.value) {
case outputType.Kafka:
return i18n.translate('xpack.fleet.settings.editOutputFlyout.kafkaOutputTypeCallout', {
defaultMessage:
'Kafka output is currently not supported on Agents using the Elastic Defend integration.',
});
default:
case outputType.Elasticsearch:
return i18n.translate('xpack.fleet.settings.editOutputFlyout.esOutputTypeCallout', {
defaultMessage:
'This output type currently does not support connectivity to a remote Elasticsearch cluster.',
});
}
};
return (
<>
<EuiSpacer size="xs" />
<EuiCallOut
data-test-subj={`settingsOutputsFlyout.${inputs.typeInput.value}OutputTypeCallout`}
title={generateWarningMessage()}
iconType="alert"
color="warning"
size="s"
heading="p"
/>
</>
);
};

return (
<EuiFlyout maxWidth={FLYOUT_MAX_WIDTH} onClose={onClose}>
<EuiFlyoutHeader hasBorder={true}>
Expand Down Expand Up @@ -350,24 +386,7 @@ export const EditOutputFlyout: React.FunctionComponent<EditOutputFlyoutProps> =
}
)}
/>
{isESOutput && (
<>
<EuiSpacer size="xs" />
<EuiCallOut
title={i18n.translate(
'xpack.fleet.settings.editOutputFlyout.esOutputTypeCallout',
{
defaultMessage:
'This output type currently does not support connectivity to a remote Elasticsearch cluster.',
}
)}
iconType="alert"
color="warning"
size="s"
heading="p"
/>
</>
)}
{renderTypeSpecificWarning()}
</>
</EuiFormRow>

Expand Down

0 comments on commit 6bdc7d7

Please sign in to comment.