Skip to content

Commit

Permalink
UIEH-1419 Show ProxiedURL on Resource show page
Browse files Browse the repository at this point in the history
  • Loading branch information
BogdanDenis committed Jul 3, 2024
1 parent 6d44ee1 commit 8519c6d
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 86 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

* Agreements accordion - Revise Are you sure you want to unassign agreement? message. (UIEH-1420)
* Agreements accordion - Add a tooltip for the `New` and `Add` buttons. (UIEH-1424)
* eHoldings package-title (resource) view: display Proxied URL. (UIEH-1419)

## [9.1.1] (https://github.com/folio-org/ui-eholdings/tree/v9.1.1) (2024-03-24)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ import AccessTypeDisplay from '../../../access-type-display';
import ProxyDisplay from '../../../proxy-display';
import ExternalLink from '../../../external-link/external-link';

import {
accessTypesReduxStateShape,
MAX_COLUMN_WIDTH,
ONE_THIRD_OF_COLUMN_WIDTH,
QUARTER_OF_COLUMN_WIDTH,
} from '../../../../constants';
import { accessTypesReduxStateShape } from '../../../../constants';

import { getAccessTypeId } from '../../../utilities';

Expand All @@ -32,6 +27,11 @@ const propTypes = {
resourceSelected: PropTypes.bool.isRequired,
};

const COL_SIZES = {
md: 6,
xs: 12,
};

