[8.15] [Obs AI Assistant] hide ai assistant menu item when in a disabled space (#188017) (#188161)

# Backport

This will backport the following commits from `main` to `8.15`:
- [[Obs AI Assistant] hide ai assistant menu item when in a disabled
space (#188017)](https://github.com/elastic/kibana/pull/188017)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Sandra
G","email":"neptunian@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-07-11T21:06:24Z","message":"[Obs
AI Assistant] hide ai assistant menu item when in a disabled space
(#188017)\n\nHides AI Assistant button when in a space where the AI
Assistant
is\r\ndisabled","sha":"81b1705ea61ae69990a284ac7de808c7cd9eec22","branchLabelMapping":{"^v8.16.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:Obs
AI
Assistant","ci:project-deploy-observability","v8.15.0","v8.16.0"],"title":"[Obs
AI Assistant] hide ai assistant menu item when in a disabled
space","number":188017,"url":"https://github.com/elastic/kibana/pull/188017","mergeCommit":{"message":"[Obs
AI Assistant] hide ai assistant menu item when in a disabled space
(#188017)\n\nHides AI Assistant button when in a space where the AI
Assistant
is\r\ndisabled","sha":"81b1705ea61ae69990a284ac7de808c7cd9eec22"}},"sourceBranch":"main","suggestedTargetBranches":["8.15"],"targetPullRequestStates":[{"branch":"8.15","label":"v8.15.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/188017","number":188017,"mergeCommit":{"message":"[Obs
AI Assistant] hide ai assistant menu item when in a disabled space
(#188017)\n\nHides AI Assistant button when in a space where the AI
Assistant
is\r\ndisabled","sha":"81b1705ea61ae69990a284ac7de808c7cd9eec22"}}]}]
BACKPORT-->

Co-authored-by: Sandra G <neptunian@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2024-07-12 00:47:17 +02:00 committed by GitHub
parent 7504c3844e
commit dfcd9b8c4e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -103,27 +103,29 @@ export class ObservabilityAIAssistantAppPlugin
const appService = (this.appService = createAppService({
pluginsStart,
}));
const isEnabled = appService.isEnabled();
if (isEnabled) {
coreStart.chrome.navControls.registerRight({
mount: (element) => {
ReactDOM.render(
<SharedProviders
coreStart={coreStart}
pluginsStart={pluginsStart}
service={appService}
theme$={coreStart.theme.theme$}
>
<LazyNavControl />
</SharedProviders>,
element,
() => {}
);
coreStart.chrome.navControls.registerRight({
mount: (element) => {
ReactDOM.render(
<SharedProviders
coreStart={coreStart}
pluginsStart={pluginsStart}
service={appService}
theme$={coreStart.theme.theme$}
>
<LazyNavControl />
</SharedProviders>,
element,
() => {}
);
return () => {};
},
// right before the user profile
order: 1001,
});
return () => {};
},
// right before the user profile
order: 1001,
});
}
const service = pluginsStart.observabilityAIAssistant.service;