Skip to content

Commit

Permalink
Merge branch 'master' into UITEN-281
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-blazhko committed Aug 19, 2024
2 parents 9f548ce + 10d83b2 commit 1c216bc
Show file tree
Hide file tree
Showing 101 changed files with 3,044 additions and 3,519 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Change history for ui-tenant-settings

## 9.0.0 (IN PROGRESS)
## 8.2.0 (IN PROGRESS)

* [UITEN-274](https://folio-org.atlassian.net/browse/UITEN-274) Use Save & close button label stripes-component translation key.
* [UITEN-280](https://folio-org.atlassian.net/browse/UITEN-280) Conditionally include SSO Settings based on login-saml interface.
* [UITEN-286](https://folio-org.atlassian.net/browse/UITEN-286) *BREAKING* Add new interface. Add new permission to view reading room access in tenant settings.
* [UITEN-286](https://folio-org.atlassian.net/browse/UITEN-286) Add new interface. Add new permission to view reading room access in tenant settings.
* [UITEN-287](https://folio-org.atlassian.net/browse/UITEN-287) Add new permission to create, edit and remove reading room access in tenant settings.
* [UITEN-277](https://issues.folio.org/browse/UITEN-277) Ensure Reading Room Access settings page is wrapped by `Title Manager`.
* [UITEN-276](https://issues.folio.org/browse/UITEN-276) Reading Room Access (settings): Basic Layout.
Expand All @@ -14,6 +14,11 @@
* [UITEN-281](https://folio-org.atlassian.net/browse/UITEN-281) Add Routing service point option to Service point page(ECS only).
* [UITEN-285](https://folio-org.atlassian.net/browse/UITEN-285) Disable edit of Routing service point field (ECS only).
* [UITEN-294](https://folio-org.atlassian.net/browse/UITEN-294) Show routing service points on settings -> tenant -> servicePoints.
* [UITEN-290] (https://issues.folio.org/browse/UITEN-290) Make dependency on mod-reading-rooms optional.
* [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
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@folio/tenant-settings",
"version": "9.0.0",
"version": "8.1.0",
"description": "Tenant settings",
"main": "src/index.js",
"repository": "folio-org/ui-tenant-settings",
Expand All @@ -17,16 +17,16 @@
"route": "/tenant-settings",
"okapiInterfaces": {
"configuration": "2.0",
"users": "15.0 16.0",
"reading-room": "1.0"
"users": "15.0 16.0"
},
"optionalOkapiInterfaces": {
"location-units": "2.0",
"locations": "3.0",
"login-saml": "2.0",
"remote-storage-configurations": "1.0",
"remote-storage-mappings": "1.0 2.0",
"service-points": "3.0"
"service-points": "3.0",
"reading-room": "1.0"
},
"permissionSets": [
{
Expand Down Expand Up @@ -200,12 +200,11 @@
},
{
"permissionName": "ui-tenant-settings.settings.servicepoints",
"displayName": "Settings (tenant): Can create, edit and remove service points",
"displayName": "Settings (tenant): Can create and edit service points",
"subPermissions": [
"ui-tenant-settings.settings.servicepoints.view",
"inventory-storage.service-points.item.post",
"inventory-storage.service-points.item.put",
"inventory-storage.service-points.item.delete"
"inventory-storage.service-points.item.put"
],
"visible": true
},
Expand Down Expand Up @@ -305,6 +304,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-intl": "^6.4.4",
"react-query": "^3.6.0",
"react-router-dom": "^5.2.0"
}
}
190 changes: 78 additions & 112 deletions src/components/Period/Period.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
import React from 'react';
import React, { useRef } from 'react';
import PropTypes from 'prop-types';
import { FormattedMessage } from 'react-intl';

import {
Field,
} from 'react-final-form';

import {
get,
isEmpty,
isNumber,
} from 'lodash';
import { Field } from 'react-final-form';
import { get, isEmpty, isNumber } from 'lodash';

import {
Col,
Row,
Select,
TextField,
Label,
Label
} from '@folio/stripes/components';

import css from './Period.css';
import {
shortTermExpiryPeriod,
shortTermClosedDateManagementMenu,
longTermClosedDateManagementMenu
} from '../../settings/ServicePoints/constants';
import css from './Period.css';


const validateDuration = value => {
if (typeof value !== 'number') {
Expand All @@ -39,32 +32,19 @@ const validateDuration = value => {
return undefined;
};

class Period extends React.Component {
static propTypes = {
fieldLabel: PropTypes.string.isRequired,
selectPlaceholder: PropTypes.string.isRequired,
dependentValuePath: PropTypes.string.isRequired,
inputValuePath: PropTypes.string.isRequired,
selectValuePath: PropTypes.string.isRequired,
entity: PropTypes.object.isRequired,
intervalPeriods: PropTypes.arrayOf(PropTypes.object),
changeFormValue: PropTypes.func.isRequired,
};

constructor(props) {
super(props);

this.inputRef = React.createRef();
}

onInputBlur = () => {
const {
inputValuePath,
selectValuePath,
entity,
changeFormValue,
} = this.props;

const Period = ({
fieldLabel,
selectPlaceholder,
dependentValuePath,
inputValuePath,
selectValuePath,
entity,
intervalPeriods,
changeFormValue
}) => {
const inputRef = useRef(null);

const onInputBlur = () => {
const inputValue = get(entity, inputValuePath);

if (isNumber(inputValue)) {
Expand All @@ -74,104 +54,90 @@ class Period extends React.Component {
changeFormValue(selectValuePath, '');
};

onInputClear = () => {
const {
inputValuePath,
changeFormValue,
} = this.props;

const onInputClear = () => {
changeFormValue(inputValuePath, '');
};

onSelectChange = (e) => {
const {
selectValuePath,
changeFormValue,
dependentValuePath,
} = this.props;

const onSelectChange = (e) => {
changeFormValue(selectValuePath, e.target.value);
const holdShelfClosedLibraryDateManagementValue =
shortTermExpiryPeriod.findIndex(item => item === e.target.value) > -1
? shortTermClosedDateManagementMenu[0].value
: longTermClosedDateManagementMenu[0].value;
changeFormValue(dependentValuePath, holdShelfClosedLibraryDateManagementValue);

this.inputRef.current.focus();
inputRef.current.focus();
};

transformInputValue = (value) => {
const transformInputValue = (value) => {
if (isEmpty(value)) {
return '';
}

return Number(value);
};

generateOptions = () => {
const {
intervalPeriods,
selectValuePath,
} = this.props;

const generateOptions = () => {
return intervalPeriods.map(({ value, label }) => (
<option value={value} key={`${selectValuePath}-${value}`}>
{label}
</option>
));
};

render() {
const {
fieldLabel,
selectPlaceholder,
inputValuePath,
selectValuePath,
} = this.props;

return (
<>
<Row className={css.labelRow}>
<Col xs={12}>
<Label className={css.label} required>
<FormattedMessage id={fieldLabel} />
</Label>
</Col>
</Row>
<Row>
<Col xs={2}>
<Field
data-test-period-duration
type="number"
name={inputValuePath}
component={TextField}
forwardRef
inputRef={this.inputRef}
onBlur={this.onInputBlur}
onClearField={this.onInputClear}
parse={this.transformInputValue}
validate={validateDuration}
/>
</Col>
<Col xs={2}>
<FormattedMessage id={selectPlaceholder}>
{placeholder => (
<Field
data-test-period-interval
name={selectValuePath}
component={Select}
placeholder={placeholder}
onChange={this.onSelectChange}
>
{this.generateOptions()}
</Field>
)}
</FormattedMessage>
</Col>
</Row>
</>
);
}
}
return (
<>
<Row className={css.labelRow}>
<Col xs={12}>
<Label className={css.label} required>
<FormattedMessage id={fieldLabel} />
</Label>
</Col>
</Row>
<Row>
<Col xs={2}>
<Field
data-test-period-duration
type="number"
name={inputValuePath}
component={TextField}
forwardRef
inputRef={inputRef}
onBlur={onInputBlur}
onClearField={onInputClear}
parse={transformInputValue}
validate={validateDuration}
/>
</Col>
<Col xs={2}>
<FormattedMessage id={selectPlaceholder}>
{placeholder => (
<Field
data-test-period-interval
name={selectValuePath}
component={Select}
placeholder={placeholder}
onChange={onSelectChange}
>
{generateOptions()}
</Field>
)}
</FormattedMessage>
</Col>
</Row>
</>
);
};

Period.propTypes = {
fieldLabel: PropTypes.string.isRequired,
selectPlaceholder: PropTypes.string.isRequired,
dependentValuePath: PropTypes.string.isRequired,
inputValuePath: PropTypes.string.isRequired,
selectValuePath: PropTypes.string.isRequired,
entity: PropTypes.object.isRequired,
intervalPeriods: PropTypes.arrayOf(PropTypes.object),
changeFormValue: PropTypes.func.isRequired,
};

export default Period;
20 changes: 20 additions & 0 deletions src/hooks/useCampusDetails.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { useNamespace, useOkapiKy } from '@folio/stripes/core';
import { useQuery } from 'react-query';

export const CAMPUS_DETAILS = 'CAMPUS_DETAILS';

export const useCampusDetails = ({ id, searchParams }) => {
const ky = useOkapiKy();
const [namespaceKey] = useNamespace({ key: CAMPUS_DETAILS });

const { data, isLoading: isCampusLoading } = useQuery({
queryKey: [CAMPUS_DETAILS, namespaceKey, id, searchParams],
queryFn: () => ky.get(`location-units/campuses/${id}`, { searchParams }).json(),
enabled: !!id,
});

return {
campus: data,
isCampusLoading,
};
};
19 changes: 19 additions & 0 deletions src/hooks/useCampuses.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { useNamespace, useOkapiKy } from '@folio/stripes/core';
import { useQuery } from 'react-query';

export const CAMPUSES = 'CAMPUSES';

export const useCampuses = ({ searchParams }) => {
const ky = useOkapiKy();
const [namespaceKey] = useNamespace({ key: CAMPUSES });

const { data, isLoading: isCampusesLoading } = useQuery({
queryKey: [CAMPUSES, namespaceKey, searchParams],
queryFn: () => ky.get('location-units/campuses', { searchParams }).json(),
});

return {
campuses: data?.loccamps || [],
isCampusesLoading,
};
};
19 changes: 19 additions & 0 deletions src/hooks/useConfigurations.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { useNamespace, useOkapiKy } from '@folio/stripes/core';
import { useQuery } from 'react-query';

export const CONFIGURATIONS = 'CONFIGURATIONS';

export const useConfigurations = ({ searchParams }) => {
const ky = useOkapiKy();
const [namespaceKey] = useNamespace({ key: CONFIGURATIONS });

const { data, isLoading: isConfigsLoading } = useQuery({
queryKey: [CONFIGURATIONS, namespaceKey, searchParams],
queryFn: () => ky.get('configurations/entries', { searchParams }).json(),
});

return {
configs: data?.configs || [],
isConfigsLoading,
};
};
Loading

0 comments on commit 1c216bc

Please sign in to comment.