forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request elastic#18 from joemcelroy/add-view-code-fields-re…
…design changes for fields redesign
- Loading branch information
Showing
4 changed files
with
202 additions
and
47 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
95 changes: 95 additions & 0 deletions
95
packages/kbn-ai-playground/components/view_code/view_code_action.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,95 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import React, { useState } from 'react'; | ||
import { | ||
EuiFlyout, | ||
EuiFlyoutHeader, | ||
EuiFlyoutBody, | ||
EuiTitle, | ||
EuiCodeBlock, | ||
EuiButton, | ||
EuiText, | ||
EuiSpacer, | ||
EuiSteps, | ||
EuiCode, | ||
} from '@elastic/eui'; | ||
import { useFormContext } from 'react-hook-form'; | ||
import { ChatForm } from '../../types'; | ||
|
||
interface ViewCodeActionProps {} | ||
|
||
export const ViewCodeAction: React.FC<ViewCodeActionProps> = () => { | ||
const { getValues } = useFormContext<ChatForm>(); | ||
const [showFlyout, setShowFlyout] = useState(false); | ||
const selectedIndices: string[] = getValues('indices'); | ||
|
||
let flyout; | ||
|
||
const steps = [ | ||
{ | ||
title: 'Generate and copy an API key', | ||
children: ( | ||
<> | ||
<EuiText> | ||
<p>Run this code snippet to install things.</p> | ||
</EuiText> | ||
<EuiSpacer /> | ||
<EuiCodeBlock language="bash">npm install</EuiCodeBlock> | ||
</> | ||
), | ||
}, | ||
{ | ||
title: 'Create application', | ||
children: ( | ||
<EuiText> | ||
<p> | ||
Now that you've completed step 2, go find the <EuiCode>thing</EuiCode>. | ||
</p> | ||
<p> | ||
Go to <strong>Overview >> Endpoints</strong> note <strong>Elasticsearch</strong>{' '} | ||
as <EuiCode><thing></EuiCode>. | ||
</p> | ||
</EuiText> | ||
), | ||
}, | ||
]; | ||
|
||
if (showFlyout) { | ||
flyout = ( | ||
<EuiFlyout ownFocus onClose={() => setShowFlyout(false)}> | ||
<EuiFlyoutHeader hasBorder> | ||
<EuiTitle size="m"> | ||
<h2>Download Code</h2> | ||
</EuiTitle> | ||
<EuiSpacer size="s" /> | ||
<EuiText color="subdued"> | ||
<p>Download the code to use in your application.</p> | ||
</EuiText> | ||
</EuiFlyoutHeader> | ||
<EuiFlyoutBody> | ||
<EuiSteps steps={steps} headingElement="h2" /> | ||
</EuiFlyoutBody> | ||
</EuiFlyout> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
{flyout} | ||
<EuiButton | ||
color="primary" | ||
fill | ||
onClick={() => setShowFlyout(true)} | ||
disabled={!selectedIndices || selectedIndices?.length === 0} | ||
> | ||
Download Code | ||
</EuiButton> | ||
</> | ||
); | ||
}; |
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