Skip to content

Commit

Permalink
Merge pull request #1296 from ral-facilities/release/v1.1.0
Browse files Browse the repository at this point in the history
Release v1.1.0
  • Loading branch information
louise-davies authored Jun 23, 2022
2 parents 3a5073e + d0feb83 commit 7324fc0
Show file tree
Hide file tree
Showing 87 changed files with 3,247 additions and 1,984 deletions.
11 changes: 8 additions & 3 deletions .github/workflows/release-build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Release Build
on:
push:
branches: main
branches:
- main
- develop
tags: '*'

jobs:
Expand Down Expand Up @@ -44,6 +46,9 @@ jobs:
if [ "${{ github.ref }}" = "refs/heads/main" ]
then
echo TAG_NAME=snapshot >> $GITHUB_ENV
elif [ "${{ github.ref }}" = "refs/heads/develop" ]
then
echo TAG_NAME=snapshot-develop >> $GITHUB_ENV
else
echo TAG_NAME=`basename ${{ github.ref }}` >> $GITHUB_ENV
fi
Expand Down Expand Up @@ -78,7 +83,7 @@ jobs:
tag_name: ${{ env.TAG_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ github.ref == 'refs/heads/main' }}
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' }}

- name: Create/update release
uses: johnwbyrd/[email protected]
Expand All @@ -87,5 +92,5 @@ jobs:
files: ./datagateway-dataview-${{ env.TAG_NAME }}.tar.gz ./datagateway-download-${{ env.TAG_NAME }}.tar.gz ./datagateway-search-${{ env.TAG_NAME }}.tar.gz
release: Release ${{ env.TAG_NAME }}
tag: ${{ env.TAG_NAME }}
prerelease: ${{ github.ref == 'refs/heads/main' }}
prerelease: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' }}
draft: false
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ npm-debug.log*
yarn-debug.log*
yarn-error.log*

