Skip to content

Icons, Fonts & Notifications #102

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

Merged
merged 12 commits into from
Feb 2, 2020
Next Next commit
setup notification
  • Loading branch information
ShMcK committed Feb 1, 2020
commit 2ab6c3a6bee19a6996506731bcb884b37c868a1b
3 changes: 0 additions & 3 deletions src/editor/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,10 @@ export const createCommands = ({ extensionPath, workspaceState, workspaceRoot }:
testRunner = createTestRunner(config, {
onSuccess: (payload: Payload) => {
// send test pass message back to client
notify({ message: 'PASS' })
webview.send({ type: 'TEST_PASS', payload })
// update local storage
},
onFail: (payload: Payload, message: string) => {
// send test fail message back to client
notify({ message: `FAIL ${message}` })
webview.send({ type: 'TEST_FAIL', payload })
},
onError: (payload: Payload) => {
Expand Down
1 change: 0 additions & 1 deletion typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ export interface MachineStateSchema {
TestRunning: {}
TestPass: {}
TestFail: {}
TestError: {}
StepNext: {}
LevelComplete: {}
}
Expand Down
26 changes: 26 additions & 0 deletions web-app/src/services/notify/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Notification } from '@alifd/next'

interface Props {
key: string
title: string
content: string
duration?: number
onClose?: () => void
icon?: string
}

Notification.config({
placement: 'topRight',
})

const notify = (props: Props) => {
Notification.open({
key: props.key,
title: props.title,
content: props.content,
duration: props.duration,
onClose: props.onClose,
})
}

export default notify
13 changes: 13 additions & 0 deletions web-app/src/services/state/actions/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import editorActions from './editor'
import commandActions from './command'
import contextActions from './context'
import testActions from './test'

const createActions = (editorSend: any) => ({
...editorActions(editorSend),
...commandActions,
...contextActions,
...testActions,
})

export default createActions
24 changes: 24 additions & 0 deletions web-app/src/services/state/actions/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as CR from 'typings'
import { ActionFunctionMap } from 'xstate'
import notify from '../../notify'

const testActions: ActionFunctionMap<CR.MachineContext, CR.MachineEvent> = {
testPass() {
notify({
key: 'test',
title: 'Success!',
content: '',
duration: 1500,
})
},
testFail(context, event) {
notify({
key: 'test',
title: 'Fail',
content: '',
duration: 3000,
})
},
}

export default testActions
29 changes: 11 additions & 18 deletions web-app/src/services/state/machine.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import * as CR from 'typings'
import { assign, Machine, MachineOptions } from 'xstate'
import editorActions from './actions/editor'
import commandActions from './actions/command'
import contextActions from './actions/context'
import createActions from './actions'
import * as services from './services'

const createOptions = ({ editorSend }: any): MachineOptions<CR.MachineContext, CR.MachineEvent> => ({
activities: {},
actions: {
...editorActions(editorSend),
...contextActions,
...commandActions,
},
actions: createActions(editorSend),
guards: {},
services: {},
delays: {},
Expand Down Expand Up @@ -195,16 +189,16 @@ export const createMachine = (options: any) => {
on: {
TEST_PASS: {
target: 'TestPass',
actions: ['updateStepProgress'],
actions: ['updateStepProgress', 'testPass'],
},
TEST_FAIL: {
target: 'TestFail',
actions: ['testFail'],
},
TEST_ERROR: {
target: 'TestFail',
actions: ['testFail'],
},
TEST_FAIL: 'TestFail',
TEST_ERROR: 'TestError',
},
},
TestError: {
onEntry: ['testFail'],
after: {
0: 'Normal',
},
},
TestPass: {
Expand All @@ -214,7 +208,6 @@ export const createMachine = (options: any) => {
},
},
TestFail: {
onEntry: ['testFail'],
after: {
0: 'Normal',
},
Expand Down