Skip to content

Commit

Permalink
Merge branch 'master' of github.com:folio-org/ui-users into feat/numb…
Browse files Browse the repository at this point in the history
…er_generator
  • Loading branch information
EthanFreestone committed Sep 29, 2023
2 parents f5835c7 + 06f6ea7 commit aefd058
Show file tree
Hide file tree
Showing 74 changed files with 655 additions and 282 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@
* Add dropdown to specify user type: Patron or Staff. Refs UIU-2936.
* *BREAKING* bump `react-intl` to `v6.4.4`. Refs UIU-2946.
* Generate "Create request" url for users without barcode. Refs UIU-2869.
* Add auto focus to textarea on staff and patron info modal. Fixes UIU-2932.
* ECS - Filter users by "User Type". Refs UIU-2943.
* Users App: Consume {{FormattedDate}} and {{FormattedTime}} via stripes-component. Refs UIU-1860.
* ECS - Prevent editing of specific shadow user data. Refs UIU-2951.
* Relabel "Users: Can create new user" to "Users: Can create and edit users". Refs UIU-2955.

## [9.0.0](https://github.com/folio-org/ui-users/tree/v9.0.0) (2023-02-20)
[Full Changelog](https://github.com/folio-org/ui-users/compare/v8.1.0...v9.0.0)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
},
{
"permissionName": "ui-users.create",
"displayName": "Users: Can create new user",
"displayName": "Users: Can create and edit users",
"description": "Some subperms can be deleted later when bl does updates and ModulePermissions can be used",
"subPermissions": [
"ui-users.edit",
Expand Down
4 changes: 2 additions & 2 deletions src/components/Accounts/ViewFeesFines/ViewFeesFines.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import {
FormattedDate,
FormattedMessage,
FormattedTime,
} from 'react-intl';

import {
Expand All @@ -17,6 +15,8 @@ import {
Row,
Col,
Icon,
FormattedDate,
FormattedTime,
} from '@folio/stripes/components';

import { itemStatuses } from '../../../constants';
Expand Down
3 changes: 3 additions & 0 deletions src/components/Accounts/ViewFeesFines/ViewFeesFines.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jest.mock('../../util', () => ({
jest.mock('react-intl', () => ({
...jest.requireActual('react-intl'),
FormattedMessage: jest.fn(({ id }) => id),
}));
jest.mock('@folio/stripes/components', () => ({
...jest.requireActual('@folio/stripes/components'),
FormattedTime: jest.fn(({ value }) => value),
FormattedDate: jest.fn(({ value }) => value),
}));
Expand Down
2 changes: 1 addition & 1 deletion src/components/BulkOverrideDialog/BulkOverrideLoansList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { get } from 'lodash';
import {
FormattedTime,
FormattedMessage,
injectIntl,
} from 'react-intl';

import {
Icon,
MultiColumnList,
FormattedTime,
} from '@folio/stripes/components';
import { effectiveCallNumber } from '@folio/stripes/util';

Expand Down
2 changes: 1 addition & 1 deletion src/components/BulkRenewalDialog/BulkRenewedLoansList.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import get from 'lodash/get';

import {
FormattedMessage,
FormattedTime,
} from 'react-intl';

import {
Icon,
MultiColumnList,
FormattedTime,
} from '@folio/stripes/components';
import { effectiveCallNumber } from '@folio/stripes/util';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const EditContactInfo = ({
addressTypes,
preferredContactTypeId,
intl,
disabled,
}) => {
const contactTypeOptions = (contactTypes || []).map(g => {
return (
Expand Down Expand Up @@ -64,6 +65,7 @@ const EditContactInfo = ({
component={TextField}
required
fullWidth
disabled={disabled}
/>
</Col>
<Col xs={12} md={3}>
Expand All @@ -73,6 +75,7 @@ const EditContactInfo = ({
id="adduser_phone"
component={TextField}
fullWidth
disabled={disabled}
/>
</Col>
<Col xs={12} md={3}>
Expand All @@ -82,6 +85,7 @@ const EditContactInfo = ({
id="adduser_mobilePhone"
component={TextField}
fullWidth
disabled={disabled}
/>
</Col>
<Col xs={12} md={3}>
Expand All @@ -93,6 +97,7 @@ const EditContactInfo = ({
fullWidth
aria-required="true"
required
disabled={disabled}
defaultValue={selectedContactTypeId}
>
<FormattedMessage id="ui-users.contact.selectContactType">
Expand All @@ -108,6 +113,7 @@ const EditContactInfo = ({
fieldComponents={addressFields}
canDelete
formType="final-form"
disabled={disabled}
/>
</Accordion>
);
Expand All @@ -120,6 +126,7 @@ EditContactInfo.propTypes = {
addressTypes: PropTypes.arrayOf(PropTypes.object),
preferredContactTypeId: PropTypes.string,
intl: PropTypes.object.isRequired,
disabled: PropTypes.bool,
};

export default injectIntl(EditContactInfo);
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { screen } from '@folio/jest-config-stripes/testing-library/react';
import userEvent from '@folio/jest-config-stripes/testing-library/user-event';
import { Form } from 'react-final-form';

import '__mock__/stripesComponents.mock';
import { screen } from '@folio/jest-config-stripes/testing-library/react';
import userEvent from '@folio/jest-config-stripes/testing-library/user-event';

import renderWithRouter from 'helpers/renderWithRouter';
import EditContactInfo from './EditContactInfo';

jest.unmock('@folio/stripes/components');

const onSubmit = jest.fn();

const arrayMutators = {
Expand All @@ -28,7 +29,8 @@ const renderEditContactInfo = (props) => {
<EditContactInfo {...props} />
</>
);
renderWithRouter(

return renderWithRouter(
<Form
id="form-user"
mutators={{
Expand Down Expand Up @@ -71,9 +73,21 @@ describe('Render Edit contact Information component', () => {
renderEditContactInfo(props);
expect(screen.getByText('AddressEditList')).toBeInTheDocument();
});

it('Must be rendered', async () => {
renderEditContactInfo(props);
await userEvent.type(document.querySelector('[id="adduser_email"]'), '[email protected]');
expect(document.querySelector('[id="adduser_email"]').value).toBe('[email protected]');

const emailInput = screen.getByRole('textbox', { name: /email/i });

await userEvent.type(emailInput, '[email protected]');
expect(emailInput.value).toBe('[email protected]');
});

it('should render with disabled fields', () => {
renderEditContactInfo({ ...props, disabled: true });

expect(screen.getByRole('textbox', { name: /email/i })).toBeDisabled();
expect(screen.getByRole('textbox', { name: /mobilePhone/i })).toBeDisabled();
expect(screen.getByLabelText('ui-users.contact.phone')).toBeDisabled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,9 @@
&:focus {
outline: none;
}

&:disabled {
color: var(--checkable-disabled-fill);
cursor: not-allowed;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class CreateResetPasswordControl extends React.Component {
POST: PropTypes.func.isRequired,
}).isRequired,
}).isRequired,
disabled: PropTypes.bool,
};

static manifest = Object.freeze({
Expand Down Expand Up @@ -111,6 +112,8 @@ class CreateResetPasswordControl extends React.Component {
};

render() {
const { disabled } = this.props;

return (
<Col
xs={12}
Expand All @@ -123,6 +126,7 @@ class CreateResetPasswordControl extends React.Component {
type="button"
className={css.resetPasswordButton}
onClick={this.handleLinkClick}
disabled={disabled}
>
<FormattedMessage id="ui-users.extended.sendResetPassword" />
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jest.unmock('@folio/stripes/smart-components');

const renderCreateResetPasswordControl = (props) => renderWithRouter(<CreateResetPasswordControl {...props} />);

const propData = (postMock) => {
const propData = (postMock, disabled = false) => {
return {
email: '[email protected]',
name: 'sample',
Expand All @@ -22,6 +22,7 @@ const propData = (postMock) => {
POST: postMock,
}
},
disabled,
};
};

Expand All @@ -42,6 +43,13 @@ describe('CreateResetPasswordControl component', () => {
await waitFor(() => userEvent.click(screen.getByText('ui-users.extended.sendResetPassword')));
await waitFor(() => expect(screen.getByText('ui-users.extended.copyLink')).toBeInTheDocument());
});
it('should link be disabled', () => {
const mockFunc = jest.fn(() => new Promise((resolve, _) => {
resolve({ ok: true, link: 'bl-users/password-reset/link' });
}));
renderCreateResetPasswordControl(propData(mockFunc, true));
expect(screen.getByText('ui-users.extended.sendResetPassword')).toBeDisabled();
});
/* Can be uncommented after the createResetpasswordControl modal logic is reworked. Should add an assertion at the end after the results */
// it('If it redirects after POST fails', async () => {
// const mockFunc = jest.fn(() => new Promise((_, reject) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
FormattedMessage,
useIntl,
} from 'react-intl';
import PropTypes from 'prop-types';
import { Field } from 'react-final-form';
import { FieldArray } from 'react-final-form-arrays';

Expand All @@ -15,7 +16,7 @@ import { departmentsShape } from '../../../../shapes';

import css from './DepartmentsNameEdit.css';

const DepartmentsNameEdit = ({ departments }) => {
const DepartmentsNameEdit = ({ departments, disabled }) => {
const { formatMessage } = useIntl();
const defaultDepartment = {
label: formatMessage({ id: 'ui-users.extended.department.default' }),
Expand All @@ -35,10 +36,13 @@ const DepartmentsNameEdit = ({ departments }) => {
component={RepeatableField}
name="departments"
onAdd={fields => fields.push()}
canRemove={!disabled}
canAdd={!disabled}
renderField={field => (
<Field
component={Select}
name={field}
disabled={disabled}
dataOptions={[defaultDepartment, ...formattedDepartments]}
/>
)}
Expand All @@ -47,6 +51,9 @@ const DepartmentsNameEdit = ({ departments }) => {
);
};

DepartmentsNameEdit.propTypes = { departments: departmentsShape };
DepartmentsNameEdit.propTypes = {
departments: departmentsShape,
disabled: PropTypes.bool
};

export default DepartmentsNameEdit;
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
import userEvent from '@folio/jest-config-stripes/testing-library/user-event';
import renderWithRouter from 'helpers/renderWithRouter';
import DepartmentsNameEdit from './DepartmentsNameEdit';
import '__mock__/stripesSmartComponent.mock';

jest.unmock('@folio/stripes/components');
jest.unmock('@folio/stripes/smart-components');

const onSubmit = jest.fn();

Expand Down Expand Up @@ -63,3 +63,10 @@ describe('Given DepartmentsNameEdit', () => {
expect(screen.queryByPlaceholderText(/ui-users.extended.department.default/i));
});
});

describe('Given DepartmentsNameEdit with disabled: true', () => {
it('should add button to be disabled', async () => {
renderDepartmentsNameEdit({ ...props, disabled: true });
expect(screen.getByRole('button')).toBeDisabled();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class EditExtendedInfo extends Component {
change: PropTypes.func.isRequired,
values: PropTypes.object,
uniquenessValidator: PropTypes.object,
disabled: PropTypes.bool,
};

buildAccordionHeader = () => {
Expand Down Expand Up @@ -83,6 +84,7 @@ class EditExtendedInfo extends Component {
departments,
change,
uniquenessValidator,
disabled,
} = this.props;

const accordionHeader = this.buildAccordionHeader();
Expand Down Expand Up @@ -110,6 +112,7 @@ class EditExtendedInfo extends Component {
name="enrollmentDate"
id="adduser_enrollmentdate"
validate={validateMinDate('ui-users.errors.extended.dateEnrolled')}
disabled={disabled}
/>
</Col>
<Col
Expand All @@ -122,6 +125,7 @@ class EditExtendedInfo extends Component {
id="adduser_externalsystemid"
component={TextField}
fullWidth
disabled={disabled}
/>
</Col>
<Col
Expand All @@ -136,6 +140,7 @@ class EditExtendedInfo extends Component {
id="adduser_dateofbirth"
timeZone="UTC"
backendDateStandard="YYYY-MM-DD"
disabled={disabled}
validate={validateMinDate('ui-users.errors.personal.dateOfBirth')}
/>
</Col>
Expand All @@ -161,6 +166,7 @@ class EditExtendedInfo extends Component {
defaultDeliveryAddressTypeId={defaultDeliveryAddressTypeId}
deliveryAvailable={deliveryAvailable}
setFieldValue={change}
disabled={disabled}
/>
</Row>
</Col>
Expand All @@ -170,7 +176,7 @@ class EditExtendedInfo extends Component {
xs={12}
md={3}
>
<DepartmentsNameEdit departments={departments} />
<DepartmentsNameEdit departments={departments} disabled={disabled} />
</Col>
)
: null
Expand All @@ -188,6 +194,7 @@ class EditExtendedInfo extends Component {
component={TextField}
fullWidth
validStylesEnabled
disabled={disabled}
validate={asyncValidateField('username', username, uniquenessValidator)}
/>
</Col>
Expand All @@ -199,6 +206,7 @@ class EditExtendedInfo extends Component {
email={userEmail}
name={userFirstName}
username={username}
disabled={disabled}
/>
)
}
Expand Down
Loading

0 comments on commit aefd058

Please sign in to comment.