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

[DUOS-2897] Remove more hyperscript helpers #2438

Merged
merged 38 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
fa0b0b0
refactor: switch CloseIconComponent to JSX
fboulnois Jan 19, 2024
0a8920f
refactor: switch LibraryCardAgreementTermsDownload to JSX
fboulnois Jan 17, 2024
b089ff4
refactor: switch ScrollableMarkdownContainer to JSX
fboulnois Jan 17, 2024
5001a88
fix: remove unused ScrollButton
fboulnois Jan 17, 2024
40d0bda
refactor: switch CollaboratorRow to JSX
fboulnois Jan 17, 2024
7440da0
refactor: switch DeleteCollaboratorModal to JSX
fboulnois Jan 17, 2024
c6311a9
refactor: switch NihAnvilUse to JSX
fboulnois Jan 17, 2024
19e1399
refactor: switch DacMembersModal to JSX
fboulnois Jan 17, 2024
278dccf
refactor: switch SigningOfficialDataSubmitters to JSX
fboulnois Jan 17, 2024
3a49fc3
refactor: switch SigningOfficialResearchers to JSX
fboulnois Jan 17, 2024
8d1835a
refactor: switch TableTextButton to JSX
fboulnois Jan 17, 2024
ba0b89a
refactor: switch CollectionVoteButton to JSX
fboulnois Jan 17, 2024
1bdc75f
refactor: switch TableHeaderSection to JSX
fboulnois Jan 18, 2024
90ed5be
refactor: switch AtAGlance to JSX
fboulnois Jan 18, 2024
4f430a0
refactor: switch DarCollectionReview to JSX
fboulnois Jan 18, 2024
b82c5a9
refactor: switch SigningOfficialDarRequests to JSX
fboulnois Jan 18, 2024
3ace918
refactor: switch CancelCollectionButton to JSX
fboulnois Jan 19, 2024
47a6d5b
refactor: switch DarCollectionAdminReviewLink to JSX
fboulnois Jan 19, 2024
103415a
refactor: switch ManageDacTable to JSX
fboulnois Jan 19, 2024
d7aedc8
refactor: switch ManageUsersTable to JSX
fboulnois Jan 19, 2024
01af921
refactor: switch MultiDatasetVotingTab to JSX
fboulnois Jan 22, 2024
4edb63c
refactor: switch ConsentGroupForm to JSX
fboulnois Jan 22, 2024
d90a17b
refactor: switch TableIconButton to JSX
fboulnois Jan 22, 2024
2a2418d
refactor: switch Alert to JSX
fboulnois Jan 22, 2024
0234432
refactor: switch CollectionVoteNoButton to JSX
fboulnois Jan 22, 2024
24027b9
refactor: switch CollectionVoteYesButton to JSX
fboulnois Jan 22, 2024
182c859
refactor: switch TableSkeletonLoader to JSX
fboulnois Jan 22, 2024
c2aeefd
refactor: switch NIHPilotInfo to JSX
fboulnois Jan 22, 2024
f4515b2
refactor: switch DataUseAlertBox to JSX
fboulnois Jan 23, 2024
9a48315
refactor: switch DataUsePill to JSX
fboulnois Jan 23, 2024
ebde565
refactor: switch TabControl to JSX
fboulnois Jan 23, 2024
e06fa00
refactor: switch VotesPieChart to JSX
fboulnois Jan 23, 2024
84c1c86
refactor: switch ConfirmationModal to JSX
fboulnois Jan 26, 2024
ac7d575
refactor: switch CollectionAlgorithmDecision to JSX
fboulnois Jan 26, 2024
69c9c0b
refactor: switch SearchSelect to JSX
fboulnois Jan 26, 2024
937de94
refactor: switch ReviewHeader to JSX
fboulnois Jan 26, 2024
e83d331
refactor: switch CollectionConfirmationModal to JSX
fboulnois Jan 26, 2024
8e614f1
refactor: switch ConfirmationDialog_new to JSX
fboulnois Jan 26, 2024
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
33 changes: 9 additions & 24 deletions src/components/Alert.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
import { Component } from 'react';
import { div, hh, h4, span } from 'react-hyperscript-helpers';
import React from 'react';
import './Alert.css';

export const Alert = hh(class Alert extends Component {

render() {

return div({
id: this.props.id + '_alert',
className: 'alert-wrapper ' + (this.props.type)
}, [
h4({
id: this.props.id + '_title',
className: 'alert-title',
isRendered: this.props.title !== undefined
}, [this.props.title]),
span({
id: this.props.id + '_description',
className: 'alert-description',
isRendered: this.props.description !== undefined
}, [this.props.description]),
]);
}

});
export const Alert = ({ id, type, title, description }) => {
return (
<div id={`${id}_alert`} className={`alert-wrapper ${type}`}>
{title && <h4 id={`${id}_title`} className="alert-title">{title}</h4>}
{description && <span id={`${id}_description`} className="alert-description">{description}</span>}
</div>
);
};
16 changes: 7 additions & 9 deletions src/components/CloseIconComponent.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { button, span } from 'react-hyperscript-helpers';
import React from 'react';

