Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring back :style command #602

Merged
merged 1 commit into from
Jun 28, 2017
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
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