Skip to content
This repository was archived by the owner on Jan 19, 2025. It is now read-only.

Commit 472982d

Browse files
authored
feat(gui): mark annotations as correct/unsure/wrong when reviewing (#915)
* feat(gui): mark annotations as unsure or wrong * feat(gui): don't send annotations to backend that are marked as wrong * feat(gui): update quality view * feat(gui): more consistent area colors in quality chart
1 parent c2f76a8 commit 472982d

File tree

5 files changed

+232
-97
lines changed

5 files changed

+232
-97
lines changed

api-editor/gui/src/features/annotatedPackageData/model/AnnotatedPythonPackageBuilder.ts

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AnnotationStore } from '../../annotations/versioning/AnnotationStoreV2';
1+
import { Annotation, AnnotationStore, ReviewResult } from '../../annotations/versioning/AnnotationStoreV2';
22
import { PythonClass } from '../../packageData/model/PythonClass';
33
import { PythonFunction } from '../../packageData/model/PythonFunction';
44
import { PythonModule } from '../../packageData/model/PythonModule';
@@ -171,7 +171,7 @@ export class AnnotatedPythonPackageBuilder {
171171
switch (annotationType) {
172172
case 'Boundary':
173173
const boundaryAnnotation = this.annotationStore.boundaryAnnotations[target];
174-
if (boundaryAnnotation && !boundaryAnnotation.isRemoved) {
174+
if (annotationShouldBeProcessed(boundaryAnnotation)) {
175175
return new InferableBoundaryAnnotation(boundaryAnnotation);
176176
}
177177
break;
@@ -181,17 +181,17 @@ export class AnnotatedPythonPackageBuilder {
181181
break;
182182
}
183183
return Object.values(calledAfterAnnotations)
184-
.filter((it) => !it.isRemoved)
184+
.filter(annotationShouldBeProcessed)
185185
.map((calledAfterAnnotation) => new InferableCalledAfterAnnotation(calledAfterAnnotation));
186186
case 'Constant':
187187
const valueAnnotation1 = this.annotationStore.valueAnnotations[target];
188-
if (valueAnnotation1 && !valueAnnotation1.isRemoved && valueAnnotation1.variant === 'constant') {
188+
if (annotationShouldBeProcessed(valueAnnotation1) && valueAnnotation1.variant === 'constant') {
189189
return new InferableConstantAnnotation(valueAnnotation1);
190190
}
191191
break;
192192
case 'Description':
193193
const descriptionAnnotation = this.annotationStore.descriptionAnnotations[target];
194-
if (descriptionAnnotation && !descriptionAnnotation.isRemoved) {
194+
if (annotationShouldBeProcessed(descriptionAnnotation)) {
195195
return new InferableDescriptionAnnotation(descriptionAnnotation);
196196
}
197197
break;
@@ -201,57 +201,61 @@ export class AnnotatedPythonPackageBuilder {
201201
break;
202202
}
203203
return Object.values(groupAnnotations)
204-
.filter((it) => !it.isRemoved)
204+
.filter(annotationShouldBeProcessed)
205205
.map((groupAnnotation) => new InferableGroupAnnotation(groupAnnotation));
206206
case 'Enum':
207207
const enumAnnotation = this.annotationStore.enumAnnotations[target];
208-
if (enumAnnotation && !enumAnnotation.isRemoved) {
208+
if (annotationShouldBeProcessed(enumAnnotation)) {
209209
return new InferableEnumAnnotation(enumAnnotation);
210210
}
211211
break;
212212
case 'Move':
213213
const moveAnnotation = this.annotationStore.moveAnnotations[target];
214-
if (moveAnnotation && !moveAnnotation.isRemoved) {
214+
if (annotationShouldBeProcessed(moveAnnotation)) {
215215
return new InferableMoveAnnotation(moveAnnotation);
216216
}
217217
break;
218218
case 'Optional':
219219
const valueAnnotation2 = this.annotationStore.valueAnnotations[target];
220-
if (valueAnnotation2 && !valueAnnotation2.isRemoved && valueAnnotation2.variant === 'optional') {
220+
if (annotationShouldBeProcessed(valueAnnotation2) && valueAnnotation2.variant === 'optional') {
221221
return new InferableOptionalAnnotation(valueAnnotation2);
222222
}
223223
break;
224224
case 'Pure':
225225
const pureAnnotation = this.annotationStore.pureAnnotations[target];
226-
if (pureAnnotation && !pureAnnotation.isRemoved) {
226+
if (annotationShouldBeProcessed(pureAnnotation)) {
227227
return new InferablePureAnnotation();
228228
}
229229
break;
230230
case 'Remove':
231231
const removeAnnotation = this.annotationStore.removeAnnotations[target];
232-
if (removeAnnotation && !removeAnnotation.isRemoved) {
232+
if (annotationShouldBeProcessed(removeAnnotation)) {
233233
return new InferableRemoveAnnotation();
234234
}
235235
break;
236236
case 'Rename':
237237
const renameAnnotation = this.annotationStore.renameAnnotations[target];
238-
if (renameAnnotation && !renameAnnotation.isRemoved) {
238+
if (annotationShouldBeProcessed(renameAnnotation)) {
239239
return new InferableRenameAnnotation(renameAnnotation);
240240
}
241241
break;
242242
case 'Required':
243243
const valueAnnotation3 = this.annotationStore.valueAnnotations[target];
244-
if (valueAnnotation3 && !valueAnnotation3.isRemoved && valueAnnotation3.variant === 'required') {
244+
if (annotationShouldBeProcessed(valueAnnotation3) && valueAnnotation3.variant === 'required') {
245245
return new InferableRequiredAnnotation();
246246
}
247247
break;
248248
case 'Todo':
249249
const todoAnnotation = this.annotationStore.todoAnnotations[target];
250-
if (todoAnnotation && !todoAnnotation.isRemoved) {
250+
if (annotationShouldBeProcessed(todoAnnotation)) {
251251
return new InferableTodoAnnotation(todoAnnotation);
252252
}
253253
break;
254254
}
255255
return undefined;
256256
}
257257
}
258+
259+
const annotationShouldBeProcessed = function (annotation: Annotation): boolean {
260+
return annotation && !annotation.isRemoved && annotation.reviewResult === ReviewResult.Wrong;
261+
};

0 commit comments

Comments
 (0)