-
Notifications
You must be signed in to change notification settings - Fork 916
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: Kristen Tian <tyarong@amazon.com>
- Loading branch information
1 parent
fec5e3d
commit 4727e54
Showing
14 changed files
with
347 additions
and
28 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
6 changes: 5 additions & 1 deletion
6
...nents/create_index_pattern_wizard/__snapshots__/create_index_pattern_wizard.test.tsx.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
96 changes: 96 additions & 0 deletions
96
...ents/create_index_pattern_wizard/components/step_data_source/components/header/header.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,96 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
|
||
import { EuiTitle, EuiSpacer, EuiText, EuiFlexItem, EuiFormRow, EuiButton } from '@elastic/eui'; | ||
|
||
import { FormattedMessage } from '@osd/i18n/react'; | ||
import { i18n } from '@osd/i18n'; | ||
import { | ||
DataSourceRef, | ||
IndexPatternManagmentContext, | ||
} from 'src/plugins/index_pattern_management/public/types'; | ||
import { SavedObjectFinderUi } from '../../../../../../../../../plugins/saved_objects/public'; | ||
import { useOpenSearchDashboards } from '../../../../../../../../../plugins/opensearch_dashboards_react/public'; | ||
|
||
interface HeaderProps { | ||
onSearchSelected: (id: string, type: string) => void; | ||
dataSourceRef: DataSourceRef; | ||
goToNextStep: (dataSourceRef: DataSourceRef) => void; | ||
isNextStepDisabled: boolean; | ||
} | ||
|
||
const DATA_SOURCE_PAGE_SIZE = 5; | ||
|
||
export const Header: React.FC<HeaderProps> = (props: HeaderProps) => { | ||
const { dataSourceRef, onSearchSelected, goToNextStep, isNextStepDisabled } = props; | ||
|
||
const { savedObjects, uiSettings } = useOpenSearchDashboards< | ||
IndexPatternManagmentContext | ||
>().services; | ||
|
||
return ( | ||
<div> | ||
<EuiTitle size="s"> | ||
<h2> | ||
<FormattedMessage | ||
id="indexPatternManagement.createIndexPattern.stepDataSourceHeader" | ||
defaultMessage="Step 0 of 2: Configure data source" // todo: make dynamic: Next PR | ||
/> | ||
</h2> | ||
</EuiTitle> | ||
<EuiSpacer size="m" /> | ||
<EuiText> | ||
<FormattedMessage | ||
id="indexPatternManagement.createIndexPattern.stepDataSourceLabel" | ||
defaultMessage="Please pick the data source -- within which to configure index patterns." | ||
/> | ||
</EuiText> | ||
<EuiFlexItem grow={false}> | ||
<SavedObjectFinderUi | ||
key="searchSavedObjectFinder" | ||
onChoose={onSearchSelected} | ||
showFilter={false} | ||
noItemsMessage={i18n.translate( | ||
'indexPatternManagement.createIndexPattern.searchSelection.notFoundLabel', | ||
{ | ||
defaultMessage: 'No data sources have been configured yet.', | ||
} | ||
)} | ||
savedObjectMetaData={[ | ||
{ | ||
type: 'data-source', | ||
getIconForSavedObject: () => 'apps', // todo: #2034 | ||
name: i18n.translate( | ||
'indexPatternManagement.createIndexPattern.searchSelection.savedObjectType.dataSource', | ||
{ | ||
defaultMessage: 'Data Source', | ||
} | ||
), | ||
}, | ||
]} | ||
fixedPageSize={DATA_SOURCE_PAGE_SIZE} | ||
uiSettings={uiSettings} | ||
savedObjects={savedObjects} | ||
/> | ||
<EuiFormRow hasEmptyLabelSpace> | ||
<EuiButton | ||
fill | ||
iconSide="right" | ||
iconType="arrowRight" | ||
onClick={() => goToNextStep(dataSourceRef)} | ||
isDisabled={isNextStepDisabled} | ||
> | ||
<FormattedMessage | ||
id="indexPatternManagement.createIndexPattern.step.nextStepButton" | ||
defaultMessage="Next step" | ||
/> | ||
</EuiButton> | ||
</EuiFormRow> | ||
</EuiFlexItem> | ||
</div> | ||
); | ||
}; |
6 changes: 6 additions & 0 deletions
6
...onents/create_index_pattern_wizard/components/step_data_source/components/header/index.ts
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,6 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export { Header } from './header'; |
6 changes: 6 additions & 0 deletions
6
...gement/public/components/create_index_pattern_wizard/components/step_data_source/index.ts
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,6 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
export { StepDataSource } from './step_data_source'; |
43 changes: 43 additions & 0 deletions
43
...c/components/create_index_pattern_wizard/components/step_data_source/step_data_source.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,43 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { EuiPageContent } from '@elastic/eui'; | ||
import React, { useState } from 'react'; | ||
import { DataSourceRef } from 'src/plugins/index_pattern_management/public/types'; | ||
|
||
import { Header } from './components/header'; | ||
|
||
interface StepDataSourceProps { | ||
goToNextStep: (dataSourceRef: DataSourceRef) => void; | ||
} | ||
|
||
export const StepDataSource = (props: StepDataSourceProps) => { | ||
const { goToNextStep } = props; | ||
|
||
const [selectedDataSource, setSelectedDataSource] = useState<DataSourceRef>(); | ||
const [isNextStepDisabled, setIsNextStepDisabled] = useState(true); | ||
|
||
const onSearchSelected = (id: string, selectedType: string) => { | ||
const selected = { id, type: selectedType }; | ||
|
||
setSelectedDataSource(selected); | ||
setIsNextStepDisabled(false); | ||
}; | ||
|
||
const renderContent = () => { | ||
return ( | ||
<EuiPageContent> | ||
<Header | ||
onSearchSelected={onSearchSelected} | ||
dataSourceRef={selectedDataSource!} | ||
goToNextStep={() => goToNextStep(selectedDataSource!)} | ||
isNextStepDisabled={isNextStepDisabled} | ||
/> | ||
</EuiPageContent> | ||
); | ||
}; | ||
|
||
return <>{renderContent()}</>; | ||
}; |
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
Oops, something went wrong.