-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add functional buttons in form headers; fix query parse bug (#649)
* Add test flow button in form headers Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com> * Refactor flyout into standalone component Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com> * More refactoring and layout updates Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com> * Move datasourceversion fetching into custom reusable hook Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com> * Remove unnecessary loading state param Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com> * More refactoring; set up multi-resource flyout Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com> * Get multi resource flyout working and entrypoints in main flow Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com> * Fix regex replacement Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com> * Add examples for ingest and search Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com> * Propagate runtime props to flyout content Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com> * Propagate in existing resources tab alsog Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com> --------- Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
- Loading branch information
Showing
10 changed files
with
620 additions
and
179 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
51 changes: 51 additions & 0 deletions
51
public/pages/workflow_detail/tools/resources/resource_flyout.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,51 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { | ||
EuiFlyout, | ||
EuiFlyoutBody, | ||
EuiFlyoutHeader, | ||
EuiTitle, | ||
} from '@elastic/eui'; | ||
import { WorkflowResource } from '../../../../../common'; | ||
import { ResourceFlyoutContent } from './resource_flyout_content'; | ||
|
||
interface ResourceFlyoutProps { | ||
resource: WorkflowResource; | ||
resourceDetails: string; | ||
onClose: () => void; | ||
errorMessage?: string; | ||
indexName?: string; | ||
searchPipelineName?: string; | ||
ingestPipelineName?: string; | ||
searchQuery?: string; | ||
} | ||
|
||
/** | ||
* A simple flyout to display details for a particular workflow resource. | ||
*/ | ||
export function ResourceFlyout(props: ResourceFlyoutProps) { | ||
return ( | ||
<EuiFlyout onClose={props.onClose}> | ||
<EuiFlyoutHeader> | ||
<EuiTitle> | ||
<h2>Resource details</h2> | ||
</EuiTitle> | ||
</EuiFlyoutHeader> | ||
<EuiFlyoutBody> | ||
<ResourceFlyoutContent | ||
resource={props.resource} | ||
resourceDetails={props.resourceDetails} | ||
errorMessage={props.errorMessage} | ||
indexName={props.indexName} | ||
ingestPipelineName={props.ingestPipelineName} | ||
searchPipelineName={props.searchPipelineName} | ||
searchQuery={props.searchQuery} | ||
/> | ||
</EuiFlyoutBody> | ||
</EuiFlyout> | ||
); | ||
} |
160 changes: 160 additions & 0 deletions
160
public/pages/workflow_detail/tools/resources/resource_flyout_content.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,160 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { | ||
EuiCodeBlock, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiTitle, | ||
EuiText, | ||
EuiEmptyPrompt, | ||
EuiHealth, | ||
EuiSpacer, | ||
EuiLink, | ||
} from '@elastic/eui'; | ||
import { | ||
BULK_API_DOCS_LINK, | ||
SEARCH_PIPELINE_DOCS_LINK, | ||
WORKFLOW_STEP_TYPE, | ||
WorkflowResource, | ||
} from '../../../../../common'; | ||
|
||
interface ResourceFlyoutContentProps { | ||
resource: WorkflowResource; | ||
resourceDetails: string; | ||
errorMessage?: string; | ||
indexName?: string; | ||
searchPipelineName?: string; | ||
ingestPipelineName?: string; | ||
searchQuery?: string; | ||
} | ||
|
||
/** | ||
* The static flyout content for a particular workflow resource. | ||
*/ | ||
export function ResourceFlyoutContent(props: ResourceFlyoutContentProps) { | ||
return ( | ||
<EuiFlexGroup direction="column" gutterSize="xs"> | ||
<EuiFlexItem grow={false}> | ||
<EuiTitle size="s"> | ||
<h4>Name</h4> | ||
</EuiTitle> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiText>{props.resource?.id || ''}</EuiText> | ||
</EuiFlexItem> | ||
<EuiSpacer size="s" /> | ||
<EuiFlexItem grow={false}> | ||
<EuiTitle size="s"> | ||
<h4>Status</h4> | ||
</EuiTitle> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiHealth color="success">Active</EuiHealth> | ||
</EuiFlexItem> | ||
<EuiSpacer size="s" /> | ||
<EuiFlexItem grow={false}> | ||
<EuiTitle size="s"> | ||
<h4> | ||
{props.resource?.stepType === | ||
WORKFLOW_STEP_TYPE.CREATE_INDEX_STEP_TYPE | ||
? 'Configuration' | ||
: 'Pipeline configuration'} | ||
</h4> | ||
</EuiTitle> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={true}> | ||
{!props.errorMessage ? ( | ||
<EuiCodeBlock | ||
language="json" | ||
fontSize="m" | ||
isCopyable={true} | ||
overflowHeight={600} | ||
> | ||
{props.resourceDetails} | ||
</EuiCodeBlock> | ||
) : ( | ||
<EuiEmptyPrompt | ||
iconType="alert" | ||
iconColor="danger" | ||
title={<h2>Error loading resource details</h2>} | ||
body={<p>{props.errorMessage}</p>} | ||
/> | ||
)} | ||
</EuiFlexItem> | ||
<EuiSpacer size="s" /> | ||
<EuiFlexItem grow={false}> | ||
<EuiTitle size="s"> | ||
<h4> | ||
{props.resource?.stepType === | ||
WORKFLOW_STEP_TYPE.CREATE_INDEX_STEP_TYPE | ||
? 'Ingest additional data using the bulk API' | ||
: props.resource?.stepType === | ||
WORKFLOW_STEP_TYPE.CREATE_INGEST_PIPELINE_STEP_TYPE | ||
? 'Ingest additional data using the bulk API' | ||
: 'Apply a search pipeline to your applications'} | ||
</h4> | ||
</EuiTitle> | ||
</EuiFlexItem> | ||
{props.resource?.stepType === | ||
WORKFLOW_STEP_TYPE.CREATE_SEARCH_PIPELINE_STEP_TYPE ? ( | ||
<EuiFlexItem grow={false}> | ||
<EuiText size="s"> | ||
<p> | ||
You can invoke the search pipeline API in your applications.{' '} | ||
<EuiLink href={SEARCH_PIPELINE_DOCS_LINK} target="_blank"> | ||
Learn more | ||
</EuiLink> | ||
</p> | ||
</EuiText> | ||
</EuiFlexItem> | ||
) : ( | ||
<EuiFlexItem grow={false}> | ||
<EuiText size="s"> | ||
<p> | ||
You can ingest a larger amount of data using the Bulk API.{' '} | ||
<EuiLink href={BULK_API_DOCS_LINK} target="_blank"> | ||
Learn more | ||
</EuiLink> | ||
</p> | ||
</EuiText> | ||
</EuiFlexItem> | ||
)} | ||
{props.resource?.stepType === | ||
WORKFLOW_STEP_TYPE.CREATE_SEARCH_PIPELINE_STEP_TYPE ? ( | ||
<EuiFlexItem grow={false}> | ||
<EuiCodeBlock fontSize="m" isCopyable={true}> | ||
{`GET /${props.indexName || 'my_index'}/_search?search_pipeline=${ | ||
props.searchPipelineName || 'my_pipeline' | ||
}` + | ||
`${ | ||
props.searchQuery | ||
? `\n${props.searchQuery}` | ||
: ` | ||
{ | ||
"query": { | ||
"term": { | ||
"item_text": { | ||
"value": "{{query_text}}" | ||
} | ||
} | ||
} | ||
}` | ||
}`} | ||
</EuiCodeBlock> | ||
</EuiFlexItem> | ||
) : ( | ||
<EuiFlexItem grow={false}> | ||
<EuiCodeBlock fontSize="m" isCopyable={true}> | ||
{`POST _bulk | ||
{ "index": { "_index": "${props.indexName || 'my_index'}", "_id": "abc123" } } | ||
{ "my_field_1": "my_field_value_1", "my_field_2": "my_field_value_2" }`} | ||
</EuiCodeBlock> | ||
</EuiFlexItem> | ||
)} | ||
</EuiFlexGroup> | ||
); | ||
} |
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.