From 13bfa157409f97cac9fdeda52e103f004271dee3 Mon Sep 17 00:00:00 2001 From: Francois Date: Wed, 14 Aug 2019 10:13:03 -0400 Subject: [PATCH 1/2] feat(studio): toast msg to remind about auto-save when hitting ctrl+s --- .../src/web/views/FlowBuilder/index.tsx | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/src/bp/ui-studio/src/web/views/FlowBuilder/index.tsx b/src/bp/ui-studio/src/web/views/FlowBuilder/index.tsx index 9dd280fb6b3..c11af7a742a 100644 --- a/src/bp/ui-studio/src/web/views/FlowBuilder/index.tsx +++ b/src/bp/ui-studio/src/web/views/FlowBuilder/index.tsx @@ -19,6 +19,8 @@ import { PannelPermissions } from './sidePanel' import { MutexInfo } from './sidePanel/Toolbar' import style from './style.scss' +const toastMutex: _.Dictionary = {} + const FlowToaster = Toaster.create({ position: Position.TOP }) @@ -81,12 +83,7 @@ class FlowBuilder extends Component { status === 403 ? 'Unauthorized flow update. You have insufficient role privileges to modify flows.' : 'There was an error while saving, deleting or renaming a flow. Last modification might not have been saved on server. Please reload page before continuing flow edition' - FlowToaster.show({ - message, - intent: Intent.DANGER, - timeout: 0, - onDismiss: this.props.clearErrorSaveFlows - }) + toast(message, Intent.DANGER, 0, this.props.clearErrorSaveFlows) } const flowsHaveChanged = !_.isEqual(prevProps.flowsByName, this.props.flowsByName) @@ -162,6 +159,10 @@ class FlowBuilder extends Component { 'preview-flow': e => { e.preventDefault() this.setState({ flowPreview: true }) + }, + save: e => { + e.preventDefault() + toast('Botpress now works with auto-save', Intent.PRIMARY, 700) } } @@ -197,6 +198,23 @@ class FlowBuilder extends Component { } } +const toast = (message: string, intent: Intent, timeout: number, onDismissCb?: () => void) => { + if (toastMutex[message]) { + return + } + + toastMutex[message] = true + FlowToaster.show({ + message, + intent, + timeout, + onDismiss: () => { + toastMutex[message] = false + onDismissCb && onDismissCb() + } + }) +} + const mapStateToProps = (state: RootReducer) => ({ currentFlow: state.flows.currentFlow, flowsByName: state.flows.flowsByName, From 524bef9809ba35105fb6c4e81c87b1795fbcacc5 Mon Sep 17 00:00:00 2001 From: Sylvain Perron <1315508+slvnperron@users.noreply.github.com> Date: Wed, 14 Aug 2019 10:34:42 -0400 Subject: [PATCH 2/2] Update index.tsx --- src/bp/ui-studio/src/web/views/FlowBuilder/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bp/ui-studio/src/web/views/FlowBuilder/index.tsx b/src/bp/ui-studio/src/web/views/FlowBuilder/index.tsx index c11af7a742a..10af317636e 100644 --- a/src/bp/ui-studio/src/web/views/FlowBuilder/index.tsx +++ b/src/bp/ui-studio/src/web/views/FlowBuilder/index.tsx @@ -162,7 +162,7 @@ class FlowBuilder extends Component { }, save: e => { e.preventDefault() - toast('Botpress now works with auto-save', Intent.PRIMARY, 700) + toast('Pssst! Flows now save automatically, no need to save anymore.', Intent.PRIMARY, 700) } }