Skip to content

Commit 7371b47

Browse files
authored
Feature/manually add related work (#1112)
1 parent 6615a1d commit 7371b47

File tree

26 files changed

+1548
-671
lines changed

26 files changed

+1548
-671
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
## Added
2+
- Added ability to manually add a related work via a DOI [#835]
23
- Added a shared `utils/apolloErrorHandler.ts` file to handle `AbortError` related to the updated Apollo Client v4 [#1094]
34
- Added new graphql queries `MetadataStandardsByURIs` and `RepositoriesByURIs` to get the preferred standards and repos for the Research Output Answer modals [#1094]
45
- Added `errorTypePolicies` to use in the `apollo-wrapper.tsx` file, due to changes in Apollo's default caching and merge behavior. Setting "merge: false" always replaces new data, instead of trying to merge error objects [#1089]

app/[locale]/projects/[projectId]/dmp/[dmpid]/members/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import { addPlanMemberAction } from './actions/addPlanMemberAction';
5050
import { ProjectMembersInterface } from '@/app/types';
5151
import { routePath } from '@/utils/routes';
5252
import styles from './ProjectsProjectPlanAdjustMembers.module.scss';
53-
import { orcidToUrl } from "@/lib/idToUrl";
53+
import { orcidToUrl } from "@/lib/identifierUtils";
5454

5555
interface PlanMemberDropdown {
5656
id: string;

app/[locale]/projects/[projectId]/dmp/[dmpid]/related-works/__tests__/page.spec.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ import { RelatedWorksByPlanDocument } from "@/generated/graphql";
1111
import {
1212
MOCK_ACCEPTED_WORKS,
1313
MOCK_PENDING_WORKS,
14-
MOCK_REJECTED_WORKS,
15-
} from "@/components/RelatedWorksList/__tests__/index.spec";
14+
MOCK_REJECTED_WORKS
15+
} from "@/app/[locale]/projects/[projectId]/dmp/[dmpid]/related-works/mockWorks";
1616

1717
expect.extend(toHaveNoViolations);
1818

@@ -87,14 +87,16 @@ describe("RelatedWorks", () => {
8787

8888
it("should render the page header with correct title and description", () => {
8989
render(<RelatedWorksHarness />);
90-
expect(screen.getByText("header.title")).toBeInTheDocument();
91-
expect(screen.getByText("header.description")).toBeInTheDocument();
90+
expect(screen.getByRole("heading", { level: 1, name: 'title' })).toBeInTheDocument();
91+
expect(screen.getByText("description")).toBeInTheDocument();
9292
});
9393

9494
it("should render the breadcrumb links", () => {
9595
render(<RelatedWorksHarness />);
96-
expect(screen.getByText("Home")).toBeInTheDocument();
97-
expect(screen.getByText("Projects")).toBeInTheDocument();
96+
expect(screen.getByText("breadcrumbs.home")).toBeInTheDocument();
97+
expect(screen.getByText("breadcrumbs.projects")).toBeInTheDocument();
98+
expect(screen.getByText("breadcrumbs.projectOverview")).toBeInTheDocument();
99+
expect(screen.getByText("breadcrumbs.planOverview")).toBeInTheDocument();
98100
});
99101

100102
it("should render tabs", () => {
@@ -200,7 +202,7 @@ describe("RelatedWorks", () => {
200202
});
201203

202204
render(<RelatedWorksHarness />);
203-
const addButton = screen.getByRole("button", { name: "buttons.addRelatedWorkManually" });
205+
const addButton = screen.getByRole("link", { name: "buttons.addRelatedWorkManually" });
204206
expect(addButton).toBeInTheDocument();
205207
});
206208

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
"use server";
2+
3+
import { executeGraphQLMutation } from "@/utils/server/graphqlServerActionHandler";
4+
import { ActionResponse } from "@/app/types";
5+
import { UpsertRelatedWorkDocument, RelatedWorkStatus } from "@/generated/graphql";
6+
7+
export async function upsertRelatedWorkAction({ planId, doi, hash, status }: { planId: number; doi: string; hash: string, status: RelatedWorkStatus }): Promise<ActionResponse> {
8+
return await executeGraphQLMutation({
9+
document: UpsertRelatedWorkDocument,
10+
variables: { input: { planId, doi, hash, status } },
11+
dataPath: "upsertRelatedWork",
12+
});
13+
}
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
@use "@/styles/responsive.scss" as *;
2+
3+
.relatedWorksItem {
4+
padding: 1.25rem 0.8rem 1.25rem var(--space-4);
5+
border-radius: var(--card-border-radius);
6+
background: var(--bg-white);
7+
box-shadow: var(--card-shadow);
8+
border: 1px solid var(--card-border);
9+
}
10+
11+
.overview {
12+
display: flex;
13+
flex-direction: column;
14+
}
15+
16+
.overviewHeader {
17+
display: flex;
18+
flex-direction: column;
19+
gap: 0.5rem;
20+
21+
@include device(md) {
22+
flex-direction: row;
23+
gap: 1rem;
24+
}
25+
}
26+
27+
.overviewTitle {
28+
display: flex;
29+
flex-direction: column;
30+
flex: 1;
31+
min-width: 0;
32+
33+
h3 {
34+
margin: 0;
35+
padding: 0 0 0.2rem;
36+
line-height: var(--lh-tight) !important;
37+
display: -webkit-box;
38+
line-clamp: 2;
39+
-webkit-line-clamp: 2;
40+
-webkit-box-orient: vertical;
41+
overflow: hidden;
42+
text-overflow: ellipsis;
43+
44+
a {
45+
color: var(--text-color);
46+
font-size: var(--fs-lg);
47+
font-weight: var(--fw-bold);
48+
line-height: var(--lh-tight) !important;
49+
}
50+
}
51+
52+
h4 {
53+
color: var(--gray-600);
54+
font-size: var(--fs-base);
55+
font-weight: var(--fw-normal);
56+
line-height: var(--lh-tight);
57+
margin: 0;
58+
display: -webkit-box;
59+
line-clamp: 2;
60+
-webkit-line-clamp: 2;
61+
-webkit-box-orient: vertical;
62+
overflow: hidden;
63+
text-overflow: ellipsis;
64+
}
65+
}
66+
67+
.overviewHeaderActions {
68+
padding-top: 0.1rem;
69+
display: flex;
70+
gap: 1rem;
71+
align-items: flex-start;
72+
}
73+
74+
.overviewFooter {
75+
display: flex;
76+
flex-direction: column;
77+
gap: 1rem;
78+
79+
@include device(md) {
80+
flex-direction: row;
81+
justify-content: space-between;
82+
}
83+
}
84+
85+
.overviewMetadata {
86+
display: flex;
87+
gap: var(--space-4);
88+
color: var(--gray-500);
89+
font-size: var(--fs-small);
90+
font-weight: var(--fw-normal);
91+
padding-top: 1rem;
92+
}
93+
94+
.status {
95+
line-height: 1.1rem;
96+
color: var(--text-color);
97+
font-weight: var(--fw-bold);
98+
padding-top: 0.1rem;
99+
padding-right: var(--space-2);
100+
}
101+
102+
.overviewFooterActions {
103+
display: flex;
104+
flex-direction: row;
105+
align-items: flex-end;
106+
justify-content: flex-start;
107+
gap: var(--space-2);
108+
margin-right: 0.5rem;
109+
110+
@include device(md) {
111+
flex-direction: row;
112+
justify-content: space-between;
113+
}
114+
}
115+
116+
.sourceUrl {
117+
color: var(--gray-500) !important;
118+
}
119+
120+
.searchSection {
121+
margin-bottom: 2rem;
122+
}

0 commit comments

Comments
 (0)