Skip to content

Commit

Permalink
Merge branch 'master' of github.com:folio-org/ui-organizations into f…
Browse files Browse the repository at this point in the history
…eat/number_generator
  • Loading branch information
EthanFreestone committed Dec 8, 2023
2 parents 5b3bde5 + 2580943 commit be51dbf
Show file tree
Hide file tree
Showing 127 changed files with 5,323 additions and 1,259 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
## 5.1.0 (IN PROGRESS)

* Designate Organization as donor. Refs UIORGS-383.
* Settings for banking information. Refs UIORGS-391.
* Implement organization's banking information form. Refs UIORGS-390.
* Implement organization's banking information details view. Refs UIORGS-389.
* Modify summary display in organization view mode. Refs UIORGS-398.
* Protection of viewing and changes of banking information by permissions. Refs UIORGS-388.
* Search organization on bank account number. Refs UIORGS-392.
* Enable "Hourly" and "Monthly" EDI export scheduling frequency options. Refs UIORGS-415.
* Create Privileged donor information accordion in organization record. Refs UIORGS-397.

## [5.0.0](https://github.com/folio-org/ui-organizations/tree/v5.0.0) (2023-10-12)
[Full Changelog](https://github.com/folio-org/ui-organizations/compare/v4.0.0...v5.0.0)
Expand Down
20 changes: 10 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,19 @@ class Organizations extends Component {
<Switch>
<Route
component={ContactsContainer}
path="/organizations/contacts/"
path={[
'/organizations/contacts/',
'/organizations/privileged-contacts/',
'/organizations/:orgId/contacts/',
'/organizations/:orgId/privileged-contacts/',
]}
/>
<Route
component={InterfaceContainer}
path="/organizations/interface/"
/>
<Route
component={ContactsContainer}
path="/organizations/:orgId/contacts/"
/>
<Route
component={InterfaceContainer}
path="/organizations/:orgId/interface/"
path={[
'/organizations/interface/',
'/organizations/:orgId/interface/',
]}
/>
<Route
path="/organizations/:orgId/integration/"
Expand Down
57 changes: 55 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"home": "/organizations",
"okapiInterfaces": {
"acquisition-methods": "1.0",
"banking-information": "1.0",
"data-export-spring": "1.0",
"configuration": "2.0",
"organizations.organizations": "1.0",
Expand All @@ -29,6 +30,8 @@
"organizations-storage.emails": "1.1",
"organizations-storage.interfaces": "2.1",
"organizations-storage.phone-numbers": "2.0",
"organizations-storage.privileged-contacts": "1.0",
"organizations-storage.settings": "1.0",
"organizations-storage.urls": "1.1",
"tags": "1.0",
"users": "15.1 16.0"
Expand Down Expand Up @@ -94,6 +97,9 @@
"organizations-storage.interfaces.collection.get",
"organizations-storage.phone-numbers.collection.get",
"organizations-storage.phone-numbers.item.get",
"organizations-storage.privileged-contacts.collection.get",
"organizations-storage.privileged-contacts.item.get",
"organizations-storage.settings.collection.get",
"organizations-storage.urls.collection.get",
"organizations-storage.urls.item.get",
"ui-organizations.third-party-services"
Expand All @@ -115,6 +121,9 @@
"organizations-storage.contacts.item.post",
"organizations-storage.contacts.item.put",
"organizations-storage.contacts.item.delete",
"organizations-storage.privileged-contacts.item.post",
"organizations-storage.privileged-contacts.item.put",
"organizations-storage.privileged-contacts.item.delete",
"organizations-storage.interfaces.item.post",
"organizations-storage.interfaces.item.put",
"organizations-storage.interfaces.item.delete",
Expand Down Expand Up @@ -147,6 +156,42 @@
"ui-organizations.edit"
]
},
{
"permissionName": "ui-organizations.banking-information.view",
"displayName": "Organizations: View banking information",
"visible": true,
"subPermissions": [
"organizations.banking-information.collection.get",
"organizations.banking-information.item.get"
]
},
{
"permissionName": "ui-organizations.banking-information.edit",
"displayName": "Organizations: View and edit banking information",
"visible": true,
"subPermissions": [
"ui-organizations.banking-information.view",
"organizations.banking-information.item.put"
]
},
{
"permissionName": "ui-organizations.banking-information.create",
"displayName": "Organizations: View, edit and create banking information",
"visible": true,
"subPermissions": [
"ui-organizations.banking-information.edit",
"organizations.banking-information.item.post"
]
},
{
"permissionName": "ui-organizations.banking-information.delete",
"displayName": "Organizations: View, edit, create and delete banking information",
"visible": true,
"subPermissions": [
"ui-organizations.banking-information.create",
"organizations.banking-information.item.delete"
]
},
{
"permissionName": "ui-organizations.creds.view",
"displayName": "Organizations: Interface usernames and passwords: view",
Expand Down Expand Up @@ -207,7 +252,11 @@
"settings.organizations.enabled",
"organizations-storage.organization-types.collection.get",
"organizations-storage.organization-types.item.get",
"organizations-storage.categories.collection.get"
"organizations-storage.categories.collection.get",
"organizations-storage.settings.collection.get",
"organizations-storage.settings.item.get",
"organizations-storage.banking-account-types.collection.get",
"organizations-storage.banking-account-types.item.get"
]
},
{
Expand All @@ -221,7 +270,11 @@
"organizations-storage.organization-types.item.delete",
"organizations-storage.categories.item.delete",
"organizations-storage.categories.item.post",
"organizations-storage.categories.item.put"
"organizations-storage.categories.item.put",
"organizations-storage.settings.item.put",
"organizations-storage.banking-account-types.item.post",
"organizations-storage.banking-account-types.item.put",
"organizations-storage.banking-account-types.item.delete"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ import {
WEEKDAYS,
} from '../../constants';

const ALLOWED_SCHEDULE_PERIODS = [SCHEDULE_PERIODS.days, SCHEDULE_PERIODS.weeks, SCHEDULE_PERIODS.none];
const ALLOWED_SCHEDULE_PERIODS = [
SCHEDULE_PERIODS.none,
SCHEDULE_PERIODS.hours,
SCHEDULE_PERIODS.days,
SCHEDULE_PERIODS.weeks,
SCHEDULE_PERIODS.months,
];

const normalizeNumber = value => {
if (!value && value !== 0) return value;
Expand Down
39 changes: 28 additions & 11 deletions src/Organizations/OrganizationCreate/OrganizationCreate.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
import React, { useCallback } from 'react';
import PropTypes from 'prop-types';
import { withRouter } from 'react-router-dom';
import { useCallback, useMemo } from 'react';
import { useIntl } from 'react-intl';
import { withRouter } from 'react-router-dom';

import {
stripesConnect,
} from '@folio/stripes/core';
import { stripesConnect } from '@folio/stripes/core';
import { useShowCallout } from '@folio/stripes-acq-components';

import { VIEW_ORG_DETAILS } from '../../common/constants';
import { organizationsResource } from '../../common/resources';
import {
OrganizationForm,
} from '../OrganizationForm';
import { BANKING_INFORMATION_FIELD_NAME } from '../constants';
import { handleSaveErrorResponse } from '../handleSaveErrorResponse';
import { OrganizationForm } from '../OrganizationForm';
import { useBankingInformationManager } from '../useBankingInformationManager';

const INITIAL_VALUES = {
interfaces: [],
Expand All @@ -32,6 +30,8 @@ const INITIAL_VALUES = {
};

export const OrganizationCreate = ({ history, location, mutator }) => {
const { manageBankingInformation } = useBankingInformationManager();

const cancelForm = useCallback(
(id) => {
history.push({
Expand All @@ -45,9 +45,21 @@ export const OrganizationCreate = ({ history, location, mutator }) => {

const showCallout = useShowCallout();
const intl = useIntl();

const createOrganization = useCallback(
(data) => {
(values, { getFieldState }) => {
const { [BANKING_INFORMATION_FIELD_NAME]: bankingInformation, ...data } = values;

return mutator.createOrganizationOrg.POST(data)
.then(async organization => {
await manageBankingInformation({
initBankingInformation: getFieldState(BANKING_INFORMATION_FIELD_NAME)?.initial,
bankingInformation,
organization,
});

return organization;
})
.then(organization => {
setTimeout(() => cancelForm(organization.id));
showCallout({
Expand All @@ -60,12 +72,17 @@ export const OrganizationCreate = ({ history, location, mutator }) => {
});
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[cancelForm, intl, showCallout],
[cancelForm, intl, manageBankingInformation, showCallout],
);

const initialValues = useMemo(() => ({
[BANKING_INFORMATION_FIELD_NAME]: [],
...INITIAL_VALUES,
}), []);

return (
<OrganizationForm
initialValues={INITIAL_VALUES}
initialValues={initialValues}
onSubmit={createOrganization}
cancelForm={cancelForm}
/>
Expand Down
42 changes: 38 additions & 4 deletions src/Organizations/OrganizationCreate/OrganizationCreate.test.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import React from 'react';
import { QueryClient, QueryClientProvider } from 'react-query';
import { render, screen } from '@folio/jest-config-stripes/testing-library/react';

import { OrganizationForm } from '../OrganizationForm';

import { useBankingInformationManager } from '../useBankingInformationManager';
import { OrganizationCreate } from './OrganizationCreate';

jest.mock('../OrganizationForm', () => ({
OrganizationForm: jest.fn().mockReturnValue('OrganizationForm'),
}));
jest.mock('../useBankingInformationManager', () => ({
useBankingInformationManager: jest.fn(),
}));

const mutatorMock = {
createOrganizationOrg: {
Expand All @@ -17,21 +20,40 @@ const mutatorMock = {
const historyMock = {
push: jest.fn(),
};

const getFieldState = jest.fn();
const manageBankingInformation = jest.fn();

const queryClient = new QueryClient();

const wrapper = ({ children }) => (
<QueryClientProvider client={queryClient}>
{children}
</QueryClientProvider>
);

const renderOrganizationCreate = (props) => render(
<OrganizationCreate
location={{}}
history={historyMock}
mutator={mutatorMock}
{...props}
/>,
{ wrapper },
);

describe('OrganizationCreate', () => {
beforeEach(() => {
OrganizationForm.mockClear();

getFieldState.mockClear();
historyMock.push.mockClear();
manageBankingInformation.mockClear();
mutatorMock.createOrganizationOrg.POST.mockClear();

useBankingInformationManager
.mockClear()
.mockReturnValue({ manageBankingInformation });
});

it('should display organization form', () => {
Expand All @@ -56,11 +78,23 @@ describe('OrganizationCreate', () => {
expect(historyMock.push.mock.calls[0][0].pathname).toBe('/organizations/view/orgUid');
});

it('should save organization', () => {
it('should save organization', async () => {
mutatorMock.createOrganizationOrg.POST.mockReturnValue(Promise.resolve({ id: 'orgUid' }));

renderOrganizationCreate();

OrganizationForm.mock.calls[0][0].onSubmit({});
await OrganizationForm.mock.calls[0][0].onSubmit({}, { getFieldState });

expect(mutatorMock.createOrganizationOrg.POST).toHaveBeenCalled();
});

it('should handle banking information on form submit', async () => {
mutatorMock.createOrganizationOrg.POST.mockReturnValue(Promise.resolve({ id: 'orgUid' }));

renderOrganizationCreate();

await OrganizationForm.mock.calls[0][0].onSubmit({}, { getFieldState });

expect(manageBankingInformation).toHaveBeenCalled();
});
});
Loading

0 comments on commit be51dbf

Please sign in to comment.