Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into UIIN-3100
Browse files Browse the repository at this point in the history
  • Loading branch information
vashjs committed Nov 17, 2024
2 parents 51528e2 + 452379b commit b60f1d0
Show file tree
Hide file tree
Showing 27 changed files with 222 additions and 376 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
# Change history for ui-inventory

## [12.0.1] (IN PROGRESS)
## [13.0.0] (IN PROGRESS)

* ECS | Instance details pane does not contain all tenants when user does not have affiliations / permissions in all tenants. Fixes UIIN-3113.
* *BREAKING* Rename quick-marc routes from `bib` to `bibliographic` and `duplicate` to `derive`. Refs UIIN-3120.
* *BREAKING* Provide necessary props for browse lookup facets. Remove the facets state reset functionality. Refs UIIN-3099.

## [12.0.1](https://github.com/folio-org/ui-inventory/tree/v12.0.1) (2024-11-15)
[Full Changelog](https://github.com/folio-org/ui-inventory/compare/v12.0.0...v12.0.1)

* Run `history.replace` once during component mount and update to avoid URL rewriting. Refs UIIN-3099.
* ECS | "FOLIO/MARC-shared" source is displayed in manually shared instance record. Fixes UIIN-3115.
* Allow user to move item to another holdings associated with another instance. Fixes UIIN-3102.
* Cautiously evaluate tenant permissions to avoid NPEs. Refs UIIN-3124.

## [12.0.0](https://github.com/folio-org/ui-inventory/tree/v12.0.0) (2024-10-31)
[Full Changelog](https://github.com/folio-org/ui-inventory/compare/v11.0.5...v12.0.0)
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@folio/inventory",
"version": "12.0.0",
"version": "13.0.0",
"description": "Inventory manager",
"repository": "folio-org/ui-inventory",
"publishConfig": {
Expand Down Expand Up @@ -1001,7 +1001,7 @@
"@folio/stripes-components": "^12.2.2",
"@folio/stripes-connect": "^9.2.0",
"@folio/stripes-core": "^10.2.1",
"@folio/stripes-inventory-components": "^1.0.0",
"@folio/stripes-inventory-components": "^2.0.0",
"@folio/stripes-marc-components": "^1.1.0",
"@folio/stripes-smart-components": "^9.2.1",
"@folio/stripes-testing": "^4.6.0",
Expand Down Expand Up @@ -1045,7 +1045,7 @@
},
"peerDependencies": {
"@folio/stripes": "^9.2.2",
"@folio/stripes-inventory-components": "^1.0.0",
"@folio/stripes-inventory-components": "^2.0.0",
"@folio/stripes-marc-components": "^1.1.0",
"react": "^18.2.0",
"react-intl": "^6.4.4",
Expand All @@ -1056,7 +1056,7 @@
},
"optionalDependencies": {
"@folio/plugin-create-inventory-records": "^5.0.0",
"@folio/plugin-find-instance": "^8.0.0"
"@folio/plugin-find-instance": "^9.0.0"
},
"resolutions": {
"moment": "~2.29.4"
Expand Down
4 changes: 2 additions & 2 deletions src/ViewInstance.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ import RequestsReorderButton from './components/ViewInstance/MenuSection/Request
import { IdReportGenerator } from './reports';

const quickMarcPages = {
editInstance: 'edit-bib',
duplicateInstance: 'duplicate-bib',
editInstance: 'edit-bibliographic',
duplicateInstance: 'derive-bibliographic',
createHoldings: 'create-holdings',
};

Expand Down
6 changes: 3 additions & 3 deletions src/ViewInstance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ describe('ViewInstance', () => {
it('push function should be called when the user clicks the "Edit MARC bibliographic record" button', async () => {
renderViewInstance();
const expectedValue = {
pathname: `/inventory/quick-marc/edit-bib/${defaultProp.selectedInstance.id}`,
pathname: `/inventory/quick-marc/edit-bibliographic/${defaultProp.selectedInstance.id}`,
search: 'filters=test1&query=test2&sort=test3&qindex=test',
};
fireEvent.click(screen.getByRole('button', { name: 'Actions' }));
Expand Down Expand Up @@ -991,7 +991,7 @@ describe('ViewInstance', () => {
it('push function should be called when the user clicks the "Derive new MARC bibliographic record" button', async () => {
renderViewInstance({ isShared: false });
const expectedValue = {
pathname: `/inventory/quick-marc/duplicate-bib/${defaultProp.selectedInstance.id}`,
pathname: `/inventory/quick-marc/derive-bibliographic/${defaultProp.selectedInstance.id}`,
search: 'filters=test1&query=test2&sort=test3&qindex=test',
};
fireEvent.click(screen.getByRole('button', { name: 'Actions' }));
Expand Down Expand Up @@ -1284,7 +1284,7 @@ describe('ViewInstance', () => {
fireEvent.click(screen.getByRole('button', { name: 'editMARC' }));

expect(mockPush).toHaveBeenLastCalledWith({
pathname: `/inventory/quick-marc/edit-bib/${instance.id}`,
pathname: `/inventory/quick-marc/edit-bibliographic/${instance.id}`,
search: 'filters=test1&query=test2&sort=test3&qindex=test&shared=true',
});
});
Expand Down
12 changes: 9 additions & 3 deletions src/components/BrowseInventoryFilters/BrowseInventoryFilters.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import PropTypes from 'prop-types';
import { useContext } from 'react';
import {
useCallback,
useContext,
} from 'react';

import { DataContext } from '../../contexts';
import InstanceFiltersBrowse from '../InstanceFiltersBrowse';
Expand All @@ -10,12 +13,15 @@ const BrowseInventoryFilters = ({
}) => {
const data = useContext(DataContext);

const handleChange = useCallback(({ name, values }) => {
applyFilters(name, values);
}, [applyFilters]);

return (
<InstanceFiltersBrowse
data={data}
query={query}
onChange={({ name, values }) => applyFilters(name, values)}
onClear={(name) => applyFilters(name, [])}
onChange={handleChange}
/>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ describe('BrowseInventoryFilters', () => {
data,
query,
onChange: expect.any(Function),
onClear: expect.any(Function),
}, {});
});
});
6 changes: 0 additions & 6 deletions src/components/BrowseResultsList/getBrowseResultsFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {
} from '@folio/stripes/components';
import {
browseModeOptions,
deleteFacetStates,
} from '@folio/stripes-inventory-components';

import {
Expand Down Expand Up @@ -53,14 +52,9 @@ const getTargetRecord = (
}),
};

const handleClick = () => {
deleteFacetStates(namespace);
};

return (
<TextLink
to={toParams}
onClick={handleClick}
>
{record}
</TextLink>
Expand Down
85 changes: 32 additions & 53 deletions src/components/InstanceFiltersBrowse/InstanceFiltersBrowse.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,37 @@
import React, { useMemo } from 'react';
import PropTypes from 'prop-types';
import { useIntl } from 'react-intl';
import omit from 'lodash/omit';

import {
checkIfUserInMemberTenant,
useStripes,
} from '@folio/stripes/core';
import { AccordionSet } from '@folio/stripes/components';
import {
FACETS,
HeldByFacet,
browseModeOptions,
browseCallNumberOptions,
browseClassificationOptions,
useFacets,
FACETS_TO_REQUEST,
SharedFacet,
EffectiveLocationFacet,
NameTypeFacet,
isConsortiaEnv,
FACETS_TO_REQUEST,
MultiSelectionFacet,
} from '@folio/stripes-inventory-components';

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

const InstanceFiltersBrowse = props => {
const {
data,
query,
onChange,
onClear,
} = props;

const intl = useIntl();
const stripes = useStripes();
const qindex = query.qindex;

const initialAccordionStates = useMemo(() => ({
const initialFacetStates = {
[FACETS.SHARED]: false,
[FACETS.CALL_NUMBERS_HELD_BY]: false,
[FACETS.CLASSIFICATION_SHARED]: false,
Expand All @@ -47,54 +43,46 @@ const InstanceFiltersBrowse = props => {
[FACETS.NAME_TYPE]: false,
[FACETS.SUBJECT_SOURCE]: false,
[FACETS.SUBJECT_TYPE]: false,
}), []);

const activeFilters = useMemo(() => omit(query || {}, ['qindex', 'query']), [query]);
};

const {
accordionStatus,
accordionsStatus,
activeFilters,
facetOptions,
getIsLoading,
onToggleAccordion,
onInputFocusAndMoreClick,
onFacetOptionSearch,
getIsLoading,
} = useFacets({
initialAccordionStates,
initialAccordionStates: initialFacetStates,
query,
isBrowseLookup: true,
activeFilters,
data,
isBrowseLookup: true,
});

const renderSharedFacet = (name) => (
<SharedFacet
name={name}
accordionsStatus={accordionsStatus}
activeFilters={activeFilters}
getIsLoading={getIsLoading}
facetOptions={facetOptions}
onChange={onChange}
onClear={onClear}
getIsLoading={getIsLoading}
onToggle={onToggleAccordion}
/>
);

const renderHeldByFacet = (name) => (
<HeldByFacet
name={name}
accordionsStatus={accordionsStatus}
activeFilters={activeFilters}
facetOptions={facetOptions}
getIsLoading={getIsLoading}
onChange={onChange}
onClear={onClear}
onFetch={onInputFocusAndMoreClick}
onSearch={onFacetOptionSearch}
onToggle={onToggleAccordion}
/>
);

return (
<AccordionSet
accordionStatus={accordionStatus}
onToggle={onToggleAccordion}
>
<>
{Object.values(browseClassificationOptions).includes(qindex) && (
renderSharedFacet(FACETS.CLASSIFICATION_SHARED)
)}
Expand All @@ -104,14 +92,12 @@ const InstanceFiltersBrowse = props => {
{renderHeldByFacet(FACETS.CALL_NUMBERS_HELD_BY)}
<EffectiveLocationFacet
name={FACETS.EFFECTIVE_LOCATION}
accordionsStatus={accordionsStatus}
facetOptions={facetOptions}
separator={isConsortiaEnv(stripes)}
activeFilters={activeFilters}
getIsLoading={getIsLoading}
onChange={onChange}
onClear={onClear}
onFetch={onInputFocusAndMoreClick}
onSearch={onFacetOptionSearch}
onToggle={onToggleAccordion}
/>
</>
)}
Expand All @@ -120,18 +106,14 @@ const InstanceFiltersBrowse = props => {
{renderSharedFacet(FACETS.CONTRIBUTORS_SHARED)}
{/* Hide Held by facet for contributors and subjects browse until back-end requirements and implementation are done */}
{/* {renderHeldByFacet(FACETS.CONTRIBUTORS_HELD_BY)} */}
<MultiSelectionFacet
id={FACETS.NAME_TYPE}
label={intl.formatMessage({ id: `ui-inventory.filters.${FACETS.NAME_TYPE}` })}
<NameTypeFacet
name={FACETS.NAME_TYPE}
closedByDefault
accordionsStatus={accordionsStatus}
activeFilters={activeFilters}
separator={checkIfUserInMemberTenant(stripes)}
options={facetOptions[FACETS_TO_REQUEST[FACETS.NAME_TYPE]]}
selectedValues={activeFilters[FACETS.NAME_TYPE]}
onFilterChange={onChange}
onClearFilter={() => onClear(FACETS.NAME_TYPE)}
displayClearButton={!!activeFilters[FACETS.NAME_TYPE]?.length}
isPending={getIsLoading(FACETS.NAME_TYPE)}
facetOptions={facetOptions}
onChange={onChange}
onToggle={onToggleAccordion}
/>
</>
)}
Expand All @@ -143,39 +125,36 @@ const InstanceFiltersBrowse = props => {
<MultiSelectionFacet
id={FACETS.SUBJECT_SOURCE}
label={intl.formatMessage({ id: `ui-inventory.${FACETS.SUBJECT_SOURCE}` })}
open={accordionsStatus[FACETS.SUBJECT_SOURCE]}
onToggle={onToggleAccordion}
name={FACETS.SUBJECT_SOURCE}
closedByDefault
separator={checkIfUserInMemberTenant(stripes)}
onChange={onChange}
options={facetOptions[FACETS_TO_REQUEST[FACETS.SUBJECT_SOURCE]]}
selectedValues={activeFilters[FACETS.SUBJECT_SOURCE]}
onFilterChange={onChange}
onClearFilter={() => onClear(FACETS.SUBJECT_SOURCE)}
displayClearButton={!!activeFilters[FACETS.SUBJECT_SOURCE]?.length}
isPending={getIsLoading(FACETS.SUBJECT_SOURCE)}
separator={checkIfUserInMemberTenant(stripes)}
/>
<MultiSelectionFacet
id={FACETS.SUBJECT_TYPE}
label={intl.formatMessage({ id: `ui-inventory.${FACETS.SUBJECT_TYPE}` })}
open={accordionsStatus[FACETS.SUBJECT_TYPE]}
onToggle={onToggleAccordion}
name={FACETS.SUBJECT_TYPE}
closedByDefault
onChange={onChange}
options={facetOptions[FACETS_TO_REQUEST[FACETS.SUBJECT_TYPE]]}
selectedValues={activeFilters[FACETS.SUBJECT_TYPE]}
onFilterChange={onChange}
onClearFilter={() => onClear(FACETS.SUBJECT_TYPE)}
displayClearButton={!!activeFilters[FACETS.SUBJECT_TYPE]?.length}
isPending={getIsLoading(FACETS.SUBJECT_TYPE)}
/>
</>
)}
</AccordionSet>
</>
);
};

export default InstanceFiltersBrowse;

InstanceFiltersBrowse.propTypes = {
onChange: PropTypes.func.isRequired,
onClear: PropTypes.func.isRequired,
data: PropTypes.object.isRequired,
query: PropTypes.object.isRequired,
};
Loading

0 comments on commit b60f1d0

Please sign in to comment.