Skip to content

Commit d176b60

Browse files
pa-lembilalabbad
andauthored
Tasks pagination fix in proposed changes (#4434)
* update pagination in query * update error and loading screen * remove loading test * add changelog * pair review --------- Co-authored-by: bilalabbad <[email protected]>
1 parent 7c595b8 commit d176b60

File tree

4 files changed

+38
-28
lines changed

4 files changed

+38
-28
lines changed

changelog/4434.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixes the tasks pagination in the proposed changes tab

frontend/app/src/graphql/queries/tasks/getTasksItems.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import Handlebars from "handlebars";
22

33
export const getTasksItems = Handlebars.compile(`
4-
query GetTasks {
5-
{{kind}}({{{filters}}} {{#if relatedNode}}related_node__ids: ["{{relatedNode}}"]{{/if}}) {
4+
query GetTasks($offset: Int, $limit: Int) {
5+
{{kind}}(offset: $offset, limit: $limit, {{#if relatedNode}}related_node__ids: ["{{relatedNode}}"]{{/if}}) {
66
count
77
edges {
88
node {

frontend/app/src/pages/proposed-changes/details.tsx

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ import { proposedChangedState } from "@/state/atoms/proposedChanges.atom";
1717
import { constructPath } from "@/utils/fetch";
1818
import { Icon } from "@iconify-icon/react";
1919
import { useAtom } from "jotai";
20-
import { Link, Navigate, useLocation, useParams } from "react-router-dom";
20+
import { Link, useLocation, useParams } from "react-router-dom";
2121
import { StringParam, useQueryParam } from "use-query-params";
2222
import LoadingScreen from "@/screens/loading-screen/loading-screen";
2323
import { ProposedChangesChecksTab } from "@/screens/proposed-changes/checks-tab";
2424
import { ProposedChangeDetails } from "@/screens/proposed-changes/proposed-change-details";
25-
import { NetworkStatus } from "@apollo/client";
2625
import { CoreProposedChange } from "@/generated/graphql";
2726
import { Badge } from "@/components/ui/badge";
2827
import { getObjectDetailsUrl } from "@/utils/objects";
2928
import { ObjectHelpButton } from "@/components/menu/object-help-button";
3029
import { useSchema } from "@/hooks/useSchema";
30+
import NoDataFound from "@/screens/errors/no-data-found";
3131

3232
export const PROPOSED_CHANGES_TABS = {
3333
CONVERSATIONS: "conversations",
@@ -105,30 +105,19 @@ export function Component() {
105105
const { proposedChangeId } = useParams();
106106
const { schema } = useSchema(PROPOSED_CHANGES_OBJECT);
107107

108-
const { loading, networkStatus, error, data, client } = useQuery(GET_PROPOSED_CHANGE_DETAILS, {
109-
notifyOnNetworkStatusChange: true,
108+
const { loading, error, data, client } = useQuery(GET_PROPOSED_CHANGE_DETAILS, {
110109
variables: {
111110
id: proposedChangeId,
112111
nodeId: proposedChangeId, // Used for tasks, which is a different type
113112
},
114113
});
115114

116-
if (networkStatus === NetworkStatus.loading) {
115+
if (loading) {
117116
return <LoadingScreen className="m-auto h-auto" />;
118117
}
119118

120-
if (error) {
121-
return (
122-
<ErrorScreen message="Something went wrong when fetching the proposed changes details." />
123-
);
124-
}
125-
126119
const proposedChangesData = data?.[PROPOSED_CHANGES_OBJECT]?.edges?.[0]?.node;
127120

128-
if (!proposedChangesData) {
129-
return <Navigate to={constructPath("/proposed-changes")} />;
130-
}
131-
132121
const tabs = [
133122
{
134123
label: "Overview",
@@ -162,6 +151,37 @@ export function Component() {
162151
},
163152
];
164153

154+
if (error || !proposedChangesData) {
155+
return (
156+
<Content>
157+
<Content.Title
158+
title={
159+
<div className="flex items-center gap-2">
160+
<Link
161+
className="no-underline hover:underline"
162+
to={constructPath("/proposed-changes")}>
163+
Proposed changes
164+
</Link>
165+
</div>
166+
}
167+
reload={() => client.reFetchObservableQueries()}
168+
isReloadLoading={loading}>
169+
<ObjectHelpButton
170+
documentationUrl={schema?.documentation}
171+
kind={PROPOSED_CHANGES_OBJECT}
172+
className="ml-auto"
173+
/>
174+
</Content.Title>
175+
176+
{error && (
177+
<ErrorScreen message="Something went wrong when fetching the proposed changes details." />
178+
)}
179+
180+
{!proposedChangesData && <NoDataFound message="No proposed changes found." />}
181+
</Content>
182+
);
183+
}
184+
165185
return (
166186
<Content>
167187
<Content.Title

frontend/app/src/screens/tasks/task-items.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { DurationDisplay } from "@/components/display/duration-display";
99
import { Id } from "@/components/ui/id";
1010
import { QSP } from "@/config/qsp";
1111
import { getTasksItems } from "@/graphql/queries/tasks/getTasksItems";
12-
import usePagination from "@/hooks/usePagination";
1312
import ErrorScreen from "@/screens/errors/error-screen";
1413
import LoadingScreen from "@/screens/loading-screen/loading-screen";
1514
import { constructPath } from "@/utils/fetch";
@@ -24,22 +23,12 @@ interface TaskItemsProps {
2423
export const TaskItems = forwardRef(({ hideRelatedNode }: TaskItemsProps, ref) => {
2524
const { objectid, proposedChangeId } = useParams();
2625
const location = useLocation();
27-
const [pagination] = usePagination();
2826

2927
const { pathname } = location;
3028

31-
const filtersString = [
32-
// Add pagination filters
33-
...[
34-
{ name: "offset", value: pagination?.offset },
35-
{ name: "limit", value: pagination?.limit },
36-
].map((row: any) => `${row.name}: ${row.value}`),
37-
].join(",");
38-
3929
const queryString = getTasksItems({
4030
kind: TASK_OBJECT,
4131
relatedNode: objectid || proposedChangeId,
42-
filters: filtersString,
4332
});
4433

4534
const query = gql`

0 commit comments

Comments
 (0)