diff --git a/src/browser/components/TabNavigation/Navigation.jsx b/src/browser/components/TabNavigation/Navigation.jsx index 6404702a831..0d7fc6f4ce5 100644 --- a/src/browser/components/TabNavigation/Navigation.jsx +++ b/src/browser/components/TabNavigation/Navigation.jsx @@ -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 ( @@ -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 ( ) }) - } + 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 } diff --git a/src/browser/modules/Sidebar/DocumentItems.jsx b/src/browser/modules/Sidebar/DocumentItems.jsx index 0c3b3315526..7828d419e5c 100644 --- a/src/browser/modules/Sidebar/DocumentItems.jsx +++ b/src/browser/modules/Sidebar/DocumentItems.jsx @@ -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)) diff --git a/src/browser/modules/Sidebar/Documents.jsx b/src/browser/modules/Sidebar/Documents.jsx index 723b98d2ef2..58e3b184827 100644 --- a/src/browser/modules/Sidebar/Documents.jsx +++ b/src/browser/modules/Sidebar/Documents.jsx @@ -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}/`, diff --git a/src/browser/modules/Sidebar/DragItemTypes.js b/src/browser/modules/Sidebar/DragItemTypes.js deleted file mode 100644 index c50f7f20216..00000000000 --- a/src/browser/modules/Sidebar/DragItemTypes.js +++ /dev/null @@ -1,3 +0,0 @@ -export default { - FAVORITE: 'favorite' -} diff --git a/src/shared/modules/commands/commandsDuck.js b/src/shared/modules/commands/commandsDuck.js index 429d9782d53..4ef0bd1bbe0 100644 --- a/src/shared/modules/commands/commandsDuck.js +++ b/src/shared/modules/commands/commandsDuck.js @@ -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 }, @@ -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(() => {}) diff --git a/src/shared/services/commandUtils.js b/src/shared/services/commandUtils.js index 9d1f656650a..6b42f27d46c 100644 --- a/src/shared/services/commandUtils.js +++ b/src/shared/services/commandUtils.js @@ -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) { @@ -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() diff --git a/src/shared/services/commandUtils.test.js b/src/shared/services/commandUtils.test.js index ce6bd0bcfa5..98c5bd2f35c 100644 --- a/src/shared/services/commandUtils.test.js +++ b/src/shared/services/commandUtils.test.js @@ -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) }) }) @@ -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` + ] } ]