Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIDATIMP-1686: Replace _/proxy/tenants/${tenant}/modules request with stripes.discovery.modules object #1661

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
### Bugs fixed:
* Allow central tenant to create action profile for Orders and Invoices. (UIDATIMP-1679)
* Allow central tenant to create filed mapping profile for Orders and Invoices. (UIDATIMP-1685)
* Replace `_/proxy/tenants/${tenant}/modules` with `stripes.discovery.modules` object. (UIDATIMP-1686)

## [8.0.2](https://github.com/folio-org/ui-data-import/tree/v8.0.2) (2024-11-21)

Expand Down
22 changes: 6 additions & 16 deletions src/settings/MatchProfiles/MatchProfiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,16 +237,6 @@ export class MatchProfiles extends Component {
staticFallback: { params: {} },
},
},
modules: {
type: 'okapi',
path: (queryParams, pathComponents, resourceData, logger, props) => {
const { stripes: { okapi: { tenant } } } = props;

return `_/proxy/tenants/${tenant}/modules`;
},
throwErrors: false,
GET: { params: { full: true } },
},
});

static propTypes = {
Expand Down Expand Up @@ -308,17 +298,17 @@ export class MatchProfiles extends Component {
};

async componentDidUpdate(prevProps) {
if (!isEqual(prevProps.resources.modules, this.props.resources.modules)
&& !isEmpty(this.props.resources.modules.records)) {
if (!isEqual(prevProps.stripes.discovery.modules, this.props.stripes.discovery.modules)
&& !isEmpty(this.props.stripes.discovery.modules)) {
const {
stripes,
stripes: { okapi },
resources: { modules: { records } },
stripes: { discovery: { modules } },
} = this.props;

const inventoryModuleVersion = getModuleVersion(records, 'Inventory Storage Module');
const ordersModuleVersion = getModuleVersion(records, 'Orders Business Logic Module');
const invoiceModuleVersion = getModuleVersion(records, 'Invoice business logic module');
const inventoryModuleVersion = getModuleVersion(modules, 'Inventory Storage Module');
const ordersModuleVersion = getModuleVersion(modules, 'Orders Business Logic Module');
const invoiceModuleVersion = getModuleVersion(modules, 'Invoice business logic module');

const requestsToInstance = INSTANCE_RESOURCE_PATHS.map(path => fetchJsonSchema(path, inventoryModuleVersion, okapi));
const requestsToHoldings = HOLDINGS_RESOURCE_PATHS.map(path => fetchJsonSchema(path, inventoryModuleVersion, okapi));
Expand Down
4 changes: 2 additions & 2 deletions src/utils/fetchJsonShemas.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const getModuleVersion = (modules, moduleName) => {
const version = modules.find(module => module.name === moduleName);
const version = Object.keys(modules).find(key => modules[key] === moduleName);

return version ? version.id : undefined;
return version || undefined;
};

export const fetchJsonSchema = async (path, module, okapi) => {
Expand Down
13 changes: 5 additions & 8 deletions src/utils/tests/fetchJsonSchemas.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,12 @@ import { STATUS_CODES } from '../constants';

describe('getModuleVersion function', () => {
it('returns module version of a module with given name', () => {
const testModules = [{
name: 'module1',
id: 'testId1',
}, {
name: 'module2',
id: 'testId2',
}];
const testModules = {
testId1: 'module1',
testId2: 'module2',
};

expect(getModuleVersion(testModules, 'module2')).toBe(testModules[1].id);
expect(getModuleVersion(testModules, 'module2')).toBe('testId2');
expect(getModuleVersion(testModules, 'module3')).toBeUndefined();
});
});
Expand Down
Loading