Commit ac453f01 authored by Alejandro De Maria Antolinos's avatar Alejandro De Maria Antolinos
Browse files

Merge branch 'issue_518' into 'master'

It fixes #518

Closes #518

See merge request !536
parents 67701d7c 51ce8acf
Pipeline #51124 passed with stages
in 14 minutes and 29 seconds
...@@ -12,6 +12,7 @@ import { ...@@ -12,6 +12,7 @@ import {
datasetCountFormatter, datasetCountFormatter,
fileCountFormatter, fileCountFormatter,
dateFormatter, dateFormatter,
userPortalLinkFormatter,
} from './utils'; } from './utils';
import InvestigationDateFilter from './InvestigationDateFilter'; import InvestigationDateFilter from './InvestigationDateFilter';
import styles from './InvestigationTable.module.css'; import styles from './InvestigationTable.module.css';
...@@ -29,7 +30,12 @@ function getLgHeaderStyle(width, hidden) { ...@@ -29,7 +30,12 @@ function getLgHeaderStyle(width, hidden) {
}; };
} }
function getColumns({ showProposalLinks, showInvestigationStats, showFiles }) { function getColumns({
showProposalLinks,
showInvestigationStats,
showFiles,
withUserPortalLink,
}) {
return [ return [
{ {
text: 'id', text: 'id',
...@@ -66,6 +72,7 @@ function getColumns({ showProposalLinks, showInvestigationStats, showFiles }) { ...@@ -66,6 +72,7 @@ function getColumns({ showProposalLinks, showInvestigationStats, showFiles }) {
lg: { width: 140, textAlign: 'center' }, lg: { width: 140, textAlign: 'center' },
}, },
}, },
{ {
text: 'Beamline', text: 'Beamline',
dataField: 'visitId', dataField: 'visitId',
...@@ -90,12 +97,6 @@ function getColumns({ showProposalLinks, showInvestigationStats, showFiles }) { ...@@ -90,12 +97,6 @@ function getColumns({ showProposalLinks, showInvestigationStats, showFiles }) {
sort: true, sort: true,
responsiveHeaderStyle: getLgHeaderStyle(110, false), responsiveHeaderStyle: getLgHeaderStyle(110, false),
}, },
{
text: 'Summary',
dataField: 'summary',
sort: true,
hidden: true,
},
// See https://gitlab.esrf.fr/icat/E-DataPortal/-/issues/439 // See https://gitlab.esrf.fr/icat/E-DataPortal/-/issues/439
{ {
text: 'Title', text: 'Title',
...@@ -110,6 +111,21 @@ function getColumns({ showProposalLinks, showInvestigationStats, showFiles }) { ...@@ -110,6 +111,21 @@ function getColumns({ showProposalLinks, showInvestigationStats, showFiles }) {
sm: { hidden: true }, sm: { hidden: true },
}, },
}, },
{
text: 'A-Form',
dataField: 'userPortal',
formatter: (_, investigation) => {
return userPortalLinkFormatter(investigation, 120);
},
sort: true,
headerStyle: () => ({ width: '50%', textAlign: 'center' }),
responsiveHeaderStyle: {
xs: { hidden: !withUserPortalLink },
sm: { hidden: !withUserPortalLink },
md: { width: 140, textAlign: 'center', hidden: !withUserPortalLink },
lg: { width: 140, textAlign: 'center', hidden: !withUserPortalLink },
},
},
{ {
text: 'Datasets', text: 'Datasets',
dataField: 'datasets', dataField: 'datasets',
...@@ -153,6 +169,7 @@ function InvestigationTable(props) { ...@@ -153,6 +169,7 @@ function InvestigationTable(props) {
withInvestigationStats = false, withInvestigationStats = false,
showStatisticsMenu = false, showStatisticsMenu = false,
instrumentName, instrumentName,
withUserPortalLink = false,
} = props; } = props;
const user = useSelector((state) => state.user); const user = useSelector((state) => state.user);
...@@ -257,6 +274,7 @@ function InvestigationTable(props) { ...@@ -257,6 +274,7 @@ function InvestigationTable(props) {
showProposalLinks: withProposalLinks || isAdministrator, showProposalLinks: withProposalLinks || isAdministrator,
showInvestigationStats: withInvestigationStats || isAdministrator, showInvestigationStats: withInvestigationStats || isAdministrator,
showFiles: isAdministrator, showFiles: isAdministrator,
withUserPortalLink: withUserPortalLink || isAdministrator,
})} })}
expandRow={expandRow} expandRow={expandRow}
/> />
......
...@@ -21,6 +21,7 @@ import { ...@@ -21,6 +21,7 @@ import {
} from '../../constants'; } from '../../constants';
import DOIBadge from '../doi/DOIBadge'; import DOIBadge from '../doi/DOIBadge';
import { stringifyBytesSize } from '../../helpers'; import { stringifyBytesSize } from '../../helpers';
import UI from '../../config/ui';
export function startDateFormatter(investigation) { export function startDateFormatter(investigation) {
function getDateFormat(date, dateFormat, timeFormat, title) { function getDateFormat(date, dateFormat, timeFormat, title) {
...@@ -84,6 +85,27 @@ export function dateFormatter(date, format, hasIcon) { ...@@ -84,6 +85,27 @@ export function dateFormatter(date, format, hasIcon) {
); );
} }
/**
* This method checks if there is a pk to the user portal and a link then it will return a link to the user portal
* @param {*} investigation
* @param {*} link
*/
export function userPortalLinkFormatter(investigation, width) {
if (investigation?.parameters?.[UI.userPortal.investigationParameterPkName]) {
const link =
UI.userPortal.link +
investigation.parameters[UI.userPortal.investigationParameterPkName];
return (
<Button style={{ width, textAlign: 'left' }} bsSize="xsmall">
<a href={link} target="_blank" rel="noopener noreferrer">
<Glyphicon glyph="list-alt" />
<span style={{ marginLeft: 10 }}>{investigation.name}</span>
</a>
</Button>
);
}
}
export function beamlineFormatter(investigation) { export function beamlineFormatter(investigation) {
try { try {
return (investigation?.instrument?.name || '').toUpperCase(); return (investigation?.instrument?.name || '').toUpperCase();
......
...@@ -182,7 +182,6 @@ function ParcelTable(props) { ...@@ -182,7 +182,6 @@ function ParcelTable(props) {
columns={columnsWithHandles} columns={columnsWithHandles}
search={{ defaultSearch: searchFilter, searchFormatted: true }} search={{ defaultSearch: searchFilter, searchFormatted: true }}
onSearch={handleSearchFilterChange} onSearch={handleSearchFilterChange}
rowEvents={{ onClick: (_, parcel) => handleView(parcel) }}
rowClasses={styles.clickable} rowClasses={styles.clickable}
pageOptions={{ pageOptions={{
showTotal: true, showTotal: true,
......
import React from 'react'; import React from 'react';
import ParcelCondensedView from '../Parcels/ParcelCondensedView'; import ParcelCondensedView from '../Parcels/ParcelCondensedView';
import { beamlineFormatter, startDateFormatter } from '../Investigation/utils'; import {
userPortalLinkFormatter,
beamlineFormatter,
startDateFormatter,
nameFormatter,
} from '../Investigation/utils';
import styles from './ParcelSection.module.css'; import styles from './ParcelSection.module.css';
import { STATUS_DEFS } from '../../constants/parcelStatuses'; import { STATUS_DEFS } from '../../constants/parcelStatuses';
import { itemsFormatter } from '../../helpers'; import { itemsFormatter } from '../../helpers';
import UI from '../../config/ui';
const ParcelColumns = [ const ParcelColumns = [
{ text: '', dataField: '_id', hidden: true, searchable: false }, { text: '', dataField: '_id', hidden: true, searchable: false },
...@@ -32,15 +38,30 @@ const ParcelColumns = [ ...@@ -32,15 +38,30 @@ const ParcelColumns = [
}, },
{ {
text: 'Proposal', text: 'Proposal',
dataField: 'investigationName', dataField: 'experiment',
formatter: (_, parcel) => nameFormatter(parcel.investigation, true),
sort: true, sort: true,
responsiveHeaderStyle: { responsiveHeaderStyle: {
xs: { hidden: true }, xs: { width: 150, hidden: UI.userPortal.isLinkEnabled },
sm: { hidden: true }, sm: { width: 150, hidden: UI.userPortal.isLinkEnabled },
md: { width: 150 }, md: { width: 150, hidden: UI.userPortal.isLinkEnabled },
lg: { width: 150 }, lg: { width: 150, hidden: UI.userPortal.isLinkEnabled },
}, },
}, },
{
text: 'A-Form',
dataField: 'userPortal',
width: 150,
formatter: (_, parcel) =>
userPortalLinkFormatter(parcel.investigation, 120),
responsiveHeaderStyle: {
xs: { width: 140, hidden: !UI.userPortal.isLinkEnabled },
sm: { width: 140, hidden: !UI.userPortal.isLinkEnabled },
md: { width: 140, hidden: !UI.userPortal.isLinkEnabled },
lg: { width: 140, hidden: !UI.userPortal.isLinkEnabled },
},
},
{ {
text: 'Beamline', text: 'Beamline',
dataField: 'beamline', dataField: 'beamline',
......
...@@ -23,6 +23,13 @@ const UI = { ...@@ -23,6 +23,13 @@ const UI = {
usernameLabel: 'Username', usernameLabel: 'Username',
ssoBtnLabel: 'Sign in with ESRF SSO', ssoBtnLabel: 'Sign in with ESRF SSO',
}, },
userPortal: {
isLinkEnabled: true,
/** This is the name of the investigationParameter where it is stored the pk of the investigation in the User Portal */
investigationParameterPkName: 'Id',
link:
'https://smis.esrf.fr/misapps/SMISWebClient/protected/aform/manageAForm.do?action=view&expSessionVO.pk=',
},
investigationContainer: { investigationContainer: {
isDatasetListVisible: true, isDatasetListVisible: true,
}, },
......
...@@ -18,6 +18,7 @@ function BeamlineDataTable(props) { ...@@ -18,6 +18,7 @@ function BeamlineDataTable(props) {
withProposalLinks withProposalLinks
showStatisticsMenu={showStatisticsMenu} showStatisticsMenu={showStatisticsMenu}
instrumentName={name} instrumentName={name}
withUserPortalLink={true}
/> />
); );
} }
......
...@@ -18,6 +18,7 @@ function MyInvestigationsTable() { ...@@ -18,6 +18,7 @@ function MyInvestigationsTable() {
investigations={mySessions} investigations={mySessions}
withInvestigationStats withInvestigationStats
withProposalLinks withProposalLinks
withUserPortalLink={true}
/> />
); );
} }
......
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