-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4141 from beyondessential/release-2022-36
Release 2022-36
- Loading branch information
Showing
131 changed files
with
2,792 additions
and
391 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* Tupaia MediTrak | ||
* Copyright (c) 2018 Beyond Essential Systems Pty Ltd | ||
*/ | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { connect } from 'react-redux'; | ||
import DescriptionIcon from '@material-ui/icons/Description'; | ||
import { IconButton } from '../widgets'; | ||
import { openLogsModal } from './actions'; | ||
|
||
export const LogsButtonComponent = props => { | ||
const { openModal } = props; | ||
return ( | ||
<IconButton onClick={openModal}> | ||
<DescriptionIcon /> | ||
</IconButton> | ||
); | ||
}; | ||
|
||
LogsButtonComponent.propTypes = { | ||
openModal: PropTypes.func.isRequired, | ||
}; | ||
|
||
const mapDispatchToProps = (dispatch, { actionConfig, value: recordId, row }) => ({ | ||
openModal: () => { | ||
dispatch(openLogsModal(actionConfig, recordId, row)); | ||
}, | ||
}); | ||
|
||
const mergeProps = ({ ...stateProps }, { ...dispatchProps }, { ...ownProps }) => { | ||
return { | ||
...ownProps, | ||
...stateProps, | ||
...dispatchProps, | ||
}; | ||
}; | ||
|
||
export const LogsButton = connect(null, mapDispatchToProps, mergeProps)(LogsButtonComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/** | ||
* Tupaia MediTrak | ||
* Copyright (c) 2018 Beyond Essential Systems Pty Ltd | ||
*/ | ||
|
||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { connect } from 'react-redux'; | ||
import { Button, Dialog, DialogFooter, DialogHeader } from '@tupaia/ui-components'; | ||
import { changeLogsTablePage, closeLogsModal } from './actions'; | ||
import { ModalContentProvider } from '../widgets'; | ||
import { LogsTable } from './LogsTable'; | ||
|
||
export const LogsModalComponent = ({ | ||
errorMessage, | ||
logs, | ||
logsCount, | ||
page, | ||
logsPerPage, | ||
onChangeLogsTablePage, | ||
isLoading, | ||
isOpen, | ||
onDismiss, | ||
title, | ||
}) => { | ||
return ( | ||
<Dialog onClose={onDismiss} open={isOpen} disableBackdropClick maxWidth="xl"> | ||
<DialogHeader onClose={onDismiss} title={title} /> | ||
<ModalContentProvider errorMessage={errorMessage} isLoading={isLoading}> | ||
<LogsTable | ||
logs={logs} | ||
logsCount={logsCount} | ||
page={page} | ||
logsPerPage={logsPerPage} | ||
onChangePage={onChangeLogsTablePage} | ||
/> | ||
</ModalContentProvider> | ||
<DialogFooter> | ||
<Button variant="outlined" onClick={onDismiss} disabled={isLoading}> | ||
{errorMessage ? 'Dismiss' : 'Cancel'} | ||
</Button> | ||
</DialogFooter> | ||
</Dialog> | ||
); | ||
}; | ||
|
||
LogsModalComponent.propTypes = { | ||
errorMessage: PropTypes.string, | ||
isLoading: PropTypes.object.isRequired, | ||
isOpen: PropTypes.bool.isRequired, | ||
onDismiss: PropTypes.func.isRequired, | ||
title: PropTypes.string, | ||
logs: PropTypes.arrayOf(PropTypes.string).isRequired, | ||
logsCount: PropTypes.number.isRequired, | ||
page: PropTypes.number.isRequired, | ||
logsPerPage: PropTypes.number.isRequired, | ||
onChangeLogsTablePage: PropTypes.func.isRequired, | ||
}; | ||
|
||
LogsModalComponent.defaultProps = { | ||
errorMessage: null, | ||
title: 'Logs', | ||
}; | ||
|
||
const mapStateToProps = state => ({ | ||
...state.logs, | ||
}); | ||
|
||
const mapDispatchToProps = dispatch => ({ | ||
onDismiss: () => dispatch(closeLogsModal()), | ||
onChangeLogsTablePage: page => dispatch(changeLogsTablePage(page)), | ||
dispatch, | ||
}); | ||
|
||
const mergeProps = ({ ...stateProps }, { dispatch, ...dispatchProps }, { ...ownProps }) => { | ||
return { | ||
...ownProps, | ||
...stateProps, | ||
...dispatchProps, | ||
}; | ||
}; | ||
|
||
export const LogsModal = connect( | ||
mapStateToProps, | ||
mapDispatchToProps, | ||
mergeProps, | ||
)(LogsModalComponent); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* Tupaia | ||
* Copyright (c) 2017 - 2022 Beyond Essential Systems Pty Ltd | ||
*/ | ||
|
||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import PropTypes from 'prop-types'; | ||
import { Table, useTableSorting } from '@tupaia/ui-components'; | ||
|
||
const StyledTable = styled(Table)` | ||
.MuiTableCell-root { | ||
height: 30px; | ||
} | ||
`; | ||
|
||
export const LogsTable = ({ logs, logsCount, page, logsPerPage, onChangePage }) => { | ||
const { sortedData, order, orderBy, sortColumn } = useTableSorting(logs); | ||
return ( | ||
<StyledTable | ||
count={logsCount} | ||
page={page} | ||
onChangePage={onChangePage} | ||
rowsPerPage={logsPerPage} | ||
rowsPerPageOptions={[]} | ||
data={sortedData} | ||
order={order} | ||
orderBy={orderBy} | ||
onChangeOrderBy={sortColumn} | ||
columns={[ | ||
{ key: 'timestamp', title: 'time', sortable: true, width: '250px', align: 'left' }, | ||
{ key: 'message', title: 'message', sortable: false, align: 'left' }, | ||
]} | ||
/> | ||
); | ||
}; | ||
|
||
LogsTable.propTypes = { | ||
logs: PropTypes.arrayOf( | ||
PropTypes.shape({ timestamp: PropTypes.string, message: PropTypes.string }), | ||
).isRequired, | ||
logsCount: PropTypes.number.isRequired, | ||
page: PropTypes.number.isRequired, | ||
logsPerPage: PropTypes.number.isRequired, | ||
onChangePage: PropTypes.func.isRequired, | ||
}; |
Oops, something went wrong.