forked from opensearch-project/OpenSearch-Dashboards
-
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.
Add data source step into IndexPattern with Mock switch (opensearch-p…
…roject#2064) Signed-off-by: Kristen Tian <tyarong@amazon.com>
- Loading branch information
1 parent
fec5e3d
commit 79ff64c
Showing
12 changed files
with
343 additions
and
26 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
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: add dynamic stuff other than 0/2 | ||
/> | ||
</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 | ||
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'; |
44 changes: 44 additions & 0 deletions
44
...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,44 @@ | ||
/* | ||
* 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); | ||
|
||
// todo: consistent name | ||
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.