Commit 65cca554 authored by Maxime Chaillet's avatar Maxime Chaillet

Merge branch 'issue158' into 'master'

Issue158

Closes #158

See merge request !142
parents a75224e6 294b7c17
Pipeline #11446 passed with stages
......@@ -17,12 +17,12 @@ class OverlayBox extends React.Component {
render() {
return (<Modal
classNames={this.props.classNames}
onClose={() => null}
onClose={this.props.onClose}
onEntered={this.onEntered}
onExited={this.onExited}
open={this.props.open}
blockScroll={false}
showCloseIcon={false}
showCloseIcon={this.props.onClose ? true : false}
focusTrapped={false}
center={true}
>
......
......@@ -316,6 +316,15 @@ div.collapsedEventPanel-heading:hover {
}
}
.userMessageModalClass {
padding: unset;
}
.userMessageCloseButton {
top: 7px;
right: 10px;
}
/* TinyMCE editor */
.mce-tinymce, .mce-container-body, #code_ifr {
......
import React from 'react';
import PropTypes from 'prop-types';
import { INFO_MESSAGE_TYPE, SUCCESS_MESSAGE_TYPE, ERROR_MESSAGE_TYPE } from '../constants/UserMessages';
import { Alert } from 'react-bootstrap';
import { Panel } from 'react-bootstrap';
/* React component which displays a message to the user */
class UserMessage extends React.Component {
render() {
const { type, message, isTextCentered } = this.props;
function getStyle(isTextCentered) {
if (isTextCentered) {
return { textAlign: 'center', borderRadius: '20px', marginLeft:'10px', marginRight:'10px' };
} else {
return { textAlign: 'left', borderRadius: '20px', marginLeft:'10px', marginRight:'10px' };
}
}
const { type, message } = this.props;
if (type && message && message !== '') {
if (type === INFO_MESSAGE_TYPE) {
return (<Alert bsStyle='info' style={getStyle(isTextCentered)} > {message} </Alert>);
}
if (type === SUCCESS_MESSAGE_TYPE) {
return (
<Alert bsStyle='success' style={getStyle(isTextCentered)} > {message} </Alert>);
}
if (type === ERROR_MESSAGE_TYPE) {
return (
<Alert bsStyle='danger' style={getStyle(isTextCentered)} > {message} </Alert>);
}
} else {
return null;
return (<Panel bsStyle={type === INFO_MESSAGE_TYPE ? 'info' : (type === SUCCESS_MESSAGE_TYPE) ? 'success' : (type === ERROR_MESSAGE_TYPE) ? 'danger' : 'primary'} style={{ marginBottom: '0px' }}>
<Panel.Heading>
{type === INFO_MESSAGE_TYPE ? 'Information message' : (type === SUCCESS_MESSAGE_TYPE) ? 'Information message' : (type === ERROR_MESSAGE_TYPE) ? 'Error message' : 'Message'}
</Panel.Heading>
<Panel.Body>
{message}
</Panel.Body>
</Panel>)
}
return null;
}
}
......@@ -39,8 +27,6 @@ UserMessage.propTypes = {
message: PropTypes.string.isRequired,
/* the type of the message */
type: PropTypes.string.isRequired,
/* whether the text is centered. TRUE when the text is centered. FALSE or NO VALUE aligns the text on the left */
isTextCentered: PropTypes.bool
};
export default UserMessage;
\ No newline at end of file
......@@ -74,7 +74,9 @@ class LogbookContainer extends React.Component {
if (this.isAppProperlyConfigured()) {
return (
<div style={{ marginBottom: '40px' }}>
<UserMessage type={ERROR_MESSAGE_TYPE} message={this.state.errorMessage} />
<OverlayBox open={this.state.errorMessage} onClose={() => { this.setState({ errorMessage: null }) }} classNames={{ modal: 'userMessageModalClass', closeButton:'userMessageCloseButton' }}>
<UserMessage type={ERROR_MESSAGE_TYPE} message={this.state.errorMessage} />
</OverlayBox>
<EventActionBar
availableTags={this.props.availableTags}
......@@ -174,6 +176,9 @@ class LogbookContainer extends React.Component {
}
onEventClicked = (event) => {
if (this.state.eventBeingEdited && this.state.eventBeingEdited != event) {
this.setState({ errorMessage: 'Action refused. Please save or cancel the log which is currently being edited.' });
}
this.setState({ eventBeingEdited: event });
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment