Skip to content

Commit

Permalink
feat(backend): delete response headers, add hint that files are uploa…
Browse files Browse the repository at this point in the history
…ding, redirect after success
  • Loading branch information
TobiasKampmann committed Feb 12, 2024
1 parent e53ead0 commit dd95149
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 74 deletions.
2 changes: 1 addition & 1 deletion website/src/components/ConfirmationDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type ConfirmationDialogProps = {

type DisplayConfirmationProps = {
dialogText: string;
onConfirmation: () => void;
onConfirmation: () => Promise<void>;
};

export const ConfirmationDialog: FC<ConfirmationDialogProps> = ({ dialogText, onConfirmation, onClose }) => {
Expand Down
13 changes: 8 additions & 5 deletions website/src/components/DataUploadForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
dataUseTermsTypes,
openDataUseTermsType,
restrictedDataUseTermsType,
type SubmissionIdMapping,
} from '../types/backend.ts';
import type { ClientConfig } from '../types/runtimeConfig.ts';
import { dateTimeInMonths } from '../utils/DateTimeInMonths.tsx';
Expand All @@ -30,7 +29,7 @@ type DataUploadFormProps = {
organism: string;
clientConfig: ClientConfig;
action: Action;
onSuccess: (value: SubmissionIdMapping[]) => void;
onSuccess: () => void;
onError: (message: string) => void;
};

Expand Down Expand Up @@ -112,8 +111,6 @@ const InnerDataUploadForm = ({
revise({ metadataFile, sequenceFile });
break;
}
// TODO(#702): Redirect to the review page after submission is successful
// window.location.href = routes.userSequenceReviewPage(organism);
};

useEffect(() => {
Expand Down Expand Up @@ -264,6 +261,12 @@ const InnerDataUploadForm = ({
{isLoading ? <CircularProgress size={20} color='primary' /> : 'Submit'}
</button>
</div>

<div className='text-gray-500'>
{isLoading
? 'Uploading files. Please wait. Depending on the size of the files this can take a while'
: ''}
</div>
</form>
);
};
Expand All @@ -274,7 +277,7 @@ function useSubmitFiles(
accessToken: string,
organism: string,
clientConfig: ClientConfig,
onSuccess: (value: SubmissionIdMapping[]) => void,
onSuccess: () => void,
onError: (message: string) => void,
) {
const hooks = backendClientHooks(clientConfig);
Expand Down
27 changes: 5 additions & 22 deletions website/src/components/Revision/RevisionForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type FC, useState } from 'react';
import { type FC } from 'react';

import type { SubmissionIdMapping } from '../../types/backend.ts';
import { routes } from '../../routes.ts';
import type { ClientConfig } from '../../types/runtimeConfig.ts';
import { DataUploadForm } from '../DataUploadForm.tsx';
import { ManagedErrorFeedback, useErrorFeedbackState } from '../common/ManagedErrorFeedback';
Expand All @@ -12,8 +12,6 @@ type RevisionFormProps = {
};

export const RevisionForm: FC<RevisionFormProps> = ({ accessToken, organism, clientConfig }) => {
const [responseSequenceHeaders, setResponseSequenceHeaders] = useState<SubmissionIdMapping[] | null>(null);

const { errorMessage, isErrorOpen, openErrorFeedback, closeErrorFeedback } = useErrorFeedbackState();

return (
Expand All @@ -25,25 +23,10 @@ export const RevisionForm: FC<RevisionFormProps> = ({ accessToken, organism, cli
clientConfig={clientConfig}
action='revise'
onError={openErrorFeedback}
onSuccess={setResponseSequenceHeaders}
onSuccess={() => {
window.location.href = routes.userSequenceReviewPage(organism);
}}
/>

<div>
{responseSequenceHeaders ? (
<div className='p-6 space-y-6 w-full'>
<h2 className='text-lg font-bold'>Result of Revision</h2>
<ul className='list-disc list-inside'>
{responseSequenceHeaders.map((header) => (
<li key={header.accession}>
Sequence {header.accession} successful revised; new version is {header.version}
</li>
))}
</ul>
</div>
) : (
<div className='font-bold'>No data submitted yet</div>
)}
</div>
</div>
);
};
5 changes: 0 additions & 5 deletions website/src/components/Submission/SubmissionForm.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ describe('SubmitForm', () => {

const submitButton = getByText('Submit');
await userEvent.click(submitButton);

await waitFor(() => {
expect(getByText((text) => text.includes('header0'))).toBeInTheDocument();
expect(getByText((text) => text.includes('header1'))).toBeInTheDocument();
});
});

test('should answer with feedback that a file is missing', async () => {
Expand Down
40 changes: 5 additions & 35 deletions website/src/components/Submission/SubmissionForm.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { type FC, useState } from 'react';
import { type FC } from 'react';

import { type SubmissionIdMapping, restrictedDataUseTermsType } from '../../types/backend.ts';
import { routes } from '../../routes.ts';
import type { ClientConfig } from '../../types/runtimeConfig.ts';
import { getAccessionVersionString } from '../../utils/extractAccessionVersion.ts';
import { DataUploadForm } from '../DataUploadForm.tsx';
import { ManagedErrorFeedback, useErrorFeedbackState } from '../common/ManagedErrorFeedback';

Expand All @@ -13,8 +12,6 @@ type SubmissionFormProps = {
};

export const SubmissionForm: FC<SubmissionFormProps> = ({ accessToken, organism, clientConfig }) => {
const [responseSequenceHeaders, setResponseSequenceHeaders] = useState<SubmissionIdMapping[] | null>(null);

const { errorMessage, isErrorOpen, openErrorFeedback, closeErrorFeedback } = useErrorFeedbackState();

return (
Expand All @@ -26,37 +23,10 @@ export const SubmissionForm: FC<SubmissionFormProps> = ({ accessToken, organism,
clientConfig={clientConfig}
action='submit'
onError={openErrorFeedback}
onSuccess={setResponseSequenceHeaders}
onSuccess={() => {
window.location.href = routes.userSequenceReviewPage(organism);
}}
/>

<div>
{responseSequenceHeaders ? (
<FormatResponseSequenceHeaders responseSequenceHeaders={responseSequenceHeaders} />
) : (
<div className='font-bold'>No data submitted yet</div>
)}
</div>
</div>
);
};
type FormatResponseSequenceHeadersProps = {
responseSequenceHeaders: SubmissionIdMapping[];
};
const FormatResponseSequenceHeaders: FC<FormatResponseSequenceHeadersProps> = ({ responseSequenceHeaders }) => {
return (
<div className='p-6 space-y-6 w-full'>
<h2 className='text-lg font-bold'>Response Sequence Headers</h2>
<ul className='list-disc list-inside'>
{responseSequenceHeaders.map((header) => (
<li key={header.accession}>
{getAccessionVersionString(header)}: {header.submissionId} ({header.dataUseTerms?.type}
{header.dataUseTerms?.type === restrictedDataUseTermsType
? ` until: ${header.dataUseTerms.restrictedUntil}`
: ''}
)
</li>
))}
</ul>
</div>
);
};
3 changes: 1 addition & 2 deletions website/tests/pages/revise/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ test.describe('The revise page', () => {

await revisePage.submitRevisedData(sequenceEntries.map((entry) => entry.accession));

// TODO(#702): Redirect to the review page after submission is successful
// await revisePage.page.waitForURL(`${baseUrl}${routes.userSequenceReviewPage(dummyOrganism.key)}`);
await revisePage.page.waitForURL(`${baseUrl}${routes.userSequenceReviewPage(dummyOrganism.key)}`);
});
});
7 changes: 3 additions & 4 deletions website/tests/pages/submit/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ test.describe('The submit page', () => {

await submitPage.submitButton.click();

// TODO(#702): Redirect to the review page after submission is successful
// await submitPage.page.waitForURL(`${baseUrl}${routes.userSequenceReviewPage(dummyOrganism.key)}`);
await submitPage.page.waitForURL(`${baseUrl}${routes.userSequenceReviewPage(dummyOrganism.key)}`);
});

test('should upload compressed files and submit', async ({ submitPage, loginAsTestUser }) => {
Expand All @@ -24,11 +23,11 @@ test.describe('The submit page', () => {

await submitPage.submitButton.click();

// TODO(#702): Redirect to the review page after submission is successful
// await submitPage.page.waitForURL(`${baseUrl}${routes.userSequenceReviewPage(dummyOrganism.key)}`);
await submitPage.page.waitForURL(`${baseUrl}${routes.userSequenceReviewPage(dummyOrganism.key)}`);
});

test('should set data use terms', async ({ submitPage, loginAsTestUser }) => {
test.skip();
await loginAsTestUser();
await submitPage.goto();

Expand Down

0 comments on commit dd95149

Please sign in to comment.