export default function CloseIconComponent(props) {
const { closeFn } = props;
return button({
type: 'button',
className: 'modal-close-btn close',
onClick: closeFn
}, [
span({ className: 'glyphicon glyphicon-remove default-color'})
]);
}
return (
<button type="button" className="modal-close-btn close" onClick={closeFn}>
<span className="glyphicon glyphicon-remove default-color" />
</button>
);
}
38 changes: 19 additions & 19 deletions src/components/CollectionAlgorithmDecision.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {React} from 'react';
import { div, h5, p, span, } from 'react-hyperscript-helpers';
import { formatDate } from '../libs/utils';
import{ isEmpty, isNil } from 'lodash/fp';

Expand Down Expand Up @@ -53,23 +52,24 @@ export default function CollectionAlgorithmDecision(props) {
};

return (
div(containerProps, [
div({style: {flex: 1, padding: '1%'}}, [
h5({id: `collection-${id}-subtitle`, style: {fontFamily: 'Montserrat', fontWeight: 800, fontSize: 17, color: '#333F52'}}, ['DUOS Algorithm Decision']),
div({style: {fontSize: '1.5rem'}}, [
span({id: `collection-${id}-decision-label`, style: {paddingRight: '1%', color: '#333F52'}}, ['Decision:']),
span({id: `collection-${id}-decision-value`, style: {fontWeight: 400}}, [getResult(result)])
]),
div({style: {fontSize: '1.5rem'}}, [
span({id: `collection-${id}-reason-label`, style: {paddingRight: '1%', color: '#333F52'}}, ['Reason:']),
span({id: `collection-${id}-reason-value`, style: {fontWeight: 400}},
[!isEmpty(rationales) ? rationales.map((r, idx) => p({key: idx}, [r])) : 'N/A'])
]),
div({style: {fontSize: '1.5rem'}}, [
span({id: `collection-${id}-date-label`, style: {paddingRight: '1%', color: '#333F52'}}, ['Date:']),
span({id: `collection-${id}-date-value`, style: {fontWeight: 400}}, [!isNil(createDate) ? formatDate(createDate) : 'N/A'])
])
])
])
<div {...containerProps}>
<div style={{flex: 1, padding: '1%'}}>
<h5 id={`collection-${id}-subtitle`} style={{fontFamily: 'Montserrat', fontWeight: 800, fontSize: 17, color: '#333F52'}}>DUOS Algorithm Decision</h5>
<div style={{fontSize: '1.5rem'}}>
<span id={`collection-${id}-decision-label`} style={{paddingRight: '1%', color: '#333F52'}}>Decision:</span>
<span id={`collection-${id}-decision-value`} style={{fontWeight: 400}}>{getResult(result)}</span>
</div>
<div style={{fontSize: '1.5rem'}}>
<span id={`collection-${id}-reason-label`} style={{paddingRight: '1%', color: '#333F52'}}>Reason:</span>
<span id={`collection-${id}-reason-value`} style={{fontWeight: 400}}>
{!isEmpty(rationales) ? rationales.map((r, idx) => <p key={idx}>{r}</p>) : 'N/A'}
</span>
</div>
<div style={{fontSize: '1.5rem'}}>
<span id={`collection-${id}-date-label`} style={{paddingRight: '1%', color: '#333F52'}}>Date:</span>
<span id={`collection-${id}-date-value`} style={{fontWeight: 400}}>{!isNil(createDate) ? formatDate(createDate) : 'N/A'}</span>
</div>
</div>
</div>
);
}
83 changes: 40 additions & 43 deletions src/components/ConfirmationDialog_new.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { mergeAll } from 'lodash/fp';
import { a, div, h, h2 } from 'react-hyperscript-helpers';
import React from 'react';
import Modal from 'react-modal';
import { Alert } from './Alert';
import CloseIconComponent from './CloseIconComponent';
Expand Down Expand Up @@ -33,48 +32,46 @@ export const ConfirmationDialog = (props) => {
const { disableOkBtn = false, disableNoBtn = false, alertMessage, alertTitle } = props;

return (
h(Modal, {
isOpen: props.showModal,
onAfterOpen: props.afterOpenModal,
onRequestClose: props.onRequestClose,
style: mergeAll([customStyles, props.style]),
contentLabel: 'Modal'
}, [
div({ className: 'dialog-header' }, [
h(CloseIconComponent, {closeFn: props.action.handler(false)}),
h2({ id: 'lbl_dialogTitle', className: 'dialog-title ' }, [props.title]),
]),
<Modal
isOpen={props.showModal}
onAfterOpen={props.afterOpenModal}
onRequestClose={props.onRequestClose}
style={{ ...customStyles, ...props.style }}
contentLabel="Modal"
>
<div className="dialog-header">
<CloseIconComponent closeFn={props.action.handler(false)} />
<h2 id="lbl_dialogTitle" className="dialog-title">{props.title}</h2>
</div>

div({ id: 'lbl_dialogContent', className: 'dialog-content' }, [
props.children,
div({ isRendered: alertTitle !== undefined, className: 'dialog-alert' }, [
Alert({ id: 'dialog', type: 'danger', title: alertTitle, description: alertMessage })
])
]),
<div id="lbl_dialogContent" className="dialog-content">
{props.children}
{alertTitle !== undefined && (
<div className="dialog-alert">
<Alert id="dialog" type="danger" title={alertTitle} description={alertMessage} />
</div>
)}
</div>


div({ className: 'flex flex-row', style: {
justifyContent: 'flex-end',
marginTop: '20px',
}, }, [
a({
id: 'btn_save',
className: 'button button-white',
style: {
marginRight: '2rem',
},
onClick: props.action.handler(false),
disabled: disableNoBtn
}, ['No']),
a({
id: 'btn_submit',
className: 'button button-blue',
onClick: props.action.handler(true),
disabled: disableOkBtn
}, [
props.action.label
]),
])
])
<div className="flex flex-row" style={{ justifyContent: 'flex-end', marginTop: '20px' }}>
<a
id="btn_save"
className="button button-white"
style={{ marginRight: '2rem' }}
onClick={props.action.handler(false)}
disabled={disableNoBtn}
>
No
</a>
<a
id="btn_submit"
className="button button-blue"
onClick={props.action.handler(true)}
disabled={disableOkBtn}
>
{props.action.label}
</a>
</div>
</Modal>
);
};
27 changes: 15 additions & 12 deletions src/components/LibraryCardAgreementTermsDownload.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import React from 'react';
import LibraryCardAgreementLink from '../assets/Library_Card_Agreement_2023_ApplicationVersion.pdf';
import DownloadIcon from 'react-material-icon-svg/dist/Download';
import {a, div} from 'react-hyperscript-helpers';
import React from 'react';

