-
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.
Add UI for creating a template variable
- Loading branch information
1 parent
2a45302
commit e854c0e
Showing
17 changed files
with
235 additions
and
17 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
15 changes: 15 additions & 0 deletions
15
ui/src/organizations/components/CreateVariableOverlay.scss
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,15 @@ | ||
/* | ||
Create Variable Overlay Styles | ||
----------------------------------------------------------------------------- | ||
*/ | ||
|
||
@import 'src/style/modules'; | ||
|
||
.overlay-flux-editor { | ||
position: relative; | ||
height: 300px; | ||
} | ||
|
||
.overlay-flux-editor--spacing { | ||
margin-bottom: $ix-marg-c; | ||
} |
116 changes: 116 additions & 0 deletions
116
ui/src/organizations/components/CreateVariableOverlay.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,116 @@ | ||
// Libraries | ||
import React, {PureComponent, ChangeEvent} from 'react' | ||
|
||
// Styles | ||
import 'src/organizations/components/CreateVariableOverlay.scss' | ||
|
||
// Components | ||
import { | ||
Form, | ||
OverlayBody, | ||
OverlayHeading, | ||
OverlayContainer, | ||
Input, | ||
Button, | ||
ComponentColor, | ||
ComponentStatus, | ||
ButtonType, | ||
OverlayFooter, | ||
} from 'src/clockface' | ||
import FluxEditor from 'src/shared/components/FluxEditor' | ||
|
||
interface Props { | ||
onCreateVariable: () => void | ||
onCloseModal: () => void | ||
} | ||
|
||
interface State { | ||
name: string | ||
script: string | ||
nameInputStatus: ComponentStatus | ||
errorMessage: string | ||
} | ||
|
||
export default class CreateOrgOverlay extends PureComponent<Props, State> { | ||
constructor(props) { | ||
super(props) | ||
this.state = { | ||
name: '', | ||
script: '', | ||
nameInputStatus: ComponentStatus.Default, | ||
errorMessage: '', | ||
} | ||
} | ||
|
||
public render() { | ||
const {onCloseModal} = this.props | ||
const {nameInputStatus, name, script} = this.state | ||
|
||
return ( | ||
<OverlayContainer maxWidth={1000}> | ||
<OverlayHeading | ||
title="Create Variable" | ||
onDismiss={this.props.onCloseModal} | ||
/> | ||
|
||
<Form> | ||
<OverlayBody> | ||
<div className="overlay-flux-editor--spacing"> | ||
<Form.Element label="Name"> | ||
<Input | ||
placeholder="Give your variable a name" | ||
name="name" | ||
autoFocus={true} | ||
value={name} | ||
onChange={this.handleChangeInput} | ||
status={nameInputStatus} | ||
/> | ||
</Form.Element> | ||
</div> | ||
|
||
<Form.Element label="Value"> | ||
<div className="overlay-flux-editor"> | ||
<FluxEditor | ||
script={script} | ||
onChangeScript={this.handleChangeScript} | ||
visibility="visible" | ||
suggestions={[]} | ||
/> | ||
</div> | ||
</Form.Element> | ||
|
||
<OverlayFooter> | ||
<Button | ||
text="Cancel" | ||
color={ComponentColor.Danger} | ||
onClick={onCloseModal} | ||
/> | ||
<Button | ||
text="Create" | ||
type={ButtonType.Submit} | ||
onClick={this.handleCreateVariable} | ||
color={ComponentColor.Primary} | ||
/> | ||
</OverlayFooter> | ||
</OverlayBody> | ||
</Form> | ||
</OverlayContainer> | ||
) | ||
} | ||
|
||
private handleCreateVariable = () => { | ||
this.props.onCloseModal() | ||
} | ||
|
||
private handleChangeInput = (e: ChangeEvent<HTMLInputElement>) => { | ||
const {value, name} = e.target | ||
|
||
const newState = {...this.state} | ||
newState[name] = value | ||
this.setState(newState) | ||
} | ||
|
||
private handleChangeScript = (script: string): void => { | ||
this.setState({script}) | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Libraries | ||
import React, {PureComponent} from 'react' | ||
import _ from 'lodash' | ||
|
||
// Components | ||
import TabbedPageHeader from 'src/shared/components/tabbed_page/TabbedPageHeader' | ||
import CreateVariableOverlay from 'src/organizations/components/CreateVariableOverlay' | ||
import { | ||
Input, | ||
Button, | ||
ComponentColor, | ||
IconFont, | ||
OverlayTechnology, | ||
} from 'src/clockface' | ||
|
||
// Types | ||
import {OverlayState} from 'src/types' | ||
|
||
interface Props {} | ||
|
||
interface State { | ||
searchTerm: string | ||
overlayState: OverlayState | ||
} | ||
|
||
export default class Buckets extends PureComponent<Props, State> { | ||
constructor(props: Props) { | ||
super(props) | ||
this.state = { | ||
searchTerm: '', | ||
overlayState: OverlayState.Closed, | ||
} | ||
} | ||
|
||
public render() { | ||
const {searchTerm, overlayState} = this.state | ||
|
||
return ( | ||
<> | ||
<TabbedPageHeader> | ||
<Input | ||
icon={IconFont.Search} | ||
placeholder="Filter variables..." | ||
widthPixels={290} | ||
value={searchTerm} | ||
onChange={this.handleFilterChange} | ||
onBlur={this.handleFilterBlur} | ||
/> | ||
<Button | ||
text="Create Variable" | ||
icon={IconFont.Plus} | ||
color={ComponentColor.Primary} | ||
onClick={this.handleOpenModal} | ||
/> | ||
</TabbedPageHeader> | ||
<OverlayTechnology visible={overlayState === OverlayState.Open}> | ||
<CreateVariableOverlay | ||
onCreateVariable={this.handleCreateVariable} | ||
onCloseModal={this.handleCloseModal} | ||
/> | ||
</OverlayTechnology> | ||
</> | ||
) | ||
} | ||
|
||
private handleFilterChange() {} | ||
|
||
private handleFilterBlur() {} | ||
|
||
private handleOpenModal = (): void => { | ||
this.setState({overlayState: OverlayState.Open}) | ||
} | ||
|
||
private handleCloseModal = (): void => { | ||
this.setState({overlayState: OverlayState.Closed}) | ||
} | ||
|
||
private handleCreateVariable() {} | ||
} |
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
File renamed without changes.
Oops, something went wrong.