Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mint custom datapublications #1529 #1531 #1537

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
6457580
#1529 - add generate DOI button that checks ismintable
louise-davies May 25, 2023
aafb082
#1529 #1531 add basic DOI form and link it from the cart
louise-davies May 26, 2023
63b2a43
#1531 - fetch list of users for every item in the cart
louise-davies May 26, 2023
30d8b3c
#1531 - add selected user table & allow for deletion of users other t…
louise-davies May 26, 2023
f8fb7b8
#1531 - improve acceptDataPolicy look
louise-davies May 26, 2023
cdd334a
#1531 - implement add users ability
louise-davies Jun 1, 2023
ee6f393
#1531 - connect check user functionality to backend properly
louise-davies Jun 2, 2023
962a19c
#1531 - add simple summary table
louise-davies Jun 2, 2023
16c811c
#1529 - Fix typo that prevented single item carts from being minted
louise-davies Jun 5, 2023
7c54914
#1531 - hide cart tabs that are empty and select a non-empty one by d…
louise-davies Jun 5, 2023
be61457
#1531 - add mint DOI functionality
louise-davies Jun 6, 2023
e0b8e7d
#1531 - add DOI confirmation dialogue
louise-davies Jun 7, 2023
2bcd899
#1531 - change email to username in DOI creators stuff
louise-davies Jun 7, 2023
aaa1940
#1531 - prevent mint DOI page from being accessed directly
louise-davies Jun 7, 2023
43fd8b6
#1531 - improve layout on larger screens
louise-davies Jun 13, 2023
8f26a07
Fix dark mode issues with buttons & tabs
louise-davies Jun 23, 2023
78d9404
#1531 - fix a few more dark mode things
louise-davies Jun 23, 2023
7bdc362
#1529 #1531 - don't pass empty arrays to minting API
louise-davies Jun 23, 2023
47cb969
#1529 - highlight which rows a user doesn't have permission to mint
louise-davies Jun 27, 2023
2809289
Fix table row hover
louise-davies Jun 27, 2023
e45c51a
#1529 - improve hover detection for row highlighting
louise-davies Jun 28, 2023
ebc33d5
#1529 #1531 - extract strings to translation file
louise-davies Jul 3, 2023
f339c61
#1529 #1531 - fix broken unit tests
louise-davies Jul 4, 2023
3f0a920
#1529 #1531 - add unit tests for minting api hooks
louise-davies Jul 5, 2023
591f818
#1291 - add tests for mint cart button
louise-davies Jul 6, 2023
701b742
#1531 - add tests for DOIGenerationForm
louise-davies Jul 7, 2023
77ced80
#1531 - add DOIConfirmDialog tests
louise-davies Jul 18, 2023
ffe241b
#1531 - fix names of tests & decrease characters typed
louise-davies Jul 18, 2023
f60a9a4
#1529 #1531 add e2e tests for doi minting stuff
louise-davies Jul 31, 2023
5a10957
Fix yaml syntax error
louise-davies Jul 31, 2023
a2a7332
Fix path
louise-davies Jul 31, 2023
a787f87
Fix python-icat code
louise-davies Jul 31, 2023
dc6d86a
Fix python syntax
louise-davies Jul 31, 2023
22988ff
Remove unnecessary command
louise-davies Jul 31, 2023
92af2ac
Remove quotes from config.env file
louise-davies Jul 31, 2023
be56ea1
Debug docker command
louise-davies Jul 31, 2023
fbe606a
Fix docker env file flag
louise-davies Aug 1, 2023
cecdb1d
Fix docker localhost
louise-davies Aug 1, 2023
e03d43b
Add detached flag back in
louise-davies Aug 1, 2023
f425b47
Debug icat config changes
louise-davies Aug 1, 2023
4ed6f55
More debugging
louise-davies Aug 1, 2023
f0b53d0
More debugging
louise-davies Aug 1, 2023
f559199
Remove debugging messages & restart glassfish
louise-davies Aug 1, 2023
8d74c25
Restart payara in different way
louise-davies Aug 1, 2023
a0a33ad
Add sudo to restart payara command
louise-davies Aug 1, 2023
630208f
Fix adminUserNames in TopCAT
louise-davies Aug 1, 2023
d3f0815
Use python2 for Topcat reinstall
louise-davies Aug 1, 2023
00cb5ed
Fix dataset card view e2e tests that failed on the 1st of the month
louise-davies Aug 2, 2023
b2a6bda
Merge branch 'develop' into feature/mint-custom-datapublications-#152…
louise-davies Aug 17, 2023
eadd66f
#1531 add ability to add contributors
louise-davies Aug 17, 2023
4843b61
#1531 add unit tests for contributors feature
louise-davies Aug 17, 2023
8e716e6
#1531 - add e2e test for add contributors feature
louise-davies Aug 17, 2023
8da01ec
#1531 - fix mint API interfacing by accounting for new params/new re…
louise-davies Sep 8, 2023
0432fa8
Merge branch 'develop' into feature/mint-custom-datapublications-#152…
louise-davies Oct 24, 2023
65401fd
#1531 - fix unit tests broken by DOI API changes
louise-davies Oct 24, 2023
327acc0
Fix e2e test broken by merge conflict
louise-davies Oct 24, 2023
0b09966
#1531 - fix CI by changing topcat to datagateway-download-api
louise-davies Oct 24, 2023
2c06af2
Add initialQueryOffset to admin downloads query key
louise-davies Oct 24, 2023
8696948
Fix CI build
louise-davies Oct 25, 2023
5ff4cfe
Merge branch 'develop' into feature/mint-custom-datapublications-#152…
louise-davies Oct 25, 2023
59392b3
#1531 add related items functionality
louise-davies Oct 27, 2023
674f00c
#1531 - extract out users & related dois components & write unit test…
louise-davies Nov 1, 2023
32f4ab6
#1531 - add e2e test for related DOIs
louise-davies Nov 2, 2023
ab61bd3
#1531 - render related DOIs as links + show title on hover
louise-davies Nov 2, 2023
d133ba8
#1531 - set minWidths for selects & disable add user buttons when car…
louise-davies Nov 2, 2023
0fa5ed4
#1531 - fix some tests
louise-davies Nov 2, 2023
7d6e862
Increase Jest timeouts
louise-davies Nov 2, 2023
b04e9a0
Merge branch 'develop' into feature/mint-custom-datapublications-#152…
louise-davies Jan 15, 2024
959e853
Remove .only from test & fix settings context declaration
louise-davies Jan 17, 2024
f59f3b8
#1529 #1531 - fix how we send entity IDs to minter DOI
louise-davies Jan 17, 2024
93796b0
#1531 fix test error by updating api error message when an invalid us…
louise-davies Jan 17, 2024
ae1fb81
Fix casing
louise-davies Jan 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/add_doi_datapublicationtype.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from icat.client import Client

