Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/2468 add new variant page #2494

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 44 additions & 38 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,25 @@ import ErrorBoundary from 'ErrorBoundary';
import ROUTES from 'common/routes';
import isPlainObject from 'lodash/isPlainObject';
import isEmpty from 'lodash/isEmpty';
import VariantDb from './components/VariantDb';

const userIsRequiredToLogIn = loggedInUser => {
return (
(loggedInUser === null ||
loggedInUser === undefined ||
(isPlainObject(loggedInUser) && isEmpty(loggedInUser))) &&
requireLogin
);
};
const userIsRequiredToLogIn = (loggedInUser) =>
(loggedInUser === null ||
loggedInUser === undefined ||
(isPlainObject(loggedInUser) && isEmpty(loggedInUser))) &&
requireLogin;

const userIsNotLoggedInOrMustCompleteJoinForm = loggedInUser => {
return (
!loggedInUser ||
isEmpty(loggedInUser) ||
!loggedInUser.roles ||
!loggedInUser.roles[0] ||
!loggedInUser.acceptedTerms
);
};
const userIsNotLoggedInOrMustCompleteJoinForm = (loggedInUser) =>
!loggedInUser ||
isEmpty(loggedInUser) ||
!loggedInUser.roles ||
!loggedInUser.roles[0] ||
!loggedInUser.acceptedTerms;

const userIsLoggedInButMustCompleteJoinForm = loggedInUser => {
return (
isPlainObject(loggedInUser) &&
!isEmpty(loggedInUser) &&
(!loggedInUser.roles || !loggedInUser.roles[0] || !loggedInUser.acceptedTerms)
);
};
const userIsLoggedInButMustCompleteJoinForm = (loggedInUser) =>
isPlainObject(loggedInUser) &&
!isEmpty(loggedInUser) &&
(!loggedInUser.roles || !loggedInUser.roles[0] || !loggedInUser.acceptedTerms);

