Skip to content

Commit

Permalink
Support #35284 - Add attachments on MolecularAnalysisRun
Browse files Browse the repository at this point in the history
- Removed edit buttons for attachment if not in edit mode.
- Updated test.
  • Loading branch information
brandonandre committed Dec 3, 2024
1 parent e974f94 commit 3f2119a
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { ColumnDef } from "@tanstack/react-table";
import { DinaMessage } from "../../../intl/dina-ui-intl";
import { GenericMolecularAnalysis } from "packages/dina-ui/types/seqdb-api/resources/GenericMolecularAnalysis";
import { AttachmentsEditor } from "../../object-store/attachment-list/AttachmentsField";
import { AttachmentReadOnlySection } from "../../object-store/attachment-list/AttachmentReadOnlySection";

export interface MolecularAnalysisRunStepProps {
molecularAnalysisId: string;
Expand Down Expand Up @@ -43,7 +44,8 @@ export function MolecularAnalysisRunStep({
sequencingRunName,
sequencingRunItems,
attachments,
setAttachments
setAttachments,
sequencingRunId
} = useGenericMolecularAnalysisRun({
editMode,
setEditMode,
Expand Down Expand Up @@ -200,15 +202,28 @@ export function MolecularAnalysisRunStep({
</div>
<div className="col-12 mt-3">
<DinaForm initialValues={{}}>
<AttachmentsEditor
attachmentPath={``}
name="attachments"
onChange={setAttachments}
value={attachments}
title={
<DinaMessage id="molecularAnalysisRunStep_attachments" />
}
/>
{editMode ? (
<AttachmentsEditor
attachmentPath={``}
name="attachments"
onChange={setAttachments}
value={attachments}
title={
<DinaMessage id="molecularAnalysisRunStep_attachments" />
}
/>
) : (
<>
{sequencingRunId && (
<AttachmentReadOnlySection
attachmentPath={`seqdb-api/molecular-analysis-run/${sequencingRunId}/attachments`}
title={
<DinaMessage id="molecularAnalysisRunStep_attachments" />
}
/>
)}
</>
)}
</DinaForm>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const mockGet = jest.fn<any, any>(async (path, params) => {
return { data: TEST_MOLECULAR_ANALYSIS_RUN };

case "objectstore-api/metadata":
case "seqdb-api/molecular-analysis-run/" +
TEST_MOLECULAR_ANALYSIS_RUN_ID +
"/attachments":
return {
data: [TEST_METADATA]
};
Expand Down Expand Up @@ -75,6 +78,7 @@ const mockBulkGet = jest.fn(async (paths) => {

// Attachments
case "metadata/7f3eccfa-3bc1-412f-9385-bb00e2319ac6?include=derivatives":
case "metadata/7f3eccfa-3bc1-412f-9385-bb00e2319ac6?include=acMetadataCreator,derivatives":
return TEST_METADATA;
}
});
Expand Down Expand Up @@ -414,7 +418,7 @@ describe("Molecular Analysis Workflow - Step 4 - Molecular Analysis Run Step", (
expect(wrapper.queryByText(/edit mode: false/i)).toBeInTheDocument();

// Switch into edit mode:
userEvent.click(wrapper.getByRole("button", { name: /edit/i }));
userEvent.click(wrapper.getByRole("button", { name: "Edit" }));
expect(wrapper.queryByText(/edit mode: true/i)).toBeInTheDocument();

// Change the sequencing run name to something different.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ export interface UseGenericMolecularAnalysisRunReturn {
*/
sequencingRunItems?: SequencingRunItem[];

/**
* UUID of the sequencing run.
*/
sequencingRunId?: string;

/**
* Displays the current attachments. This is used since the run not might exist yet and can't
* be saved directly.
Expand Down Expand Up @@ -487,7 +492,8 @@ export function useGenericMolecularAnalysisRun({
setSequencingRunName,
sequencingRunItems,
attachments,
setAttachments
setAttachments,
sequencingRunId: sequencingRun?.id
};
}

Expand Down

0 comments on commit 3f2119a

Please sign in to comment.