client = Client(
"https://localhost:8181",
checkCert=False,
)
client.login("simple", {"username": "root", "password": "pw"})

data_publication_type = client.new("dataPublicationType")
data_publication_type.name = "User-defined"
data_publication_type.description = "User-defined"
data_publication_type.facility = client.get("Facility", 1)
data_publication_type.create()
18 changes: 18 additions & 0 deletions .github/config.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
ICAT_URL=https://host.docker.internal:8181
FACILITY=LILS
ICAT_USERNAME=root
ICAT_PASSWORD=pw
PUBLISHER=test
MINTER_ROLE=PI
VERSION=0.01

ICAT_DOI_BASE_URL=https://example.stfc.ac.uk/
ICAT_SESSION_PATH=/icat/session/
ICAT_AUTHENTICATOR_NAME=simple
ICAT_CHECK_CERT=False
SSL_CERT_VERIFICATION=False

DATACITE_PREFIX=10.5286
DATACITE_URL=https://api.test.datacite.org/dois
DATACITE_USERNAME=BL.STFC

35 changes: 33 additions & 2 deletions .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,21 @@ jobs:
ansible-playbook icat-ansible/icat_test_hosts.yml -i icat-ansible/hosts --vault-password-file icat-ansible/vault_pass.txt -vv

# Fixes on ICAT components needed for e2e tests
- name: Add anon user to rootUserNames
- name: Removing authenticator prefix for simple auth
run: |
awk -F" =" '/rootUserNames/{$2="= simple/root anon/anon";print;next}1' /home/runner/install/icat.server/run.properties > /home/runner/install/icat.server/run.properties.tmp
sed -i 's/mechanism = simple/!mechanism = simple/' /home/runner/install/authn.simple/run.properties
- name: Adding Chris481 user
run: |
sed -i '/user\.list/ s/$/ Chris481/' /home/runner/install/authn.simple/run.properties
- name: Adding Chris481 user password
run: |
echo "user.Chris481.password = pw" >> /home/runner/install/authn.simple/run.properties
- name: Reinstall authn.simple
run: |
cd /home/runner/install/authn.simple/ && ./setup -vv install
- name: Add anon, root (simple without prefix) and Chris481 users to rootUserNames
run: |
awk -F" =" '/rootUserNames/{$2="= root Chris481 anon/anon";print;next}1' /home/runner/install/icat.server/run.properties > /home/runner/install/icat.server/run.properties.tmp
- name: Apply rootUserNames change
run: |
mv -f /home/runner/install/icat.server/run.properties.tmp /home/runner/install/icat.server/run.properties
Expand All @@ -260,6 +272,15 @@ jobs:
- name: Reinstall IDS Server
run: |
cd /home/runner/install/ids.server/ && python2 ./setup -vv install
- name: Add root (simple without prefix) to datagateway-download-api adminUserNames
run: |
awk -F" =" '/adminUserNames/{$2="= root";print;next}1' /home/runner/install/datagateway-download-api/run.properties > /home/runner/install/datagateway-download-api/run.properties.tmp
- name: Apply adminUserNames change
run: |
mv -f /home/runner/install/datagateway-download-api/run.properties.tmp /home/runner/install/datagateway-download-api/run.properties
- name: Reinstall datagateway-download-api
run: |
cd /home/runner/install/datagateway-download-api/ && python2 ./setup -vv install