const forceSelectRole = ({ loggedInUser, isLoadingUser, WrapperPage = Page, ...props }) => {
if (isLoadingUser) {
Expand Down Expand Up @@ -99,7 +91,7 @@ const App = compose(
<Route
path={ROUTES.cohortBuilder}
exact
render={props =>
render={(props) =>
forceSelectRole({
isLoadingUser,
Component: CohortBuilder,
Expand All @@ -116,21 +108,35 @@ const App = compose(
<Route
path={ROUTES.searchMember}
exact
render={props => {
return forceSelectRole({
render={(props) =>
forceSelectRole({
isLoadingUser,
Component: MemberSearchPage,
loggedInUser,
isAdmin: state.isAdmin,
loggedInUserToken: state.loggedInUserToken,
...props,
});
}}
})
}
/>
<Route
path={ROUTES.variantDb}
exact
render={(props) =>
forceSelectRole({
api,
isLoadingUser,
Component: VariantDb,
loggedInUser,
WrapperPage: FixedFooterPage,
...props,
})
}
/>
<Route
path={`${ROUTES.file}/:fileId`}
exact
render={props =>
render={(props) =>
forceSelectRole({
api,
isLoadingUser,
Expand All @@ -144,7 +150,7 @@ const App = compose(
<Route
path={`${ROUTES.participant}/:participantId`}
exact
render={props =>
render={(props) =>
forceSelectRole({
isLoadingUser,
loggedInUser,
Expand All @@ -157,7 +163,7 @@ const App = compose(
<Route
path={`${ROUTES.search}/:index`}
exact
render={props =>
render={(props) =>
forceSelectRole({
isLoadingUser,
Component: FileRepo,
Expand All @@ -172,7 +178,7 @@ const App = compose(
<Route
path={ROUTES.dashboard}
exact
render={props =>
render={(props) =>
forceSelectRole({
api,
isLoadingUser,
Expand All @@ -185,7 +191,7 @@ const App = compose(
<Route
path={ROUTES.join}
exact
render={props => {
render={(props) => {
if (userIsNotLoggedInOrMustCompleteJoinForm(loggedInUser)) {
return (
<ApiContext.Provider
Expand Down Expand Up @@ -214,7 +220,7 @@ const App = compose(
<Route
path="/"
exact
render={props =>
render={(props) =>
forceSelectRole({
api,
isLoadingUser,
Expand All @@ -228,7 +234,7 @@ const App = compose(
<Route
path={ROUTES.orcid}
exact
render={props => (
render={(props) => (
<SideImagePage
logo={logo}
backgroundImage={scienceBgPath}
Expand All @@ -246,7 +252,7 @@ const App = compose(
<Route
path={ROUTES.profile}
exact
render={props =>
render={(props) =>
forceSelectRole({
api,
isLoadingUser,
Expand All @@ -260,7 +266,7 @@ const App = compose(
<Route
path={`${ROUTES.user}/:userID`}
exact
render={props => {
render={(props) => {
const userIdUrlParam = props.match.params.userID;
return forceSelectRole({
api,
Expand Down
Binary file added src/assets/appache-zeppelin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/common/injectGlobals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export const reactApiDataVersionApi: string = getApplicationEnvVar('DATA_VERSION
export const reactApiDataVersionFallback: string =
getApplicationEnvVar('DATA_VERSION_FALLBACK') || '';
export const reactApiSearchMembersApi = getApplicationEnvVar('SEARCH_MEMBERS_API') || null;
export const kfVariantClusterUrl = getApplicationEnvVar('VARIANT_CLUSTER_API') || null;

// Public Stats
export const publicStatsApiRoot = getApplicationEnvVar('PUBLIC_STATS_ROOT') || '';
Expand Down
6 changes: 4 additions & 2 deletions src/common/profile.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ROLES } from './constants';

export const extractInfoFromRoles = roles => {
export const extractInfoFromRoles = (roles) => {
if (!Array.isArray(roles) || roles.length === 0) {
return null;
}

const role = roles[0];
const displayInfo = ROLES.find(r => r.type === role);
const displayInfo = ROLES.find((r) => r.type === role);
const Icon = displayInfo.icon;
const backgroundColor = displayInfo.color;
const roleName = displayInfo.displayName;
Expand All @@ -17,3 +17,5 @@ export const extractInfoFromRoles = roles => {
Icon,
};
};

export const isPartOfGroup = (group, user) => (user?.egoGroups || []).includes(group);
1 change: 1 addition & 0 deletions src/common/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const ROUTES = {
search: '/search',
searchMember: '/memberPage',
user: '/user',
variantDb: '/variantDb',
profile: '/profile',
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import FileIcon from 'icons/FileIcon';
import { MONDOLink } from '../../Utils/DiagnosisAndPhenotypeLinks';
import SaveSetModal from './SaveSetModal';
import './ParticipantTableView.css';
import { isFeatureEnabled } from 'common/featuresToggles';
import { isPartOfGroup } from 'common/profile';

const SelectionCell = ({ value: checked, onCellSelected, row }) => {
return (
Expand All @@ -30,15 +30,15 @@ const SelectionCell = ({ value: checked, onCellSelected, row }) => {
onChange={
row
? () => onCellSelected(!checked, row)
: evt => {
: (evt) => {
onCellSelected(evt.currentTarget.checked);
}
}
/>
);
};

const isMondo = datum => typeof datum === 'string' && datum.includes('MONDO');
const isMondo = (datum) => typeof datum === 'string' && datum.includes('MONDO');

const enhance = compose(withState('collapsed', 'setCollapsed', true));

Expand Down Expand Up @@ -121,7 +121,7 @@ const ParticipantIdLink = compose(({ value: idParticipant }) => {

const participantsTableViewColumns = (onRowSelected, onAllRowsSelected, dirtyHack) => [
{
Header: props => {
Header: (props) => {
return (
<SelectionCell
{...props}
Expand All @@ -130,7 +130,7 @@ const participantsTableViewColumns = (onRowSelected, onAllRowsSelected, dirtyHac
/>
);
},
Cell: props => {
Cell: (props) => {
return <SelectionCell value={props.value} row={props.row} onCellSelected={onRowSelected} />;
},
accessor: 'selected',
Expand All @@ -143,7 +143,7 @@ const participantsTableViewColumns = (onRowSelected, onAllRowsSelected, dirtyHac
{
Header: 'Participant ID',
accessor: 'participantId',
Cell: props => <ParticipantIdLink value={props.value} />,
Cell: (props) => <ParticipantIdLink value={props.value} />,
},
{
Header: 'Study Name',
Expand All @@ -155,7 +155,7 @@ const participantsTableViewColumns = (onRowSelected, onAllRowsSelected, dirtyHac
{
Header: 'Diagnosis Category',
accessor: 'diagnosisCategories',
Cell: props => (
Cell: (props) => (
<CollapsibleMultiLineCell
value={props.value}
collapsed={props.collapsed}
Expand All @@ -168,7 +168,7 @@ const participantsTableViewColumns = (onRowSelected, onAllRowsSelected, dirtyHac
{
Header: 'Diagnosis (Mondo)',
accessor: 'diagnosisMondo',
Cell: props => (
Cell: (props) => (
<CollapsibleMultiLineCell
value={props.value}
collapsed={props.collapsed}
Expand All @@ -182,7 +182,7 @@ const participantsTableViewColumns = (onRowSelected, onAllRowsSelected, dirtyHac
{
Header: 'Age at Diagnosis (days)',
accessor: 'ageAtDiagnosis',
Cell: props => (
Cell: (props) => (
<CollapsibleMultiLineCell
value={props.value}
collapsed={props.collapsed}
Expand All @@ -197,7 +197,7 @@ const participantsTableViewColumns = (onRowSelected, onAllRowsSelected, dirtyHac
{
Header: 'Family Composition',
accessor: 'familyCompositions',
Cell: props => (
Cell: (props) => (
<CollapsibleMultiLineCell
value={props.value}
collapsed={props.collapsed}
Expand All @@ -210,7 +210,7 @@ const participantsTableViewColumns = (onRowSelected, onAllRowsSelected, dirtyHac
{
Header: 'Files',
accessor: 'filesCount',
Cell: props => <NbFilesCell value={props.value} row={props.row} />,
Cell: (props) => <NbFilesCell value={props.value} row={props.row} />,
field: 'files',
sortable: false,
},
Expand All @@ -231,7 +231,7 @@ class ParticipantsTable extends Component {
this.state = {
columns: configureCols(
participantsTableViewColumns(props.onRowSelected, props.onAllRowsSelected, this.dirtyHack),
).map(field =>
).map((field) =>
field.sortable !== false && SORTABLE_FIELDS_MAPPING.has(field.accessor)
? { ...field, sortable: true }
: { ...field, sortable: false },
Expand Down Expand Up @@ -311,7 +311,7 @@ class ParticipantsTable extends Component {
<span>{`\u00A0participant${
selectedRowsCount > 1 ? 's are' : ' is'
} selected\u00A0`}</span>
<button onClick={evt => onClearSelected()} className="clearSelection">
<button onClick={() => onClearSelected()} className="clearSelection">
{'clear selection'}
</button>
</Fragment>
Expand All @@ -320,7 +320,7 @@ class ParticipantsTable extends Component {
</Fragment>
</ToolbarGroup>
<div className={'action-btns-layout'}>
{isFeatureEnabled('variantsDb') && (
{isPartOfGroup('kf-investigator', loggedInUser) && (
<Button
className={'save-set-btn'}
onClick={() =>
Expand Down
Loading