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
14 changes: 7 additions & 7 deletions src/browser/components/TabNavigation/Navigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Navigation extends Component {

componentDidUpdate(prevProps, prevState) {
if (prevProps.openDrawer !== this.props.openDrawer) {
var newState = {}
const newState = {}
if (this.props.openDrawer) {
newState.drawerContent = this.props.openDrawer
if (
Expand Down Expand Up @@ -90,8 +90,8 @@ class Navigation extends Component {
render() {
const { onNavClick, topNavItems, bottomNavItems = [] } = this.props

const buildNavList = (list, selected) => {
return list.map((item, index) => {
const buildNavList = (list, selected) =>
list.map(item => {
const isOpen = item.name.toLowerCase() === selected
return (
<NavigationButtonContainer
Expand All @@ -107,12 +107,12 @@ class Navigation extends Component {
</NavigationButtonContainer>
)
})
}

const getContentToShow = openDrawer => {
if (openDrawer) {
const filteredList = topNavItems.concat(bottomNavItems).filter(item => {
return item.name.toLowerCase() === openDrawer
})
const filteredList = topNavItems
.concat(bottomNavItems)
.filter(item => item.name.toLowerCase() === openDrawer)
const TabContent = filteredList[0].content
return <TabContent />
}
Expand Down
2 changes: 1 addition & 1 deletion src/browser/modules/Sidebar/DocumentItems.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export const DocumentItems = ({ header, items, onItemClick = null }) => {
)
}

const mapDispatchToProps = (dispatch, ownProps) => {
const mapDispatchToProps = (_dispatch, ownProps) => {
return {
onItemClick: cmd => {
ownProps.bus.send(SET_CONTENT, setContent(cmd))
Expand Down
11 changes: 5 additions & 6 deletions src/browser/modules/Sidebar/Documents.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,11 @@ const getReferences = (version, v) => {
command: `https://neo4j.com/docs/operations-manual/${v}/`,
type: 'link'
},
// Drivers manual needs to wait for the page to be published
// {
// name: 'Drivers Manual',
// command: `https://neo4j.com/docs/driver-manual/current/`,
// type: 'link'
// },
{
name: 'Drivers Manual',
command: `https://neo4j.com/docs/driver-manual/current/`,
type: 'link'
},
{
name: 'Cypher Refcard',
command: `https://neo4j.com/docs/cypher-refcard/${v}/`,
Expand Down
3 changes: 0 additions & 3 deletions src/browser/modules/Sidebar/DragItemTypes.js

This file was deleted.

15 changes: 7 additions & 8 deletions src/shared/modules/commands/commandsDuck.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,18 +177,17 @@ export const handleCommandEpic = (action$, store) =>
addFrame({ type: 'cypher-script', id: parentId, cmd: action.cmd })
)
const cmdchar = getCmdChar(store.getState())
const jobs = []
statements.forEach(cmd => {
const jobs = statements.map(cmd => {
const cleanCmd = cleanCommand(cmd)
const requestId = v4()
const cmdId = v4()
const whitelistedCommands = whitelistedMultiCommands()
const isWhitelisted =
whitelistedCommands.filter(wcmd => !!cleanCmd.startsWith(wcmd))
.length > 0
const isWhitelisted = whitelistedCommands.some(wcmd =>
cleanCmd.startsWith(wcmd)
)

// Ignore client commands that aren't whitelisted
const ignore = !!cleanCmd.startsWith(cmdchar) && !isWhitelisted
const ignore = cleanCmd.startsWith(cmdchar) && !isWhitelisted

const { action, interpreted } = buildCommandObject(
{ cmd: cleanCmd, ignore },
Expand All @@ -202,13 +201,13 @@ export const handleCommandEpic = (action$, store) =>
addFrame({ ...action, requestId, type: interpreted.name })
)
store.dispatch(updateQueryResult(requestId, null, 'waiting'))
jobs.push({
return {
workFn: () =>
interpreted.exec(action, cmdchar, store.dispatch, store),
onStart: () => {},
onSkip: () =>
store.dispatch(updateQueryResult(requestId, null, 'skipped'))
})
}
})

serialExecution(...jobs).catch(() => {})
Expand Down
8 changes: 6 additions & 2 deletions src/shared/services/commandUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ export function stripEmptyCommandLines(str) {
}

export function stripCommandComments(str) {
return str.replace(/((^|\n)\/\/[^\n$]+\n?)/g, '')
return str
.split('\n')
.filter(line => !line.trim().startsWith('//'))
.join('\n')
}

export function splitStringOnFirst(str, delimiter) {
Expand Down Expand Up @@ -141,7 +144,8 @@ export const mapParamToCypherStatement = (key, param) => {
}

export const extractStatementsFromString = str => {
const parsed = extractStatements(str)
const cleanCmd = cleanCommand(str)
const parsed = extractStatements(cleanCmd)
const { statements } = parsed.referencesListener
return statements[0]
.raw()
Expand Down
45 changes: 40 additions & 5 deletions src/shared/services/commandUtils.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,30 @@ import * as utils from './commandUtils'
describe('commandutils', () => {
test('stripCommandComments should remove lines starting with a comment ', () => {
const testStrs = [
'//This is a comment\nRETURN 1',
'// Another comment\nRETURN 1',
'// Another comment\nRETURN 1\n//Next comment'
{ str: '//This is a comment\nRETURN 1', expect: 'RETURN 1' },
{ str: '// Another comment\nRETURN 1', expect: 'RETURN 1' },
{
str: '// Another comment\nRETURN 1\n//Next comment',
expect: 'RETURN 1'
},
{
str: `RETURN 1
;

// comment 1
// comment 2
// comment 3
RETURN 2
;`,
expect: `RETURN 1
;

RETURN 2
;`
}
]
testStrs.forEach(str => {
expect(utils.stripCommandComments(str)).toEqual('RETURN 1')
testStrs.forEach(item => {
expect(utils.stripCommandComments(item.str)).toEqual(item.expect)
})
})

Expand Down Expand Up @@ -211,6 +229,23 @@ describe('commandutils', () => {
{
stmt: ':history; RETURN 1;\nMATCH (n)\nRETURN n',
expect: [':history', 'RETURN 1', 'MATCH (n)\nRETURN n']
},
{
stmt: 'RETURN 1\n;\n\n// comment 1\n//comment 2\nRETURN 2\n;',
expect: ['RETURN 1', 'RETURN 2']
},
{
stmt: `MATCH (n) return n LIMIT 1;
MATCH (n)
UNWIND range(0, 5) as x
// Return n
RETURN n`,
expect: [
'MATCH (n) return n LIMIT 1',
`MATCH (n)
UNWIND range(0, 5) as x
RETURN n`
]
}
]

Expand Down