-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(flagged): wireup simple url and name overlay
- Loading branch information
1 parent
55e58c9
commit ba3d011
Showing
5 changed files
with
217 additions
and
10 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
92 changes: 92 additions & 0 deletions
92
ui/src/templates/components/CommunityTemplateImportOverlay.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,92 @@ | ||
import React, {PureComponent} from 'react' | ||
import {withRouter, WithRouterProps} from 'react-router' | ||
import {connect} from 'react-redux' | ||
|
||
// Components | ||
import {TemplateInstallerOverlay} from 'src/templates/components/TemplateInstallerOverlay' | ||
|
||
// Actions | ||
import {createTemplate as createTemplateAction} from 'src/templates/actions/thunks' | ||
import {notify as notifyAction} from 'src/shared/actions/notifications' | ||
|
||
// Types | ||
import {AppState, Organization, ResourceType} from 'src/types' | ||
import {ComponentStatus} from '@influxdata/clockface' | ||
|
||
// Utils | ||
import {getByID} from 'src/resources/selectors' | ||
|
||
interface State { | ||
status: ComponentStatus | ||
} | ||
|
||
interface DispatchProps { | ||
createTemplate: typeof createTemplateAction | ||
notify: typeof notifyAction | ||
} | ||
|
||
interface StateProps { | ||
org: Organization | ||
templateName: string | ||
} | ||
|
||
interface OwnProps extends WithRouterProps { | ||
params: {orgID: string; templateName: string} | ||
} | ||
|
||
type Props = DispatchProps & OwnProps & StateProps | ||
|
||
class UnconnectedTemplateImportOverlay extends PureComponent<Props> { | ||
public state: State = { | ||
status: ComponentStatus.Default, | ||
} | ||
|
||
public render() { | ||
return ( | ||
<TemplateInstallerOverlay | ||
onDismissOverlay={this.onDismiss} | ||
onSubmit={this.handleInstallTemplate} | ||
status={this.state.status} | ||
templateName={this.props.templateName} | ||
updateStatus={this.updateOverlayStatus} | ||
/> | ||
) | ||
} | ||
|
||
private onDismiss = () => { | ||
const {router} = this.props | ||
|
||
router.goBack() | ||
} | ||
|
||
private updateOverlayStatus = (status: ComponentStatus) => | ||
this.setState(() => ({status})) | ||
|
||
private handleInstallTemplate = (importString: string) => { | ||
importString | ||
} | ||
} | ||
|
||
const mstp = (state: AppState, props: Props): StateProps => { | ||
const org = getByID<Organization>( | ||
state, | ||
ResourceType.Orgs, | ||
props.params.orgID | ||
) | ||
|
||
return {org, templateName: props.params.templateName} | ||
} | ||
|
||
const mdtp: DispatchProps = { | ||
createTemplate: createTemplateAction, | ||
notify: notifyAction, | ||
} | ||
|
||
export const CommunityTemplateImportOverlay = connect< | ||
StateProps, | ||
DispatchProps, | ||
Props | ||
>( | ||
mstp, | ||
mdtp | ||
)(withRouter(UnconnectedTemplateImportOverlay)) |
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,68 @@ | ||
// Libraries | ||
import React, {PureComponent} from 'react' | ||
import {withRouter, WithRouterProps} from 'react-router' | ||
|
||
// Components | ||
import { | ||
Gradients, | ||
Heading, | ||
HeadingElement, | ||
Overlay, | ||
Panel, | ||
} from '@influxdata/clockface' | ||
|
||
// Types | ||
import {ComponentStatus} from '@influxdata/clockface' | ||
|
||
interface OwnProps { | ||
isVisible?: boolean | ||
onDismissOverlay: () => void | ||
onSubmit: (importString: string, orgID: string) => void | ||
status?: ComponentStatus | ||
templateName: string | ||
updateStatus?: (status: ComponentStatus) => void | ||
} | ||
|
||
type Props = OwnProps & WithRouterProps | ||
|
||
class UnconnectedImportOverlay extends PureComponent<Props> { | ||
public static defaultProps: {isVisible: boolean} = { | ||
isVisible: true, | ||
} | ||
|
||
public render() { | ||
const {isVisible, templateName} = this.props | ||
|
||
const resourceCount = 0 | ||
|
||
return ( | ||
<Overlay visible={isVisible}> | ||
<Overlay.Container maxWidth={800}> | ||
<Overlay.Header | ||
title="Template Installer" | ||
onDismiss={this.onDismiss} | ||
/> | ||
<Overlay.Body> | ||
<Panel border={true} gradient={Gradients.RebelAlliance}> | ||
<Panel.Header> | ||
<Heading element={HeadingElement.H3}>{templateName}</Heading> | ||
</Panel.Header> | ||
<Panel.Body> | ||
Installing this template will create {resourceCount} resources | ||
in your system | ||
</Panel.Body> | ||
</Panel> | ||
</Overlay.Body> | ||
</Overlay.Container> | ||
</Overlay> | ||
) | ||
} | ||
|
||
private onDismiss = () => { | ||
this.props.onDismissOverlay() | ||
} | ||
} | ||
|
||
export const TemplateInstallerOverlay = withRouter<OwnProps>( | ||
UnconnectedImportOverlay | ||
) |
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