diff --git a/public/app/plugins/datasource/graphite/state/helpers.ts b/public/app/plugins/datasource/graphite/state/helpers.ts index ae21740e203..d65305c002e 100644 --- a/public/app/plugins/datasource/graphite/state/helpers.ts +++ b/public/app/plugins/datasource/graphite/state/helpers.ts @@ -1,5 +1,5 @@ import { GraphiteQueryEditorState } from './store'; -import { map } from 'lodash'; +import { clone } from 'lodash'; import { dispatch } from '../../../../store/store'; import { notifyApp } from '../../../../core/reducers/appNotification'; import { createErrorNotification } from '../../../../core/copy/appNotification'; @@ -31,10 +31,8 @@ export async function parseTarget(state: GraphiteQueryEditorState): Promise { - // TODO: This is just a copy of query model segments. Check if queryModel segments could be used directly - state.segments = map(state.queryModel.segments, (segment) => { - return segment; - }); + // Start with a shallow copy from the model, then check if "select metric" segment should be added at the end + state.segments = clone(state.queryModel.segments); const checkOtherSegmentsIndex = state.queryModel.checkOtherSegmentsIndex || 0;