Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
vashjs committed Aug 6, 2024
1 parent b35539b commit 548cd3f
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* [UITEN-298] (https://issues.folio.org/browse/UITEN-298) Update translation ids for reading room.
* [UITEN-301] (https://issues.folio.org/browse/UITEN-301) Display Reading room access in alphabetical order on settings page.
* [UITEN-212](https://folio-org.atlassian.net/browse/UITEN-212) Permission changes for service point management.
* [UITEN-299](https://folio-org.atlassian.net/browse/UITEN-299) Rewrite class components to functional ones (ui-tenant-settings module).

## [8.1.0](https://github.com/folio-org/ui-tenant-settings/tree/v8.1.0)(2024-03-19)
[Full Changelog](https://github.com/folio-org/ui-tenant-settings/compare/v8.0.0...v8.1.0)
Expand Down
3 changes: 0 additions & 3 deletions src/settings/LocationLocations/LocationDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,6 @@ const LocationDetail = ({

LocationDetail.propTypes = {
initialValues: PropTypes.object,
institutions: PropTypes.arrayOf(PropTypes.object),
campuses: PropTypes.arrayOf(PropTypes.object),
libraries: PropTypes.arrayOf(PropTypes.object),
servicePointsById: PropTypes.object,
onEdit: PropTypes.func.isRequired,
onClone: PropTypes.func.isRequired,
Expand Down
8 changes: 7 additions & 1 deletion src/settings/LocationLocations/LocationForm/LocationForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ const LocationForm = ({
detailsSection: true,
});

const mappedInstitutions = institutions.map(i => ({ value: i.id, label: `${i.name} ${i.code ? `(${i.code})` : ''}` }));
const mappedInstitutions = institutions.map(i => {
let label = i.name;
if (i.code) {
label += ` (${i.code})`;
}
return { value: i.id, label };
});
const mappedServicePoints = sortBy(servicePoints, ['name']).map(i => ({ label: `${i.name}` }));

const handleExpandAll = (newSections) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,23 @@ const LocationFormContainer = ({

const callout = useContext(CalloutContext);

function showSubmitErrorCallout(error) {
const showSubmitErrorCallout = (error) => {
callout.sendCallout({
type: 'error',
message: error.message || error.statusText || <FormattedMessage id="ui-tenant-settings.settings.save.error.network" />,
});
}
};

const { setMapping } = useRemoteStorageApi();

const { createLocation } = useLocationCreate({
const sharedOptions = {
onSuccess: () => {
queryClient.invalidateQueries(SERVICE_POINTS);
queryClient.invalidateQueries(LOCATIONS);
},
});
};

const { updateLocation } = useLocationUpdate({
onSuccess: () => {
queryClient.invalidateQueries(SERVICE_POINTS);
queryClient.invalidateQueries(LOCATIONS);
},
});
const { createLocation } = useLocationCreate(sharedOptions);
const { updateLocation } = useLocationUpdate(sharedOptions);

const initiateSetMapping = (...args) => setMapping(...args).catch(showSubmitErrorCallout);

Expand Down
11 changes: 9 additions & 2 deletions src/settings/LocationLocations/LocationManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,13 @@ const LocationManager = ({ label }) => {
};

const formatLocationDisplayName = (loc) => {
return `${loc.name}${loc.code ? ` (${loc.code})` : ''}`;
let lbl = loc.name;

if (loc.code) {
lbl += ` (${loc.code})`;
}

return lbl;
};

const onSort = (e, { name: fieldName }) => {
Expand Down Expand Up @@ -292,7 +298,8 @@ const LocationManager = ({ label }) => {

const parseInitialValues = (loc, cloning = false) => {
if (!loc) return loc;
loc.detailsArray = Object.keys(loc.details || []).map(name => ({ name, value: loc.details[name] })).sort();
loc.detailsArray = Object.keys(loc.details || []).map(name => ({ name, value: loc.details[name] }))
.sort((a, b) => a.name.localeCompare(b.name));
return cloning ? omit(loc, 'id') : loc;
};

Expand Down
2 changes: 1 addition & 1 deletion src/settings/Plugins/PluginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const PluginForm = ({

const options = [{ value: '@@', label: '(none)' }].concat(pluginType.map(p => ({
value: p.module,
label: `${intl.formatMessage({ id: `ui-tenant-settings.settings.pluginNames.${p.pluginType}` })} ${p.version}`,
label: intl.formatMessage({ id: `ui-tenant-settings.settings.pluginNames.${p.pluginType}` }) + ' ' + p.version,
})));

const lbl = <FormattedMessage id={`ui-tenant-settings.settings.pluginNames.${plugin.configName}`} />;
Expand Down
15 changes: 12 additions & 3 deletions src/settings/Plugins/Plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useRef } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage, useIntl } from 'react-intl';
import { map, omit } from 'lodash';
import { useQueryClient } from 'react-query';

import { modules } from 'stripes-config'; // eslint-disable-line import/no-unresolved, import/no-extraneous-dependencies
import {
Expand All @@ -13,12 +14,13 @@ import { TitleManager, useStripes } from '@folio/stripes/core';
import PluginForm from './PluginForm';
import { useConfigurationsCreate } from '../../hooks/useConfigurationsCreate';
import { useConfigurationsUpdate } from '../../hooks/useConfigurationsUpdate';
import { useConfigurations } from '../../hooks/useConfigurations';
import { CONFIGURATIONS, useConfigurations } from '../../hooks/useConfigurations';


const Plugins = ({ label }) => {
const intl = useIntl();
const stripes = useStripes();
const queryClient = useQueryClient();
const callout = useRef(null);

const { configs } = useConfigurations({
Expand All @@ -27,8 +29,15 @@ const Plugins = ({ label }) => {
limit: '1000',
},
});
const { createConfiguration } = useConfigurationsCreate();
const { updateConfiguration } = useConfigurationsUpdate();

const sharedOptions = {
onSuccess: () => {
queryClient.invalidateQueries(CONFIGURATIONS);
},
};

const { createConfiguration } = useConfigurationsCreate(sharedOptions);
const { updateConfiguration } = useConfigurationsUpdate(sharedOptions);

const pluginTypes = (() => {
const plugins = modules.plugin || [];
Expand Down
6 changes: 3 additions & 3 deletions src/settings/ServicePoints/LocationList.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@ import {
const LocationList = ({ locations, expanded, servicePoint, onToggle }) => {
const intl = useIntl();

const renderLocation = (location) => {
const renderLocation = (location, index) => {
if (!location) return (<div />);

const { name, code, primaryServicePoint } = location;
const primary = (primaryServicePoint === servicePoint.id)
? intl.formatMessage({ id: 'ui-tenant-settings.settings.servicePoints.primary' }) :
'';
const title = `${name} - ${code} ${primary}`;
return (<li key={title}>{title}</li>);
return (<li key={index}>{title}</li>);
};

const renderLocations = () => {
return (
<List
items={locations}
itemFormatter={location => renderLocation(location)}
itemFormatter={renderLocation}
isEmptyMessage={<FormattedMessage id="ui-tenant-settings.settings.servicePoints.noLocationsFound" />}
/>
);
Expand Down
1 change: 0 additions & 1 deletion src/settings/ServicePoints/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export const shortTermExpiryPeriod = ['Hours', 'Minutes'];
export const longTermExpiryPeriod = ['Months', 'Weeks', 'Days'];

export const closedLibraryDateManagementMapping = {
Keep_the_current_due_date_time: 'keepTheOriginalDateTime',
Expand Down

0 comments on commit 548cd3f

Please sign in to comment.