-
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.
- Loading branch information
Showing
11 changed files
with
197 additions
and
113 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
28 changes: 28 additions & 0 deletions
28
x-pack/plugins/cloud_integrations/cloud_chat/public/components/chat/index.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,28 @@ | ||
/* | ||
* 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, { Suspense } from 'react'; | ||
import { EuiErrorBoundary } from '@elastic/eui'; | ||
import type { Props } from './chat'; | ||
export type { ChatApi, Props } from './chat'; | ||
|
||
/** | ||
* A suspense-compatible version of the Chat component. | ||
*/ | ||
export const LazyChat = React.lazy(() => import('./chat').then(({ Chat }) => ({ default: Chat }))); | ||
|
||
/** | ||
* A lazily-loaded component that will display a trigger that will allow the user to chat with a | ||
* human operator when the service is enabled; otherwise, it renders nothing. | ||
*/ | ||
export const Chat = (props: Props) => ( | ||
<EuiErrorBoundary> | ||
<Suspense fallback={<></>}> | ||
<LazyChat {...props} /> | ||
</Suspense> | ||
</EuiErrorBoundary> | ||
); |
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
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
92 changes: 92 additions & 0 deletions
92
...ntegrations/cloud_chat/public/components/chat_header_menu_item/chat_header_menu_items.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,92 @@ | ||
/* | ||
* 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 { | ||
EuiButtonEmpty, | ||
useEuiTheme, | ||
useIsWithinMinBreakpoint, | ||
EuiTourStep, | ||
EuiText, | ||
EuiIcon, | ||
} from '@elastic/eui'; | ||
import ReactDOM from 'react-dom'; | ||
import { i18n } from '@kbn/i18n'; | ||
import useLocalStorage from 'react-use/lib/useLocalStorage'; | ||
import chatIconDark from './chat_icon_dark.svg'; | ||
import chatIconLight from './chat_icon_light.svg'; | ||
import { Chat, ChatApi } from '../chat'; | ||
|
||
export function ChatHeaderMenuItem() { | ||
const [showChatButton, setChatButtonShow] = React.useState(false); | ||
const [chatApi, setChatApi] = React.useState<ChatApi | null>(null); | ||
const [showTour, setShowTour] = useLocalStorage('cloudChatTour', true); | ||
const { euiTheme } = useEuiTheme(); | ||
|
||
const isLargeScreen = useIsWithinMinBreakpoint('m'); | ||
if (!isLargeScreen) return null; | ||
|
||
return ( | ||
<> | ||
{showChatButton && ( | ||
<EuiTourStep | ||
title={ | ||
<> | ||
<EuiIcon type={chatIconDark} size={'l'} css={{ marginRight: euiTheme.size.s }} /> | ||
{i18n.translate('xpack.cloudChat.chatTourHeaderText', { | ||
defaultMessage: 'Live Chat Now', | ||
})} | ||
</> | ||
} | ||
content={ | ||
<EuiText size={'s'}> | ||
<p> | ||
{i18n.translate('xpack.cloudChat.chatTourText', { | ||
defaultMessage: | ||
'Open chat for assistance with topics such as ingesting data, configuring your instance, and troubleshooting.', | ||
})} | ||
</p> | ||
</EuiText> | ||
} | ||
isStepOpen={showTour} | ||
onFinish={() => setShowTour(false)} | ||
minWidth={300} | ||
maxWidth={360} | ||
step={1} | ||
stepsTotal={1} | ||
anchorPosition="downRight" | ||
> | ||
<EuiButtonEmpty | ||
css={{ color: euiTheme.colors.ghost, marginRight: euiTheme.size.m }} | ||
size="s" | ||
iconType={chatIconLight} | ||
data-test-subj="cloudChat" | ||
onClick={() => { | ||
if (showTour) setShowTour(false); | ||
chatApi?.toggle(); | ||
}} | ||
> | ||
{i18n.translate('xpack.cloudChat.chatButtonLabel', { | ||
defaultMessage: 'Live Chat', | ||
})} | ||
</EuiButtonEmpty> | ||
</EuiTourStep> | ||
)} | ||
{ReactDOM.createPortal( | ||
<Chat | ||
onReady={(_chatApi) => { | ||
setChatApi(_chatApi); | ||
}} | ||
onPlaybookFired={() => { | ||
setChatButtonShow(true); | ||
}} | ||
/>, | ||
document.body | ||
)} | ||
</> | ||
); | ||
} |
5 changes: 5 additions & 0 deletions
5
...egrations/cloud_chat/public/components/chat_header_menu_item/chat_icon_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
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
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
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
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