Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fleet] Show callout when EPR unavailable #117598

Merged
merged 16 commits into from
Nov 9, 2021
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ readonly links: {
fleetServerAddFleetServer: string;
settings: string;
settingsFleetServerHostSettings: string;
settingsFleetServerProxySettings: string;
troubleshooting: string;
elasticAgent: string;
datastreams: string;
Expand All @@ -245,6 +246,7 @@ readonly links: {
upgradeElasticAgent712lower: string;
learnMoreBlog: string;
apiKeysLearnMore: string;
onPremRegistry: string;
}>;
readonly ecs: {
readonly guide: string;
Expand Down

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,7 @@ export class DocLinksService {
fleetServerAddFleetServer: `${FLEET_DOCS}fleet-server.html#add-fleet-server`,
settings: `${FLEET_DOCS}fleet-settings.html#fleet-server-hosts-setting`,
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`,
elasticAgent: `${FLEET_DOCS}elastic-agent-installation.html`,
beatsAgentComparison: `${FLEET_DOCS}beats-agent-comparison.html`,
Expand All @@ -490,6 +491,7 @@ export class DocLinksService {
upgradeElasticAgent712lower: `${FLEET_DOCS}upgrade-elastic-agent.html#upgrade-7.12-lower`,
learnMoreBlog: `${ELASTIC_WEBSITE_URL}blog/elastic-agent-and-fleet-make-it-easier-to-integrate-your-systems-with-elastic`,
apiKeysLearnMore: `${KIBANA_DOCS}api-keys.html`,
onPremRegistry: `${ELASTIC_WEBSITE_URL}guide/en/integrations-developer/${DOC_LINK_VERSION}/air-gapped.html`,
},
ecs: {
guide: `${ELASTIC_WEBSITE_URL}guide/en/ecs/current/index.html`,
Expand Down Expand Up @@ -745,6 +747,7 @@ export interface DocLinksStart {
fleetServerAddFleetServer: string;
settings: string;
settingsFleetServerHostSettings: string;
settingsFleetServerProxySettings: string;
troubleshooting: string;
elasticAgent: string;
datastreams: string;
Expand All @@ -754,6 +757,7 @@ export interface DocLinksStart {
upgradeElasticAgent712lower: string;
learnMoreBlog: string;
apiKeysLearnMore: string;
onPremRegistry: string;
}>;
readonly ecs: {
readonly guide: string;
Expand Down
2 changes: 2 additions & 0 deletions src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,7 @@ export interface DocLinksStart {
fleetServerAddFleetServer: string;
settings: string;
settingsFleetServerHostSettings: string;
settingsFleetServerProxySettings: string;
troubleshooting: string;
elasticAgent: string;
datastreams: string;
Expand All @@ -712,6 +713,7 @@ export interface DocLinksStart {
upgradeElasticAgent712lower: string;
learnMoreBlog: string;
apiKeysLearnMore: string;
onPremRegistry: string;
}>;
readonly ecs: {
readonly guide: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,16 @@ import React, { memo, useMemo, useState } from 'react';
import { useLocation, useHistory, useParams } from 'react-router-dom';
import _ from 'lodash';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import {
EuiHorizontalRule,
EuiFlexItem,
EuiFlexGrid,
EuiSpacer,
EuiCard,
EuiIcon,
EuiCallOut,
EuiLink,
} from '@elastic/eui';

import { useStartServices } from '../../../../hooks';
Expand Down Expand Up @@ -133,10 +136,13 @@ export const AvailablePackages: React.FC = memo(() => {
history.replace(pagePathGetters.integrations_all({ searchTerm: search })[1]);
}

const { data: eprPackages, isLoading: isLoadingAllPackages } = useGetPackages({
const {
data: eprPackages,
isLoading: isLoadingAllPackages,
error: eprPackageLoadingError,
} = useGetPackages({
category: '',
});

const eprIntegrationList = useMemo(
() => packageListToIntegrationsList(eprPackages?.response || []),
[eprPackages]
Expand Down Expand Up @@ -166,18 +172,23 @@ export const AvailablePackages: React.FC = memo(() => {
return a.title.localeCompare(b.title);
});

const { data: eprCategories, isLoading: isLoadingCategories } = useGetCategories({
const {
data: eprCategories,
isLoading: isLoadingCategories,
error: eprCategoryLoadingError,
} = useGetCategories({
include_policy_templates: true,
});

const categories = useMemo(() => {
const eprAndCustomCategories: CategoryFacet[] =
isLoadingCategories || !eprCategories
? []
: mergeCategoriesAndCount(
eprCategories.response as Array<{ id: string; title: string; count: number }>,
cards
);
const eprAndCustomCategories: CategoryFacet[] = isLoadingCategories
? []
: mergeCategoriesAndCount(
eprCategories
? (eprCategories.response as Array<{ id: string; title: string; count: number }>)
: [],
cards
);
return [
{
...ALL_CATEGORY,
Expand Down Expand Up @@ -291,6 +302,54 @@ export const AvailablePackages: React.FC = memo(() => {
setSelectedCategory={setSelectedCategory}
onSearchChange={setSearchTerm}
showMissingIntegrationMessage
callout={eprPackageLoadingError || eprCategoryLoadingError ? <NoEprCallout /> : undefined}
thomasneirynck marked this conversation as resolved.
Show resolved Hide resolved
/>
);
});

function NoEprCallout() {
return (
<EuiCallOut
title={i18n.translate('xpack.fleet.epmList.eprUnavailableCalloutTitle', {
defaultMessage: 'Update your package registry setting to view more integrations\n',
})}
iconType="iInCircle"
color={'warning'}
>
<p>
<FormattedMessage
id="xpack.fleet.epmList.eprUnavailableCalloutTitleMessage"
defaultMessage="Kibana cannot reach the Elastic Package Registry, which provides Elastic Agent integrations. To view these integrations, set the URL for a {registryproxy} or an {onpremregistry}."
thomasneirynck marked this conversation as resolved.
Show resolved Hide resolved
values={{
registryproxy: <ProxyLink />,
onpremregistry: <OnPremLink />,
}}
/>
</p>
</EuiCallOut>
);
}

function ProxyLink() {
const { docLinks } = useStartServices();

return (
<EuiLink href={docLinks.links.fleet.settingsFleetServerProxySettings} target="_blank">
{i18n.translate('xpack.fleet.epmList.proxyLinkSnippedText', {
defaultMessage: 'registry proxy',
})}
</EuiLink>
);
}

function OnPremLink() {
const { docLinks } = useStartServices();

return (
<EuiLink href={docLinks.links.fleet.onPremRegistry} target="_blank">
{i18n.translate('xpack.fleet.epmList.onPremLinkSnippetText', {
defaultMessage: 'on-prem registry',
})}
</EuiLink>
);
}