-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]> (cherry picked from commit ad86b00) Co-authored-by: Tyler Ohlsen <[email protected]>
- Loading branch information
1 parent
cd959e0
commit 45240ad
Showing
13 changed files
with
372 additions
and
253 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,5 @@ | |
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export * from './base_indexer'; | ||
export * from './knn_indexer'; |
114 changes: 114 additions & 0 deletions
114
public/pages/workflow_detail/components/export_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,114 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React, { useEffect, useState } from 'react'; | ||
import yaml from 'js-yaml'; | ||
import { | ||
EuiCodeBlock, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiCompressedRadioGroup, | ||
EuiText, | ||
EuiLink, | ||
EuiModal, | ||
EuiModalHeader, | ||
EuiModalHeaderTitle, | ||
EuiModalBody, | ||
EuiModalFooter, | ||
EuiSmallButtonEmpty, | ||
} from '@elastic/eui'; | ||
import { CREATE_WORKFLOW_LINK, Workflow } from '../../../../common'; | ||
import { reduceToTemplate } from '../../../utils'; | ||
|
||
interface ExportModalProps { | ||
workflow?: Workflow; | ||
setIsExportModalOpen(isOpen: boolean): void; | ||
} | ||
|
||
enum EXPORT_OPTION { | ||
JSON = 'json', | ||
YAML = 'yaml', | ||
} | ||
|
||
const exportOptions = [ | ||
{ | ||
id: EXPORT_OPTION.JSON, | ||
label: 'JSON', | ||
}, | ||
{ | ||
id: EXPORT_OPTION.YAML, | ||
label: 'YAML', | ||
}, | ||
]; | ||
|
||
/** | ||
* Modal containing all of the export options | ||
*/ | ||
export function ExportModal(props: ExportModalProps) { | ||
// format type state | ||
const [selectedOption, setSelectedOption] = useState<EXPORT_OPTION>( | ||
EXPORT_OPTION.JSON | ||
); | ||
|
||
// formatted string state | ||
const [formattedConfig, setFormattedConfig] = useState<string>(''); | ||
useEffect(() => { | ||
if (props.workflow) { | ||
const workflowTemplate = reduceToTemplate(props.workflow); | ||
if (selectedOption === EXPORT_OPTION.JSON) { | ||
setFormattedConfig(JSON.stringify(workflowTemplate, undefined, 2)); | ||
} else if (selectedOption === EXPORT_OPTION.YAML) { | ||
setFormattedConfig(yaml.dump(workflowTemplate)); | ||
} | ||
} | ||
}, [props.workflow, selectedOption]); | ||
|
||
return ( | ||
<EuiModal onClose={() => props.setIsExportModalOpen(false)}> | ||
<EuiModalHeader> | ||
<EuiModalHeaderTitle> | ||
<p>{`Export ${props.workflow?.name}`}</p> | ||
</EuiModalHeaderTitle> | ||
</EuiModalHeader> | ||
<EuiModalBody> | ||
<EuiFlexGroup direction="column"> | ||
<EuiFlexItem grow={false}> | ||
<EuiText> | ||
Copy the below workflow templates to use in other clusters. | ||
</EuiText> | ||
<EuiLink href={CREATE_WORKFLOW_LINK} target="_blank"> | ||
Learn more | ||
</EuiLink> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiCompressedRadioGroup | ||
options={exportOptions} | ||
idSelected={selectedOption} | ||
onChange={(option) => { | ||
setSelectedOption(option as EXPORT_OPTION); | ||
}} | ||
/> | ||
</EuiFlexItem> | ||
{props.workflow !== undefined && ( | ||
<EuiFlexItem grow={false}> | ||
<EuiCodeBlock | ||
language={selectedOption} | ||
fontSize="m" | ||
isCopyable={true} | ||
> | ||
{formattedConfig} | ||
</EuiCodeBlock> | ||
</EuiFlexItem> | ||
)} | ||
</EuiFlexGroup> | ||
</EuiModalBody> | ||
<EuiModalFooter> | ||
<EuiSmallButtonEmpty onClick={() => props.setIsExportModalOpen(false)}> | ||
Close | ||
</EuiSmallButtonEmpty> | ||
</EuiModalFooter> | ||
</EuiModal> | ||
); | ||
} |
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
83 changes: 0 additions & 83 deletions
83
public/pages/workflow_detail/workflow_inputs/export_options/export_options.tsx
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
public/pages/workflow_detail/workflow_inputs/export_options/index.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.