-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UIORGS-356 - Show in version history record view, which fields have b…
…een edited (#658) * UIORGS-356 Show in version history record view, which fields have been edited * update card header * Update labels mapping * fix old test * provide keys for arrays items and add tests * add tests * updates * resolve comments
- Loading branch information
1 parent
9a29cc4
commit 1b58202
Showing
48 changed files
with
1,828 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { default } from './ContactPerson'; | ||
export { default as ContactPersonSection } from './ContactPersonSection'; |
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
147 changes: 147 additions & 0 deletions
147
src/Organizations/OrganizationVersion/OrganizationVersionView/OrganizationVersionView.js
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,147 @@ | ||
import PropTypes from 'prop-types'; | ||
import { useRef } from 'react'; | ||
|
||
import { | ||
Accordion, | ||
AccordionSet, | ||
AccordionStatus, | ||
checkScope, | ||
Col, | ||
collapseAllSections, | ||
ExpandAllButton, | ||
expandAllSections, | ||
HasCommand, | ||
Row, | ||
} from '@folio/stripes/components'; | ||
|
||
import { | ||
ORGANIZATION_SECTION_LABELS, | ||
ORGANIZATION_SECTIONS, | ||
} from '../../constants'; | ||
import { | ||
OrganizationAccountsVersionView, | ||
OrganizationContactInfoVersionView, | ||
OrganizationContactPeopleVersionView, | ||
OrganizationInterfacesVersionView, | ||
OrganizationSummaryVersionView, | ||
OrganizationVendorInfoVersionView, | ||
OrganizationVendorTermsVersionView, | ||
} from '../components'; | ||
|
||
const initialAccordionStatus = { | ||
[ORGANIZATION_SECTIONS.summarySection]: true, | ||
[ORGANIZATION_SECTIONS.contactInformationSection]: false, | ||
[ORGANIZATION_SECTIONS.contactPeopleSection]: true, | ||
[ORGANIZATION_SECTIONS.interfacesSection]: false, | ||
[ORGANIZATION_SECTIONS.vendorInformationSection]: false, | ||
[ORGANIZATION_SECTIONS.vendorTermsSection]: false, | ||
[ORGANIZATION_SECTIONS.integrationDetailsSection]: false, | ||
[ORGANIZATION_SECTIONS.accountsSection]: false, | ||
[ORGANIZATION_SECTIONS.agreements]: false, | ||
}; | ||
|
||
export const OrganizationVersionView = ({ version }) => { | ||
const accordionStatusRef = useRef(); | ||
|
||
const shortcuts = [ | ||
{ | ||
name: 'expandAllSections', | ||
handler: (e) => expandAllSections(e, accordionStatusRef), | ||
}, | ||
{ | ||
name: 'collapseAllSections', | ||
handler: (e) => collapseAllSections(e, accordionStatusRef), | ||
}, | ||
]; | ||
|
||
return ( | ||
<HasCommand | ||
commands={shortcuts} | ||
isWithinScope={checkScope} | ||
scope={document.body} | ||
> | ||
<AccordionStatus ref={accordionStatusRef}> | ||
<Row end="xs"> | ||
<Col xs={12}> | ||
<ExpandAllButton /> | ||
</Col> | ||
</Row> | ||
|
||
<AccordionSet initialStatus={initialAccordionStatus}> | ||
<Accordion | ||
id={ORGANIZATION_SECTIONS.summarySection} | ||
label={ORGANIZATION_SECTION_LABELS[ORGANIZATION_SECTIONS.summarySection]} | ||
> | ||
<OrganizationSummaryVersionView version={version} /> | ||
</Accordion> | ||
|
||
<Accordion | ||
id={ORGANIZATION_SECTIONS.contactInformationSection} | ||
label={ORGANIZATION_SECTION_LABELS[ORGANIZATION_SECTIONS.contactInformationSection]} | ||
> | ||
<OrganizationContactInfoVersionView | ||
version={version} | ||
/> | ||
</Accordion> | ||
|
||
<Accordion | ||
id={ORGANIZATION_SECTIONS.contactPeopleSection} | ||
label={ORGANIZATION_SECTION_LABELS[ORGANIZATION_SECTIONS.contactPeopleSection]} | ||
> | ||
<OrganizationContactPeopleVersionView | ||
name="contacts" | ||
version={version} | ||
/> | ||
</Accordion> | ||
|
||
<Accordion | ||
id={ORGANIZATION_SECTIONS.interfacesSection} | ||
label={ORGANIZATION_SECTION_LABELS[ORGANIZATION_SECTIONS.interfacesSection]} | ||
> | ||
<OrganizationInterfacesVersionView | ||
name="interfaces" | ||
version={version} | ||
/> | ||
</Accordion> | ||
|
||
{ | ||
version?.isVendor && ( | ||
<> | ||
<Accordion | ||
id={ORGANIZATION_SECTIONS.vendorInformationSection} | ||
label={ORGANIZATION_SECTION_LABELS[ORGANIZATION_SECTIONS.vendorInformationSection]} | ||
> | ||
<OrganizationVendorInfoVersionView version={version} /> | ||
</Accordion> | ||
|
||
<Accordion | ||
id={ORGANIZATION_SECTIONS.vendorTermsSection} | ||
label={ORGANIZATION_SECTION_LABELS[ORGANIZATION_SECTIONS.vendorTermsSection]} | ||
> | ||
<OrganizationVendorTermsVersionView | ||
name="agreements" | ||
version={version} | ||
/> | ||
</Accordion> | ||
|
||
<Accordion | ||
id={ORGANIZATION_SECTIONS.accountsSection} | ||
label={ORGANIZATION_SECTION_LABELS[ORGANIZATION_SECTIONS.accountsSection]} | ||
> | ||
<OrganizationAccountsVersionView | ||
name="accounts" | ||
version={version} | ||
/> | ||
</Accordion> | ||
</> | ||
) | ||
} | ||
</AccordionSet> | ||
</AccordionStatus> | ||
</HasCommand> | ||
); | ||
}; | ||
|
||
OrganizationVersionView.propTypes = { | ||
version: PropTypes.object, | ||
}; |
68 changes: 68 additions & 0 deletions
68
...Organizations/OrganizationVersion/OrganizationVersionView/OrganizationVersionView.test.js
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,68 @@ | ||
import { | ||
QueryClient, | ||
QueryClientProvider, | ||
} from 'react-query'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
|
||
import { | ||
render, | ||
screen, | ||
} from '@folio/jest-config-stripes/testing-library/react'; | ||
import { useCategories } from '@folio/stripes-acq-components'; | ||
|
||
import { | ||
organization, | ||
organizationAuditEvent, | ||
} from 'fixtures'; | ||
import { ORGANIZATION_VERSIONS_VIEW_ROUTE } from '../../../common/constants'; | ||
import { OrganizationVersionView } from './OrganizationVersionView'; | ||
|
||
jest.mock('@folio/stripes-acq-components', () => ({ | ||
...jest.requireActual('@folio/stripes-acq-components'), | ||
useCategories: jest.fn(), | ||
})); | ||
|
||
const { organizationSnapshot } = organizationAuditEvent; | ||
|
||
const queryClient = new QueryClient(); | ||
const wrapper = ({ children }) => ( | ||
<QueryClientProvider client={queryClient}> | ||
<MemoryRouter | ||
initialEntries={[{ | ||
pathname: ORGANIZATION_VERSIONS_VIEW_ROUTE.replace(':id', organization.id), | ||
}]} | ||
> | ||
{children} | ||
</MemoryRouter> | ||
</QueryClientProvider> | ||
); | ||
|
||
const renderOrganizationVersionView = (props = {}) => render( | ||
<OrganizationVersionView | ||
version={organizationSnapshot.map} | ||
{...props} | ||
/>, | ||
{ wrapper }, | ||
); | ||
|
||
describe('OrganizationVersion', () => { | ||
beforeEach(() => { | ||
useCategories.mockReturnValue({ categories: [{ id: 'f52ceea4-8e35-404b-9ebd-5c7db6613195', value: 'cat' }] }); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
|
||
it('should render version history view', async () => { | ||
renderOrganizationVersionView(); | ||
|
||
expect(screen.getByText('ui-organizations.summary')).toBeInTheDocument(); | ||
expect(screen.getByText('ui-organizations.contactInformation')).toBeInTheDocument(); | ||
expect(screen.getByText('ui-organizations.contactPeople')).toBeInTheDocument(); | ||
expect(screen.getByText('ui-organizations.interface')).toBeInTheDocument(); | ||
expect(screen.getByText('ui-organizations.vendorInformation')).toBeInTheDocument(); | ||
expect(screen.getByText('ui-organizations.vendorTerms')).toBeInTheDocument(); | ||
expect(screen.getByText('ui-organizations.accounts')).toBeInTheDocument(); | ||
}); | ||
}); |
1 change: 1 addition & 0 deletions
1
src/Organizations/OrganizationVersion/OrganizationVersionView/index.js
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 @@ | ||
export { OrganizationVersionView } from './OrganizationVersionView'; |
Oops, something went wrong.