Skip to content

Commit

Permalink
fix(bi): Add logic to not load variables when flag is turned off (#25392
Browse files Browse the repository at this point in the history
)

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
Gilbert09 and github-actions[bot] authored Oct 4, 2024
1 parent 6e8f035 commit 914ef39
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { actions, afterMount, connect, kea, key, path, props, reducers, selector
import { loaders } from 'kea-loaders'
import { subscriptions } from 'kea-subscriptions'
import api from 'lib/api'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { getVariablesFromQuery } from 'scenes/insights/utils/queryUtils'

import { DataVisualizationNode, HogQLVariable } from '~/queries/schema'
Expand All @@ -22,7 +24,7 @@ export const variablesLogic = kea<variablesLogicType>([
key((props) => props.key),
connect({
actions: [dataVisualizationLogic, ['setQuery', 'loadData']],
values: [dataVisualizationLogic, ['query']],
values: [dataVisualizationLogic, ['query'], featureFlagLogic, ['featureFlags']],
}),
actions({
addVariable: (variable: HogQLVariable) => ({ variable }),
Expand Down Expand Up @@ -110,6 +112,10 @@ export const variablesLogic = kea<variablesLogicType>([
},
}

if (!values.featureFlags[FEATURE_FLAGS.INSIGHT_VARIABLES]) {
return
}

if (props.readOnly) {
// Refresh the data manaully via dataNodeLogic when in insight view mode
actions.loadData(true, undefined, query.source)
Expand Down Expand Up @@ -139,6 +145,10 @@ export const variablesLogic = kea<variablesLogicType>([
},
})),
afterMount(({ actions, values }) => {
if (!values.featureFlags[FEATURE_FLAGS.INSIGHT_VARIABLES]) {
return
}

Object.values(values.query.source.variables ?? {}).forEach((variable) => {
actions.addVariable(variable)
})
Expand Down

0 comments on commit 914ef39

Please sign in to comment.