-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.x] [Inventory][ECO] Enable elastic entity model from inventory (#1…
…93557) (#193712) # Backport This will backport the following commits from `main` to `8.x`: - [[Inventory][ECO] Enable elastic entity model from inventory (#193557)](#193557) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Katerina","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-23T12:01:00Z","message":"[Inventory][ECO] Enable elastic entity model from inventory (#193557)\n\n## Summary\r\n\r\ncloses #192328 \r\n\r\n> [!Note] \r\n> Empty state will be handled in a different ticket\r\n### Checklist\r\n\r\n### Enable with permissions \r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/c7a5390b-2d7c-4897-a167-485da74ac336\r\n\r\n\r\nhttps://github.com/user-attachments/assets/44e30654-04bd-42c3-9c1e-a24042b4cb40\r\n\r\n\r\n\r\n\r\n### Enable without permissions \r\n\r\n\r\nhttps://github.com/user-attachments/assets/b5f16f43-1cd4-48a7-bf04-3926b03e5a30\r\n\r\n\r\nhttps://github.com/user-attachments/assets/be17ddf7-de7a-4573-b0c4-caadeece3cc5\r\n\r\n\r\n\r\n### TODO\r\n\r\n- [x] add dark screenshot of inventory","sha":"b5a061ec64ba4246c6f476dbe192435cb896fef1","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:prev-minor","ci:project-deploy-observability","v8.16.0"],"title":"[Inventory][ECO] Enable elastic entity model from inventory","number":193557,"url":"https://github.com/elastic/kibana/pull/193557","mergeCommit":{"message":"[Inventory][ECO] Enable elastic entity model from inventory (#193557)\n\n## Summary\r\n\r\ncloses #192328 \r\n\r\n> [!Note] \r\n> Empty state will be handled in a different ticket\r\n### Checklist\r\n\r\n### Enable with permissions \r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/c7a5390b-2d7c-4897-a167-485da74ac336\r\n\r\n\r\nhttps://github.com/user-attachments/assets/44e30654-04bd-42c3-9c1e-a24042b4cb40\r\n\r\n\r\n\r\n\r\n### Enable without permissions \r\n\r\n\r\nhttps://github.com/user-attachments/assets/b5f16f43-1cd4-48a7-bf04-3926b03e5a30\r\n\r\n\r\nhttps://github.com/user-attachments/assets/be17ddf7-de7a-4573-b0c4-caadeece3cc5\r\n\r\n\r\n\r\n### TODO\r\n\r\n- [x] add dark screenshot of inventory","sha":"b5a061ec64ba4246c6f476dbe192435cb896fef1"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193557","number":193557,"mergeCommit":{"message":"[Inventory][ECO] Enable elastic entity model from inventory (#193557)\n\n## Summary\r\n\r\ncloses #192328 \r\n\r\n> [!Note] \r\n> Empty state will be handled in a different ticket\r\n### Checklist\r\n\r\n### Enable with permissions \r\n\r\n\r\n\r\nhttps://github.com/user-attachments/assets/c7a5390b-2d7c-4897-a167-485da74ac336\r\n\r\n\r\nhttps://github.com/user-attachments/assets/44e30654-04bd-42c3-9c1e-a24042b4cb40\r\n\r\n\r\n\r\n\r\n### Enable without permissions \r\n\r\n\r\nhttps://github.com/user-attachments/assets/b5f16f43-1cd4-48a7-bf04-3926b03e5a30\r\n\r\n\r\nhttps://github.com/user-attachments/assets/be17ddf7-de7a-4573-b0c4-caadeece3cc5\r\n\r\n\r\n\r\n### TODO\r\n\r\n- [x] add dark screenshot of inventory","sha":"b5a061ec64ba4246c6f476dbe192435cb896fef1"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Katerina <[email protected]>
- Loading branch information
1 parent
7c1b342
commit e3723fe
Showing
10 changed files
with
403 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Binary file added
BIN
+176 KB
...gins/observability_solution/inventory/public/assets/entities_inventory_dark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+176 KB
...ins/observability_solution/inventory/public/assets/entities_inventory_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions
68
...ity_solution/inventory/public/components/entity_enablement/enable_entity_model_button.tsx
This file contains 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,68 @@ | ||
/* | ||
* 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 { | ||
services: { entityManager, 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> | ||
{showModal ? <Unauthorized onClose={() => setModalVisible(false)} /> : null} | ||
</> | ||
); | ||
} |
100 changes: 100 additions & 0 deletions
100
...servability_solution/inventory/public/components/entity_enablement/unauthorized_modal.tsx
This file contains 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,100 @@ | ||
/* | ||
* 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, | ||
useEuiTheme, | ||
COLOR_MODES_STANDARD, | ||
} from '@elastic/eui'; | ||
import inventoryLight from '../../assets/entities_inventory_light.png'; | ||
import inventoryDark from '../../assets/entities_inventory_dark.png'; | ||
|
||
export function Unauthorized({ onClose }: { onClose: () => void }) { | ||
const { colorMode } = useEuiTheme(); | ||
|
||
return ( | ||
<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={colorMode === COLOR_MODES_STANDARD.dark ? inventoryDark : inventoryLight} | ||
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> | ||
); | ||
} |
100 changes: 100 additions & 0 deletions
100
...ns/observability_solution/inventory/public/components/entity_enablement/welcome_modal.tsx
This file contains 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,100 @@ | ||
/* | ||
* 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, | ||
useEuiTheme, | ||
COLOR_MODES_STANDARD, | ||
} from '@elastic/eui'; | ||
import inventoryLight from '../../assets/entities_inventory_light.png'; | ||
import inventoryDark from '../../assets/entities_inventory_dark.png'; | ||
|
||
export function Welcome({ onClose, onConfirm }: { onClose: () => void; onConfirm: () => void }) { | ||
const { colorMode } = useEuiTheme(); | ||
|
||
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={colorMode === COLOR_MODES_STANDARD.dark ? inventoryDark : 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 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.