Skip to content

Commit

Permalink
Edit text strings and links in add logstash output UI (#129551) (#129795
Browse files Browse the repository at this point in the history
)

* Edit text strings and links in add logstash output UI

* fix test to match

* Add changes from review

* Fix tests

* Fix type

* Fix I18N error

Co-authored-by: Nicolas Chaulet <[email protected]>
Co-authored-by: gchaps <[email protected]>
(cherry picked from commit a583edc)

Co-authored-by: DeDe Morton <[email protected]>
  • Loading branch information
kibanamachine and dedemorton authored Apr 7, 2022
1 parent 21721ea commit d6b0ddc
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 34 deletions.
3 changes: 2 additions & 1 deletion packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
},
logstash: {
base: `${ELASTIC_WEBSITE_URL}guide/en/logstash/${DOC_LINK_VERSION}`,
inputElasticAgent: `${ELASTIC_WEBSITE_URL}guide/en/logstash/${DOC_LINK_VERSION}/plugins-inputs-elastic_agent.html`,
},
functionbeat: {
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/functionbeat/${DOC_LINK_VERSION}`,
Expand Down Expand Up @@ -579,7 +580,7 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
guide: `${FLEET_DOCS}index.html`,
fleetServer: `${FLEET_DOCS}fleet-server.html`,
fleetServerAddFleetServer: `${FLEET_DOCS}add-a-fleet-server.html`,
settings: `${FLEET_DOCS}fleet-settings.html#fleet-server-hosts-setting`,
settings: `${FLEET_DOCS}fleet-settings.html`,
settingsFleetServerHostSettings: `${FLEET_DOCS}fleet-settings.html#fleet-server-hosts-setting`,
settingsFleetServerProxySettings: `${KIBANA_DOCS}fleet-settings-kb.html#fleet-data-visualizer-settings`,
troubleshooting: `${FLEET_DOCS}fleet-troubleshooting.html`,
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-doc-links/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export interface DocLinks {
};
readonly logstash: {
readonly base: string;
readonly inputElasticAgent: string;
};
readonly functionbeat: {
readonly base: string;
Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/public/applications/fleet/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ const FleetTopNav = memo(
const topNavConfig: TopNavMenuData[] = [
{
label: i18n.translate('xpack.fleet.appNavigation.sendFeedbackButton', {
defaultMessage: 'Send Feedback',
defaultMessage: 'Send feedback',
}),
iconType: 'popout',
run: () => window.open(FEEDBACK_URL),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export interface EditOutputFlyoutProps {

const OUTPUT_TYPE_OPTIONS = [
{ value: 'elasticsearch', text: 'Elasticsearch' },
{ value: 'logstash', text: 'Logstash (BETA)' },
{ value: 'logstash', text: 'Logstash (beta)' },
];

export const EditOutputFlyout: React.FunctionComponent<EditOutputFlyoutProps> = ({
Expand Down Expand Up @@ -138,14 +138,15 @@ export const EditOutputFlyout: React.FunctionComponent<EditOutputFlyoutProps> =
isLogstashOutput && (
<FormattedMessage
id="xpack.fleet.editOutputFlyout.logstashTypeOutputBetaHelpText"
defaultMessage="Logstash output is in BETA, Please help by reporting any bugs. {learnMoreLink}."
defaultMessage="Logstash output is in beta. Click {sendFeedback} to report bugs and suggest improvements."
values={{
learnMoreLink: (
<EuiLink href={docLinks.links.fleet.guide} external>
{i18n.translate('xpack.fleet.editOutputFlyout.learnMoreLink', {
defaultMessage: 'Learn more',
})}
</EuiLink>
sendFeedback: (
<strong>
<FormattedMessage
id="xpack.fleet.editOutputFlyout.sendFeedback"
defaultMessage="Send feedback"
/>
</strong>
),
}}
/>
Expand Down Expand Up @@ -203,13 +204,13 @@ export const EditOutputFlyout: React.FunctionComponent<EditOutputFlyoutProps> =
helpText={
<FormattedMessage
id="xpack.fleet.settings.editOutputFlyout.logstashHostsInputDescription"
defaultMessage="Specify the URLs that your agents will use to connect to a Logstash. For more information, see the {guideLink}."
defaultMessage="Specify the addresses that your agents will use to connect to Logstash. {guideLink}."
values={{
guideLink: (
<EuiLink href={docLinks.links.fleet.guide} target="_blank" external>
<EuiLink href={docLinks.links.fleet.settings} target="_blank" external>
<FormattedMessage
id="xpack.fleet.settings.fleetUserGuideLink"
defaultMessage="Fleet User Guide"
id="xpack.fleet.settings.fleetSettingsLink"
defaultMessage="Learn more"
/>
</EuiLink>
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('Output form validation', () => {
const res = validateLogstashHosts(['https://test.fr:5044']);

expect(res).toEqual([
{ index: 0, message: 'Invalid logstash host should not start with http(s)' },
{ index: 0, message: 'Host address must begin with a domain name or IP address' },
]);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function validateLogstashHosts(value: string[]) {
if (val.match(/^http([s]){0,1}:\/\//)) {
res.push({
message: i18n.translate('xpack.fleet.settings.outputForm.logstashHostProtocolError', {
defaultMessage: 'Invalid logstash host should not start with http(s)',
defaultMessage: 'Host address must begin with a domain name or IP address',
}),
index: idx,
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,21 @@ export const LogstashInstructions = () => {
title={
<FormattedMessage
id="xpack.fleet.settings.logstashInstructions.calloutTitle"
defaultMessage="Configure Logstash for Elastic Agent"
defaultMessage="Additional Logstash configuration required"
/>
}
>
<>
<FormattedMessage
id="xpack.fleet.settings.logstashInstructions.description"
defaultMessage="You must add a pipeline for Elastic Agent to Logstash. For more information, visit our
defaultMessage="Add an Elastic Agent pipeline configuration to Logstash to receive events from the Elastic Agent framework.
{documentationLink}."
values={{
documentationLink: (
<EuiLink external={true} href={docLinks.links.fleet.guide}>
<EuiLink external={true} href={docLinks.links.logstash.inputElasticAgent}>
<FormattedMessage
id="xpack.fleet.settings.logstashInstructions.documentationLink"
defaultMessage="documentation"
defaultMessage="Learn more"
/>
</EuiLink>
),
Expand All @@ -71,14 +71,14 @@ const CollapsibleCallout: React.FunctionComponent<EuiCallOutProps> = ({ children
<EuiButton onClick={() => setIsOpen(false)}>
<FormattedMessage
id="xpack.fleet.settings.logstashInstructions.collapseInstructionsButtonLabel"
defaultMessage="Collapse instructions"
defaultMessage="Collapse steps"
/>
</EuiButton>
) : (
<EuiButton onClick={() => setIsOpen(true)} fill={true}>
<FormattedMessage
id="xpack.fleet.settings.logstashInstructions.viewInstructionButtonLabel"
defaultMessage="View instructions"
defaultMessage="View steps"
/>
</EuiButton>
)}
Expand Down Expand Up @@ -191,13 +191,6 @@ const LogstashInstructionSteps = () => {
}}
/>
<EuiSpacer size="m" />
<EuiButton href={docLinks.links.fleet.guide} target="_blank">
<FormattedMessage
id="xpack.fleet.settings.logstashInstructions.viewDocumentationButtonLabel"
defaultMessage="View documentation"
/>
</EuiButton>
<EuiSpacer size="m" />
</>
),
},
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/fleet/server/types/models/output.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ describe('Output model', () => {
});

it('should return an error for an invalid host', () => {
expect(validateLogstashHost('!@#%&!#!@')).toMatchInlineSnapshot(`"Invalid logstash host"`);
expect(validateLogstashHost('!@#%&!#!@')).toMatchInlineSnapshot(`"Invalid Logstash host"`);
});

it('should return an error for an invalid host with http scheme', () => {
expect(validateLogstashHost('https://test.fr:5044')).toMatchInlineSnapshot(
`"Invalid logstash host should not start with http(s)"`
`"Host address must begin with a domain name or IP address"`
);
});
});
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/fleet/server/types/models/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { outputType } from '../../../common/constants';

export function validateLogstashHost(val: string) {
if (val.match(/^http([s]){0,1}:\/\//)) {
return 'Invalid logstash host should not start with http(s)';
return 'Host address must begin with a domain name or IP address';
}

try {
Expand All @@ -21,7 +21,7 @@ export function validateLogstashHost(val: string) {
return 'Invalid host';
}
} catch (err) {
return 'Invalid logstash host';
return 'Invalid Logstash host';
}
}

Expand Down
4 changes: 3 additions & 1 deletion x-pack/test/fleet_api_integration/apis/outputs/crud.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ export default function (providerContext: FtrProviderContext) {
})
.expect(400);

expect(postResponse.message).match(/Invalid logstash host should not start with http\(s\)/);
expect(postResponse.message).match(
/Host address must begin with a domain name or IP address/
);
});

it('should toggle default output when creating a new default output ', async function () {
Expand Down

0 comments on commit d6b0ddc

Please sign in to comment.