Skip to content

Commit

Permalink
5.2.1 release (#63)
Browse files Browse the repository at this point in the history
* 5.2.1 release
  • Loading branch information
melil02 authored Jun 23, 2023
1 parent cfe0299 commit 6c08d90
Show file tree
Hide file tree
Showing 24 changed files with 755 additions and 514 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"get-intrinsic": "~1.1.3",
"serialize-javascript": "~3.1.0",
"qs": "6.9.7",
"ua-parser-js": "0.7.35",
"url-parse": "^1.5.9",
"fast-json-patch": "3.1.1"
}
Expand Down
4 changes: 3 additions & 1 deletion packages/layer7-apihub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@material-ui/core": "~4.9.3",
"@material-ui/lab": "~4.0.0-alpha.45",
"@rehooks/local-storage": "~2.4.0",
"decode-uri-component": "0.2.1",
"final-form-calculate": "~1.3.2",
"focus-trap-react": "~6.0.0",
"jsencrypt": "~3.0.0-rc.1",
Expand All @@ -28,12 +29,13 @@
"react-dnd": "~10.0.2",
"react-dnd-html5-backend": "~10.0.2",
"react-markdown-editor-lite": "~1.0.2",
"trim": "0.0.3",
"recompose":"~0.30.0",
"remark-parse": "9.0.0",
"remark-react": "~7.0.1",
"remove-markdown": "~0.3.0",
"slugify": "~1.4.4",
"swagger-ui-react": "~3.27.0",
"trim": "0.0.3",
"unified": "~8.4.2"
},
"peerDependencies": {
Expand Down
9 changes: 8 additions & 1 deletion packages/layer7-apihub/src/apis/ApiAssetsField.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,10 @@ export const ApiAssetsField = props => {

export const AssetsList = ({ record, links, ...rest }) => {
const { urlWithTenant } = useApiHub();
const { apiServiceType, publishedByPortal } = record;

const isGatewayPublishedSoapApi =
apiServiceType === 'SOAP' && !publishedByPortal;
return (
<>
<List {...rest}>
Expand All @@ -70,7 +73,11 @@ export const AssetsList = ({ record, links, ...rest }) => {
<ListItem key={link.id} disableGutters>
<Link
type={link.type}
href={`${urlWithTenant}${link.href}`}
href={
isGatewayPublishedSoapApi
? `${link.href}`
: `${urlWithTenant}${link.href}`
}
download={link.name}
>
{link.name}
Expand Down
16 changes: 5 additions & 11 deletions packages/layer7-apihub/src/apis/Application/ApiApplications.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ export const ApiApplications = ({ id }) => {
React.useEffect(() => {
let active = true;

if (!search || search.length < 2) {
return undefined;
}

(async () => {
const [data, total] = await fetchApplications(search);

Expand All @@ -71,10 +67,8 @@ export const ApiApplications = ({ id }) => {
setApplications(data);
setLoading(false);
} else if (applications.length < total) {
setApplications(
uniqBy([ ...applications, ...data ], 'uuid')
);
setCurrentPage(currentPage+1);
setApplications(uniqBy([...applications, ...data], 'uuid'));
setCurrentPage(currentPage + 1);
} else {
setLoading(false);
}
Expand Down Expand Up @@ -102,10 +96,10 @@ export const ApiApplications = ({ id }) => {
open={open}
onOpen={() => setOpen(true)}
onClose={(event, reason) => setOpen(false)}
onChange={(event, app, reason) => {
setSelectedApp(app)
onChange={(event, app, reason) => {
setSelectedApp(app);
if (reason == 'clear') {
setApplications([])
setApplications([]);
}
}}
getOptionSelected={(option, value) =>
Expand Down
45 changes: 30 additions & 15 deletions packages/layer7-apihub/src/apis/Application/ApiApplications.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,16 @@ describe('Applications', () => {
id: 3,
name: 'application 3',
},
{
id: 4,
name: 'app 4',
},
{
id: 5,
name: 'app 5',
},
],
total: 3,
total: 5,
}),
};

Expand All @@ -64,22 +72,29 @@ describe('Applications', () => {
initialState
);

await wait(() => {
const select = getByLabelText(
'resources.apis.specification.actions.search_or_select_application'
);
fireEvent.mouseDown(select);
// Enter search criteria
fireEvent.change(select, { target: { value: 'application' } });
});
const select = getByLabelText(
'resources.apis.specification.actions.search_or_select_application'
);

await wait(() => {
expect(queryByText('application 1')).not.toBeNull();
expect(queryByText('application 2')).not.toBeNull();
expect(queryByText('application 3')).not.toBeNull();
});
// Show all applications when select when no search criteria
await wait(() => fireEvent.mouseDown(select));
expect(queryByText('application 1')).not.toBeNull();
expect(queryByText('application 2')).not.toBeNull();
expect(queryByText('application 3')).not.toBeNull();
expect(queryByText('app 4')).not.toBeNull();
expect(queryByText('app 5')).not.toBeNull();

expect.assertions(3);
// Enter search criteria
await wait(() =>
fireEvent.change(select, { target: { value: 'application' } })
);
expect(queryByText('application 1')).not.toBeNull();
expect(queryByText('application 2')).not.toBeNull();
expect(queryByText('application 3')).not.toBeNull();
expect(queryByText('app 4')).toBeNull();
expect(queryByText('app 5')).toBeNull();

expect.assertions(10);
});

test('should display the selected application credentials', async () => {
Expand Down
15 changes: 15 additions & 0 deletions packages/layer7-apihub/src/applications/ApplicationDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Typography from '@material-ui/core/Typography';
import List from '@material-ui/core/List';
import { makeStyles } from '@material-ui/core/styles';
import sortBy from 'lodash/sortBy';
import get from 'lodash/get';

import { useUserContext } from '../userContexts';
import { ApplicationApisList } from './ApplicationApisList';
Expand Down Expand Up @@ -54,6 +55,19 @@ export const ApplicationDetails = ({ record }) => {
resource: 'applications',
payload: { id: record.id },
});

const { data: applicationApiKeyExpirySettings } = useQuery({
type: 'getKeyExpirySettings',
resource: 'applications',
payload: {},
});

const isKeyExpiryEnabled = get(
applicationApiKeyExpirySettings,
'enabled',
false
);

React.useEffect(() => {
if (apisData && apisData.length > 0) {
setApiIds(apisData.map(item => item.uuid));
Expand Down Expand Up @@ -256,6 +270,7 @@ export const ApplicationDetails = ({ record }) => {
key={apiKey.id}
data={apiKey}
includeSecret={true}
isKeyExpiryEnabled={isKeyExpiryEnabled}
labelClasses={contentLabelClasses}
dataProvider={dataProvider}
refreshApiKeys={fetchApiKeys}
Expand Down
106 changes: 103 additions & 3 deletions packages/layer7-apihub/src/applications/ApplicationDetailsKeyClient.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { Fragment } from 'react';
import { Labeled, TextField } from 'react-admin';
import { useTranslate } from 'ra-core';
import Grid from '@material-ui/core/Grid';
Expand All @@ -13,6 +13,7 @@ import ExpansionPanel from '@material-ui/core/ExpansionPanel';
import ExpansionPanelSummary from '@material-ui/core/ExpansionPanelSummary';
import ExpansionPanelDetails from '@material-ui/core/ExpansionPanelDetails';
import classnames from 'classnames';
import moment from 'moment';

import { useCopyToClipboard } from '../ui';

Expand All @@ -33,6 +34,11 @@ const getStatusColor = (classes, status) => {
statusLabel: 'Delete_Failed',
statusColorClass: classes.disabled,
};
case 'EXPIRED':
return {
statusLabel: 'Expired',
statusColorClass: classes.expired,
};
default:
return {
statusLabel: 'Disabled',
Expand All @@ -42,7 +48,7 @@ const getStatusColor = (classes, status) => {
};

export const ApplicationDetailsKeyClient = props => {
const { data, includeSecret } = props;
const { data, includeSecret, isKeyExpiryEnabled } = props;
const classes = useStyles();
const translate = useTranslate();
const copyToClipboard = useCopyToClipboard({
Expand All @@ -58,6 +64,56 @@ export const ApplicationDetailsKeyClient = props => {
data.status
);

const getExpiryDateText = data => {
let expiryDateText = translate(
'resources.applications.fields.none'
);
const secretExpiryTs = data.secretExpiryTs;
if (isKeyExpiryEnabled && secretExpiryTs) {
const keyExpiryDate = moment(secretExpiryTs);
expiryDateText = keyExpiryDate.format(
'dddd, MMMM Do YYYY, HH:mm:ss'
);
}
return expiryDateText;
};

const getExpiryDateSubText = data => {
let expiryDateSubText = '';
const secretExpiryTs = data.secretExpiryTs;
const keyStatus = data.status;
if (isKeyExpiryEnabled && secretExpiryTs) {
const keyExpiryDate = moment(secretExpiryTs);
const currentTime = moment();
if (keyStatus === 'EXPIRED') {
expiryDateSubText = translate(
'resources.applications.status.expired'
);
} else {
const days = keyExpiryDate.diff(currentTime, 'days');
let suffix = translate(
'resources.applications.fields.days'
);
if (days === 1) {
suffix = translate(
'resources.applications.fields.day'
);
}
expiryDateSubText = `${days} ${suffix}`;
}
}
return expiryDateSubText;
};

const getExpiryDateSubTextClass = data => {
let expiryDateSubTextClass = '';
const keyStatus = data.status;
if (keyStatus === 'EXPIRED') {
expiryDateSubTextClass = classes.expiredKeyStatus;
}
return expiryDateSubTextClass;
};

return (
<ListItem
disableGutters
Expand Down Expand Up @@ -225,7 +281,7 @@ export const ApplicationDetailsKeyClient = props => {
</Grid>
)}
</Grid>
<Grid>
<Grid container>
{data.oauthType && (
<Grid item md={6} sm={6} xs={12}>
<Labeled
Expand All @@ -245,6 +301,40 @@ export const ApplicationDetailsKeyClient = props => {
</Labeled>
</Grid>
)}
{isKeyExpiryEnabled && (
<Grid item md={6} sm={6} xs={12}>
<Labeled
// On <Labeled />, this will translate in a correct `for` attribute on the label
id="expiryDate"
label={
'resources.applications.fields.expiryDate'
}
classes={classes}
className={classes.fieldLabel}
>
<Fragment>
<Typography
variant="body2"
className={classes.fieldContent}
>
<span
className={classes.fieldValue}
>
{getExpiryDateText(data)}
</span>
</Typography>
<Typography
className={getExpiryDateSubTextClass(
data
)}
variant="body2"
>
{getExpiryDateSubText(data)}
</Typography>
</Fragment>
</Labeled>
</Grid>
)}
</Grid>
</ExpansionPanelDetails>
</ExpansionPanel>
Expand Down Expand Up @@ -277,6 +367,16 @@ const useStyles = makeStyles(
backgroundColor: '#4CAF50',
},
},
expired: {
color: '#B30303',
'&:before': {
backgroundColor: '#B30303',
},
},
expiredKeyStatus: {
color: '#B30303',
fontFamily: 'clear-sans-bold',
},
disabled: {
color: '#696969',
'&:before': {
Expand Down
Loading

0 comments on commit 6c08d90

Please sign in to comment.