Skip to content

Commit 6364396

Browse files
pa-lembilalabbad
andauthored
Fix and refactor checks retry (#7456)
* fix const * add api function * add domain * add query * update domain * use fsd in checks * add check api * update keys * add domain * add mutation * update query * cleanup useless style * remove refetch * update mutation * remove unused file * remove unused file * add api * update query keys * add domain * add query * update component * remove file * add changelog * add errors check * fix type * use as const * update type * update ui for retry * update retry all ui * ensure kind * revert tooltip * improve TS * rephrase changelog --------- Co-authored-by: bilalabbad <[email protected]>
1 parent 4dec631 commit 6364396

19 files changed

+277
-158
lines changed

changelog/+checks.fixed.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Resolved a problem that caused generator checks to fail when retrying requests

frontend/app/src/config/constants.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { CheckType } from "@/shared/api/graphql/generated/graphql";
2+
13
import { RelationshipKind } from "@/entities/nodes/types";
24
import { PROPOSED_CHANGE_OBJECT } from "@/entities/proposed-changes/constants";
35

@@ -115,9 +117,10 @@ export const CHECKS_LABEL = {
115117
IN_PROGRESS: "In progress",
116118
};
117119

118-
export const VALIDATIONS_ENUM_MAP: { [key: string]: string } = {
120+
export const VALIDATIONS_ENUM_MAP: { [key: string]: CheckType } = {
119121
CoreArtifactValidator: "ARTIFACT",
120122
CoreDataValidator: "DATA",
123+
CoreGeneratorValidator: "GENERATOR",
121124
CoreRepositoryValidator: "REPOSITORY",
122125
CoreSchemaValidator: "SCHEMA",
123126
CoreUserValidator: "USER",

frontend/app/src/entities/diff/api/getCheckDetails.ts renamed to frontend/app/src/entities/diff/api/get-check-details-from-api.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import { gql } from "@apollo/client";
22

3-
export const GET_CHECKS = gql`
4-
query GET_CORE_CHECKS($ids: [ID]!) {
5-
CoreCheck(ids: $ids) {
3+
import {
4+
Get_Check_DetailsQuery,
5+
Get_Check_DetailsQueryVariables,
6+
} from "@/shared/api/graphql/generated/graphql";
7+
import graphqlClient from "@/shared/api/graphql/graphqlClientApollo";
8+
9+
const GET_CHECK_DETAILS = gql`
10+
query GET_CHECK_DETAILS($id: ID!) {
11+
CoreCheck(ids: [$id]) {
612
edges {
713
node {
814
id
@@ -63,3 +69,12 @@ export const GET_CHECKS = gql`
6369
}
6470
}
6571
`;
72+
73+
export interface GetCheckDetailsFromApiParams extends Get_Check_DetailsQueryVariables {}
74+
75+
export const getCheckDetailsFromApi = async (variables: GetCheckDetailsFromApiParams) => {
76+
return graphqlClient.query<Get_Check_DetailsQuery, Get_Check_DetailsQueryVariables>({
77+
query: GET_CHECK_DETAILS,
78+
variables,
79+
});
80+
};
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import { gql } from "@apollo/client";
2+
3+
import {
4+
Get_Check_DetailsQueryVariables,
5+
Get_Core_ValidatorsQuery,
6+
} from "@/shared/api/graphql/generated/graphql";
7+
import graphqlClient from "@/shared/api/graphql/graphqlClientApollo";
8+
9+
const GET_VALIDATORS = gql`
10+
query GET_CORE_VALIDATORS($id: ID!) {
11+
CoreValidator(proposed_change__ids: [$id]) {
12+
edges {
13+
node {
14+
id
15+
display_label
16+
conclusion {
17+
value
18+
}
19+
started_at {
20+
value
21+
}
22+
completed_at {
23+
value
24+
}
25+
state {
26+
value
27+
}
28+
checks {
29+
edges {
30+
node {
31+
conclusion {
32+
value
33+
}
34+
severity {
35+
value
36+
}
37+
}
38+
}
39+
}
40+
__typename
41+
}
42+
}
43+
}
44+
}
45+
`;
46+
47+
export interface GetValidatorsFromApiParams extends Get_Check_DetailsQueryVariables {}
48+
49+
export const getValidatorsFromApi = async (variables: GetValidatorsFromApiParams) => {
50+
return graphqlClient.query<Get_Core_ValidatorsQuery, Get_Check_DetailsQueryVariables>({
51+
query: GET_VALIDATORS,
52+
variables,
53+
});
54+
};

frontend/app/src/entities/diff/api/getValidators.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { gql } from "@apollo/client";
2+
3+
import {
4+
Run_CheckMutation,
5+
Run_CheckMutationVariables,
6+
} from "@/shared/api/graphql/generated/graphql";
7+
import graphqlClient from "@/shared/api/graphql/graphqlClientApollo";
8+
9+
export const RUN_CHECK = gql`
10+
mutation RUN_CHECK($proposedChangeId: String!, $checkType: CheckType) {
11+
CoreProposedChangeRunCheck (
12+
data: {
13+
id: $proposedChangeId,
14+
check_type: $checkType
15+
}
16+
) {
17+
ok
18+
}
19+
}
20+
`;
21+
22+
export interface RunCheckFromApiParams extends Run_CheckMutationVariables {}
23+
24+
export const runCheckFromApi = ({ proposedChangeId, checkType }: RunCheckFromApiParams) => {
25+
return graphqlClient.mutate<Run_CheckMutation, Run_CheckMutationVariables>({
26+
mutation: RUN_CHECK,
27+
variables: {
28+
proposedChangeId,
29+
checkType,
30+
},
31+
});
32+
};

frontend/app/src/entities/diff/api/runCheck.ts

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

frontend/app/src/entities/diff/checks/check.tsx

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,22 @@
11
import { Icon } from "@iconify-icon/react";
22
import { useAtomValue } from "jotai";
33

4-
import useQuery from "@/shared/api/graphql/useQuery";
54
import { InfoButton } from "@/shared/components/buttons/info-button";
65
import Accordion from "@/shared/components/display/accordion";
76
import { DateDisplay } from "@/shared/components/display/date-display";
87
import { CodeViewer } from "@/shared/components/editor/code/code-viewer";
98
import ErrorScreen from "@/shared/components/errors/error-screen";
10-
import { Skeleton } from "@/shared/components/skeleton";
9+
import { LoadingIndicator } from "@/shared/components/loading/loading-indicator";
1110
import { List } from "@/shared/components/table/list";
1211
import { Popover, PopoverContent, PopoverTrigger } from "@/shared/components/ui/popover";
1312
import { Tooltip } from "@/shared/components/ui/tooltip";
1413
import { classNames } from "@/shared/utils/common";
1514

16-
import { GET_CHECKS } from "@/entities/diff/api/getCheckDetails";
15+
import { DataIntegrityConflicts } from "@/entities/diff/checks/data-integrity-conflicts";
16+
import { SchemaIntegrityConflicts } from "@/entities/diff/checks/schema-integrity-conflicts";
17+
import { useGetCheckDetails } from "@/entities/diff/domain/get-check-details.query";
1718
import { schemaKindLabelState } from "@/entities/schema/stores/schemaKindLabel.atom";
1819

19-
import { DataIntegrityConflicts } from "./data-integrity-conflicts";
20-
import { SchemaIntegrityConflicts } from "./schema-integrity-conflicts";
21-
2220
type tCheckProps = {
2321
id: string;
2422
};
@@ -75,9 +73,23 @@ const getCheckBorderColor = (severity?: string) => {
7573
export const Check = ({ id }: tCheckProps) => {
7674
const schemaKindLabel = useAtomValue(schemaKindLabelState);
7775

78-
const { loading, error, data } = useQuery(GET_CHECKS, { variables: { ids: [id] } });
76+
const { isPending, error, data: check } = useGetCheckDetails({ checkId: id });
77+
78+
if (error) {
79+
return (
80+
<div className={"flex flex-col rounded-md border-l-4 bg-white p-2"}>
81+
<ErrorScreen message="Something went wrong when fetching the check details" />
82+
</div>
83+
);
84+
}
85+
86+
if (isPending) {
87+
return <LoadingIndicator />;
88+
}
7989

80-
const check = data?.CoreCheck?.edges?.[0]?.node ?? {};
90+
if (!check) {
91+
return null;
92+
}
8193

8294
const {
8395
__typename,
@@ -92,14 +104,6 @@ export const Check = ({ id }: tCheckProps) => {
92104
conflicts,
93105
} = check;
94106

95-
if (error) {
96-
return (
97-
<div className={"flex flex-col rounded-md border-l-4 bg-white p-2"}>
98-
<ErrorScreen message="Something went wrong when fetching the check details" />
99-
</div>
100-
);
101-
}
102-
103107
const columns = [
104108
{
105109
name: "type",
@@ -133,20 +137,12 @@ export const Check = ({ id }: tCheckProps) => {
133137
<div className="mb-2 flex">
134138
<div className="flex flex-1 flex-col">
135139
<div className="flex items-center">
136-
{loading ? (
137-
<Skeleton className="mr-2 h-3 w-3 rounded-sm" />
138-
) : (
139-
getCheckIcon(conclusion?.value)
140-
)}
140+
{getCheckIcon(conclusion?.value)}
141141

142-
{loading ? <Skeleton className="h-3 w-40" /> : name?.value || display_label}
142+
{name?.value || display_label}
143143

144144
<div className="flex flex-1 items-center justify-end">
145-
{loading ? (
146-
<Skeleton className="h-3 w-24" />
147-
) : (
148-
created_at?.value && <DateDisplay date={created_at?.value} />
149-
)}
145+
{created_at?.value && <DateDisplay date={created_at?.value} />}
150146

151147
<Popover>
152148
<PopoverTrigger asChild>

0 commit comments

Comments
 (0)