-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[EPM] 52075 add data source first page #52320
Merged
neptunian
merged 5 commits into
elastic:feature-ingest
from
neptunian:52075-add-data-source-first-page
Dec 9, 2019
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
84 changes: 84 additions & 0 deletions
84
x-pack/legacy/plugins/epm/public/screens/add_data_source/add_data_source_steps.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,84 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import React, { useState, Fragment, useCallback } from 'react'; | ||
import styled from 'styled-components'; | ||
import { EuiPanel, EuiSteps, EuiButton, EuiHorizontalRule } from '@elastic/eui'; | ||
import { Redirect } from 'react-router-dom'; | ||
import { StepOneTemplate } from './step_one'; | ||
import { installDatasource } from '../../data'; | ||
import { useCore, useLinks } from '../../hooks'; | ||
|
||
const StyledSteps = styled.div` | ||
.euiStep__titleWrapper { | ||
border-bottom: 1px solid ${props => props.theme.eui.euiBorderColor}; | ||
padding-bottom: ${props => props.theme.eui.paddingSizes.l}; | ||
} | ||
.euiStep__content { | ||
padding-bottom: 0; | ||
} | ||
`; | ||
interface AddDataSourceStepsProps { | ||
pkgName: string; | ||
pkgTitle: string; | ||
pkgVersion: string; | ||
} | ||
const FormNav = styled.div` | ||
text-align: right; | ||
`; | ||
export const AddDataSourceSteps = (props: AddDataSourceStepsProps) => { | ||
const [addDataSourceSuccess, setAddDataSourceSuccess] = useState<boolean>(false); | ||
const { notifications } = useCore(); | ||
const { toDetailView } = useLinks(); | ||
const { pkgName, pkgTitle, pkgVersion } = props; | ||
const handleRequestInstallDatasource = useCallback(async () => { | ||
try { | ||
await installDatasource(`${pkgName}-${pkgVersion}`); | ||
setAddDataSourceSuccess(true); | ||
notifications.toasts.addSuccess({ | ||
title: `Added ${pkgTitle} data source`, | ||
}); | ||
return; | ||
} catch (err) { | ||
notifications.toasts.addWarning({ | ||
title: `Failed to add data source to ${pkgTitle}`, | ||
iconType: 'alert', | ||
}); | ||
} | ||
}, [notifications.toasts, pkgName, pkgTitle, pkgVersion]); | ||
const stepOne = [ | ||
{ | ||
title: 'Define your data source', | ||
children: <StepOneTemplate />, | ||
}, | ||
]; | ||
|
||
return ( | ||
<Fragment> | ||
{addDataSourceSuccess ? ( | ||
<Redirect | ||
to={toDetailView({ | ||
name: pkgName, | ||
version: pkgVersion, | ||
panel: 'data-sources', | ||
withAppRoot: false, | ||
})} | ||
/> | ||
) : ( | ||
<EuiPanel> | ||
<StyledSteps> | ||
<EuiSteps steps={stepOne} /> | ||
</StyledSteps> | ||
<FormNav> | ||
<EuiHorizontalRule margin="xl" /> | ||
<EuiButton fill onClick={handleRequestInstallDatasource}> | ||
Continue | ||
</EuiButton> | ||
</FormNav> | ||
</EuiPanel> | ||
)} | ||
</Fragment> | ||
); | ||
}; |
84 changes: 84 additions & 0 deletions
84
x-pack/legacy/plugins/epm/public/screens/add_data_source/index.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,84 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import React, { useState, useEffect } from 'react'; | ||
import { ICON_TYPES, EuiPageHeader, EuiTitle, EuiFlexGroup, EuiIcon, EuiPanel } from '@elastic/eui'; | ||
import styled from 'styled-components'; | ||
import { NavButtonBack } from '../../components/nav_button_back'; | ||
import { useLinks } from '../../hooks'; | ||
import { PackageInfo } from '../../../common/types'; | ||
import { getPackageInfoByKey } from '../../data'; | ||
import { AddDataSourceSteps } from './add_data_source_steps'; | ||
|
||
export interface AddDataSourceProps { | ||
pkgkey: string; | ||
} | ||
|
||
// TODO: change to percentages? | ||
const SIDEBAR_WIDTH = '168px'; | ||
|
||
const PageContainer = styled.div` | ||
neptunian marked this conversation as resolved.
Show resolved
Hide resolved
|
||
margin: 0 auto; | ||
width: 1200px; | ||
`; | ||
const PageBody = styled.div` | ||
min-width: 772px; | ||
`; | ||
const NavButtonBackWrapper = styled.div` | ||
padding: ${props => props.theme.eui.paddingSizes.xl} 0 ${props => props.theme.eui.paddingSizes.m} | ||
0; | ||
`; | ||
const SideBar = styled.div` | ||
margin-right: ${props => props.theme.eui.paddingSizes.xl}; | ||
max-width: ${SIDEBAR_WIDTH}; | ||
`; | ||
const IconPanel = styled(EuiPanel)` | ||
padding: ${props => props.theme.eui.paddingSizes.xl} !important; | ||
text-align: center; | ||
width: ${SIDEBAR_WIDTH}; | ||
height: ${SIDEBAR_WIDTH}; | ||
`; | ||
export function AddDataSource({ pkgkey }: AddDataSourceProps) { | ||
const [info, setInfo] = useState<PackageInfo | null>(null); | ||
const { toDetailView } = useLinks(); | ||
|
||
useEffect(() => { | ||
getPackageInfoByKey(pkgkey).then(response => { | ||
setInfo(response); | ||
}); | ||
}, [pkgkey]); | ||
|
||
// don't have designs for loading/empty states | ||
if (!info) return null; | ||
|
||
const { version, name, title } = info; | ||
const iconType = ICON_TYPES.find(key => key.toLowerCase() === `logo${name}`); | ||
|
||
return ( | ||
<PageContainer> | ||
<NavButtonBackWrapper> | ||
<NavButtonBack | ||
href={toDetailView({ name, panel: 'data-sources', version })} | ||
text="Cancel" | ||
/> | ||
</NavButtonBackWrapper> | ||
<EuiFlexGroup gutterSize="none"> | ||
<SideBar> | ||
<IconPanel> | ||
neptunian marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{iconType ? <EuiIcon width="102" height="102" type={iconType} size="original" /> : null} | ||
</IconPanel> | ||
</SideBar> | ||
<PageBody> | ||
<EuiPageHeader> | ||
<EuiTitle size="l"> | ||
<h1>Add {title} data source</h1> | ||
</EuiTitle> | ||
</EuiPageHeader> | ||
<AddDataSourceSteps pkgName={name} pkgVersion={version} pkgTitle={title} /> | ||
</PageBody> | ||
</EuiFlexGroup> | ||
</PageContainer> | ||
); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally we wouldn't target these internal selectors but if that's the only way 🤷♀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yea, unfortunately EuiSteps only allows a string into the title or I could pass an element to style. Henry recommended I do something like this to have a custom styled title. I'll make a note to mention it to the eui team about making it more flexible with an element.