Skip to content

Commit

Permalink
Bring back :style command
Browse files Browse the repository at this point in the history
In it's simplest form, outputting the style data into a `<pre>` frame.
  • Loading branch information
oskarhane committed Jun 27, 2017
1 parent b1270e8 commit b7af4a8
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
32 changes: 31 additions & 1 deletion src/shared/modules/commands/commandsDuck.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ describe('commandsDuck', () => {
},
history: [':xxx'],
connections: {},
params: {}
params: {},
grass: {
node: {
color: '#000'
}
}
})
})
afterEach(() => {
Expand Down Expand Up @@ -257,6 +262,31 @@ describe('commandsDuck', () => {
// See above
})

test('does the right thing for :style', (done) => {
// Given
const cmd = store.getState().settings.cmdchar + 'style'
const cmdString = cmd
const id = 1
const action = commands.executeCommand(cmdString, id)
bus.take('NOOP', (currentAction) => {
// Then
expect(store.getActions()).toEqual([
action,
addHistory(cmdString, maxHistory),
{ type: commands.KNOWN_COMMAND },
frames.add({...action, type: 'pre', result: JSON.stringify({ node: { color: '#000' } }, null, 2)}),
{ type: 'NOOP' }
])
done()
})

// When
store.dispatch(action)

// Then
// See above
})

test('does the right thing for list queries', (done) => {
const cmd = store.getState().settings.cmdchar + 'queries'
const id = 1
Expand Down
6 changes: 3 additions & 3 deletions src/shared/services/commandInterpreterHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { getHistory } from 'shared/modules/history/historyDuck'
import { update as updateQueryResult } from 'shared/modules/requests/requestsDuck'
import { getActiveConnectionData } from 'shared/modules/connections/connectionsDuck'
import { getParams } from 'shared/modules/params/paramsDuck'
import { updateGraphStyleData } from 'shared/modules/grass/grassDuck'
import { updateGraphStyleData, getGraphStyleData } from 'shared/modules/grass/grassDuck'
import { getRemoteContentHostnameWhitelist } from 'shared/modules/dbMeta/dbMetaDuck'
import { fetchRemoteGuide } from 'shared/modules/commands/helpers/play'
import remote from 'services/remote'
Expand Down Expand Up @@ -199,8 +199,8 @@ const availableCommands = [{
let param = match && match[1] ? match[1] : ''

if (param === '') {
// Todo: show popup
put(showErrorMessage(':style command missing a parameter - grass url, grass style data or reset'))
const grassData = JSON.stringify(getGraphStyleData(store.getState()), null, 2)
put(frames.add({...action, type: 'pre', result: grassData}))
} else if (param === 'reset') {
put(updateGraphStyleData(null))
} else if (isValidURL(param)) {
Expand Down

0 comments on commit b7af4a8

Please sign in to comment.