Skip to content

Commit

Permalink
fix: drop delete (#5258)
Browse files Browse the repository at this point in the history
* fix: drop delete

* fix: tsc error
  • Loading branch information
121watts authored and desa committed Aug 20, 2019
1 parent a36ffca commit ae7fed3
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions ui/src/shared/utils/TimeMachineContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,28 @@ export class TimeMachineContainer extends Container<TimeMachineState> {
state = {...state, queryDrafts}
}

// prevents "DROP" or "DELETE" queries from being persisted.
const savable = getDeep<CellQuery[]>(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<string>(queries, `${i}`, '').toLocaleLowerCase()
if (qs.startsWith('drop') || qs.startsWith('delete')) {
isSavable = false
}
}

return isSavable
}
)

state = {...state, queryDrafts: savable}

return this.setAndPersistState(state)
}

Expand Down

0 comments on commit ae7fed3

Please sign in to comment.