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

Commit 117682b

Browse files
authored
feat(gui): don't delete autogenerated annotations (#810)
* feat(gui): don't delete autogenerated annotations * feat(gui): autogenerated annotations get visually deleted again * feat(gui): autogenerated annotations get visually deleted again * feat(gui): copy buttons for module * feat(gui): copy buttons for module * feat(gui): copy qualified name to clipboard * feat(gui): don't send deleted annotations to backend * fix(gui): heatmap annotation counts * fix(gui): annotation statistics * fix(gui): properly shadow delete autogenerated attribute/constant/optional/required annotations * style: apply automatic fixes of linters Co-authored-by: lars-reimann <[email protected]>
1 parent a04e517 commit 117682b

File tree

9 files changed

+172
-113
lines changed

9 files changed

+172
-113
lines changed

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

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,13 @@ export class AnnotatedPythonPackageBuilder {
172172
switch (annotationType) {
173173
case 'Attribute':
174174
const attributeAnnotation = this.annotationStore.attributes[target];
175-
if (attributeAnnotation) {
175+
if (attributeAnnotation && !attributeAnnotation.isRemoved) {
176176
return new InferableAttributeAnnotation(attributeAnnotation);
177177
}
178178
break;
179179
case 'Boundary':
180180
const boundaryAnnotation = this.annotationStore.boundaries[target];
181-
if (boundaryAnnotation) {
181+
if (boundaryAnnotation && !boundaryAnnotation.isRemoved) {
182182
return new InferableBoundaryAnnotation(boundaryAnnotation);
183183
}
184184
break;
@@ -187,18 +187,18 @@ export class AnnotatedPythonPackageBuilder {
187187
if (!calledAfterAnnotations) {
188188
break;
189189
}
190-
return Object.values(calledAfterAnnotations).map(
191-
(calledAfterAnnotation) => new InferableCalledAfterAnnotation(calledAfterAnnotation),
192-
);
190+
return Object.values(calledAfterAnnotations)
191+
.filter((it) => !it.isRemoved)
192+
.map((calledAfterAnnotation) => new InferableCalledAfterAnnotation(calledAfterAnnotation));
193193
case 'Constant':
194194
const constantAnnotation = this.annotationStore.constants[target];
195-
if (constantAnnotation) {
195+
if (constantAnnotation && !constantAnnotation.isRemoved) {
196196
return new InferableConstantAnnotation(constantAnnotation);
197197
}
198198
break;
199199
case 'Description':
200200
const descriptionAnnotation = this.annotationStore.descriptions[target];
201-
if (descriptionAnnotation) {
201+
if (descriptionAnnotation && !descriptionAnnotation.isRemoved) {
202202
return new InferableDescriptionAnnotation(descriptionAnnotation);
203203
}
204204
break;
@@ -207,54 +207,54 @@ export class AnnotatedPythonPackageBuilder {
207207
if (!groupAnnotations) {
208208
break;
209209
}
210-
return Object.values(groupAnnotations).map(
211-
(groupAnnotation) => new InferableGroupAnnotation(groupAnnotation),
212-
);
210+
return Object.values(groupAnnotations)
211+
.filter((it) => !it.isRemoved)
212+
.map((groupAnnotation) => new InferableGroupAnnotation(groupAnnotation));
213213
case 'Enum':
214214
const enumAnnotation = this.annotationStore.enums[target];
215-
if (enumAnnotation) {
215+
if (enumAnnotation && !enumAnnotation.isRemoved) {
216216
return new InferableEnumAnnotation(enumAnnotation);
217217
}
218218
break;
219219
case 'Move':
220220
const moveAnnotation = this.annotationStore.moves[target];
221-
if (moveAnnotation) {
221+
if (moveAnnotation && !moveAnnotation.isRemoved) {
222222
return new InferableMoveAnnotation(moveAnnotation);
223223
}
224224
break;
225225
case 'Optional':
226226
const optionalAnnotation = this.annotationStore.optionals[target];
227-
if (optionalAnnotation) {
227+
if (optionalAnnotation && !optionalAnnotation.isRemoved) {
228228
return new InferableOptionalAnnotation(optionalAnnotation);
229229
}
230230
break;
231231
case 'Pure':
232232
const pureAnnotation = this.annotationStore.pures[target];
233-
if (pureAnnotation) {
233+
if (pureAnnotation && !pureAnnotation.isRemoved) {
234234
return new InferablePureAnnotation();
235235
}
236236
break;
237237
case 'Remove':
238238
const removeAnnotation = this.annotationStore.removes[target];
239-
if (removeAnnotation) {
239+
if (removeAnnotation && !removeAnnotation.isRemoved) {
240240
return new InferableRemoveAnnotation();
241241
}
242242
break;
243243
case 'Rename':
244244
const renameAnnotation = this.annotationStore.renamings[target];
245-
if (renameAnnotation) {
245+
if (renameAnnotation && !renameAnnotation.isRemoved) {
246246
return new InferableRenameAnnotation(renameAnnotation);
247247
}
248248
break;
249249
case 'Required':
250250
const requiredAnnotation = this.annotationStore.requireds[target];
251-
if (requiredAnnotation) {
251+
if (requiredAnnotation && !requiredAnnotation.isRemoved) {
252252
return new InferableRequiredAnnotation();
253253
}
254254
break;
255255
case 'Todo':
256256
const todoAnnotation = this.annotationStore.todos[target];
257-
if (todoAnnotation) {
257+
if (todoAnnotation && !todoAnnotation.isRemoved) {
258258
return new InferableTodoAnnotation(todoAnnotation);
259259
}
260260
break;

api-editor/gui/src/features/annotations/AnnotationView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ const AnnotationTag: React.FC<AnnotationTagProps> = function ({
353353
@{type}
354354
{name && (
355355
<ChakraText as="span" fontWeight="normal" justifySelf="flex-end">
356-
: {name}
356+
: {name} {annotation.isRemoved}
357357
</ChakraText>
358358
)}
359359
</Button>

api-editor/gui/src/features/annotations/MinimalDataCopyButtons.tsx renamed to api-editor/gui/src/features/annotations/DataCopyButtons.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ interface MinimalDataButtonsProps {
1212
target: string;
1313
}
1414

15-
export const MinimalDataCopyButtons: React.FC<MinimalDataButtonsProps> = function ({ target }) {
15+
export const DataCopyButtons: React.FC<MinimalDataButtonsProps> = function ({ target }) {
1616
const pythonPackage = useAppSelector(selectRawPythonPackage);
1717
const declaration = pythonPackage.getDeclarationById(target);
1818
const usages = useAppSelector(selectUsages);
@@ -22,6 +22,7 @@ export const MinimalDataCopyButtons: React.FC<MinimalDataButtonsProps> = functio
2222
const { onCopy: onCopyUsages } = useClipboard(
2323
details(jsonCode(buildMinimalUsagesStoreJson(usages, declaration)), `Minimal Usage Store for \`${target}\``),
2424
);
25+
const { onCopy: onCopyQualifiedName } = useClipboard(declaration?.preferredQualifiedName() ?? '');
2526

2627
return (
2728
<ButtonGroup size="sm" variant="outline" isAttached>
@@ -45,6 +46,16 @@ export const MinimalDataCopyButtons: React.FC<MinimalDataButtonsProps> = functio
4546
Usages
4647
</Button>
4748
</Tooltip>
49+
<Tooltip label="Copy the qualified name of this declaration to the clipboard.">
50+
<Button
51+
leftIcon={<FaClipboard />}
52+
onClick={() => {
53+
onCopyQualifiedName();
54+
}}
55+
>
56+
Qualified Name
57+
</Button>
58+
</Tooltip>
4859
</ButtonGroup>
4960
);
5061
};

0 commit comments

Comments
 (0)