**/public/settings.json
**/public/datagateway-dataview-settings.json
**/public/datagateway-download-settings.json
**/public/datagateway-search-settings.json
**/public/*settings*.json
!**/public/*settings.example.json

5 changes: 5 additions & 0 deletions CHANGELOG-BASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## [v1.0.0](https://github.com/ral-facilities/datagateway/tree/v1.0.0) (2022-03-31)

Initial release for ISIS
38 changes: 38 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,43 @@
# Changelog

## [v1.1.0](https://github.com/ral-facilities/datagateway/tree/v1.1.0) (2022-06-21)

[Full Changelog](https://github.com/ral-facilities/datagateway/compare/v1.0.0...v1.1.0)

**Implemented enhancements:**

- \#1174 - changed Title icon to Subject icon [\#1259](https://github.com/ral-facilities/datagateway/pull/1259) ([LunaBarrett](https://github.com/LunaBarrett))
- Customising notification message if it concerns session expiry \#1209 [\#1248](https://github.com/ral-facilities/datagateway/pull/1248) ([sam-glendenning](https://github.com/sam-glendenning))
- Adding alert label if file/size limit exceeded in selections table \#1183 [\#1228](https://github.com/ral-facilities/datagateway/pull/1228) ([sam-glendenning](https://github.com/sam-glendenning))
- Download tables sort by requested time descending by default \#1176 [\#1226](https://github.com/ral-facilities/datagateway/pull/1226) ([sam-glendenning](https://github.com/sam-glendenning))
- Adding ability to use DatePicker or DateTimePicker in date filter column \#1175 [\#1216](https://github.com/ral-facilities/datagateway/pull/1216) ([sam-glendenning](https://github.com/sam-glendenning))
- Refactor download cart to improve performance [\#1185](https://github.com/ral-facilities/datagateway/pull/1185) ([louise-davies](https://github.com/louise-davies))

**Fixed bugs:**

- Errors when multi selecting items for the cart [\#1210](https://github.com/ral-facilities/datagateway/issues/1210)
- Bugfix/disable download button \#1261 [\#1266](https://github.com/ral-facilities/datagateway/pull/1266) ([louise-davies](https://github.com/louise-davies))
- Bugfix/fix token refresh error \#1257 [\#1262](https://github.com/ral-facilities/datagateway/pull/1262) ([louise-davies](https://github.com/louise-davies))
- \#1196 - Use MUI theme background colour for breadcrumb gaps [\#1253](https://github.com/ral-facilities/datagateway/pull/1253) ([louise-davies](https://github.com/louise-davies))
- Fix breadcrumbs visual glitch [\#1252](https://github.com/ral-facilities/datagateway/pull/1252) ([louise-davies](https://github.com/louise-davies))
- Prevent querying for cart on homepage & fix admin download table queries [\#1250](https://github.com/ral-facilities/datagateway/pull/1250) ([louise-davies](https://github.com/louise-davies))
- Preventing download of empty files \#1195 [\#1232](https://github.com/ral-facilities/datagateway/pull/1232) ([sam-glendenning](https://github.com/sam-glendenning))
- Fix selection errors \#1210 [\#1231](https://github.com/ral-facilities/datagateway/pull/1231) ([louise-davies](https://github.com/louise-davies))

**Security fixes:**

- Bump async from 2.6.3 to 2.6.4 [\#1274](https://github.com/ral-facilities/datagateway/pull/1274) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump minimist from 1.2.5 to 1.2.6 [\#1197](https://github.com/ral-facilities/datagateway/pull/1197) ([dependabot[bot]](https://github.com/apps/dependabot))

**Merged pull requests:**

- Merge main into develop [\#1288](https://github.com/ral-facilities/datagateway/pull/1288) ([louise-davies](https://github.com/louise-davies))
- Bump ejs from 3.1.6 to 3.1.7 [\#1245](https://github.com/ral-facilities/datagateway/pull/1245) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump node-forge from 1.2.1 to 1.3.0 [\#1179](https://github.com/ral-facilities/datagateway/pull/1179) ([dependabot[bot]](https://github.com/apps/dependabot))

## [v1.0.0](https://github.com/ral-facilities/datagateway/tree/v1.0.0) (2022-03-31)

Initial release for ISIS


\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
6 changes: 4 additions & 2 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"packages": ["packages/*"],
"version": "0.0.0",
"packages": [
"packages/*"
],
"version": "1.1.0",
"npmClient": "yarn",
"useWorkspaces": true
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "datagateway",
"private": true,
"version": "1.0.0",
"version": "1.1.0",
"workspaces": [
"packages/*"
],
Expand Down
4 changes: 2 additions & 2 deletions packages/datagateway-common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "datagateway-common",
"version": "1.0.0",
"version": "1.1.0",
"private": true,
"files": [
"lib"
Expand Down Expand Up @@ -115,4 +115,4 @@
],
"resetMocks": false
}
}
}
53 changes: 34 additions & 19 deletions packages/datagateway-common/src/api/cart.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,15 @@ describe('Cart api functions', () => {
expect(result.current.data).toEqual(mockData.cartItems);
});

it('sends axios request to add item to cart once mutate function is called and calls handleICATError on failure', async () => {
(axios.post as jest.Mock).mockRejectedValue({
message: 'Test error message',
});
it('sends axios request to add item to cart once mutate function is called and calls handleICATError on failure, with a retry on code 431', async () => {
(axios.post as jest.MockedFunction<typeof axios.post>)
.mockRejectedValueOnce({
code: '431',
message: 'Test 431 error message',
})
.mockRejectedValue({
message: 'Test error message',
});

const { result, waitFor } = renderHook(() => useAddToCart('dataset'), {
wrapper: createReactQueryWrapper(),
Expand All @@ -133,8 +138,10 @@ describe('Cart api functions', () => {

result.current.mutate([1, 2]);

await waitFor(() => result.current.isError);
await waitFor(() => result.current.isError, { timeout: 2000 });

expect(result.current.failureCount).toBe(2);
expect(handleICATError).toHaveBeenCalledTimes(1);
expect(handleICATError).toHaveBeenCalledWith({
message: 'Test error message',
});
Expand All @@ -143,7 +150,7 @@ describe('Cart api functions', () => {

describe('useRemoveFromCart', () => {
it('sends axios request to remove item from cart once mutate function is called and returns successful response', async () => {
(axios.delete as jest.Mock).mockResolvedValue({
(axios.post as jest.Mock).mockResolvedValue({
data: mockData,
});

Expand All @@ -161,22 +168,28 @@ describe('Cart api functions', () => {

await waitFor(() => result.current.isSuccess);

expect(axios.delete).toHaveBeenCalledWith(
const params = new URLSearchParams();
params.append('sessionId', '');
params.append('items', 'dataset 1, dataset 2');
params.append('remove', 'true');

expect(axios.post).toHaveBeenCalledWith(
'https://example.com/topcat/user/cart/TEST/cartItems',
{
params: {
sessionId: null,
items: 'dataset 1, dataset 2',
},
}

params
);
expect(result.current.data).toEqual(mockData.cartItems);
});

it('sends axios request to remove item from cart once mutate function is called and calls handleICATError on failure', async () => {
(axios.delete as jest.Mock).mockRejectedValue({
message: 'Test error message',
});
it('sends axios request to remove item from cart once mutate function is called and calls handleICATError on failure, with a retry on code 431', async () => {
(axios.post as jest.MockedFunction<typeof axios.post>)
.mockRejectedValueOnce({
code: '431',
message: 'Test 431 error message',
})
.mockRejectedValue({
message: 'Test error message',
});

const { result, waitFor } = renderHook(
() => useRemoveFromCart('dataset'),
Expand All @@ -185,13 +198,15 @@ describe('Cart api functions', () => {
}
);

expect(axios.delete).not.toHaveBeenCalled();
expect(axios.post).not.toHaveBeenCalled();
expect(result.current.isIdle).toBe(true);

result.current.mutate([1, 2]);

await waitFor(() => result.current.isError);
await waitFor(() => result.current.isError, { timeout: 2000 });

expect(result.current.failureCount).toBe(2);
expect(handleICATError).toHaveBeenCalledTimes(1);
expect(handleICATError).toHaveBeenCalledWith({
message: 'Test error message',
});
Expand Down
63 changes: 35 additions & 28 deletions packages/datagateway-common/src/api/cart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import {
useMutation,
UseMutationResult,
} from 'react-query';
import retryICATErrors from './retryICATErrors';

const fetchDownloadCart = (config: {
export const fetchDownloadCart = (config: {
facilityName: string;
downloadApiUrl: string;
}): Promise<DownloadCartItem[]> => {
Expand All @@ -27,15 +28,19 @@ const fetchDownloadCart = (config: {
.then((response) => response.data.cartItems);
};

const addToCart = (
const addOrRemoveFromCart = (
entityType: 'investigation' | 'dataset' | 'datafile',
entityIds: number[],
config: { facilityName: string; downloadApiUrl: string }
config: { facilityName: string; downloadApiUrl: string },
remove?: boolean
): Promise<DownloadCartItem[]> => {
const { facilityName, downloadApiUrl } = config;
const params = new URLSearchParams();
params.append('sessionId', readSciGatewayToken().sessionId || '');
params.append('items', `${entityType} ${entityIds.join(`, ${entityType} `)}`);
if (typeof remove !== 'undefined') {
params.append('remove', remove.toString());
}

return axios
.post<DownloadCart>(
Expand All @@ -45,26 +50,6 @@ const addToCart = (
.then((response) => response.data.cartItems);
};

const removeFromCart = (
entityType: 'investigation' | 'dataset' | 'datafile',
entityIds: number[],
config: { facilityName: string; downloadApiUrl: string }
): Promise<DownloadCartItem[]> => {
const { facilityName, downloadApiUrl } = config;

return axios
.delete<DownloadCart>(
`${downloadApiUrl}/user/cart/${facilityName}/cartItems`,
{
params: {
sessionId: readSciGatewayToken().sessionId,
items: `${entityType} ${entityIds.join(`, ${entityType} `)}`,
},
}
)
.then((response) => response.data.cartItems);
};

export const useCart = (): UseQueryResult<DownloadCartItem[], AxiosError> => {
const downloadApiUrl = useSelector(
(state: StateType) => state.dgcommon.urls.downloadApiUrl
Expand All @@ -86,6 +71,7 @@ export const useCart = (): UseQueryResult<DownloadCartItem[], AxiosError> => {
onError: (error) => {
handleICATError(error);
},
retry: retryICATErrors,
staleTime: 0,
}
);
Expand All @@ -104,14 +90,22 @@ export const useAddToCart = (

return useMutation(
(entityIds: number[]) =>
addToCart(entityType, entityIds, {
addOrRemoveFromCart(entityType, entityIds, {
facilityName,
downloadApiUrl,
}),
{
onSuccess: (data) => {
queryClient.setQueryData('cart', data);
},
retry: (failureCount, error) => {
// if we get 431 we know this is an intermittent error so retry
if (error.code === '431' && failureCount < 3) {
return true;
} else {
return false;
}
},
onError: (error) => {
handleICATError(error);
},
Expand All @@ -132,14 +126,27 @@ export const useRemoveFromCart = (

return useMutation(
(entityIds: number[]) =>
removeFromCart(entityType, entityIds, {
facilityName,
downloadApiUrl,
}),
addOrRemoveFromCart(
entityType,
entityIds,
{
facilityName,
downloadApiUrl,
},
true
),
{
onSuccess: (data) => {
queryClient.setQueryData('cart', data);
},
retry: (failureCount, error) => {
// if we get 431 we know this is an intermittent error so retry
if (error.code === '431' && failureCount < 3) {
return true;
} else {
return false;
}
},
onError: (error) => {
handleICATError(error);
},
Expand Down
5 changes: 5 additions & 0 deletions packages/datagateway-common/src/api/datafiles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
useInfiniteQuery,
UseInfiniteQueryResult,
} from 'react-query';
import retryICATErrors from './retryICATErrors';

const fetchDatafiles = (
apiUrl: string,
Expand Down Expand Up @@ -94,6 +95,7 @@ export const useDatafilesPaginated = (
onError: (error) => {
handleICATError(error);
},
retry: retryICATErrors,
}
);
};
Expand Down Expand Up @@ -126,6 +128,7 @@ export const useDatafilesInfinite = (
onError: (error) => {
handleICATError(error);
},
retry: retryICATErrors,
}
);
};
Expand Down Expand Up @@ -182,6 +185,7 @@ export const useDatafileCount = (
onError: (error) => {
handleICATError(error);
},
retry: retryICATErrors,
}
);
};
Expand Down Expand Up @@ -229,6 +233,7 @@ export const useDatafileDetails = (
onError: (error) => {
handleICATError(error);
},
retry: retryICATErrors,
}
);
};
Expand Down
Loading

0 comments on commit 7324fc0

Please sign in to comment.