Merge pull request #4653 from influxdata/fix/change-influxql-query
Ensure de can find update query drafts correctlypull/4658/head
commit
72b19b2aaf
|
@ -9,7 +9,8 @@ import {
|
|||
UNTITLED_GRAPH,
|
||||
NEW_DEFAULT_DASHBOARD_CELL,
|
||||
} from 'src/dashboards/constants'
|
||||
import {TEMP_VAR_DASHBOARD_TIME} from 'src/shared/constants'
|
||||
import {TEMPLATE_RANGE} from 'src/tempVars/constants'
|
||||
|
||||
const MAX_COLUMNS = 12
|
||||
|
||||
// Types
|
||||
|
@ -153,12 +154,16 @@ export const getClonedDashboardCell = (
|
|||
}
|
||||
|
||||
export const getTimeRange = (queryConfig: QueryConfig): DurationRange => {
|
||||
return (
|
||||
queryConfig.range || {
|
||||
upper: null,
|
||||
lower: TEMP_VAR_DASHBOARD_TIME,
|
||||
}
|
||||
)
|
||||
const isUsingDashTime =
|
||||
queryConfig.range &&
|
||||
queryConfig.originalQuery &&
|
||||
queryConfig.originalQuery.indexOf(TEMPLATE_RANGE.lower) !== -1
|
||||
|
||||
if (isUsingDashTime || !queryConfig.range) {
|
||||
return TEMPLATE_RANGE
|
||||
}
|
||||
|
||||
return queryConfig.range
|
||||
}
|
||||
|
||||
export const getConfig = async (
|
||||
|
@ -173,5 +178,5 @@ export const getConfig = async (
|
|||
])
|
||||
const {queryConfig} = queries.find(q => q.id === id)
|
||||
|
||||
return queryConfig
|
||||
return {...queryConfig, originalQuery: query}
|
||||
}
|
||||
|
|
|
@ -231,14 +231,16 @@ export class DataExplorer extends PureComponent<Props, State> {
|
|||
return
|
||||
}
|
||||
|
||||
const id = uuid.v4()
|
||||
const queryConfig = await getConfig(
|
||||
source.links.queries,
|
||||
uuid.v4(),
|
||||
id,
|
||||
query,
|
||||
this.templates
|
||||
)
|
||||
|
||||
const queryDraft = {
|
||||
id,
|
||||
query,
|
||||
queryConfig,
|
||||
source: sourceLink,
|
||||
|
|
|
@ -14,14 +14,17 @@ import FancyScrollbar from 'src/shared/components/FancyScrollbar'
|
|||
import {TimeMachineContainer} from 'src/shared/utils/TimeMachineContainer'
|
||||
import {buildQuery} from 'src/utils/influxql'
|
||||
import {TYPE_QUERY_CONFIG} from 'src/dashboards/constants'
|
||||
import {TEMPLATE_RANGE} from 'src/tempVars/constants'
|
||||
import {AUTO_GROUP_BY} from 'src/shared/constants'
|
||||
import {getTimeRange} from 'src/dashboards/utils/cellGetters'
|
||||
|
||||
// Types
|
||||
import {QueryConfig, Source, TimeRange, Template} from 'src/types'
|
||||
|
||||
const buildText = (q: QueryConfig): string =>
|
||||
q.rawText || buildQuery(TYPE_QUERY_CONFIG, q.range || TEMPLATE_RANGE, q) || ''
|
||||
const buildText = (q: QueryConfig): string => {
|
||||
const range = getTimeRange(q)
|
||||
|
||||
return q.rawText || buildQuery(TYPE_QUERY_CONFIG, range, q) || ''
|
||||
}
|
||||
|
||||
interface ConnectedProps {
|
||||
timeRange: TimeRange
|
||||
|
|
|
@ -26,6 +26,7 @@ export interface QueryConfig {
|
|||
lower?: string
|
||||
upper?: string
|
||||
isQuerySupportedByExplorer?: boolean // doesn't come from server -- is set in CellEditorOverlay
|
||||
originalQuery?: string
|
||||
}
|
||||
|
||||
export interface QueryStatus {
|
||||
|
|
Loading…
Reference in New Issue