Skip to content

Commit

Permalink
[upd] jasmine
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasklim committed Mar 29, 2020
1 parent 34ad3f3 commit 4f015b8
Show file tree
Hide file tree
Showing 70 changed files with 1,061 additions and 640 deletions.
9 changes: 5 additions & 4 deletions js/actions/UserActions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {ACTION_FLAG, ROLE} from "../constants/DefaultConstants";
import { axiosBackend} from "./index";
import {axiosBackend} from "./index";
import * as ActionConstants from "../constants/ActionConstants";
import {loadUsers} from "./UsersActions";
import {API_URL} from '../../config';
Expand Down Expand Up @@ -27,7 +27,7 @@ export function updateUser(user, currentUser, sendEmail = true) {
...user
}).then(() => {
dispatch(saveUserSuccess(user, ACTION_FLAG.UPDATE_ENTITY));
if (currentUser.role === ROLE.ADMIN){
if (currentUser.role === ROLE.ADMIN) {
dispatch(loadUsers());
}
}).catch((error) => {
Expand Down Expand Up @@ -73,7 +73,7 @@ export function deleteUser(user, institution = null) {
axiosBackend.delete(`${API_URL}/rest/users/${user.username}`, {
...user
}).then(() => {
if (institution){
if (institution) {
dispatch(loadInstitutionMembers(institution.key))
} else {
dispatch(loadUsers());
Expand Down Expand Up @@ -255,8 +255,9 @@ export function impersonate(username) {
dispatch({type: ActionConstants.IMPERSONATE_PENDING});
axiosBackend.post(`${API_URL}/rest/users/impersonate`, username, {headers: {"Content-Type": "text/plain"}}).then(() => {
dispatch({type: ActionConstants.IMPERSONATE_SUCCESS, username});

window.location.reload();
}).catch ((error) => {
}).catch((error) => {
dispatch({type: ActionConstants.IMPERSONATE_ERROR, error: error.response.data});
});
}
Expand Down
2 changes: 1 addition & 1 deletion js/actions/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios';
import {Routes} from "../utils/Routes";
import Routes from "../constants/RoutesConstants";
import {transitionTo} from "../utils/Routing";

// Axios instance for communicating with Backend
Expand Down
2 changes: 1 addition & 1 deletion js/components/Loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const LoaderMask = () => (
</div>
);

export const LoaderPanel = (props) => (
export const LoaderCard = (props) => (
<Card variant='primary'>
<Card.Header className="text-light bg-primary" as="h6">{props.header}</Card.Header>
<Card.Body><Loader/></Card.Body>
Expand Down
3 changes: 2 additions & 1 deletion js/components/MainView.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import React from "react";
import * as I18nStore from "../stores/I18nStore";
import {Container, DropdownItem, Nav, Navbar, NavDropdown, NavItem} from "react-bootstrap";
import {Routes, authRoutes, unauthRoutes} from "../utils/Routes";
import {authRoutes, unauthRoutes} from "../utils/Routes";
import Routes from "../constants/RoutesConstants";
import {injectIntl} from "react-intl";
import withI18n from "../i18n/withI18n";
import {connect} from "react-redux";
Expand Down
11 changes: 6 additions & 5 deletions js/components/dashboard/DashboardController.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from 'react';
import {connect} from "react-redux";
import {bindActionCreators} from "redux";
import {injectIntl} from "react-intl";
import {Routes} from '../../utils/Routes';
import Routes from '../../constants/RoutesConstants';
import {transitionTo, transitionToWithOpts} from '../../utils/Routing';
import withI18n from "../../i18n/withI18n";

Expand Down Expand Up @@ -43,7 +43,8 @@ class DashboardController extends React.Component {
};

_createRecord = () => {
{/*TODO bug on cancel it doesnt return to dashboard but to patient records */}
{/*TODO bug on cancel it doesnt return to dashboard but to patient records */
}
this.props.transitionToWithOpts(Routes.createRecord, {
handlers: {
onSuccess: Routes.records,
Expand All @@ -63,9 +64,9 @@ class DashboardController extends React.Component {
showStatistics: this._showStatistics
};
return (
<div>
<Dashboard currentUser={this.props.currentUser} handlers={handlers}/>
</div>
<div>
<Dashboard currentUser={this.props.currentUser} handlers={handlers}/>
</div>
);
}
}
Expand Down
6 changes: 3 additions & 3 deletions js/components/history/HistoryDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import withI18n from "../../i18n/withI18n";
import {Button, Card} from "react-bootstrap";
import {ACTION_STATUS, ALERT_TYPES, ROLE} from "../../constants/DefaultConstants";
import {transitionTo} from "../../utils/Routing";
import {Routes} from "../../utils/Routes";
import Routes from "../../constants/RoutesConstants";
import {loadActionByKey} from "../../actions/HistoryActions";
import {bindActionCreators} from "redux";
import {LoaderPanel} from "../Loader";
import {LoaderCard} from "../Loader";
import AlertMessage from "../AlertMessage";
import HorizontalInput from "../HorizontalInput";
import * as moment from "moment/moment";
Expand All @@ -34,7 +34,7 @@ class ActionHistory extends React.Component {
if (!currentUser || currentUser.role !== ROLE.ADMIN) {
return null;
} else if (!actionLoaded.status || actionLoaded.status === ACTION_STATUS.PENDING) {
return <LoaderPanel header={this.i18n('history.panel-title')}/>;
return <LoaderCard header={this.i18n('history.panel-title')}/>;
} else if (actionLoaded.status === ACTION_STATUS.ERROR) {
return <AlertMessage type={ALERT_TYPES.DANGER}
message={this.props.formatMessage('history.load-error', {error: actionLoaded.error.message})}/>;
Expand Down
6 changes: 3 additions & 3 deletions js/components/history/HistoryList.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import {Card} from "react-bootstrap";
import {loadActions} from "../../actions/HistoryActions";
import {bindActionCreators} from "redux";
import {ACTION_STATUS, ALERT_TYPES, ACTIONS_PER_PAGE} from "../../constants/DefaultConstants";
import {LoaderPanel, LoaderSmall} from "../Loader";
import {LoaderCard, LoaderSmall} from "../Loader";
import AlertMessage from "../AlertMessage";
import HistoryTable from "./HistoryTable";
import {Routes} from "../../utils/Routes";
import Routes from "../../constants/RoutesConstants";
import {transitionToWithOpts} from "../../utils/Routing";
import HistoryPagination from "./HistoryPagination";

Expand Down Expand Up @@ -69,7 +69,7 @@ class HistoryList extends React.Component {
render() {
const {actionsLoaded} = this.props;
if (!actionsLoaded.actions && (!actionsLoaded.status || actionsLoaded.status === ACTION_STATUS.PENDING)) {
return <LoaderPanel header={this._renderHeader()}/>;
return <LoaderCard header={this._renderHeader()}/>;
} else if (actionsLoaded.status === ACTION_STATUS.ERROR) {
return <AlertMessage type={ALERT_TYPES.DANGER}
message={this.props.formatMessage('history.loading-error', {error: actionsLoaded.error.message})}/>
Expand Down
4 changes: 2 additions & 2 deletions js/components/institution/Institution.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import PropTypes from "prop-types";
import {ACTION_STATUS, ALERT_TYPES, ROLE} from "../../constants/DefaultConstants";
import {formatDate} from "../../utils/Utils";
import AlertMessage from "../AlertMessage";
import {LoaderPanel, LoaderSmall} from "../Loader";
import {LoaderCard, LoaderSmall} from "../Loader";
import InstitutionValidator from "../../validation/InstitutionValidator";
import HelpIcon from "../HelpIcon";

Expand Down Expand Up @@ -50,7 +50,7 @@ class Institution extends React.Component {
return <AlertMessage type={ALERT_TYPES.DANGER}
message={this.props.formatMessage('institution.load-error', {error: institutionLoaded.error.message})}/>;
} else if (!institution) {
return <LoaderPanel header={<span>{this.i18n('institution.panel-title')}</span>}/>;
return <LoaderCard header={<span>{this.i18n('institution.panel-title')}</span>}/>;
}

return <Card variant='primary'>
Expand Down
2 changes: 1 addition & 1 deletion js/components/institution/InstitutionController.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from "react";
import Institution from "./Institution";
import {injectIntl} from "react-intl";
import withI18n from "../../i18n/withI18n";
import {Routes} from "../../utils/Routes";
import Routes from "../../constants/RoutesConstants";
import {transitionTo, transitionToWithOpts} from "../../utils/Routing";
import {connect} from "react-redux";
import {ACTION_FLAG, ACTION_STATUS, ROLE} from "../../constants/DefaultConstants";
Expand Down
12 changes: 6 additions & 6 deletions js/components/institution/InstitutionRow.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
import React from "react";
import {injectIntl} from "react-intl";
import withI18n from "../../i18n/withI18n";
import {Routes} from "../../utils/Routes";
import {Button} from "react-bootstrap";
import {LoaderSmall} from "../Loader";
import PropTypes from "prop-types";
import {Link} from 'react-router-dom';

let InstitutionRow = (props) => {
const institution = props.institution;
return <tr>
<td className='report-row'>
<Link to={Routes.institutions.path + '/' + institution.key}
title={props.i18n('institutions.open-tooltip')}>{institution.name}</Link>
<Button variant="link" size="sm"
onClick={() => props.onEdit(props.institution)}
title={props.i18n('institutions.open-tooltip')}>{institution.name}</Button>
</td>
<td className='report-row'>{institution.emailAddress}</td>
<td className='report-row actions'>
<Button variant='primary' size='sm' title={props.i18n('institutions.open-tooltip')}
onClick={() => props.onEdit(props.institution)}>{props.i18n('open')}</Button>
<Button variant='warning' size='sm' title={props.i18n('institutions.delete-tooltip')}
onClick={() => props.onDelete(props.institution)}>{props.i18n('delete')}
{props.deletionLoading && <LoaderSmall />}</Button>
{props.deletionLoading && <LoaderSmall/>}</Button>
</td>
</tr>;
};
Expand All @@ -29,7 +28,8 @@ InstitutionRow.propTypes = {
institution: PropTypes.object.isRequired,
onEdit: PropTypes.func.isRequired,
onDelete: PropTypes.func.isRequired,
deletionLoading: PropTypes.bool.isRequired
deletionLoading: PropTypes.bool.isRequired,
i18n: PropTypes.func.isRequired,
};

export default injectIntl(withI18n(InstitutionRow));
Expand Down
4 changes: 2 additions & 2 deletions js/components/institution/Institutions.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import withI18n from '../../i18n/withI18n';
import InstitutionTable from './InstitutionTable';
import {ACTION_STATUS, ALERT_TYPES} from "../../constants/DefaultConstants";
import AlertMessage from "../AlertMessage";
import {LoaderPanel, LoaderSmall} from "../Loader";
import {LoaderCard, LoaderSmall} from "../Loader";
import PropTypes from "prop-types";

class Institutions extends React.Component {
Expand All @@ -27,7 +27,7 @@ class Institutions extends React.Component {
render() {
const {showAlert, institutionDeleted, institutionsLoaded} = this.props;
if (!institutionsLoaded.institutions && (!institutionsLoaded.status || institutionsLoaded.status === ACTION_STATUS.PENDING)) {
return <LoaderPanel header={this.i18n('institutions.panel-title')}/>;
return <LoaderCard header={this.i18n('institutions.panel-title')}/>;
} else if (institutionsLoaded.status === ACTION_STATUS.ERROR) {
return <AlertMessage type={ALERT_TYPES.DANGER}
message={this.props.formatMessage('institutions.loading-error', {error: institutionsLoaded.error.message})}/>
Expand Down
4 changes: 2 additions & 2 deletions js/components/institution/InstitutionsController.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';

import React from "react";
import {Routes} from "../../utils/Routes";
import Routes from "../../constants/RoutesConstants";
import {transitionToWithOpts} from "../../utils/Routing";
import Institutions from "./Institutions";
import {injectIntl} from "react-intl";
Expand Down Expand Up @@ -76,6 +76,6 @@ function mapDispatchToProps(dispatch) {
return {
deleteInstitution: bindActionCreators(deleteInstitution, dispatch),
loadInstitutions: bindActionCreators(loadInstitutions, dispatch),
transitionToWithOpts:bindActionCreators(transitionToWithOpts, dispatch)
transitionToWithOpts: bindActionCreators(transitionToWithOpts, dispatch)
}
}
2 changes: 1 addition & 1 deletion js/components/login/Login.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {Alert, Button, Form, Card} from "react-bootstrap";
import HorizontalInput from "../HorizontalInput";
import withI18n from "../../i18n/withI18n";
import {injectIntl} from "react-intl";
import {Routes} from "../../utils/Routes";
import Routes from "../../constants/RoutesConstants";
import {connect} from "react-redux";
import {bindActionCreators} from "redux";
import {ALERT_TYPES} from "../../constants/DefaultConstants";
Expand Down
2 changes: 1 addition & 1 deletion js/components/login/Logout.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {connect} from "react-redux";
import {bindActionCreators} from "redux";
import {logout} from "../../actions/AuthActions";
import {transitionTo} from "../../utils/Routing";
import {Routes} from "../../utils/Routes";
import Routes from "../../constants/RoutesConstants";

class Logout extends React.Component {
componentDidMount() {
Expand Down
2 changes: 1 addition & 1 deletion js/components/login/PasswordReset.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import HorizontalInput from "../HorizontalInput";
import withI18n from "../../i18n/withI18n";
import {injectIntl} from "react-intl";
import {transitionTo} from "../../utils/Routing";
import {Routes} from "../../utils/Routes";
import Routes from "../../constants/RoutesConstants";
import {connect} from "react-redux";
import {bindActionCreators} from "redux";
import {passwordReset} from "../../actions/AuthActions";
Expand Down
2 changes: 1 addition & 1 deletion js/components/login/PasswordToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {LoaderSmall} from "../Loader";
import {bindActionCreators} from "redux";
import {changePasswordToken, validateToken} from "../../actions/AuthActions";
import {transitionTo} from "../../utils/Routing";
import {Routes} from "../../utils/Routes";
import Routes from "../../constants/RoutesConstants";
import AlertMessage from "../AlertMessage";

class PasswordReset extends React.Component {
Expand Down
2 changes: 1 addition & 1 deletion js/components/misc/hoc/RequireAuth.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React, {useEffect} from 'react';
import {connect} from 'react-redux';
import PropTypes from 'prop-types';
import * as Routing from "../../../utils/Routing";
import {Routes} from "../../../utils/Routes";
import Routes from "../../../constants/RoutesConstants";

export default function (ComposedComponent) {
const Authentication = ({authenticated, history, location, match}) => {
Expand Down
4 changes: 2 additions & 2 deletions js/components/record/Record.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import RequiredAttributes from "./RequiredAttributes";
// import {FormUtils} from "s-forms";
import {ACTION_STATUS, ALERT_TYPES} from "../../constants/DefaultConstants";
import AlertMessage from "../AlertMessage";
import {LoaderPanel, LoaderSmall} from "../Loader";
import {LoaderCard, LoaderSmall} from "../Loader";
import PropTypes from "prop-types";

class Record extends React.Component {
Expand Down Expand Up @@ -50,7 +50,7 @@ class Record extends React.Component {
}

if (!record) {
return <LoaderPanel header={this._renderHeader()} variant='primary'/>;
return <LoaderCard header={this._renderHeader()} variant='primary'/>;
}

return <Card variant='primary'>
Expand Down
2 changes: 1 addition & 1 deletion js/components/record/RecordController.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';
import {injectIntl} from "react-intl";
import withI18n from '../../i18n/withI18n';
import Record from './Record';
import {Routes} from '../../utils/Routes';
import Routes from "../../constants/RoutesConstants";
import {transitionTo, transitionToWithOpts} from '../../utils/Routing';
import {ACTION_FLAG, ACTION_STATUS} from "../../constants/DefaultConstants";
import {loadFormgen, unloadSavedRecord} from "../../actions/RecordActions";
Expand Down
17 changes: 12 additions & 5 deletions js/components/record/RecordRow.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
import React from "react";
import {formatDate} from "../../utils/Utils";
import {Routes} from "../../utils/Routes";
import HelpIcon from "../HelpIcon";
import {Button} from "react-bootstrap";
import {injectIntl} from "react-intl";
import withI18n from "../../i18n/withI18n";
import RecordValidator from "../../validation/RecordValidator";
import {LoaderSmall} from "../Loader";
import PropTypes from "prop-types";
import {Link} from 'react-router-dom';

let RecordRow = (props) => {
const record = props.record,
isComplete = RecordValidator.isComplete(record),
completionTooltip = props.i18n(isComplete ? 'records.completion-status-tooltip.complete' : 'records.completion-status-tooltip.incomplete'),
deleteButton = props.disableDelete ? null :
<Button variant='warning' size='sm' title={props.i18n('records.delete-tooltip')}
onClick={() => props.onDelete(record)}>{props.i18n('delete')}{props.deletionLoading && <LoaderSmall />}</Button>;
onClick={() => props.onDelete(record)}>{props.i18n('delete')}{props.deletionLoading &&
<LoaderSmall/>}</Button>;

return <tr>
<td className='report-row'><Link to={Routes.records.path + '/' + record.key}>{record.key}</Link></td>
<td className='report-row'><Link to={Routes.records.path + '/' + record.key}>{record.localName}</Link></td>
<td className='report-row'>
<Button variant="link" size="sm"

This comment has been minimized.

Copy link
@blcham

blcham Mar 21, 2024

I think, this change broke it.

onClick={() => props.onEdit(record)}>{record.key}</Button>
</td>
<td className='report-row'>
<Button variant="link" size="sm"
onClick={() => props.onEdit(record)}>{record.localName}</Button>
</td>
<td className='report-row content-center'>
{formatDate(new Date(record.lastModified ? record.lastModified : record.dateCreated))}
</td>
Expand All @@ -35,6 +41,7 @@ let RecordRow = (props) => {
};

RecordRow.propTypes = {
i18n: PropTypes.func.isRequired,
record: PropTypes.object.isRequired,
onEdit: PropTypes.func.isRequired,
onDelete: PropTypes.func.isRequired,
Expand Down
6 changes: 3 additions & 3 deletions js/components/record/RecordsController.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import React from 'react';

import Records from "./Records";
import {Routes} from "../../utils/Routes";
import { transitionToWithOpts} from "../../utils/Routing";
import Routes from "../../constants/RoutesConstants";
import {transitionToWithOpts} from "../../utils/Routing";
import {loadRecords} from "../../actions/RecordsActions";
import {injectIntl} from "react-intl";
import withI18n from "../../i18n/withI18n";
Expand Down Expand Up @@ -77,6 +77,6 @@ function mapDispatchToProps(dispatch) {
return {
deleteRecord: bindActionCreators(deleteRecord, dispatch),
loadRecords: bindActionCreators(loadRecords, dispatch),
transitionToWithOpts:bindActionCreators(transitionToWithOpts, dispatch)
transitionToWithOpts: bindActionCreators(transitionToWithOpts, dispatch)
}
}
4 changes: 2 additions & 2 deletions js/components/statistics/Statistics.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {injectIntl} from "react-intl";
import withI18n from "../../i18n/withI18n";
import {Card, Table} from "react-bootstrap";
import {ACTION_STATUS, ALERT_TYPES} from "../../constants/DefaultConstants";
import {LoaderPanel, LoaderSmall} from "../Loader";
import {LoaderCard, LoaderSmall} from "../Loader";
import AlertMessage from "../AlertMessage";
import {bindActionCreators} from "redux";
import {loadStatistics} from "../../actions/StatisticsActions";
Expand All @@ -24,7 +24,7 @@ class Statistics extends React.Component {
render() {
const {statistics, status, error} = this.props;
if (!statistics && (!status || status === ACTION_STATUS.PENDING)) {
return <LoaderPanel header={this._renderHeader()}/>;
return <LoaderCard header={this._renderHeader()}/>;
} else if (status === ACTION_STATUS.ERROR) {
return <AlertMessage type={ALERT_TYPES.DANGER}
message={this.props.formatMessage('history.loading-error', {error: error.message})}/>
Expand Down
Loading

0 comments on commit 4f015b8

Please sign in to comment.