Commit 7606646e authored by Maxime Chaillet's avatar Maxime Chaillet

Merge branch 'issue178' into 'master'

Issue178

Closes #178

See merge request !170
parents a2fd73cd 0d0a5c22
Pipeline #13926 passed with stages
in 5 minutes and 37 seconds
......@@ -20,7 +20,7 @@ class OverlayBox extends React.Component {
render() {
return (<Modal
classNames={this.props.classNames}
onClose={this.props.onClose}
onClose={this.props.onClose ? this.props.onClose : () => null}
onEntered={this.onEntered}
onExited={this.onExited}
open={this.props.open}
......
......@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { Panel } from 'react-bootstrap';
import EventHeader from './EventHeader';
import EventFooter from './EventFooter';
import { ORIGINAL_EVENT_VERSION, LATEST_EVENT_VERSION, PUBLIC_EVENT_DETAILS_INVISIBLE } from '../../constants/EventTypes';
import { ORIGINAL_EVENT_VERSION, LATEST_EVENT_VERSION, PUBLIC_EVENT_DETAILS_INVISIBLE, ANNOTATION } from '../../constants/EventTypes';
import { getOriginalEvent, getPreviousVersionNumber } from '../../helpers/EventHelpers';
import _ from 'lodash';
import EventVersionPanel from './EventVersionPanel';
......@@ -17,22 +17,28 @@ class PublicEventHistoryPanel extends React.Component {
return (
<Panel bsStyle='primary' style={{ marginBottom: '0px', height: '100%', position: 'relative' }}>
<EventHeader text={'Public log history'} />
<div id='refForEditorHeightCalculation' style={{ position: 'absolute', top: '41px', bottom: '100px', width: '100%' }} >
<EventHeader text={'Public log details'} />
<div style={{ position: 'absolute', top: '41px', bottom: '42px', width: '100%', overflowY: 'scroll', overflowX: 'hidden' }} >
<div style={{ padding: '10px' }}>
{/* try to show latest version of the event */}
{getPreviousVersionNumber(event) === 0 ?
<p style={{ fontStyle: 'italic', color: '888888', paddingBottom: '10px' }}>This event has never been commented.</p>
: <EventVersionPanel
availableTags={availableTags}
event={event}
version={LATEST_EVENT_VERSION} />
}
{/* show the original version of the event */}
: null}
{/* Always show the latest version*/}
<EventVersionPanel
availableTags={availableTags}
event={getOriginalEvent(event)}
version={ORIGINAL_EVENT_VERSION} />
event={event}
version={LATEST_EVENT_VERSION} />
{/* Show the original version if it exists for all except annotations */}
{!_.isEqual(event.type, ANNOTATION) && getPreviousVersionNumber(event) !== 0 ?
<EventVersionPanel
availableTags={availableTags}
event={getOriginalEvent(event)}
version={ORIGINAL_EVENT_VERSION} />
: null}
</div>
</div>
......
......@@ -114,8 +114,7 @@ export class LogbookContainer extends React.Component {
</PeriodicRefresher>
<OverlayBox open={this.state.isShowingNewEventUI === true || this.state.isShowingEditEventUI === true || this.state.isShowingPublicEventUI === true}
classNames={{ overlay: 'newOrEditOverlayClass', modal: 'newOrEditModalClass' }}
onClose={() => null}>
classNames={{ overlay: 'newOrEditOverlayClass', modal: 'newOrEditModalClass' }}>
{this.state.isShowingNewEventUI === true ?
<div style={{ height: this.getPanelHeightInPercent(), paddingBottom: this.state.isShowingEditEventUI ? '5px' : '0px' }}>
......
......@@ -14,6 +14,9 @@
* goodError1: an error event , previousVersionEvent undefined
* goodError2: an error event which has been commented (in plain text)
* goodError3: an error event which has been commented (in html text)
* goodError3_OriginalVersion: original version of goodError3
* goodError4: an error event which has been commented 2 times
* goodError4_OriginalVersion: original version of goodError4
* goodInfo1: an info event
* goodCommandLine1 : a command line event
* goodDebug1 : a debug event
......@@ -320,30 +323,30 @@ export const goodComment7 = {
username: "mchaille"
}
export const goodComment7_OriginalVersion={
export const goodComment7_OriginalVersion = {
title: 'this is the title initial version',
category: "comment",
content: [{
format: 'plainText',
text: 'version 1 of plain text'
}, {
format: 'html',
text: '<p> version 1 of html text </p>'
}],
createdAt: "2018-09-10T13:23:08.727Z",
creationDate: "2018-09-11T01:00:00.000Z",
datasetId: null,
file: [],
fileSize: null,
filename: null,
investigationId: 77570462,
machine: null,
previousVersionEvent: null,
software: null,
tag: ["firstTag", "secondTag"],
type: "annotation",
updatedAt: "2018-09-10T13:23:08.727Z",
username: "mchaille"
category: "comment",
content: [{
format: 'plainText',
text: 'version 1 of plain text'
}, {
format: 'html',
text: '<p> version 1 of html text </p>'
}],
createdAt: "2018-09-10T13:23:08.727Z",
creationDate: "2018-09-11T01:00:00.000Z",
datasetId: null,
file: [],
fileSize: null,
filename: null,
investigationId: 77570462,
machine: null,
previousVersionEvent: null,
software: null,
tag: ["firstTag", "secondTag"],
type: "annotation",
updatedAt: "2018-09-10T13:23:08.727Z",
username: "mchaille"
}
export const goodError1 = {
......@@ -408,6 +411,68 @@ export const goodError3 = {
}]
}
}
export const goodError3_OriginalVersion = {
investigationId: 77570462,
creationDate: "2018-09-10T13:23:08.000Z",
type: "notification",
category: "error",
username: "agoetz",
software: "E-Dataportal",
content: [{
format: "plainText",
text: "beamline lost"
}]
}
export const goodError4 = {
investigationId: 77570462,
creationDate: "2018-09-10T13:23:08.000Z",
type: "notification",
category: "error",
username: "asole",
software: "E-Dataportal",
content: [{
format: "html",
text: "<p> this is the second version of a comment </p>"
}],
previousVersionEvent: {
investigationId: 77570462,
creationDate: "2018-09-10T13:23:08.000Z",
type: "notification",
category: "error",
username: "agoetz",
software: "E-Dataportal",
content: [{
format: "html",
text: "<p> this is the first version of a comment </p>"
}],
previousVersionEvent: {
investigationId: 77570462,
creationDate: "2018-09-10T13:23:08.000Z",
type: "notification",
category: "error",
username: "agoetz",
software: "E-Dataportal",
content: [{
format: "plainText",
text: "beamline lost"
}]
}
}
}
export const goodError4_OriginalVersion = {
investigationId: 77570462,
creationDate: "2018-09-10T13:23:08.000Z",
type: "notification",
category: "error",
username: "agoetz",
software: "E-Dataportal",
content: [{
format: "plainText",
text: "beamline lost"
}]
}
export const goodInfo1 = {
investigationId: 77570462,
......
......@@ -24,13 +24,13 @@ describe('Unit tests on PublicEventHistoryPanel', () => {
}
describe('rendering', () => {
it.each(resources.renderingEventHeader, '[note: %s ]', ['aboutThisTest'],
it.each(resources.renderingEventHeader, '[renderingEventHeader: %s ]', ['aboutThisTest'],
function (element, next) {
expect(getShallowedWrapper(element.availableTags, element.event).find('EventHeader').prop('text')).toEqual(element.expected);
next();
})
it.each(resources.renderingParagraphWhenEventHasASingleVersion, '[note: %s ]', ['aboutThisTest'],
it.each(resources.renderingParagraphWhenEventHasASingleVersion, '[renderingParagraphWhenEventHasASingleVersion: %s ]', ['aboutThisTest'],
function (element, next) {
expect(getShallowedWrapper(element.availableTags, element.event).find('p').length).toBe(element.expected.paragraphCount);
if (element.expected.paragraphCount != 0) {
......@@ -39,7 +39,7 @@ describe('Unit tests on PublicEventHistoryPanel', () => {
next();
})
it.each(resources.renderingEventVersionPanel, '[note: %s ]', ['aboutThisTest'],
it.each(resources.renderingEventVersionPanel, '[renderingEventVersionPanel: %s ]', ['aboutThisTest'],
function (element, next) {
expect(getShallowedWrapper(element.availableTags, element.event).find('EventVersionPanel').length).toBe(element.expected.eventVersionPanelCount)
......@@ -54,7 +54,7 @@ describe('Unit tests on PublicEventHistoryPanel', () => {
next();
})
it.each(resources.renderingEventFooter, '[note: %s ]', ['aboutThisTest'],
it.each(resources.renderingEventFooter, '[renderingEventFooter: %s ]', ['aboutThisTest'],
function (element, next) {
const mockedOnCancelButtonClicked = jest.spyOn(PublicEventHistoryPanel.prototype, 'onCancelButtonClicked');
let wrapper = getShallowedWrapper(element.availableTags, element.event);
......
import { LATEST_EVENT_VERSION, ORIGINAL_EVENT_VERSION } from '../../../src/constants/EventTypes.js';
import { goodComment1, goodComment4, goodComment7, goodComment4_OriginalVersion, goodComment7_OriginalVersion } from '../../GoodEventLibrary.js';
import { goodComment1, goodComment4, goodComment7, goodError1, goodError3_OriginalVersion, goodError3, goodError4, goodError4_OriginalVersion } from '../../GoodEventLibrary.js';
module.exports = {
renderingEventHeader: [
......@@ -8,7 +8,7 @@ module.exports = {
availableTags: [],
event: goodComment1,
expected: 'Public log history'
expected: 'Public log details'
},
],
renderingParagraphWhenEventHasASingleVersion: [
......@@ -43,7 +43,7 @@ module.exports = {
],
renderingEventVersionPanel: [
{
aboutThisTest: '1 eventVersionPanel is diplayed corresponding to event orignal version. (event has 1 version)',
aboutThisTest: 'Annotation which has never been commented',
availableTags: [],
event: goodComment1,
......@@ -52,44 +52,72 @@ module.exports = {
first: {
availableTags: [],
event: goodComment1,
version: ORIGINAL_EVENT_VERSION
version: LATEST_EVENT_VERSION
}
}
},
{
aboutThisTest: '2 eventVersionPanels are diplayed: first for latest version and second for original version (event has 2 versions)',
aboutThisTest: 'Annotation which has been commented',
availableTags: [],
event: goodComment4,
expected: {
eventVersionPanelCount: 2,
eventVersionPanelCount: 1,
first: {
availableTags: [],
event: goodComment4,
version: LATEST_EVENT_VERSION
},
}
},
{
aboutThisTest: 'Notification which has never been commented',
availableTags: [],
event: goodError1,
expected: {
eventVersionPanelCount: 1,
first: {
availableTags: [],
event: goodError1,
version: LATEST_EVENT_VERSION
}
}
},
{
aboutThisTest: 'Notification which has been commented',
availableTags: [],
event: goodError3,
expected: {
eventVersionPanelCount: 2,
first: {
availableTags: [],
event: goodError3,
version: LATEST_EVENT_VERSION
},
second: {
availableTags: [],
event: goodComment4_OriginalVersion,
event: goodError3_OriginalVersion,
version: ORIGINAL_EVENT_VERSION
}
}
},
{
aboutThisTest: '2 eventVersionPanels are diplayed: first for latest version and second for original version (event has 3 versions)',
aboutThisTest: 'Notification which has been commented 2 times',
availableTags: [],
event: goodComment7,
event: goodError4,
expected: {
eventVersionPanelCount: 2,
first: {
availableTags: [],
event: goodComment7,
event: goodError4,
version: LATEST_EVENT_VERSION
},
second: {
availableTags: [],
event: goodComment7_OriginalVersion,
event: goodError4_OriginalVersion,
version: ORIGINAL_EVENT_VERSION
}
}
......
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