Commit 20684a58 authored by Axel Bocciarelli's avatar Axel Bocciarelli
Browse files

Merge branch 'dead-code' into 'master'

Remove dead code and use shorthand arrow functions

See merge request icat/E-DataPortal!407
parents b474c3a9 9658103d
Pipeline #31576 passed with stages
in 7 minutes and 31 seconds
......@@ -18,7 +18,7 @@ export function appendBreadCrumb(breadcrumb) {
};
}
export function CleanBreadcrumbs() {
export function cleanBreadcrumbs() {
return {
type: CLEAN_BREADCRUMBS,
};
......
......@@ -350,23 +350,3 @@ export function getInstrumentStatistics(sessionId) {
)
);
}
export function postAddress(sessionId, investigationId) {
return `${ICATPLUS.server}/tracking/${sessionId}/investigation/id/${investigationId}/address`;
}
export function putAddress(sessionId, investigationId) {
return `${ICATPLUS.server}/tracking/${sessionId}/investigation/id/${investigationId}/address`;
}
export function getAddresses(sessionId) {
return `${ICATPLUS.server}/tracking/${sessionId}/address`;
}
export function deleteAddress(sessionId, investigationId) {
return `${ICATPLUS.server}/tracking/${sessionId}/investigation/id/${investigationId}/address`;
}
export function getAddressByInvestigationId(sessionId, investigationId) {
return `${ICATPLUS.server}/tracking/${sessionId}/investigation/id/${investigationId}/address`;
}
......@@ -66,9 +66,7 @@ class DatasetTable extends React.Component {
techniquesFormatter(cell, row) {
if (row != null) {
const definition = row.parameters.filter((o) => {
return o.name === 'definition';
});
const definition = row.parameters.filter((o) => o.name === 'definition');
if (definition) {
if (definition.length > 0) {
return definition[0].value;
......@@ -235,15 +233,13 @@ class DatasetTable extends React.Component {
expandColumnRenderer: ({ expanded }) => (
<Glyphicon glyph={expanded ? 'zoom-out' : 'zoom-in'} />
),
renderer: (dataset) => {
return (
<DatasetWidget
dataset={dataset}
sessionId={this.props.sessionId}
selection={this.props.selection}
></DatasetWidget>
);
},
renderer: (dataset) => (
<DatasetWidget
dataset={dataset}
sessionId={this.props.sessionId}
selection={this.props.selection}
></DatasetWidget>
),
};
return (
......
......@@ -5,9 +5,9 @@ import { getFileByEventId } from '../../api/icat/icatPlus';
export default class GalleryDatasetThumbnail extends Component {
render() {
let gallery = this.props.dataset.parameters.filter((o) => {
return o.name === 'ResourcesGallery';
});
let gallery = this.props.dataset.parameters.filter(
(o) => o.name === 'ResourcesGallery'
);
if (gallery != null) {
if (gallery.length > 0) {
......
......@@ -6,9 +6,9 @@ import './PublicationSummary.css';
class PublicationSummary extends React.Component {
getImageFromGalleyByIndex(index) {
/** Checking gallery **/
let gallery = this.props.dataset.parameters.filter((o) => {
return o.name === 'ResourcesGallery';
});
let gallery = this.props.dataset.parameters.filter(
(o) => o.name === 'ResourcesGallery'
);
if (gallery != null) {
if (gallery.length > 0) {
......@@ -32,9 +32,9 @@ class PublicationSummary extends React.Component {
}
getParameterValue(name) {
const sampleNameParameter = this.props.dataset.parameters.filter((o) => {
return o.name === name;
});
const sampleNameParameter = this.props.dataset.parameters.filter(
(o) => o.name === name
);
if (sampleNameParameter) {
if (sampleNameParameter[0]) {
return sampleNameParameter[0].value;
......
......@@ -57,9 +57,9 @@ class InstrumentDetectorWidget extends React.Component {
<div className="container-fluid">
<h3>Detectors</h3>
<div className="row">
{detectors.map((detector) => {
return <div>{detector}</div>;
})}
{detectors.map((detector) => (
<div>{detector}</div>
))}
</div>
</div>
);
......
......@@ -275,14 +275,12 @@ class InvestigationTable extends React.Component {
}
return <Glyphicon glyph="zoom-in" />;
},
renderer: (investigation) => {
return (
<InvestigationWidget
investigation={investigation}
sessionId={this.props.user.sessionId}
></InvestigationWidget>
);
},
renderer: (investigation) => (
<InvestigationWidget
investigation={investigation}
sessionId={this.props.user.sessionId}
></InvestigationWidget>
),
};
return (
......
......@@ -82,18 +82,16 @@ export default function EventVersions(event) {
closeOnDocumentClick={false}
contentStyle={{ width: '90%', height: '90%' }}
>
{(close) => {
return (
<div className="fullPage">
<button type="button" className="close" onClick={close}>
&times;
</button>
<div className="content">
<CompleteEventHistory event={event} />
</div>
{(close) => (
<div className="fullPage">
<button type="button" className="close" onClick={close}>
&times;
</button>
<div className="content">
<CompleteEventHistory event={event} />
</div>
);
}}
</div>
)}
</Popup>
</div>
</Popover>
......
......@@ -196,14 +196,6 @@ export class Event extends React.Component {
events = events.concat(this.props.event.events);
}
/** Will print bottom shadow when it is the last event */
const getShadow = () => {
return '6px 0 5px -5px rgba(100, 100, 100, 0.8), -6px 0 5px -5px rgba(100, 100, 100, 0.8)';
// if (event.shadowBottomBorder) {
// }
};
const getButtonIcon = (event) => {
if (this.props.logbookContext.isReleased) {
return <Glyphicon glyph="eye-open" />;
......@@ -213,83 +205,79 @@ export class Event extends React.Component {
}
return <Glyphicon glyph="pencil" style={{ width: 10 }} />;
};
return events.map((event, index) => {
return (
<tr key={index} style={{ backgroundColor: '#f0f0f6' }}>
<td style={{ width: 16, border: 0 }}>
<EventIcon event={event} />
</td>
<td className="borderTopSeparatorBetweenEvents" style={{ width: 16 }}>
<OverlayTrigger
placement="right"
overlay={
<Tooltip id="tooltip">
return events.map((event, index) => (
<tr key={index} style={{ backgroundColor: '#f0f0f6' }}>
<td style={{ width: 16, border: 0 }}>
<EventIcon event={event} />
</td>
<td className="borderTopSeparatorBetweenEvents" style={{ width: 16 }}>
<OverlayTrigger
placement="right"
overlay={
<Tooltip id="tooltip">
{' '}
<p>
{' '}
<p>
{' '}
Events created on{' '}
{moment(getOriginalEvent(event).creationDate).format(
'MMMM Do YYYY, h:mm:ss a'
)}{' '}
</p>{' '}
</Tooltip>
}
>
<span style={{ cursor: 'pointer', color: 'black', margin: 0 }}>
{moment(getOriginalEvent(event).creationDate).format(
moment.HTML5_FMT.TIME_SECONDS
)}{' '}
</span>
</OverlayTrigger>
</td>
<td className="borderTopSeparatorBetweenEvents" style={{ width: 30 }}>
<Button
bsStyle="default"
bsSize="small"
style={{ width: 30, position: 'static', padding: 0 }}
onClick={() => this.props.onEventClicked(event)}
>
{getButtonIcon(event)}
</Button>
</td>
<td
className="borderTopSeparatorBetweenEvents"
style={{ width: 16 }}
></td>
<td
className="borderTopSeparatorBetweenEventsInline"
style={{
paddingBottom: 0,
backgroundColor: 'white',
boxShadow: getShadow(event),
}}
Events created on{' '}
{moment(getOriginalEvent(event).creationDate).format(
'MMMM Do YYYY, h:mm:ss a'
)}{' '}
</p>{' '}
</Tooltip>
}
>
<div style={{ marginLeft: 20, backgroundColor: 'white' }}>
<EventTextBox event={event} />
{event.events && this.state.collapsed && (
<Label
style={{
color: 'blue',
backgroundColor: '#f8f8f8',
cursor: 'pointer',
}}
onClick={this.handleClick}
>
.... {event.events.length} command lines more
</Label>
)}
</div>
</td>
<td
className="borderTopSeparatorBetweenEvents"
style={{ width: 200 }}
<span style={{ cursor: 'pointer', color: 'black', margin: 0 }}>
{moment(getOriginalEvent(event).creationDate).format(
moment.HTML5_FMT.TIME_SECONDS
)}{' '}
</span>
</OverlayTrigger>
</td>
<td className="borderTopSeparatorBetweenEvents" style={{ width: 30 }}>
<Button
bsStyle="default"
bsSize="small"
style={{ width: 30, position: 'static', padding: 0 }}
onClick={() => this.props.onEventClicked(event)}
>
<TagListInLine tags={event.tag} />
</td>
</tr>
);
});
{getButtonIcon(event)}
</Button>
</td>
<td
className="borderTopSeparatorBetweenEvents"
style={{ width: 16 }}
></td>
<td
className="borderTopSeparatorBetweenEventsInline"
style={{
paddingBottom: 0,
backgroundColor: 'white',
boxShadow:
'6px 0 5px -5px rgba(100, 100, 100, 0.8), -6px 0 5px -5px rgba(100, 100, 100, 0.8)',
}}
>
<div style={{ marginLeft: 20, backgroundColor: 'white' }}>
<EventTextBox event={event} />
{event.events && this.state.collapsed && (
<Label
style={{
color: 'blue',
backgroundColor: '#f8f8f8',
cursor: 'pointer',
}}
onClick={this.handleClick}
>
.... {event.events.length} command lines more
</Label>
)}
</div>
</td>
<td className="borderTopSeparatorBetweenEvents" style={{ width: 200 }}>
<TagListInLine tags={event.tag} />
</td>
</tr>
));
}
handleClick() {
......@@ -300,9 +288,9 @@ export class Event extends React.Component {
return (
<tbody>
{' '}
{this.props.event.events.map((event) => {
return this.getEventContentBody(event);
})}
{this.props.event.events.map((event) =>
this.getEventContentBody(event)
)}
</tbody>
);
}
......@@ -354,7 +342,7 @@ class EventTextBox extends React.Component {
if (this.props.event.type === NOTIFICATION) {
if (this.props.event.previousVersionEvent) {
return (
<React.Fragment>
<>
<div
className={this.getTextColorClassNameByCategory(
this.props.event.category
......@@ -396,7 +384,7 @@ class EventTextBox extends React.Component {
>
<LazyLoadedText text={text} />
</div>
</React.Fragment>
</>
);
}
......
......@@ -16,16 +16,14 @@ class TagListPanel extends React.Component {
}
let detailedTags = [];
const sortedAvailableTags = sortBy(availableTags, ['name']);
detailedTags = sortedAvailableTags.map((tag, index) => {
return (
<TagListPanelLine
key={index}
tag={tag}
onEditButtonClicked={onEditButtonClicked}
isTagEditionEnabled={this.props.isTagEditionEnabled}
/>
);
});
detailedTags = sortedAvailableTags.map((tag, index) => (
<TagListPanelLine
key={index}
tag={tag}
onEditButtonClicked={onEditButtonClicked}
isTagEditionEnabled={this.props.isTagEditionEnabled}
/>
));
return (
<div style={{ paddingBottom: 70 }}>
<Grid fluid>
......
......@@ -268,7 +268,7 @@ class DataVolumeStatisticsPanel extends React.Component {
}
return (
<React.Fragment>
<>
<br />
<p className="text-secondary">
Number of files produced for all the instruments. Note the log scale.
......@@ -294,7 +294,7 @@ class DataVolumeStatisticsPanel extends React.Component {
releaseSum={this.state.data.releasedDate.volume.sum}
releaseSumAcc={this.state.data.releasedDate.volume.sumAcc}
/>
</React.Fragment>
</>
);
}
}
......
......@@ -48,9 +48,10 @@ class GeneralStatsPanel extends React.Component {
})
.then((response) => {
const statistics = Object.keys(response.data.startDate.buckets).map(
(key) => {
return { date: key, data: response.data.startDate.buckets[key] };
}
(key) => ({
date: key,
data: response.data.startDate.buckets[key],
})
);
this.setState({
fetching: false,
......@@ -151,12 +152,10 @@ class GeneralStatsPanel extends React.Component {
hole: 0.4,
textposition: 'inside',
labels: record.data.instrument.buckets.map((i) => {
return i.key;
}),
values: record.data.instrument.buckets.map((i) => {
return i.volume_stats.sum;
}),
labels: record.data.instrument.buckets.map((i) => i.key),
values: record.data.instrument.buckets.map(
(i) => i.volume_stats.sum
),
},
]}
layout={{ showLegend: true, title: 'Volume per instrument' }}
......@@ -168,20 +167,14 @@ class GeneralStatsPanel extends React.Component {
{
name: 'Datasets',
type: 'bar',
x: record.data.instrument.buckets.map((i) => {
return i.key;
}),
y: record.data.instrument.buckets.map((i) => {
return i.doc_count;
}),
x: record.data.instrument.buckets.map((i) => i.key),
y: record.data.instrument.buckets.map((i) => i.doc_count),
},
{
x: record.data.instrument.buckets.map((i) => {
return i.key;
}),
y: record.data.instrument.buckets.map((i) => {
return i.fileCount_stats.sum;
}),
x: record.data.instrument.buckets.map((i) => i.key),
y: record.data.instrument.buckets.map(
(i) => i.fileCount_stats.sum
),
type: 'scatter',
mode: 'lines+markers',
marker: { color: 'red' },
......
......@@ -20,8 +20,11 @@ class ManagerMenu extends React.Component {
}
if (instruments && instruments.length > 0) {
const items = instruments.sort().map((value, index) => {
return value ? (
const items = instruments
.slice(0)
.filter((value) => !!value)
.sort()
.map((value, index) => (
<LinkContainer
key={value + index}
to={`/beamline/${value.toLowerCase()}`}
......@@ -39,8 +42,7 @@ class ManagerMenu extends React.Component {
</span>
</MenuItem>
</LinkContainer>
) : undefined;
});
));
//fetchInvestigationsAsInstrumentScientist
items.unshift(
......@@ -68,12 +70,11 @@ class ManagerMenu extends React.Component {
render() {
const instruments = uniq(
this.props.scientistInstrumentInvestigations.data.map((inv) => {
if (inv.investigationInstruments.length > 0) {
return inv.investigationInstruments[0].instrument.name;
}
return undefined;
})
this.props.scientistInstrumentInvestigations.data.map((inv) =>
inv.investigationInstruments.length > 0
? inv.investigationInstruments[0].instrument.name
: undefined
)
);
const navDropdownTitle = (
......
......@@ -29,13 +29,12 @@ export default class BeamlineManagerForm extends Component {
this.handleClick = this.handleClick.bind(this);
}
_renderMenuItemChildren = (option) => {
return [<span>{option.fullName}</span>, <br />];
};
_renderMenuItemChildren = (option) => [
<span>{option.fullName}</span>,
<br />,
];
_renderBeamlineItem = (option) => {
return [<span>{option}</span>, <br />];
};
_renderBeamlineItem = (option) => [<span>{option}</span>, <br />];
getUsers() {
axios
......@@ -72,9 +71,7 @@ export default class BeamlineManagerForm extends Component {
axios
.put(createInstrumentScientists(this.props.user.sessionId), {
usernames: this.state.usersSelected.map((u) => {
return u.name;
}),
usernames: this.state.usersSelected.map((u) => u.name),
instrumentnames: this.state.instrumentsSelected,
})
.then((response) => {
......
......@@ -71,17 +71,11 @@ class InstrumentScientistTable extends React.Component {
});
});
};
renderButtons = (cell, row) => {
return (
<Button
instrumentScientistId={row.id}
bsStyle="danger"
onClick={() => this.handleRevokeClick(row.id)}
>
Revoke
</Button>
);
};
renderButtons = (_, row) => (
<Button bsStyle="danger" onClick={() => this.handleRevokeClick(row.id)}>
Revoke
</Button>
);
render() {
const data = this.props.instrumentScientists.sort(
......
......@@ -28,12 +28,6 @@ export const FETCH_MY_INVESTIGATIONS_PENDING =
export const FETCH_MY_INVESTIGATIONS_FULFILLED =
'FETCH_MY_INVESTIGATIONS_FULFILLED';
export const FETCH_INVESTIGATIONS_DOI = 'FETCH_INVESTIGATIONS_DOI';
export const FETCH_INVESTIGATIONS_DOI_FULFILLED =
'FETCH_INVESTIGATIONS_DOI_FULFILLED';
export const FETCH_INVESTIGATIONS_DOI_PENDING =
'FETCH_INVESTIGATIONS_DOI_PENDING';
export const FETCH_INSTRUMENT_SCIENTIST_INVESTIGATIONS =