# Disable Globus for Download e2e tests
- name: Login to ICAT
Expand Down Expand Up @@ -299,6 +320,16 @@ jobs:
- name: Start API
run: cd datagateway-api/; nohup poetry run python -m datagateway_api.src.main > api-output.txt &

# DOI minter setup
- name: Adding 'User-defined' DataPublicationType (needed for DOI minting api)
run: cd datagateway-api/; poetry run python ../.github/add_doi_datapublicationtype.py

- name: 'Add password to env file'
run: echo DATACITE_PASSWORD=${{ secrets.DATACITE_PASSWORD }} >> ./.github/config.env

- name: Run minting api
run: docker run --env-file ./.github/config.env -p 8000:8000 --add-host host.docker.internal:host-gateway -d harbor.stfc.ac.uk/icat/doi-mint-api

# E2E tests
- name: Setup Node.js
uses: actions/setup-node@e33196f7422957bea03ed53f6fbb155025ffc7b8 # v3
Expand Down
14 changes: 9 additions & 5 deletions packages/datagateway-common/src/api/cart.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { renderHook } from '@testing-library/react-hooks';
import axios from 'axios';
import axios, { AxiosError } from 'axios';
import { useCart, useAddToCart, useRemoveFromCart } from '.';
import { DownloadCart } from '../app.types';
import handleICATError from '../handleICATError';
Expand Down Expand Up @@ -122,9 +122,11 @@ describe('Cart api functions', () => {
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',
response: {
status: 431,
},
message: 'Test 431 error message',
})
} as AxiosError)
.mockRejectedValue({
message: 'Test error message',
});
Expand Down Expand Up @@ -184,9 +186,11 @@ describe('Cart api functions', () => {
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',
response: {
status: 431,
},
message: 'Test 431 error message',
})
} as AxiosError)
.mockRejectedValue({
message: 'Test error message',
});
Expand Down
4 changes: 2 additions & 2 deletions packages/datagateway-common/src/api/cart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const useAddToCart = (
},
retry: (failureCount, error) => {
// if we get 431 we know this is an intermittent error so retry
if (error.code === '431' && failureCount < 3) {
if (error.response?.status === 431 && failureCount < 3) {
return true;
} else {
return false;
Expand Down Expand Up @@ -141,7 +141,7 @@ export const useRemoveFromCart = (
},
retry: (failureCount, error) => {
// if we get 431 we know this is an intermittent error so retry
if (error.code === '431' && failureCount < 3) {
if (error.response?.status === 431 && failureCount < 3) {
return true;
} else {
return false;
Expand Down
2 changes: 2 additions & 0 deletions packages/datagateway-common/src/app.types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ export interface User {
id: number;
name: string;
fullName?: string;
email?: string;
affiliation?: string;
}

export interface Sample {
Expand Down
35 changes: 14 additions & 21 deletions packages/datagateway-common/src/table/table.component.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import TableCell from '@mui/material/TableCell';
import { styled, SxProps, Theme, useTheme } from '@mui/material/styles';
import { styled, SxProps } from '@mui/material/styles';
import {
AutoSizer,
Column,
Expand Down Expand Up @@ -31,6 +31,9 @@ const dataColumnMinWidth = 84;

const StyledTable = styled(Table)(({ theme }) => ({
fontFamily: theme.typography.fontFamily,
'.hoverable-row:hover': {
backgroundColor: theme.palette.action.hover,
},
}));

const flexContainerStyle = {
Expand All @@ -48,12 +51,10 @@ const headerFlexContainerStyle = {

const tableRowStyle = {};

// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
const getTableRowHoverStyle = (theme: Theme) => ({
'&:hover': {
backgroundColor: theme.palette.action.hover,
},
});
const tableRowStyleCombined = {
...tableRowStyle,
...flexContainerStyle,
};

const tableCellStyle = {
flex: 1,
Expand Down Expand Up @@ -140,7 +141,6 @@ const VirtualizedTable = React.memo(
const [expandedIndex, setExpandedIndex] = React.useState(-1);
const [detailPanelHeight, setDetailPanelHeight] = React.useState(rowHeight);
const [lastChecked, setLastChecked] = React.useState(-1);
const theme = useTheme();

let tableRef: Table | null = null;
const detailPanelRef = React.useRef<HTMLDivElement>(null);
Expand Down Expand Up @@ -256,18 +256,10 @@ const VirtualizedTable = React.memo(
[detailPanelHeight, expandedIndex]
);

const getRowStyle = React.useCallback(
({ index }: Index): React.CSSProperties => {
const tableRowHoverStyle =
index > -1 ? getTableRowHoverStyle(theme) : {};
return {
...tableRowStyle,
...flexContainerStyle,
...tableRowHoverStyle,
};
},
[theme]
);
const getRowClassName = React.useCallback(({ index }: Index) => {
return index > -1 ? 'hoverable-row' : '';
}, []);

const getRow = React.useCallback(
({ index }: Index): Entity => data[index],
[data]
Expand Down Expand Up @@ -353,7 +345,8 @@ const VirtualizedTable = React.memo(
onRowsRendered={onRowsRendered}
headerHeight={headerHeight}
rowHeight={getRowHeight}
rowStyle={getRowStyle}
rowStyle={tableRowStyleCombined}
rowClassName={getRowClassName}
rowGetter={getRow}
rowRenderer={renderRow}
// Disable tab focus on whole table for accessibility;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,7 @@ describe('DLS - Datasets Cards', () => {
// check that count is correct after filtering
cy.get('[data-testid="card"]').first().contains('15');

cy.get('input[id="Create Time filter from"]').type('2019-01-01');
cy.wait(['@getDatasetsCount'], { timeout: 10000 });
cy.get('[data-testid="card"]').first().contains('DATASET 61');

cy.get('input[aria-label="Create Time filter to"]')
cy.get('input[aria-label="Start Date filter to"]')
.parent()
.find('button')
.click();
Expand All @@ -136,10 +132,16 @@ describe('DLS - Datasets Cards', () => {
date.setDate(1);
date.setMonth(0);
date.setFullYear(2020);
cy.get('input[id="Create Time filter to"]').should(
cy.get('input[id="Start Date filter to"]').should(
'have.value',
date.toISOString().slice(0, 10)
);
cy.wait(['@getDatasetsCount'], { timeout: 10000 });
cy.get('[data-testid="card"]').first().contains('DATASET 61');

cy.get('input[id="Start Date filter from"]').type('2019-01-01');
cy.wait(['@getDatasetsCount'], { timeout: 10000 });

cy.get('[data-testid="card"]').should('not.exist');
});
});
Loading