Skip to content

Commit

Permalink
Check if ingest manager is available in current space
Browse files Browse the repository at this point in the history
  • Loading branch information
jen-huang committed Jul 8, 2020
1 parent 71b8109 commit f101ec7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
TutorialDirectoryNoticeComponent,
TutorialDirectoryHeaderLinkComponent,
} from 'src/plugins/home/public';
import { sendPutSettings, useGetSettings, useLink } from '../../hooks';
import { sendPutSettings, useGetSettings, useLink, useCapabilities } from '../../hooks';

const FlexItemButtonWrapper = styled(EuiFlexItem)`
&&& {
Expand All @@ -35,6 +35,7 @@ const tutorialDirectoryNoticeState$ = new BehaviorSubject({

export const TutorialDirectoryNotice: TutorialDirectoryNoticeComponent = memo(() => {
const { getHref } = useLink();
const { show: hasIngestManager } = useCapabilities();
const { data: settingsData, isLoading } = useGetSettings();
const [dismissedNotice, setDismissedNotice] = useState<boolean>(false);

Expand All @@ -55,7 +56,7 @@ export const TutorialDirectoryNotice: TutorialDirectoryNoticeComponent = memo(()
const hasSeenNotice =
isLoading || settingsData?.item?.has_seen_add_data_notice || dismissedNotice;

return !hasSeenNotice ? (
return hasIngestManager && !hasSeenNotice ? (
<>
<EuiSpacer size="m" />
<EuiCallOut
Expand Down Expand Up @@ -129,6 +130,7 @@ export const TutorialDirectoryNotice: TutorialDirectoryNoticeComponent = memo(()

export const TutorialDirectoryHeaderLink: TutorialDirectoryHeaderLinkComponent = memo(() => {
const { getHref } = useLink();
const { show: hasIngestManager } = useCapabilities();
const [noticeState, setNoticeState] = useState({
settingsDataLoaded: false,
hasSeenNotice: false,
Expand All @@ -141,7 +143,7 @@ export const TutorialDirectoryHeaderLink: TutorialDirectoryHeaderLinkComponent =
};
}, []);

return noticeState.settingsDataLoaded && noticeState.hasSeenNotice ? (
return hasIngestManager && noticeState.settingsDataLoaded && noticeState.hasSeenNotice ? (
<EuiButtonEmpty size="s" iconType="link" flush="right" href={getHref('overview')}>
<FormattedMessage
id="xpack.ingestManager.homeIntegration.tutorialDirectory.ingestManagerAppButtonText"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ import React, { memo } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiText, EuiLink, EuiSpacer } from '@elastic/eui';
import { TutorialModuleNoticeComponent } from 'src/plugins/home/public';
import { useGetPackages, useLink } from '../../hooks';
import { useGetPackages, useLink, useCapabilities } from '../../hooks';

export const TutorialModuleNotice: TutorialModuleNoticeComponent = memo(({ moduleName }) => {
const { data: packagesData, isLoading } = useGetPackages();
const { getHref } = useLink();
const { show: hasIngestManager } = useCapabilities();
const { data: packagesData, isLoading } = useGetPackages();

const pkgInfo =
!isLoading &&
packagesData?.response &&
packagesData.response.find((pkg) => pkg.name === moduleName);

if (pkgInfo) {
if (hasIngestManager && pkgInfo) {
return (
<>
<EuiSpacer />
Expand Down

0 comments on commit f101ec7

Please sign in to comment.