Skip to content

Commit fe978cf

Browse files
authored
5.1.2 release (#51)
1 parent 477de50 commit fe978cf

File tree

20 files changed

+432
-141
lines changed

20 files changed

+432
-141
lines changed

cypress/integration/applications.js

100755100644
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,22 @@ describe('Applications', () => {
9797
// Details
9898
cy.findByLabelText('Generate New Secret').should('not.exist');
9999
});
100+
it('should NOT show Generate New Secret when Application status is DELETE_APPLICATION_PENDING_APPROVAL for an org user', () => {
101+
login('orgPublisher', 'Password@1');
102+
103+
cy.findAllByText('Applications')
104+
.first()
105+
.click();
106+
107+
cy.findByTitle('Display as list').click();
108+
109+
cy.findByTitle('GB International Interactions(Deleting)').click({
110+
force: true,
111+
});
112+
113+
// Details
114+
cy.findByLabelText('Generate New Secret').should('not.exist');
115+
});
100116

101117
context('when editing an application', () => {
102118
it('should allow the changing of an API plan on a selected API', () => {

cypress/integration/newPassword.js

100755100644
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
describe('New Password', () => {
44
it('should not load the new password form', () => {
5-
cy.loadData();
5+
// cy.loadData();
66

77
cy.visit('#/new-password/#token/GildasAndAdrien');
88

@@ -18,7 +18,7 @@ describe('New Password', () => {
1818
});
1919

2020
it('should fill the new password form', () => {
21-
cy.loadData();
21+
// cy.loadData();
2222

2323
cy.visit('#/new-password/#token/Mithrandir');
2424

@@ -58,7 +58,7 @@ describe('New Password', () => {
5858
});
5959

6060
it('should return an error if the password is the same than before', () => {
61-
cy.loadData();
61+
// cy.loadData();
6262

6363
cy.visit('#/new-password/#token/Saruman'); // Mocks will trigger an error for this token
6464

package.json

100755100644
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
"bl": "~4.0.3",
4242
"cypress": "~5.6.0",
4343
"date-fns": "~2.9.0",
44+
"es-abstract": "~1.19.0",
45+
"get-intrinsic": "~1.1.3",
4446
"serialize-javascript": "~3.1.0"
4547
}
4648
}

packages/layer7-apihub-mock/src/defaultData.json

100755100644
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,36 @@
755755
"61bc2c17-19ba-4e01-873f-e3201706908e"
756756
]
757757
},
758+
{
759+
"id": "f6a72eb7-d848-48d2-b33f-5823672cfea5",
760+
"uuid": "f6a72eb7-d848-48d2-b33f-5823672cfea5",
761+
"name": "GB International Interactions(Deleting)",
762+
"status": "DELETE_APPLICATION_PENDING_APPROVAL",
763+
"disabledByType": "EXTERNAL",
764+
"description": "Enhanced bi-directional complexity",
765+
"OauthCallbackUrl": "https://example.com/oauthCallback",
766+
"OauthScope": "OOB",
767+
"OauthType": "confidential",
768+
"apiKey": "fbb71539-e654-434c-ab4d-b83a612fcb6b",
769+
"keySecret": "b47ac256-769d-47f5-9640-8bdc25f1e9b5",
770+
"apiIds": {
771+
"results": [
772+
"9f0ee511-c6ec-4380-8057-43b6bcf49ac4",
773+
"9c531b86-d5f0-46c7-bdd0-d52fc9e1dd9c",
774+
"9e9b888a-8b2e-4a98-aab8-35843b1d3c73",
775+
"04065447-bdf5-4553-8356-ee835150f216",
776+
"61bc2c17-19ba-4e01-873f-e3201706908e",
777+
"8a334a2f-de19-472a-bb11-5a6e38e1c2ee"
778+
]
779+
},
780+
"_accessibleApis": [
781+
"9f0ee511-c6ec-4380-8057-43b6bcf49ac4",
782+
"9c531b86-d5f0-46c7-bdd0-d52fc9e1dd9c",
783+
"9e9b888a-8b2e-4a98-aab8-35843b1d3c73",
784+
"04065447-bdf5-4553-8356-ee835150f216",
785+
"61bc2c17-19ba-4e01-873f-e3201706908e"
786+
]
787+
},
758788
{
759789
"id": "fefbfb9a-9dda-47fd-ba0c-73fbcb17211d",
760790
"uuid": "fefbfb9a-9dda-47fd-ba0c-73fbcb17211d",

packages/layer7-apihub/package.json

100755100644
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
"react-dnd": "~10.0.2",
2929
"react-dnd-html5-backend": "~10.0.2",
3030
"react-markdown-editor-lite": "~1.0.2",
31+
"trim": "0.0.3",
3132
"remark-parse": "7.0.2",
3233
"remark-react": "~7.0.1",
3334
"remove-markdown": "~0.3.0",

packages/layer7-apihub/src/applications/ApplicationList.js

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ const ApplicationFilter = props => {
134134
name: 'resources.applications.status.disabled',
135135
},
136136
{
137-
id: 'APPLICATION_PENDING_APPROVAL',
137+
id: 'APPLICATION_PENDING_APPROVAL,EDIT_APPLICATION_PENDING_APPROVAL,DELETE_APPLICATION_PENDING_APPROVAL',
138138
name:
139139
'resources.applications.status.application_pending_approval',
140140
},

packages/layer7-apihub/src/applications/ApplicationShow.js

100755100644
Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from 'react';
22
import { useHistory } from 'react-router-dom';
3-
import { CRUD_DELETE, useDelete, useTranslate } from 'ra-core';
3+
import { useTranslate } from 'ra-core';
44
import { makeStyles } from '@material-ui/core/styles';
55
import Button from '@material-ui/core/Button';
66
import DeleteIcon from '@material-ui/icons/Delete';
7-
7+
import { useDataProvider, useTranslate } from 'ra-core';
88
import { EditButton, TopToolbar } from 'react-admin';
99
import { Show } from '../ui';
1010
import { ApplicationDetails } from './ApplicationDetails';
@@ -35,6 +35,7 @@ const AppShowActions = ({
3535
const notify = useLayer7Notify();
3636
const contentLabelClasses = useContentStyles();
3737
const history = useHistory();
38+
const dataProvider = useDataProvider();
3839
const [deleting, setDeleting] = React.useState(false);
3940

4041
React.useEffect(() => {
@@ -48,7 +49,9 @@ const AppShowActions = ({
4849
React.useEffect(() => {
4950
if (data && userContext) {
5051
if (
52+
data.status !== 'APPLICATION_PENDING_APPROVAL' &&
5153
data.status !== 'EDIT_APPLICATION_PENDING_APPROVAL' &&
54+
data.status !== 'DELETE_APPLICATION_PENDING_APPROVAL' &&
5255
!userContext.userDetails.developer
5356
) {
5457
setCanDelete(true);
@@ -57,29 +60,44 @@ const AppShowActions = ({
5760
}
5861
}
5962
}, [canDelete, data, userContext]);
60-
61-
const [deleteApplication] = useDelete('applications', data?.id, data, {
62-
action: CRUD_DELETE,
63-
onSuccess: () => {
64-
notify(
65-
'resources.applications.notifications.delete_success',
66-
'info',
67-
{
68-
smart_count: 1,
63+
const notifyAndNavigate = () => {
64+
setDeleting(false);
65+
notify('resources.applications.notifications.delete_success', 'info');
66+
history.push('/applications');
67+
};
68+
const deleteApplication = () => {
69+
dataProvider.delete(
70+
'applications',
71+
{
72+
id: data.id,
73+
},
74+
{
75+
onFailure: error => {
76+
setDeleting(false);
77+
notify(error || 'resources.applications.notifications.delete_error',
78+
'error');
79+
},
80+
onSuccess: delData => {
81+
dataProvider.getOne(
82+
'applications',
83+
{
84+
id: data.id,
85+
},
86+
{
87+
onFailure: error => notifyAndNavigate(error),
88+
onSuccess: getData => {
89+
setDeleting(false);
90+
notify('resources.applications.notifications.delete_request_success',
91+
'info');
92+
history.go(0);
93+
}
94+
}
95+
);
6996
}
70-
);
71-
setDeleting(false);
72-
history.push('/applications');
73-
},
74-
onFailure: error => {
75-
setDeleting(false);
76-
notify(
77-
error || 'resources.applications.notifications.delete_error',
78-
'error'
79-
);
80-
},
81-
});
82-
97+
}
98+
);
99+
};
100+
83101
const confirmDelete = event => {
84102
setDeleteConfirm(true);
85103
};

packages/layer7-apihub/src/applications/isApplicationPending.js

100755100644
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import { isOrgBoundUser } from '../userContexts';
22

33
const STATUS_PENDING_APPROVAL = 'APPLICATION_PENDING_APPROVAL';
44
const STATUS_EDIT_PENDING_APPROVAL = 'EDIT_APPLICATION_PENDING_APPROVAL';
5+
const STATUS_DELETE_PENDING_APPROVAL = 'DELETE_APPLICATION_PENDING_APPROVAL';
56
const DISABLED_BY_TYPE_EXTERNAL = 'EXTERNAL';
67

78
export const isApplicationPendingOrDisabled = (status, disabledByType) => {
89
return (
910
![DISABLED_BY_TYPE_EXTERNAL, null].includes(disabledByType) ||
10-
[STATUS_PENDING_APPROVAL, STATUS_EDIT_PENDING_APPROVAL].includes(status)
11+
[STATUS_PENDING_APPROVAL, STATUS_EDIT_PENDING_APPROVAL, STATUS_DELETE_PENDING_APPROVAL].includes(status)
1112
);
1213
};
1314

packages/layer7-apihub/src/authentication/AccountSetup/TermsDialog.js

100755100644
File mode changed.

packages/layer7-apihub/src/authentication/useResetPassword.js

100755100644
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,16 @@ export const fetchResetPassword = async (
99
username
1010
) => {
1111
const fetchJson = getFetchJson(originHubName);
12+
const headers = new Headers({
13+
'Content-Type': 'application/json; charset=UTF-8',
14+
Accept: 'text/plain, */*; q=0.01',
15+
});
1216

13-
const { json } = await fetchJson(
14-
`${urlWithTenant}/ResetMyPassword()?Username='${username}'`
15-
);
17+
const { json } = await fetchJson(`${urlWithTenant}/reset-my-password`, {
18+
method: 'put',
19+
headers: headers,
20+
body: JSON.stringify({ userName: username }),
21+
});
1622

1723
return await json;
1824
};

packages/layer7-apihub/src/authentication/useResetPassword.test.js

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('useResetPassword', () => {
1717
await fetchResetPassword(url, 'origin', username);
1818

1919
expect(global.fetch.mock.calls[0][0]).toEqual(
20-
`https://marmelab.com/api/apim/ResetMyPassword()?Username='Luwangel'`
20+
`https://marmelab.com/api/apim/reset-my-password`
2121
);
2222
});
2323

packages/layer7-apihub/src/i18n/en.js

100755100644
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ const apiHubMessages = {
375375
rejected: 'Rejected',
376376
application_pending_approval: 'Pending Approval',
377377
edit_application_pending_approval: 'Pending Approval',
378+
delete_application_pending_approval: 'Pending Approval',
378379
},
379380
list: {
380381
sort: {
@@ -407,6 +408,7 @@ const apiHubMessages = {
407408
edit_success: 'Application successfully updated.',
408409
edit_error: 'An error occurred while updating the application.',
409410
delete_success: 'Application successfully deleted.',
411+
delete_request_success: 'Application Delete requested successfully.',
410412
delete_error:
411413
'An error occurred while deleting the application.',
412414
},

packages/layer7-apihub/src/i18n/es.js

100755100644
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ const apiHubMessages = {
390390
rejected: 'Rechazado',
391391
application_pending_approval: 'Pendiente de aprobación',
392392
edit_application_pending_approval: 'Pendiente de aprobación',
393+
delete_application_pending_approval: 'Pendiente de aprobación',
393394
},
394395
list: {
395396
sort: {

packages/layer7-apihub/src/i18n/fr.js

100755100644
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ const apiHubMessages = {
385385
rejected: 'Rejeté',
386386
application_pending_approval: "En attente d'approbation",
387387
edit_application_pending_approval: "En attente d'approbation",
388+
delete_application_pending_approval: "En attente d'approbation",
388389
},
389390
list: {
390391
sort: {

packages/layer7-apihub/src/i18n/it.js

100755100644
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ const apiHubMessages = {
376376
rejected: 'Rifiutato',
377377
application_pending_approval: 'In attesa di approvazione',
378378
edit_application_pending_approval: 'In attesa di approvazione',
379+
delete_application_pending_approval: 'In attesa di approvazione',
379380
},
380381
list: {
381382
sort: {

packages/layer7-apihub/src/index.js

100755100644
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ export * from './documentation';
1515
export * from './homepage';
1616
export * from './i18n';
1717
export * from './preferences';
18+
export * from './userContexts';
1819
export * from './theme';
1920
export * from './ui';
20-
export * from './userContexts';
2121
export * from './userProfiles';
2222
export * from './fetchUtils';
2323
export * from './useLayer7Notify';

packages/layer7-apihub/src/theme/branding.js

100755100644
Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import { useState, useEffect } from 'react';
2+
import { useGetOne, CRUD_GET_ONE } from 'ra-core';
23
import merge from 'lodash/fp/merge';
34
import createMuiTheme from '@material-ui/core/styles/createMuiTheme';
45
import defaultMuiTheme from '@material-ui/core/styles/defaultTheme';
6+
import get from 'lodash/get';
57

68
import { theme } from './theme';
9+
import { isOrgBoundUser } from '../userContexts';
710
import { getFetchJson } from '../fetchUtils';
811

12+
const LOGGED_IN = '@layer7/authentication/loggedIn';
13+
914
const convertBrandingToMuiTheme = themeBranding => {
1015
const { color, typography } = themeBranding;
1116
const palette = {
@@ -109,19 +114,43 @@ const convertBrandingToMuiTheme = themeBranding => {
109114
};
110115
};
111116

112-
export const fetchBranding = async (url, originHubName) => {
117+
export const fetchBranding = async (url, originHubName, userContext) => {
118+
const fetchJson = getFetchJson(originHubName);
119+
// Pass a orgId to fetch org based theme
120+
const options = {};
121+
const isOrgUser = userContext ? isOrgBoundUser(userContext) : false;
122+
if (isOrgUser) {
123+
const orgUuid = get(userContext, 'userDetails.organizationUuid');
124+
options.headers = new Headers({ Accept: 'application/json' });
125+
options.headers.set('APIM-OrgUuid', orgUuid);
126+
}
127+
const { json } = await fetchJson(`${url}/branding/1.0/themes`, options);
128+
return json;
129+
};
130+
131+
export const fetchUserContext = async (url, originHubName) => {
113132
const fetchJson = getFetchJson(originHubName);
114-
const { json } = await fetchJson(`${url}/branding/1.0/themes`);
133+
const { json } = await fetchJson(`${url}/userContexts`);
115134
return json;
116135
};
117136

118137
export const useBranding = (url, originHubName, defaultTheme = theme) => {
119138
const [brandingTheme, setBrandingTheme] = useState(defaultTheme);
120139
const [brandingLogo, setBrandingLogo] = useState('');
121140
const [brandingFavicon, setBrandingFavicon] = useState('');
141+
const [userContext, setUserContext] = useState('');
142+
143+
useEffect(() => {
144+
if (JSON.parse(sessionStorage.getItem(LOGGED_IN))) {
145+
fetchUserContext(url, originHubName).then(response => {
146+
setUserContext(get(response, 'userContexts[0]'));
147+
});
148+
}
149+
}, [originHubName, url]);
150+
122151
useEffect(() => {
123152
if (global.APIHUB_CONFIG.USE_BRANDING_THEME) {
124-
fetchBranding(url, originHubName)
153+
fetchBranding(url, originHubName, userContext)
125154
.then(theme => {
126155
return {
127156
logo: theme.logo,
@@ -139,7 +168,7 @@ export const useBranding = (url, originHubName, defaultTheme = theme) => {
139168
setBrandingFavicon(null);
140169
setBrandingTheme(defaultTheme);
141170
}
142-
}, [defaultTheme, originHubName, url]);
171+
}, [defaultTheme, originHubName, url, userContext]);
143172

144173
return {
145174
logo: brandingLogo,

packages/layer7-apihub/src/ui/Markdown/MarkdownInput.js

100755100644
File mode changed.

0 commit comments

Comments
 (0)