const ResourceSettings = ({
isOpen,
onToggle,
Expand All @@ -45,18 +45,11 @@ const ResourceSettings = ({
: model.visibilityData.reason && `(${model.visibilityData.reason})`;

const hasInheritedProxy = !!model.package?.proxy?.id;
const hasProxiedUrl = !!model.proxy?.proxiedUrl;

const haveAccessTypesLoaded = !accessStatusTypes?.isLoading && !model.isLoading;
const isAccessStatusTypes = accessStatusTypes?.items?.data?.length > 0;

const resourceSettingsColumnWidth = isAccessStatusTypes
? MAX_COLUMN_WIDTH
: ONE_THIRD_OF_COLUMN_WIDTH;

const proxyAndAccessStatusTypeColumnWidth = isAccessStatusTypes
? QUARTER_OF_COLUMN_WIDTH
: MAX_COLUMN_WIDTH;

return (
<Accordion
label={(
Expand All @@ -69,76 +62,79 @@ const ResourceSettings = ({
onToggle={onToggle}
>
<Row>
<Col xs>
<Row>
<Col xs={6}>
<KeyValue label={<FormattedMessage id="ui-eholdings.label.showToPatrons" />}>
<div
data-test-eholdings-resource-show-visibility
data-testid="resource-show-visibility"
>
{(model.visibilityData.isHidden || !resourceSelected)
? (
<FormattedMessage
id="ui-eholdings.package.visibility.no"
values={{ visibilityMessage }}
/>
)
: <FormattedMessage id="ui-eholdings.yes" />
}
</div>
</KeyValue>
</Col>
{model.url && (
<Col xs={6}>
<KeyValue label={model.package.isCustom
? <FormattedMessage id="ui-eholdings.custom" />
: <FormattedMessage id="ui-eholdings.managed" />}
>
<div data-test-eholdings-resource-show-url>
<ExternalLink
href={model.url}
target="_blank"
rel="noopener noreferrer"
/>
</div>
</KeyValue>
</Col>
)}
</Row>
</Col>
<Col xs={resourceSettingsColumnWidth}>
<Row>
{hasInheritedProxy && (
<Col xs={proxyAndAccessStatusTypeColumnWidth}>
{!proxyTypes.request.isResolved || model.isLoading
? <Icon icon="spinner-ellipsis" />
: (
<ProxyDisplay
proxy={model.proxy}
proxyTypesRecords={proxyTypes.resolver.state.proxyTypes.records}
inheritedProxyId={model.package.proxy.id}
/>
)}
</Col>
)}
{isAccessStatusTypes && (
<Col xsOffset={3} xs={proxyAndAccessStatusTypeColumnWidth}>
<div data-test-eholdings-access-type>
{haveAccessTypesLoaded
? (
<AccessTypeDisplay
accessTypeId={getAccessTypeId(model)}
accessStatusTypes={accessStatusTypes}
/>
)
: <Icon icon="spinner-ellipsis" />
}
</div>
</Col>
)}
</Row>
<Col {...COL_SIZES}>
<KeyValue label={<FormattedMessage id="ui-eholdings.label.showToPatrons" />}>
<div
data-test-eholdings-resource-show-visibility
data-testid="resource-show-visibility"
>
{(model.visibilityData.isHidden || !resourceSelected)
? (
<FormattedMessage
id="ui-eholdings.package.visibility.no"
values={{ visibilityMessage }}
/>
)
: <FormattedMessage id="ui-eholdings.yes" />
}
</div>
</KeyValue>
</Col>
{model.url && (
<Col {...COL_SIZES}>
<KeyValue label={model.package.isCustom
? <FormattedMessage id="ui-eholdings.custom" />
: <FormattedMessage id="ui-eholdings.managed" />}
>
<div data-test-eholdings-resource-show-url>
<ExternalLink
href={model.url}
target="_blank"
rel="noopener noreferrer"
/>
</div>
</KeyValue>
</Col>
)}
{hasInheritedProxy && (
<Col {...COL_SIZES}>
{!proxyTypes.request.isResolved || model.isLoading
? <Icon icon="spinner-ellipsis" />
: (
<ProxyDisplay
proxy={model.proxy}
proxyTypesRecords={proxyTypes.resolver.state.proxyTypes.records}
inheritedProxyId={model.package.proxy.id}
/>
)}
</Col>
)}
{hasProxiedUrl && (
<Col {...COL_SIZES}>
<KeyValue label={<FormattedMessage id="ui-eholdings.proxiedUrl" />}>
<ExternalLink
href={model.proxy.proxiedUrl}
target="_blank"
rel="noopener noreferrer"
/>
</KeyValue>
</Col>
)}
{isAccessStatusTypes && (
<Col {...COL_SIZES}>
<div data-test-eholdings-access-type>
{haveAccessTypesLoaded
? (
<AccessTypeDisplay
accessTypeId={getAccessTypeId(model)}
accessStatusTypes={accessStatusTypes}
/>
)
: <Icon icon="spinner-ellipsis" />
}
</div>
</Col>
)}
</Row>
</Accordion>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ describe('Given ResourceSettings', () => {
title: {
isTitleCustom: false,
},
proxy: {
proxiedUrl: 'http://some.proxied.url',
},
package: defaultPackage,
data: {
relationships: {
Expand Down Expand Up @@ -142,17 +145,35 @@ describe('Given ResourceSettings', () => {
});
expect(component.getByText('ui-eholdings.managed')).toBeDefined();
});
});

it('should display a managed link', () => {
component = renderResourceSettings();
expect(component.getByText('some-url')).toBeDefined();
});
});

it('should render proxy display', () => {
component = renderResourceSettings();
expect(component.getByText('Proxy display')).toBeDefined();
});

it('should display a link', () => {
it('should show proxied url', () => {
component = renderResourceSettings();
expect(component.getByText('some-url')).toBeDefined();

expect(component.getByText('http://some.proxied.url')).toBeDefined();
});

describe('when there is no proxiedUrl in the proxy', () => {
it('should not show proxied url', () => {
component = renderResourceSettings({
model: {
...defaultModel,
proxy: {},
},
});

expect(component.queryByText('http://some.proxied.url')).not.toBeInTheDocument();
});
});

it('should render access type display', () => {
Expand Down
1 change: 1 addition & 0 deletions translations/ui-eholdings/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@
"settings.usageConsolidation.credentials.systemError": "Usage Consolidation credentials cannot be saved due to a system error. Please try again.",

"proxy": "Proxy",
"proxiedUrl": "Proxied URL",
"proxy.inherited": "Inherited - {proxy}",
"proxy.errorMessage": "Invalid proxy selected. Please contact EBSCO support.",

Expand Down

0 comments on commit 8519c6d

Please sign in to comment.