Skip to content
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

Add template variable subpage UI #11810

Merged
merged 1 commit into from
Feb 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
1. [11740](https://github.com/influxdata/influxdb/pull/11740): Add view button to view the telegraf config toml
1. [11522](https://github.com/influxdata/influxdb/pull/11522): Add plugin information step to allow for config naming and configure one plugin at a time
1. [11758](https://github.com/influxdata/influxdb/pull/11758): Update Dashboards tab on Org page to look like Dashboards Page
1. [11810](https://github.com/influxdata/influxdb/pull/11810): Add tab for template variables under organizations page

## Bug Fixes
1. [11678](https://github.com/influxdata/influxdb/pull/11678): Update the System Telegraf Plugin bundle to include the swap plugin
Expand Down
2 changes: 1 addition & 1 deletion ui/src/configuration/components/LabelList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {validateLabelName} from 'src/configuration/utils/labels'

// Types
import {LabelType} from 'src/clockface'
import {OverlayState} from 'src/types/v2'
import {OverlayState} from 'src/types'

// Decorators
import {ErrorHandling} from 'src/shared/decorators/errors'
Expand Down
2 changes: 1 addition & 1 deletion ui/src/organizations/components/BucketList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import DataLoaderSwitcher from 'src/dataLoaders/components/DataLoaderSwitcher'
import {setBucketInfo} from 'src/dataLoaders/actions/steps'

// Types
import {OverlayState} from 'src/types/v2'
import {OverlayState} from 'src/types'
import {Substep, DataLoaderStep, DataLoaderType} from 'src/types/v2/dataLoaders'
import {setDataLoadersType} from 'src/dataLoaders/actions/dataLoaders'
import {AppState} from 'src/types/v2'
Expand Down
2 changes: 1 addition & 1 deletion ui/src/organizations/components/Buckets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {ruleToString} from 'src/utils/formatting'
import {client} from 'src/utils/api'

// Types
import {OverlayState} from 'src/types/v2'
import {OverlayState} from 'src/types'

import {Bucket, Organization, BucketRetentionRules} from '@influxdata/influx'

Expand Down
2 changes: 1 addition & 1 deletion ui/src/organizations/components/Collectors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {ErrorHandling} from 'src/shared/decorators/errors'

// Types
import {Telegraf, Bucket} from '@influxdata/influx'
import {OverlayState} from 'src/types/v2'
import {OverlayState} from 'src/types'
import {
setDataLoadersType,
setTelegrafConfigID,
Expand Down
15 changes: 15 additions & 0 deletions ui/src/organizations/components/CreateVariableOverlay.scss
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 ui/src/organizations/components/CreateVariableOverlay.tsx
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,
ComponentColor,
ComponentStatus,
ButtonType,
OverlayFooter,
} from 'src/clockface'
import {Button} from '@influxdata/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}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
onDismiss={this.props.onCloseModal}
onDismiss={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})
}
}
1 change: 0 additions & 1 deletion ui/src/organizations/components/OrgTaskEditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ class OrgTaskEditPage extends PureComponent<
script={currentScript}
onChangeScript={this.handleChangeScript}
visibility="visible"
status={{text: '', type: ''}}
suggestions={[]}
/>
</div>
Expand Down
6 changes: 3 additions & 3 deletions ui/src/organizations/components/OrgTaskPage.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// Libraries
import _ from 'lodash'
import React, {PureComponent, ChangeEvent} from 'react'
import {InjectedRouter} from 'react-router'
import {connect} from 'react-redux'

// components
// Components
import TaskForm from 'src/tasks/components/TaskForm'
import TaskHeader from 'src/tasks/components/TaskHeader'
import FluxEditor from 'src/shared/components/FluxEditor'
import {Page} from 'src/pageLayout'

// actions
// Actions
import {State as TasksState} from 'src/tasks/reducers/v2'
import {
setNewScript,
Expand Down Expand Up @@ -96,7 +97,6 @@ class OrgTaskPage extends PureComponent<
script={newScript}
onChangeScript={this.handleChangeScript}
visibility="visible"
status={{text: '', type: ''}}
suggestions={[]}
/>
</div>
Expand Down
6 changes: 6 additions & 0 deletions ui/src/organizations/components/OrganizationNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ class OrganizationNavigation extends PureComponent<Props> {
url={`${route}/scrapers_tab`}
active={'scrapers_tab' === tab}
/>
<Tabs.Tab
title={'Variables'}
id={'variables'}
url={`${route}/variables_tab`}
active={'variables_tab' === tab}
/>
</Tabs.Nav>
)
}
Expand Down
2 changes: 1 addition & 1 deletion ui/src/organizations/components/Scrapers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {ErrorHandling} from 'src/shared/decorators/errors'

// Types
import {ScraperTargetResponse, Bucket} from '@influxdata/influx'
import {OverlayState} from 'src/types/v2'
import {OverlayState} from 'src/types'
import {DataLoaderType, DataLoaderStep} from 'src/types/v2/dataLoaders'

interface Props {
Expand Down
77 changes: 77 additions & 0 deletions ui/src/organizations/components/Variables.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Libraries
import React, {PureComponent, ChangeEvent} from 'react'
import _ from 'lodash'

// Components
import TabbedPageHeader from 'src/shared/components/tabbed_page/TabbedPageHeader'
import CreateVariableOverlay from 'src/organizations/components/CreateVariableOverlay'
import {Button} from '@influxdata/clockface'
import {Input, ComponentColor, IconFont, OverlayTechnology} from 'src/clockface'

// Types
import {OverlayState} from 'src/types'

interface Props {}

interface State {
searchTerm: string
overlayState: OverlayState
}

export default class Variables 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 = (e: ChangeEvent<HTMLInputElement>) => {
const {value} = e.target
this.setState({searchTerm: value})
}

private handleFilterBlur() {}

private handleOpenModal = (): void => {
this.setState({overlayState: OverlayState.Open})
}

private handleCloseModal = (): void => {
this.setState({overlayState: OverlayState.Closed})
}

private handleCreateVariable() {}
}
8 changes: 8 additions & 0 deletions ui/src/organizations/containers/OrganizationView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {Page} from 'src/pageLayout'
import {SpinnerContainer, TechnoSpinner} from 'src/clockface'
import TabbedPageSection from 'src/shared/components/tabbed_page/TabbedPageSection'
import Members from 'src/organizations/components/Members'
import Variables from 'src/organizations/components/Variables'
import Buckets from 'src/organizations/components/Buckets'
import OrgTasksPage from 'src/organizations/components/OrgTasksPage'
import Collectors from 'src/organizations/components/Collectors'
Expand Down Expand Up @@ -265,6 +266,13 @@ class OrganizationView extends PureComponent<Props> {
}}
</GetOrgResources>
</TabbedPageSection>
<TabbedPageSection
id="org-view-tab--variables"
url="variables_tab"
title="Variables"
>
<Variables />
</TabbedPageSection>
</OrganizationTabs>
</div>
</Page.Contents>
Expand Down
3 changes: 2 additions & 1 deletion ui/src/shared/components/FluxEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface Status {

interface Props {
script: string
status: Status
status?: Status
onChangeScript: OnChangeScript
onSubmitScript?: () => void
suggestions: Suggestion[]
Expand All @@ -52,6 +52,7 @@ interface EditorInstance extends IInstance {
class FluxEditor extends PureComponent<Props, State> {
public static defaultProps = {
visibility: 'visible',
status: {text: '', type: ''},
}

private editor: EditorInstance
Expand Down
1 change: 0 additions & 1 deletion ui/src/tasks/containers/TaskEditPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ class TaskEditPage extends PureComponent<
script={currentScript}
onChangeScript={this.handleChangeScript}
visibility="visible"
status={{text: '', type: ''}}
suggestions={[]}
/>
</div>
Expand Down
9 changes: 5 additions & 4 deletions ui/src/tasks/containers/TaskPage.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
// Libraries
import _ from 'lodash'
import React, {PureComponent, ChangeEvent} from 'react'
import {InjectedRouter} from 'react-router'
import {connect} from 'react-redux'

// components
// Components
import TaskForm from 'src/tasks/components/TaskForm'
import TaskHeader from 'src/tasks/components/TaskHeader'
import FluxEditor from 'src/shared/components/FluxEditor'
import {Page} from 'src/pageLayout'

// actions
// Actions
import {State as TasksState} from 'src/tasks/reducers/v2'
import {
setNewScript,
Expand All @@ -18,7 +19,8 @@ import {
clearTask,
cancel,
} from 'src/tasks/actions/v2'
// types

// Types
import {Links} from 'src/types/v2/links'
import {Organization} from 'src/types/v2'
import {
Expand Down Expand Up @@ -95,7 +97,6 @@ class TaskPage extends PureComponent<
script={newScript}
onChangeScript={this.handleChangeScript}
visibility="visible"
status={{text: '', type: ''}}
suggestions={[]}
/>
</div>
Expand Down
Loading