const downloadIcon = <DownloadIcon fill={'black'} style={{verticalAlign: 'middle', height: '24px'}}/>;
export const LibraryCardAgreementTermsDownload =
div({}, [
'I agree to the terms of the Library Card Agreement',
a({
id: 'link_downloadAgreement',
href: LibraryCardAgreementLink,
target: '_blank',
style: {marginLeft: '.5rem'}
}, [downloadIcon])]);
export const LibraryCardAgreementTermsDownload = () => (
<div>
I agree to the terms of the Library Card Agreement
<a
id="link_downloadAgreement"
href={LibraryCardAgreementLink}
target="_blank"
rel="noreferrer"
style={{marginLeft: '.5rem'}}
>
<DownloadIcon fill={'black'} style={{verticalAlign: 'middle', height: '24px'}}/>
</a>
</div>
);
23 changes: 0 additions & 23 deletions src/components/ScrollButton.js

This file was deleted.

38 changes: 21 additions & 17 deletions src/components/ScrollableMarkdownContainer.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import ReactMarkdown from 'react-markdown';
import {div} from 'react-hyperscript-helpers';
import DOMPurify from 'dompurify';
import React, {useEffect, useState} from 'react';
import {isEmpty} from 'lodash/fp';
import React, { useEffect, useState } from 'react';
import { isEmpty } from 'lodash/fp';


export default function ScrollableMarkdownContainer(props) {
Expand All @@ -21,21 +20,26 @@ export default function ScrollableMarkdownContainer(props) {
}, [markdown]);

const generateContent = (text) => {
return <ReactMarkdown components={{a: (props) => <a target={'_blank'} {...props}/>}}>
{DOMPurify.sanitize(text, null)}
</ReactMarkdown>;
return (
<ReactMarkdown components={{ a: (props) => <a target={'_blank'} {...props} /> }}>
{DOMPurify.sanitize(text, null)}
</ReactMarkdown>
);
};

const content = generateContent(text);

return div({
isRendered: !isEmpty(content),
style: {
maxWidth: '700px',
minWidth: '700px',
maxHeight: '200px',
overflow: 'auto',
marginBottom: '25px'
}
}, [content]);
}
return (
<div
style={{
maxWidth: '700px',
minWidth: '700px',
maxHeight: '200px',
overflow: 'auto',
marginBottom: '25px'
}}
>
{!isEmpty(content) && content}
</div>
);
}
Loading
Loading