From ae7fed36266757deb8e725b526e64eca254deb80 Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Tue, 13 Aug 2019 17:17:46 -0500 Subject: [PATCH] fix: drop delete (#5258) * fix: drop delete * fix: tsc error --- ui/src/shared/utils/TimeMachineContainer.ts | 22 +++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/ui/src/shared/utils/TimeMachineContainer.ts b/ui/src/shared/utils/TimeMachineContainer.ts index 66084ed228..9e5408f740 100644 --- a/ui/src/shared/utils/TimeMachineContainer.ts +++ b/ui/src/shared/utils/TimeMachineContainer.ts @@ -143,6 +143,28 @@ export class TimeMachineContainer extends Container { state = {...state, queryDrafts} } + // prevents "DROP" or "DELETE" queries from being persisted. + const savable = getDeep(state, 'queryDrafts', []).filter( + ({query, type}) => { + if (type !== 'influxql') { + return true + } + + const queries = query.split(';') + let isSavable = true + for (let i = 0; i <= queries.length; i++) { + const qs = getDeep(queries, `${i}`, '').toLocaleLowerCase() + if (qs.startsWith('drop') || qs.startsWith('delete')) { + isSavable = false + } + } + + return isSavable + } + ) + + state = {...state, queryDrafts: savable} + return this.setAndPersistState(state) }