Skip to content

Commit 04654a7

Browse files
committed
Bring back :style command
In it's simplest form, outputting the style data into a `<pre>` frame.
1 parent 2625def commit 04654a7

File tree

2 files changed

+34
-4
lines changed

2 files changed

+34
-4
lines changed

src/shared/modules/commands/commandsDuck.test.js

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ describe('commandsDuck', () => {
5050
},
5151
history: [':xxx'],
5252
connections: {},
53-
params: {}
53+
params: {},
54+
grass: {
55+
node: {
56+
color: '#000'
57+
}
58+
}
5459
})
5560
})
5661
afterEach(() => {
@@ -257,6 +262,31 @@ describe('commandsDuck', () => {
257262
// See above
258263
})
259264

265+
test('does the right thing for :style', (done) => {
266+
// Given
267+
const cmd = store.getState().settings.cmdchar + 'style'
268+
const cmdString = cmd
269+
const id = 1
270+
const action = commands.executeCommand(cmdString, id)
271+
bus.take('NOOP', (currentAction) => {
272+
// Then
273+
expect(store.getActions()).toEqual([
274+
action,
275+
addHistory(cmdString, maxHistory),
276+
{ type: commands.KNOWN_COMMAND },
277+
frames.add({...action, type: 'pre', result: JSON.stringify({ node: { color: '#000' } }, null, 2)}),
278+
{ type: 'NOOP' }
279+
])
280+
done()
281+
})
282+
283+
// When
284+
store.dispatch(action)
285+
286+
// Then
287+
// See above
288+
})
289+
260290
test('does the right thing for list queries', (done) => {
261291
const cmd = store.getState().settings.cmdchar + 'queries'
262292
const id = 1

src/shared/services/commandInterpreterHelper.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { getHistory } from 'shared/modules/history/historyDuck'
2424
import { update as updateQueryResult } from 'shared/modules/requests/requestsDuck'
2525
import { getActiveConnectionData } from 'shared/modules/connections/connectionsDuck'
2626
import { getParams } from 'shared/modules/params/paramsDuck'
27-
import { updateGraphStyleData } from 'shared/modules/grass/grassDuck'
27+
import { updateGraphStyleData, getGraphStyleData } from 'shared/modules/grass/grassDuck'
2828
import { getRemoteContentHostnameWhitelist } from 'shared/modules/dbMeta/dbMetaDuck'
2929
import { fetchRemoteGuide } from 'shared/modules/commands/helpers/play'
3030
import remote from 'services/remote'
@@ -199,8 +199,8 @@ const availableCommands = [{
199199
let param = match && match[1] ? match[1] : ''
200200

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

0 commit comments

Comments
 (0)