Skip to content

Commit 2a2442e

Browse files
authored
Add activities for graphql queries (#5962)
* udpate style and add activities for queries * add responsive layout * use code code viewer * fix activities props * update locator for new code viwer * update props and remove useParams * fix props
1 parent 3a6e234 commit 2a2442e

File tree

8 files changed

+41
-50
lines changed

8 files changed

+41
-50
lines changed

frontend/app/src/entities/events/ui/node-details-events.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@ import NoDataFound from "@/shared/components/errors/no-data-found";
66
import { Link } from "@/shared/components/ui/link";
77
import { Spinner } from "@/shared/components/ui/spinner";
88
import React from "react";
9-
import { useParams } from "react-router";
109
import { useEvents } from "../api/get-events.query";
1110
import { EventCard } from "./event-card";
1211

1312
const MAX_EVENTS = 5;
1413

15-
export const NodeEvents = ({ parentId }: { parentId?: string }) => {
16-
const { objectKind, objectid } = useParams();
17-
14+
export const NodeEvents = ({
15+
parentId,
16+
objectId,
17+
objectKind,
18+
}: { parentId?: string; objectId?: string; objectKind?: string }) => {
1819
const { isPending, data, error } = useEvents({
1920
filters: {
2021
parentIds: parentId ? [parentId] : undefined,
21-
relatedNodeIds: objectid ? [objectid] : undefined,
22+
relatedNodeIds: objectId ? [objectId] : undefined,
2223
limit: parentId ? 0 : MAX_EVENTS,
2324
},
2425
});
@@ -28,9 +29,9 @@ export const NodeEvents = ({ parentId }: { parentId?: string }) => {
2829
error: displayLabelError,
2930
data: displayLabelData,
3031
} = useNodeLabel({
31-
objectid: objectid,
32+
objectid: objectId,
3233
kind: objectKind as string,
33-
enabled: !parentId,
34+
enabled: !parentId && !!objectKind,
3435
});
3536

3637
const flatData = React.useMemo(() => data?.pages?.flat() ?? [], [data]);
@@ -53,7 +54,7 @@ export const NodeEvents = ({ parentId }: { parentId?: string }) => {
5354

5455
const filter = {
5556
name: "relatedNodeIds__value",
56-
value: [{ id: objectid, display_label: displayLabelData.display_label }],
57+
value: [{ id: objectId, display_label: displayLabelData.display_label }],
5758
};
5859

5960
return (
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { NodeEvents } from "@/entities/events/ui/node-details-events";
2+
import { Card, CardWithBorder } from "@/shared/components/ui/card";
3+
4+
export const GraphqlQueryActivities = ({ id }: { id: string }) => {
5+
return (
6+
<Card className="p-0 overflow-x-hidden">
7+
<CardWithBorder.Title>Activities</CardWithBorder.Title>
8+
9+
<NodeEvents objectId={id} />
10+
</Card>
11+
);
12+
};

frontend/app/src/entities/graphql/ui/graphql-query-details-card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const GraphqlQueryDetailsCard = ({
2929
permission,
3030
}: GraphqlQueryDetailsCardProps) => {
3131
return (
32-
<Card>
32+
<Card className="p-0 overflow-x-hidden">
3333
<GraphqlQueryDetailsTitle
3434
data={data}
3535
schema={schema}

frontend/app/src/entities/graphql/ui/graphql-query-viewer-card.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import { constructPath } from "@/shared/api/rest/fetch";
22
import { Button } from "@/shared/components/buttons/button-primitive";
33
import { CopyToClipboard } from "@/shared/components/buttons/copy-to-clipboard";
4-
import { GraphqlViewer } from "@/shared/components/editor/graphql/graphql-viewer";
4+
import { CodeViewer } from "@/shared/components/editor/code/code-viewer";
55
import { Card, CardWithBorder } from "@/shared/components/ui/card";
66
import { Icon } from "@iconify-icon/react";
77
import { Link } from "react-router";
88

99
const GraphqlQueryViewerCard = ({ query }: { query: string }) => {
1010
return (
11-
<Card className="flex-grow">
11+
<Card className="flex-grow p-0 overflow-x-hidden">
1212
<CardWithBorder.Title className="flex gap-2 items-center rounded-t">
1313
<h3 className="mr-auto">Query</h3>
1414

@@ -21,7 +21,7 @@ const GraphqlQueryViewerCard = ({ query }: { query: string }) => {
2121
</Link>
2222
</CardWithBorder.Title>
2323

24-
<GraphqlViewer value={query} />
24+
<CodeViewer language="graphql">{query}</CodeViewer>
2525
</Card>
2626
);
2727
};

frontend/app/src/entities/nodes/object-item-details/object-item-details-paginated.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export default function ObjectItemDetails({
5555
hideHeaders,
5656
}: ObjectDetailsProps) {
5757
const location = useLocation();
58-
const { objectid } = useParams();
58+
const { objectKind, objectid } = useParams();
5959
const { pathname } = location;
6060

6161
const [qspTab, setQspTab] = useQueryParam(QSP.TAB, StringParam);
@@ -214,7 +214,7 @@ export default function ObjectItemDetails({
214214

215215
<Card className="p-0 overflow-x-hidden">
216216
<CardWithBorder.Title className="border-b">Activities</CardWithBorder.Title>
217-
<NodeEvents />
217+
<NodeEvents objectId={objectid} objectKind={objectKind} />
218218
</Card>
219219
</div>
220220
)}

frontend/app/src/pages/objects/CoreGraphQLQuery/graphql-query-details.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { GRAPHQL_QUERY_OBJECT } from "@/config/constants";
2+
import { GraphqlQueryActivities } from "@/entities/graphql/ui/graphql-query-activities";
23
import GraphqlQueryDetailsCard from "@/entities/graphql/ui/graphql-query-details-card";
34
import GraphQLQueryDetailsPageSkeleton from "@/entities/graphql/ui/graphql-query-details-page-skeleton";
45
import GraphqlQueryViewerCard from "@/entities/graphql/ui/graphql-query-viewer-card";
@@ -66,15 +67,19 @@ const GraphqlQueryDetails = ({
6667
const graphqlQuery: CoreGraphQlQuery = graphqlQueries[0].node;
6768

6869
return (
69-
<section className="flex flex-wrap lg:flex-nowrap items-start gap-2 p-2">
70-
<GraphqlQueryDetailsCard
71-
data={graphqlQuery}
72-
schema={graphqlQuerySchema}
73-
refetch={refetch}
74-
permission={permission}
75-
/>
76-
70+
<section className="grid grid-cols-1 lg:grid-cols-2 gap-2 p-2">
7771
<GraphqlQueryViewerCard query={graphqlQuery.query.value ?? ""} />
72+
73+
<div className="flex flex-col gap-2">
74+
<GraphqlQueryDetailsCard
75+
data={graphqlQuery}
76+
schema={graphqlQuerySchema}
77+
refetch={refetch}
78+
permission={permission}
79+
/>
80+
81+
<GraphqlQueryActivities id={graphqlQueryId} />
82+
</div>
7883
</section>
7984
);
8085
};

frontend/app/src/shared/components/editor/graphql/graphql-viewer.tsx

Lines changed: 0 additions & 27 deletions
This file was deleted.

frontend/app/tests/e2e/objects/CoreGraphQLQuery/core-graphql-query.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ test.describe("/objects/CoreGraphQLQuery/:graphqlQueryId - GraphQL Query details
6464
await expect(
6565
page.getByText("DescriptionA profile for E2E test ", { exact: true })
6666
).toBeVisible();
67-
await expect(page.getByText("query GET_TAGS {")).toBeVisible();
67+
await expect(page.getByText("1query GET_TAGS {")).toBeVisible();
6868

6969
await page.getByTestId("edit-button").click();
7070
await page.getByLabel("Description").fill("A profile for E2E test updated");

0 commit comments

Comments
 (0)