chore(chronograf): fix rebase onto master

pull/10616/head
Andrew Watkins 2018-08-08 10:48:44 -07:00
parent 2af8a38777
commit 5568298297
23 changed files with 130 additions and 583 deletions

326
Gopkg.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,7 @@ import showDatabasesParser from 'src/shared/parsing/showDatabases'
import Dropdown from 'src/shared/components/Dropdown'
import {OnChangeArg} from 'src/types/flux'
import {Source} from 'src/types'
import {Source} from 'src/types/v2'
interface Props {
funcID: string
@ -38,8 +38,8 @@ class FromDatabaseDropdown extends PureComponent<Props, State> {
const {source} = this.props
try {
// (watts): TODO: hit actual showDatabases API
const {data} = await showDatabases(source.links.proxy)
// (watts): TODO: hit actual buckets API
const {data} = await showDatabases(source.links.buckets)
const {databases} = showDatabasesParser(data)
const sorted = databases.sort()

View File

@ -10,7 +10,7 @@ import FromDatabaseDropdown from 'src/flux/components/FromDatabaseDropdown'
import {funcNames, argTypes} from 'src/flux/constants'
import {OnChangeArg, Arg, OnGenerateScript} from 'src/types/flux'
import {Source} from 'src/types'
import {Source} from 'src/types/v2'
interface Props {
source: Source

View File

@ -6,7 +6,7 @@ import {Func, OnGenerateScript} from 'src/types/flux'
import {funcNames} from 'src/flux/constants'
import JoinArgs from 'src/flux/components/JoinArgs'
import FilterArgs from 'src/flux/components/FilterArgs'
import {Source} from 'src/types'
import {Source} from 'src/types/v2'
import {getDeep} from 'src/utils/wrappers'
interface Props {

View File

@ -15,7 +15,7 @@ import {
} from 'src/types/flux'
import {ErrorHandling} from 'src/shared/decorators/errors'
import {Source} from 'src/types'
import {Source} from 'src/types/v2'
interface Props {
func: Func

View File

@ -12,7 +12,7 @@ import {
ScriptStatus,
} from 'src/types/flux'
import {Source} from 'src/types'
import {Source} from 'src/types/v2'
import {ErrorHandling} from 'src/shared/decorators/errors'
import {HANDLE_VERTICAL, HANDLE_HORIZONTAL} from 'src/shared/constants'

View File

@ -6,8 +6,9 @@ import TimeMachineVis from 'src/flux/components/TimeMachineVis'
import {getTimeSeries} from 'src/flux/apis'
import {getDeep} from 'src/utils/wrappers'
import {FluxTable, Source} from 'src/types'
import {FluxTable} from 'src/types'
import {Func} from 'src/types/flux'
import {Source} from 'src/types/v2'
interface Props {
source: Source

View File

@ -30,7 +30,8 @@ import {notify as notifyAction} from 'src/shared/actions/notifications'
import {bodyNodes} from 'src/flux/helpers'
// Types
import {Source, Notification, FluxTable} from 'src/types'
import {Source} from 'src/types/v2'
import {Notification, FluxTable} from 'src/types'
import {
Suggestion,
FlatBody,
@ -55,7 +56,6 @@ interface Props {
notify: (message: Notification) => void
script: string
updateScript: UpdateScript
onGoToEditFlux: (service: Service) => void
}
interface Body extends FlatBody {

View File

@ -1,67 +0,0 @@
// Libraries
import classnames from 'classnames'
import React, {PureComponent} from 'react'
import {withRouter, WithRouterProps} from 'react-router'
// Types
import {Me, Role} from 'src/types'
import {ErrorHandling} from 'src/shared/decorators/errors'
interface OrgID {
organization: string
}
interface Props {
me: Me
role: Role
meLink: string
onMeChangeOrg: (meLink: string, orgID: OrgID) => void
}
@ErrorHandling
class OrgLink extends PureComponent<Props & WithRouterProps> {
public render() {
const {role} = this.props
return (
<span className={this.className} onClick={this.handleChangeOrganization}>
{this.orgName} <strong>({role.name})</strong>
</span>
)
}
private get orgName(): string {
const {me, role} = this.props
const org = me.organizations.find(o => o.id === role.organization)
if (!org) {
return ''
}
return org.name
}
private get isCurrentOrg(): boolean {
const {me, role} = this.props
return me.currentOrganization.id === role.organization
}
private get className(): string {
return classnames('sidebar-menu--item', {
active: this.isCurrentOrg,
})
}
private handleChangeOrganization = async () => {
const {router, meLink, onMeChangeOrg, role} = this.props
try {
await onMeChangeOrg(meLink, {organization: role.organization})
router.push('')
} catch (error) {
console.error(error)
}
}
}
export default withRouter<Props>(OrgLink)

View File

@ -1,117 +0,0 @@
// Libraries
import React, {PureComponent} from 'react'
import {connect} from 'react-redux'
// Components
import OrgLink from 'src/side_nav/components/OrgLink'
import FancyScrollbar from 'src/shared/components/FancyScrollbar'
// Actions
import {meChangeOrganizationAsync} from 'src/shared/actions/auth'
// Constants
import {SUPERADMIN_ROLE} from 'src/auth/Authorized'
// Types
import {Me} from 'src/types'
import {Links, ExternalLink} from 'src/types/auth'
import {ErrorHandling} from 'src/shared/decorators/errors'
interface OrgID {
organization: string
}
interface Props {
me: Me
links: Links
logoutLink: string
meChangeOrg: (meLink: string, orgID: OrgID) => void
}
@ErrorHandling
class UserNavBlock extends PureComponent<Props> {
public render() {
const {logoutLink, me, links, meChangeOrg} = this.props
return (
<div className="sidebar--item">
<div className="sidebar--square">
<div className="sidebar--icon icon user-outline" />
{this.isSuperAdmin && (
<span className="sidebar--icon sidebar--icon__superadmin icon crown2" />
)}
</div>
<div className="sidebar-menu sidebar-menu--user-nav">
{!!this.customLinks && (
<div className="sidebar-menu--section sidebar-menu--section__custom-links">
Custom Links
</div>
)}
{!!this.customLinks &&
this.customLinks.map((link, i) => (
<a
key={i}
className="sidebar-menu--item sidebar-menu--item__link-name"
href={link.url}
target="_blank"
>
{link.name}
</a>
))}
<div className="sidebar-menu--section sidebar-menu--section__switch-orgs">
Switch Organizations
</div>
<FancyScrollbar
className="sidebar-menu--scrollbar"
autoHeight={true}
maxHeight={100}
autoHide={false}
>
{me.roles.map((r, i) => (
<OrgLink
onMeChangeOrg={meChangeOrg}
meLink={links.me}
key={i}
me={me}
role={r}
/>
))}
</FancyScrollbar>
<div className="sidebar-menu--section sidebar-menu--section__account">
Account
</div>
<div className="sidebar-menu--provider">
<div>
{me.scheme} / {me.provider}
</div>
</div>
<a
className="sidebar-menu--item sidebar-menu--item__logout"
href={logoutLink}
>
Log out
</a>
<div className="sidebar-menu--heading sidebar--no-hover">
{me.name}
</div>
<div className="sidebar-menu--triangle" />
</div>
</div>
)
}
private get customLinks(): ExternalLink[] {
return this.props.links.external.custom
}
private get isSuperAdmin(): boolean {
return this.props.me.role === SUPERADMIN_ROLE
}
}
const mdtp = {
meChangeOrg: meChangeOrganizationAsync,
}
export default connect(null, mdtp)(UserNavBlock)

View File

@ -12,8 +12,6 @@ interface Props {
source: Source
sources: Source[]
onDeleteSource: (source: Source) => void
setActiveFlux: (source: Source, service: Service) => void
deleteFlux: (fluxService: Service) => void
}
@ErrorHandling
@ -35,11 +33,8 @@ class InfluxTable extends PureComponent<Props> {
<InfluxTableRow
key={s.id}
source={s}
services={this.getServicesForSource(s.id)}
currentSource={source}
onDeleteSource={onDeleteSource}
setActiveFlux={setActiveFlux}
deleteFlux={deleteFlux}
/>
)
})}
@ -51,12 +46,6 @@ class InfluxTable extends PureComponent<Props> {
</div>
)
}
private getServicesForSource(sourceID: string) {
return this.props.services.filter(s => {
return s.sourceID === sourceID
})
}
}
export default InfluxTable

View File

@ -1,9 +1,5 @@
import React, {SFC, ReactElement} from 'react'
import QuestionMarkTooltip from 'src/shared/components/QuestionMarkTooltip'
import {FLUX_CONNECTION_TOOLTIP} from 'src/flux/constants/connection'
const InfluxTableHead: SFC = (): ReactElement<HTMLTableHeaderCellElement> => {
return (
<thead>
@ -11,13 +7,6 @@ const InfluxTableHead: SFC = (): ReactElement<HTMLTableHeaderCellElement> => {
<th className="source-table--connect-col" />
<th>InfluxDB Connection</th>
<th className="text-right" />
<th>
Flux Connection
<QuestionMarkTooltip
tipID="kapacitor-node-helper"
tipContent={FLUX_CONNECTION_TOOLTIP}
/>
</th>
</tr>
</thead>
)

View File

@ -3,30 +3,20 @@ import {Link} from 'react-router'
import ConfirmButton from 'src/shared/components/ConfirmButton'
import ConnectionLink from 'src/sources/components/ConnectionLink'
import FluxDropdown from 'src/sources/components/FluxDropdown'
import {Source, Service} from 'src/types'
import {Source} from 'src/types'
import {ErrorHandling} from 'src/shared/decorators/errors'
interface Props {
source: Source
currentSource: Source
services: Service[]
onDeleteSource: (source: Source) => void
setActiveFlux: (source: Source, service: Service) => void
deleteFlux: (fluxService: Service) => void
}
@ErrorHandling
class InfluxTableRow extends PureComponent<Props> {
public render() {
const {
source,
services,
currentSource,
setActiveFlux,
deleteFlux,
} = this.props
const {source, currentSource} = this.props
return (
<tr className={this.className}>

View File

@ -3,7 +3,6 @@ import {connect} from 'react-redux'
import {ErrorHandling} from 'src/shared/decorators/errors'
import * as sourcesActions from 'src/shared/actions/sources'
import * as servicesActions from 'src/shared/actions/services'
import {notify as notifyAction} from 'src/shared/actions/notifications'
import FancyScrollbar from 'src/shared/components/FancyScrollbar'
@ -16,26 +15,21 @@ import {
} from 'src/shared/copy/notifications'
import {Source, Notification, Service} from 'src/types'
import {getDeep} from 'src/utils/wrappers'
interface Props {
source: Source
sources: Source[]
services: Service[]
notify: (n: Notification) => void
removeAndLoadSources: actions.RemoveAndLoadSources
removeAndLoadSources: sourcesActions.RemoveAndLoadSources
}
declare var VERSION: string
@ErrorHandling
class ManageSources extends PureComponent<Props> {
public componentDidMount() {
this.props.fetchAllServices(this.props.sources)
}
public render() {
const {sources, source, deleteFlux, services} = this.props
const {sources, source} = this.props
return (
<div className="page" id="manage-sources-page">
@ -45,10 +39,7 @@ class ManageSources extends PureComponent<Props> {
<InfluxTable
source={source}
sources={sources}
services={services}
deleteFlux={deleteFlux}
onDeleteSource={this.handleDeleteSource}
setActiveFlux={this.handleSetActiveFlux}
/>
<p className="version-number">Chronograf Version: {VERSION}</p>
</div>
@ -57,14 +48,6 @@ class ManageSources extends PureComponent<Props> {
)
}
private handleSetActiveFlux = async (source, service) => {
const {services, setActiveFlux} = this.props
const prevActiveService = services.find(s => {
return getDeep<boolean>(s, 'metadata.active', false)
})
await setActiveFlux(source, service, prevActiveService)
}
private handleDeleteSource = (source: Source) => {
const {notify} = this.props
@ -85,12 +68,6 @@ const mstp = ({sources, services}) => ({
const mdtp = {
notify: notifyAction,
removeAndLoadSources: sourcesActions.removeAndLoadSources,
fetchKapacitors: sourcesActions.fetchKapacitorsAsync,
setActiveKapacitor: sourcesActions.setActiveKapacitorAsync,
deleteKapacitor: sourcesActions.deleteKapacitorAsync,
fetchAllServices: servicesActions.fetchAllFluxServicesAsync,
setActiveFlux: servicesActions.setActiveServiceAsync,
deleteFlux: servicesActions.deleteServiceAsync,
}
export default connect(mstp, mdtp)(ManageSources)

View File

@ -1,5 +1,5 @@
// function definitions
import {Source} from 'src/types'
import {Source} from 'src/types/v2'
export type OnDeleteFuncNode = (ids: DeleteFuncNodeArgs) => void
export type OnChangeArg = (inputArg: InputArg) => void
export type OnAddNode = (

View File

@ -1,7 +1,7 @@
import React from 'react'
import {shallow} from 'enzyme'
import FromDatabaseDropdown from 'src/flux/components/FromDatabaseDropdown'
import {source} from 'test/resources'
import {source} from 'test/resources/v2'
jest.mock('src/shared/apis/metaQuery', () => require('mocks/flux/apis'))

View File

@ -1,7 +1,7 @@
import React from 'react'
import {shallow} from 'enzyme'
import FuncArg from 'src/flux/components/FuncArg'
import {source} from 'test/resources'
import {source} from 'test/resources/v2'
const setup = () => {
const props = {

View File

@ -1,7 +1,7 @@
import React from 'react'
import {shallow} from 'enzyme'
import TimeMachine from 'src/flux/components/TimeMachine'
import {source} from 'test/resources'
import {source} from 'test/resources/v2'
const setup = () => {
const props = {

View File

@ -4,7 +4,7 @@ import {shallow} from 'enzyme'
import {FluxPage} from 'src/flux/containers/FluxPage'
import TimeMachine from 'src/flux/components/TimeMachine'
import {ActionTypes} from 'src/flux/actions'
import {source} from 'test/resources'
import {source} from 'test/resources/v2'
jest.mock('src/flux/apis', () => require('mocks/flux/apis'))

View File

@ -505,8 +505,22 @@ export const layout = {
},
],
axes: {
x: {bounds: [], label: '', prefix: '', suffix: '', base: '', scale: ''},
y: {bounds: [], label: '', prefix: '', suffix: '', base: '', scale: ''},
x: {
bounds: [],
label: '',
prefix: '',
suffix: '',
base: '',
scale: '',
},
y: {
bounds: [],
label: '',
prefix: '',
suffix: '',
base: '',
scale: '',
},
y2: {
bounds: [],
label: '',
@ -535,8 +549,22 @@ export const layout = {
},
],
axes: {
x: {bounds: [], label: '', prefix: '', suffix: '', base: '', scale: ''},
y: {bounds: [], label: '', prefix: '', suffix: '', base: '', scale: ''},
x: {
bounds: [],
label: '',
prefix: '',
suffix: '',
base: '',
scale: '',
},
y: {
bounds: [],
label: '',
prefix: '',
suffix: '',
base: '',
scale: '',
},
y2: {
bounds: [],
label: '',
@ -565,8 +593,22 @@ export const layout = {
},
],
axes: {
x: {bounds: [], label: '', prefix: '', suffix: '', base: '', scale: ''},
y: {bounds: [], label: '', prefix: '', suffix: '', base: '', scale: ''},
x: {
bounds: [],
label: '',
prefix: '',
suffix: '',
base: '',
scale: '',
},
y: {
bounds: [],
label: '',
prefix: '',
suffix: '',
base: '',
scale: '',
},
y2: {
bounds: [],
label: '',

View File

@ -0,0 +1,22 @@
import {SourceAuthenticationMethod} from 'src/types'
import {Source} from 'src/types/v2'
import {SourceLinks} from 'src/types/v2/sources'
export const sourceLinks: SourceLinks = {
query: '/v2/sources/16/query',
self: '/v2/sources/16',
buckets: '/v2/sources/16/buckets',
}
export const source: Source = {
id: '16',
name: 'ssl',
type: 'influx',
username: 'admin',
url: 'https://localhost:9086',
insecureSkipVerify: true,
default: false,
telegraf: 'telegraf',
links: sourceLinks,
authentication: SourceAuthenticationMethod.Basic,
}

View File

@ -1,8 +1,6 @@
import React from 'react'
import {shallow} from 'enzyme'
import OverlayTechnology from 'src/reusable_ui/components/overlays/OverlayTechnology'
import TemplateVariableEditor from 'src/tempVars/components/TemplateVariableEditor'
import TemplateControl from 'src/tempVars/components/TemplateControl'
import TextTemplateSelector from 'src/tempVars/components/TextTemplateSelector'
import TemplateDropdown from 'src/tempVars/components/TemplateDropdown'
@ -38,31 +36,6 @@ const defaultProps = ({template = defaultTemplate()} = {}) => ({
})
describe('TemplateControl', () => {
it('should show a TemplateVariableEditor overlay when the settings icon is clicked', () => {
const wrapper = shallow(<TemplateControl {...defaultProps()} />, {
context: {
store: {},
},
})
const children = wrapper
.find(OverlayTechnology)
.dive()
.find("[data-test='overlay-children']")
.children()
expect(children).toHaveLength(0)
wrapper.find("[data-test='edit']").simulate('click')
const elements = wrapper
.find(OverlayTechnology)
.dive()
.find(TemplateVariableEditor)
expect(elements).toHaveLength(1)
})
it('displays a TextTemplateSelector for text templates', () => {
const props = defaultProps({
template: {

View File

@ -4,7 +4,7 @@ import (
"encoding/json"
"net/http"
query "github.com/influxdata/platform/query/builtin"
"github.com/influxdata/platform/query/complete"
"github.com/influxdata/platform/query/parser"
"github.com/julienschmidt/httprouter"
)
@ -96,7 +96,7 @@ func (h *FluxLangHandler) postFluxAST(w http.ResponseWriter, r *http.Request) {
// getFluxSuggestions returns a list of available Flux functions for the Flux Builder
func (h *FluxLangHandler) getFluxSuggestions(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
completer := query.DefaultCompleter()
completer := complete.DefaultCompleter()
names := completer.FunctionNames()
var functions []suggestionResponse
for _, name := range names {
@ -132,7 +132,7 @@ func (h *FluxLangHandler) getFluxSuggestions(w http.ResponseWriter, r *http.Requ
func (h *FluxLangHandler) getFluxSuggestion(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
name := httprouter.ParamsFromContext(ctx).ByName("name")
completer := query.DefaultCompleter()
completer := complete.DefaultCompleter()
suggestion, err := completer.FunctionSuggestion(name)
if err != nil {