From ecdfd473df1c0444bff9e93b555c1d70e307ad99 Mon Sep 17 00:00:00 2001 From: Jonathan Rainville Date: Fri, 8 Mar 2019 15:06:54 -0500 Subject: [PATCH] feat(cockpit/editor): add status messages for file operations --- .../src/components/TextEditorToolbar.js | 22 ++++++++++++++++- .../containers/TextEditorToolbarContainer.js | 9 ++++--- packages/embark-ui/src/reducers/index.js | 24 +++++++++++++++++-- packages/embark-ui/src/reducers/selectors.js | 4 ++++ 4 files changed, 53 insertions(+), 6 deletions(-) diff --git a/packages/embark-ui/src/components/TextEditorToolbar.js b/packages/embark-ui/src/components/TextEditorToolbar.js index 64a0d5c28..4fda5163d 100644 --- a/packages/embark-ui/src/components/TextEditorToolbar.js +++ b/packages/embark-ui/src/components/TextEditorToolbar.js @@ -7,6 +7,10 @@ import FontAwesomeIcon from 'react-fontawesome'; import AddFileModal from '../components/AddFileModal'; import AddFolderModal from '../components/AddFolderModal'; +const StatusText = ({message, icon, spin = false}) => ( + {message} +); + export const TextEditorToolbarTabs = { Interact: { label: 'Interact', icon: 'bolt' }, Details: { label: 'Details', icon: 'info-circle' }, @@ -18,10 +22,22 @@ export const TextEditorToolbarTabs = { class TextEditorToolbar extends Component { constructor(props) { super(props); + this.state = { + successMessage: '' + }; this.addFileModal = React.createRef(); this.addFolderModal = React.createRef(); } + componentDidUpdate(prevProps) { + if (this.props.editorOperationStatus.success !== prevProps.editorOperationStatus.success) { + this.setState({successMessage: this.props.editorOperationStatus.success}); + setTimeout(() => { + this.setState({successMessage: ''}); + }, 3000); + } + } + isActiveTab(tab) { return this.props.activeTab === tab; } @@ -64,6 +80,9 @@ class TextEditorToolbar extends Component { Delete + {this.state.successMessage && } + {this.props.editorOperationStatus.loading && } + {this.props.editorOperationStatus.error && }