GitLab will be upgraded on June 23rd evening. During the upgrade the service will be unavailable, sorry for the inconvenience.

Commit dfcda2a7 authored by Maxime Chaillet's avatar Maxime Chaillet

it fixes #429

parent 4714b1cb
Pipeline #35715 passed with stage
in 3 minutes and 16 seconds
......@@ -7,6 +7,7 @@ import {
NavDropdown,
NavItem,
Radio,
Checkbox,
Well,
} from 'react-bootstrap';
import { ComboSearch } from 'react-combo-search';
......@@ -155,9 +156,15 @@ class EventListMenu extends React.Component {
eventKey={3.5}
onSelect={() => onAutoRefreshMenuItemClicked()}
>
<span style={{ paddingLeft: 20 }}>
{isAutorefreshEnabled ? 'Stop' : 'Start'} refreshing logs
</span>
<Checkbox
checked={isAutorefreshEnabled}
onClick={(e) => {
onAutoRefreshMenuItemClicked();
e.stopPropagation();
}}
>
Auto refresh logs
</Checkbox>
</MenuItem>
</>
)}
......
......@@ -153,12 +153,11 @@ export class LogbookContainerClass extends React.Component {
logbookContext={logbookContext}
onPageClicked={this.onPageClicked}
onAutoRefreshMenuItemClicked={() =>
this.setState({
this.setState((state) => ({
autorefresh: {
...autorefresh,
isEnabled: !autorefresh.isEnabled,
isEnabled: !state.autorefresh.isEnabled,
},
})
}))
}
onSortingButtonClicked={this.flipEventsSortingOrder}
searchEvents={this.searchEvents}
......
......@@ -43,16 +43,18 @@ describe('EventListMenu unit tests', () => {
'%s',
['description'],
(element, next) => {
const { autorefreshEventList, logbookContext } = element;
const menuItemWrapper = getShallowWrapper({
autorefreshEventList: element.autorefreshEventList,
logbookContext: element.logbookContext,
autorefreshEventList,
logbookContext,
}).findWhere((n) => n.prop('eventKey') === 3.5);
if (element.logbookContext.isReleased) {
if (logbookContext.isReleased) {
expect(menuItemWrapper).not.toBeUndefined();
} else {
expect(menuItemWrapper.childAt(0).prop('children').join('')).toEqual(
element.expected.text
expect(menuItemWrapper.find('Checkbox').prop('checked')).toBe(
autorefreshEventList
);
}
next();
......@@ -89,74 +91,64 @@ describe('EventListMenu unit tests', () => {
function getShallowWrapper(params) {
if (params) {
params.activePage = params.activePage ? params.activePage : 1;
params.autorefreshEventList = params.autorefreshEventList
? params.autorefreshEventList
: false;
params.availableTags = params.availableTags ? params.availableTags : [];
params.eventCountBySelectionFilter = params.eventCountBySelectionFilter
? params.eventCountBySelectionFilter
: 0;
params.eventCountSinceLastRefresh = params.eventCountSinceLastRefresh
? params.eventCountSinceLastRefresh
: 0;
params.getEvents = params.getEvents ? params.getEvents : () => null;
params.investigationId = params.investigationId
? params.investigationId
: 123456;
params.isNewButtonEnabled =
params.isNewButtonEnabled === false ? false : true;
params.isSortingLatestEventsFirst =
params.isSortingLatestEventsFirst === false ? false : true;
params.logbookContext = params.logbookContext
? params.logbookContext
: { name: null, isReleased: null };
params.onPageClicked = params.onPageClicked
? params.onPageClicked
: () => null;
params.onRefreshEventListMenuItemClicked = params.onRefreshEventListMenuItemClicked
? params.onRefreshEventListMenuItemClicked
: () => null;
params.onSortingButtonClicked = params.onSortingButtonClicked
? params.onSortingButtonClicked
: () => null;
params.searchEvents = params.searchEvents
? params.searchEvents
: () => null;
params.selectionFilter = params.selectionFilter
? params.selectionFilter
: {};
params.sessionId = params.sessionId
? params.sessionId
: 'sessionIdForTests';
params.setNewEventVisibility = params.setNewEventVisibility
? params.setNewEventVisibility
: () => null;
params.setView = params.setView ? params.setView : () => null;
params.view = params.view ? params.view : LIST_VIEW;
let { activePage, autorefreshEventList, availableTags } = params;
let { eventCountBySelectionFilter, eventCountSinceLastRefresh } = params;
let { getEvents, investigationId, isNewButtonEnabled } = params;
let { isSortingLatestEventsFirst, logbookContext } = params;
let { onPageClicked, onRefreshEventListMenuItemClicked } = params;
let { setView, view, onSortingButtonClicked, searchEvents } = params;
let { selectionFilter, sessionId, setNewEventVisibility } = params;
activePage = activePage || 1;
autorefreshEventList = autorefreshEventList || false;
availableTags = availableTags || [];
eventCountBySelectionFilter = eventCountBySelectionFilter || 0;
eventCountSinceLastRefresh = eventCountSinceLastRefresh || 0;
getEvents = getEvents || nullFunction;
investigationId = investigationId || 123456;
isNewButtonEnabled = !(isNewButtonEnabled === false);
isSortingLatestEventsFirst = !(isSortingLatestEventsFirst === false);
logbookContext = logbookContext || {
name: null,
isReleased: null,
};
onPageClicked = onPageClicked || nullFunction;
onRefreshEventListMenuItemClicked =
onRefreshEventListMenuItemClicked || nullFunction;
onSortingButtonClicked = onSortingButtonClicked || nullFunction;
searchEvents = searchEvents || nullFunction;
selectionFilter = selectionFilter || {};
sessionId = sessionId || 'sessionIdForTests';
setNewEventVisibility = setNewEventVisibility || nullFunction;
setView = setView || nullFunction;
view = view || LIST_VIEW;
return Enzyme.shallow(
<EventListMenu
activePage={params.activePage}
isAutorefreshEnabled={params.autorefreshEventList}
availableTags={params.availableTags}
eventCountBySelectionFilter={params.eventCountBySelectionFilter}
eventCountSinceLastRefresh={params.eventCountSinceLastRefresh}
getEvents={params.getEvents}
investigationId={params.investigationId}
isNewButtonEnabled={params.isNewButtonEnabled}
isSortingLatestEventsFirst={params.isSortingLatestEventsFirst}
logbookContext={params.logbookContext}
onPageClicked={params.onPageClicked}
onAutoRefreshMenuItemClicked={params.onRefreshEventListMenuItemClicked}
onSortingButtonClicked={params.onSortingButtonClicked}
searchEvents={params.searchEvents}
selectionFilter={params.selectionFilter}
sessionId={params.sessionId}
setNewEventVisibility={params.setNewEventVisibility}
setView={params.setView}
view={params.view}
activePage={activePage}
isAutorefreshEnabled={autorefreshEventList}
availableTags={availableTags}
eventCountBySelectionFilter={eventCountBySelectionFilter}
eventCountSinceLastRefresh={eventCountSinceLastRefresh}
getEvents={getEvents}
investigationId={investigationId}
isNewButtonEnabled={isNewButtonEnabled}
isSortingLatestEventsFirst={isSortingLatestEventsFirst}
logbookContext={logbookContext}
onPageClicked={onPageClicked}
onAutoRefreshMenuItemClicked={onRefreshEventListMenuItemClicked}
onSortingButtonClicked={onSortingButtonClicked}
searchEvents={searchEvents}
selectionFilter={selectionFilter}
sessionId={sessionId}
setNewEventVisibility={setNewEventVisibility}
setView={setView}
view={view}
/>
);
}
}
function nullFunction() {
return null;
}
......@@ -156,7 +156,6 @@ module.exports = {
name: LOGBOOK_CONTEXT_NAME_PROPOSAL,
isReleased: true,
},
expected: {},
},
{
description: 'logbook is not public, is not automatically refreshing',
......@@ -165,9 +164,6 @@ module.exports = {
name: LOGBOOK_CONTEXT_NAME_PROPOSAL,
isReleased: false,
},
expected: {
text: 'Start refreshing logs',
},
},
{
description: 'logbook is not public, is automatically refreshing',
......@@ -176,9 +172,6 @@ module.exports = {
name: LOGBOOK_CONTEXT_NAME_PROPOSAL,
isReleased: false,
},
expected: {
text: 'Stop refreshing logs',
},
},
],
callingPropFunction: [
......
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