Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions cypress/e2e/cloud/scriptQueryBuilder.scriptsCrud.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,7 @@ describe('Script Builder -- scripts crud on cloud', () => {
})
})

it('will not save an invalid flux query', () => {
attemptSaveScript('invalid query')
cy.log('should notify user of an error')
cy.getByTestID('notification-error--dismiss').should('be.visible')
cy.log('modal will stay open')
cy.getByTestID('overlay--container').within(() => {
cy.getByTestID('script-query-builder--cancel').should('be.visible')
})
})

it('will save a valid flux query', () => {
it('will save a flux query', () => {
saveScript(
'from(bucket: "defbuck") |> range(start: v.timeRangeStart, stop: v.timeRangeStop)'
)
Expand Down
2 changes: 1 addition & 1 deletion src/dataExplorer/components/resources/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {ReactNode} from 'react'
import {ResourceType} from 'src/types/resources'
import scriptResourceRegistration from 'src/dataExplorer/components/resources/types/script'
import {scriptResourceRegistration} from 'src/dataExplorer/components/resources/types/script'

export const SCRIPT_EDITOR_PARAMS = '?fluxScriptEditor'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const {getScript, patchScript, postScript} = CLOUD
postScript: false,
}

export default () => {
export const scriptResourceRegistration = () => {
return {
type: ResourceType.Scripts,
editor,
Expand Down
17 changes: 0 additions & 17 deletions src/dataExplorer/context/persistance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
ResourceConnectedQuery,
} from 'src/dataExplorer/components/resources'
import {isOrgIOx} from 'src/organizations/selectors'
import {isValidFlux} from 'src/languageSupport/languages/flux/lspUtils'

interface CompositionStatus {
synced: boolean // true == can modify session's schema
Expand Down Expand Up @@ -220,12 +219,6 @@ export const PersistanceProvider: FC = ({children}) => {
]
)

const buildMockStringifiedExtern = () => {
// Only used for validation. Not persisted.
// Note: new dataExplorer (a.k.a. scripts builder) only uses these variables
return `option v = {timeRangeStart: -1h, timeRangeStop: now()}`
}

const save = (language: LanguageType) => {
if (!resource || !RESOURCES[resource.type]) {
return Promise.resolve(null)
Expand All @@ -234,16 +227,6 @@ export const PersistanceProvider: FC = ({children}) => {
resource.flux = query
resource.language = language

const externForValidation = buildMockStringifiedExtern()
if (
language === LanguageType.FLUX &&
!isValidFlux(`${externForValidation}\n${query}`)
) {
return Promise.reject(
'Invalid flux script. Please check your query text.'
)
}

return RESOURCES[resource.type].persist(resource).then(data => {
handleSetResource(data)
setHasChanged(false)
Expand Down