-
Notifications
You must be signed in to change notification settings - Fork 8.6k
[Inventory][ECO] Enable elastic entity model from inventory #193557
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
857db67
[Inventory] Enable elastic entity model from inventory
kpatticha 0dd6f26
clean up code
kpatticha 9a9c099
Add dark screenshot
kpatticha b4e21d2
Address comments
kpatticha 887b7f7
Update variable name
kpatticha e0be53e
fix types
kpatticha 97e03d6
Merge branch 'main' of github.com:elastic/kibana into 192328-eem-enab…
kpatticha e2c7d03
Fix use of useKibana
kpatticha dbc1f80
use useEuiTheme instead
kpatticha File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file added
BIN
+67.7 KB
...ins/observability_solution/inventory/public/assets/entities_intentory_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions
71
...ity_solution/inventory/public/components/entity_enablement/enable_entity_model_button.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { EuiButton } from '@elastic/eui'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import React, { useState } from 'react'; | ||
| import { EntityManagerUnauthorizedError } from '@kbn/entityManager-plugin/public'; | ||
| import type { IHttpFetchError, ResponseErrorBody } from '@kbn/core/public'; | ||
| import { useKibana } from '../../hooks/use_kibana'; | ||
| import { Unauthorized } from './unauthorized_modal'; | ||
|
|
||
| export function EnableEntityModelButton({ onSuccess }: { onSuccess: () => void }) { | ||
| const { | ||
| dependencies: { | ||
| start: { entityManager }, | ||
| }, | ||
| core: { notifications }, | ||
| } = useKibana(); | ||
|
|
||
| const [isLoading, setIsLoading] = useState(false); | ||
| const [showModal, setModalVisible] = useState(false); | ||
|
|
||
| const handleEnablement = async () => { | ||
| setIsLoading(true); | ||
| try { | ||
| const response = await entityManager.entityClient.enableManagedEntityDiscovery(); | ||
|
|
||
| if (response.success) { | ||
| setIsLoading(false); | ||
| onSuccess(); | ||
| } else { | ||
| throw new Error(response.message); | ||
| } | ||
| } catch (error) { | ||
| setIsLoading(false); | ||
|
|
||
| if (error instanceof EntityManagerUnauthorizedError) { | ||
| setModalVisible(true); | ||
| return; | ||
| } | ||
|
|
||
| const err = error as Error | IHttpFetchError<ResponseErrorBody>; | ||
| notifications.toasts.addDanger({ | ||
| title: i18n.translate('xpack.inventory.eemEnablement.errorTitle', { | ||
| defaultMessage: 'Error while enabling the new entity model', | ||
| }), | ||
| text: 'response' in err ? err.body?.message ?? err.response?.statusText : err.message, | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <> | ||
| <EuiButton | ||
| isLoading={isLoading} | ||
| data-test-subj="inventoryInventoryPageTemplateFilledButton" | ||
| fill | ||
| onClick={handleEnablement} | ||
| > | ||
| {i18n.translate('xpack.inventory.noData.card.button', { | ||
| defaultMessage: 'Enable', | ||
| })} | ||
| </EuiButton> | ||
| <Unauthorized showModal={showModal} onClose={() => setModalVisible(false)} /> | ||
|
kpatticha marked this conversation as resolved.
Outdated
|
||
| </> | ||
| ); | ||
| } | ||
110 changes: 110 additions & 0 deletions
110
...servability_solution/inventory/public/components/entity_enablement/unauthorized_modal.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { | ||
| EuiButton, | ||
| EuiConfirmModal, | ||
| EuiFlexGroup, | ||
| EuiFlexItem, | ||
| EuiIcon, | ||
| EuiImage, | ||
| EuiLink, | ||
| EuiPanel, | ||
| EuiSpacer, | ||
| EuiText, | ||
| EuiTitle, | ||
| } from '@elastic/eui'; | ||
| import inventoryLight from '../../assets/entities_intentory_light.png'; | ||
|
|
||
| export function Unauthorized({ | ||
| showModal = false, | ||
| onClose, | ||
| }: { | ||
| showModal?: boolean; | ||
| onClose: () => void; | ||
| }) { | ||
| return ( | ||
| <> | ||
| {showModal && ( | ||
| <EuiConfirmModal | ||
| style={{ | ||
| width: '630px', | ||
| }} | ||
| onCancel={onClose} | ||
| onConfirm={onClose} | ||
| confirmButtonText={ | ||
| <EuiButton data-test-subj="xpack.inventory.unauthorised.button" fill size="s"> | ||
| {i18n.translate('xpack.inventory.unauthorised.button', { | ||
| defaultMessage: 'OK', | ||
| })} | ||
| </EuiButton> | ||
| } | ||
| cancelButtonText={ | ||
| <EuiLink | ||
| target="_blank" | ||
| data-test-subj="inventoryUnauthorizedLinkExternal" | ||
| href="https://ela.st/docs-entity-inventory" | ||
| external | ||
| > | ||
| {i18n.translate('xpack.inventory.unauthorized.linkLabel', { | ||
| defaultMessage: 'Learn more', | ||
| })} | ||
| </EuiLink> | ||
| } | ||
| defaultFocusedButton="confirm" | ||
| > | ||
| <EuiPanel hasShadow={false}> | ||
| <EuiFlexGroup | ||
| direction="column" | ||
| justifyContent="center" | ||
| alignItems="center" | ||
| gutterSize="m" | ||
| > | ||
| <EuiFlexItem> | ||
| <EuiIcon type="lock" size="l" /> | ||
| </EuiFlexItem> | ||
| <EuiFlexItem> | ||
| <EuiTitle> | ||
| <h2> | ||
| {i18n.translate('xpack.inventory.unauthorised.title', { | ||
| defaultMessage: 'Insufficient permissions', | ||
| })} | ||
| </h2> | ||
| </EuiTitle> | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| </EuiPanel> | ||
|
|
||
| <EuiPanel hasShadow={false} paddingSize="s"> | ||
| <EuiText grow={false} textAlign="center"> | ||
| <p> | ||
| {i18n.translate('xpack.inventory.unauthorised.body', { | ||
| defaultMessage: | ||
| "You don't have permissions to turn on the Elastic Entity Model. Please ask your administrator to enable this for you so you can see everything you have in one place.", | ||
| })} | ||
| </p> | ||
| </EuiText> | ||
| </EuiPanel> | ||
| <EuiSpacer size="m" /> | ||
| <EuiPanel hasBorder paddingSize="none"> | ||
| <EuiImage | ||
| allowFullScreen | ||
| size="xl" | ||
| src={inventoryLight} // FIXME need dark version of this image | ||
| alt={i18n.translate('xpack.inventory.unauthorised.image.at,', { | ||
| defaultMessage: | ||
| 'Image of the new experience of the entities inventory, showing services, hosts and containers', | ||
| })} | ||
| /> | ||
| </EuiPanel> | ||
| </EuiConfirmModal> | ||
| )} | ||
| </> | ||
| ); | ||
| } |
107 changes: 107 additions & 0 deletions
107
...ns/observability_solution/inventory/public/components/entity_enablement/welcome_modal.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import React from 'react'; | ||
| import { i18n } from '@kbn/i18n'; | ||
| import { | ||
| EuiButton, | ||
| EuiConfirmModal, | ||
| EuiFlexGroup, | ||
| EuiFlexItem, | ||
| EuiIcon, | ||
| EuiImage, | ||
| EuiLink, | ||
| EuiPanel, | ||
| EuiSpacer, | ||
| EuiText, | ||
| EuiTitle, | ||
| } from '@elastic/eui'; | ||
| import inventoryLight from '../../assets/entities_intentory_light.png'; | ||
|
|
||
| export function Welcome({ | ||
| showModal = false, | ||
| onClose, | ||
| onConfirm, | ||
| }: { | ||
| showModal: boolean; | ||
| onClose: () => void; | ||
| onConfirm: () => void; | ||
| }) { | ||
| if (!showModal) { | ||
| return null; | ||
| } | ||
|
|
||
| return ( | ||
| <EuiConfirmModal | ||
| style={{ | ||
| width: '630px', | ||
| }} | ||
| onCancel={onClose} | ||
| onConfirm={onConfirm} | ||
| confirmButtonText={ | ||
| <EuiButton data-test-subj="xpack.inventory.welcome.button.open" fill size="s"> | ||
| {i18n.translate('xpack.inventory.welcome.button', { | ||
| defaultMessage: 'OK', | ||
| })} | ||
| </EuiButton> | ||
| } | ||
| cancelButtonText={ | ||
| <EuiLink | ||
| target="_blank" | ||
| data-test-subj="inventoryWelcomeLinkExternal" | ||
| href="https://ela.st/docs-entity-inventory" | ||
| external | ||
| > | ||
| {i18n.translate('xpack.inventory.welcome.linkLabel', { | ||
| defaultMessage: 'Learn more', | ||
| })} | ||
| </EuiLink> | ||
| } | ||
| defaultFocusedButton="confirm" | ||
| > | ||
| <EuiPanel hasShadow={false}> | ||
| <EuiFlexGroup direction="column" justifyContent="center" alignItems="center" gutterSize="m"> | ||
| <EuiFlexItem> | ||
| <EuiIcon type="logoElastic" size="l" /> | ||
| </EuiFlexItem> | ||
| <EuiFlexItem> | ||
| <EuiTitle> | ||
| <h2> | ||
| {i18n.translate('xpack.inventory.welcome.title', { | ||
| defaultMessage: 'See everything you have in one place!', | ||
| })} | ||
| </h2> | ||
| </EuiTitle> | ||
| </EuiFlexItem> | ||
| </EuiFlexGroup> | ||
| </EuiPanel> | ||
|
|
||
| <EuiPanel hasShadow={false} paddingSize="s"> | ||
| <EuiText grow={false} textAlign="center"> | ||
| <p> | ||
| {i18n.translate('xpack.inventory.welcome.body', { | ||
| defaultMessage: | ||
| 'The inventory will show all of your observed entities in one place so you can detect and resolve problems with them faster.', | ||
| })} | ||
| </p> | ||
| </EuiText> | ||
| </EuiPanel> | ||
| <EuiSpacer size="m" /> | ||
| <EuiPanel hasBorder paddingSize="none"> | ||
| <EuiImage | ||
| size="xl" | ||
| src={inventoryLight} | ||
| allowFullScreen | ||
| alt={i18n.translate('xpack.inventory.welcome.image.alt', { | ||
| defaultMessage: | ||
| 'Image of the new experience of the entities inventory, showing services, hosts and containers', | ||
| })} | ||
| /> | ||
| </EuiPanel> | ||
| </EuiConfirmModal> | ||
| ); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.