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

Commit 8dc3c9f

Browse files
authored
feat(gui): graphical progress bar for annotation process (#691)
* refactor(gui): extract components * refactor(gui): extract components * feat(gui): progress statistics * perf(gui): disable serialization check * feat(gui): only count annotations on matched elements * feat(gui): shorter labels * style: apply automatic fixes of linters Co-authored-by: lars-reimann <[email protected]>
1 parent ce822ec commit 8dc3c9f

File tree

15 files changed

+478
-320
lines changed

15 files changed

+478
-320
lines changed

api-editor/gui/src/app/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ import { AbstractPythonFilter } from '../features/filter/model/AbstractPythonFil
7070
import { UsageCountStore } from '../features/usages/model/UsageCountStore';
7171
import { PythonDeclaration } from '../features/packageData/model/PythonDeclaration';
7272
import { SaveFilterDialog } from '../features/filter/SaveFilterDialog';
73-
import { StatisticsView } from '../features/packageData/selectionView/StatisticsView';
73+
import { StatisticsView } from '../features/statistics/StatisticsView';
7474

7575
export const App: React.FC = function () {
7676
useIndexedDB();

api-editor/gui/src/app/store.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,7 @@ export const store = configureStore({
1414
},
1515
middleware: (getDefaultMiddleware) =>
1616
getDefaultMiddleware({
17-
serializableCheck: {
18-
// Ignore these action types
19-
ignoredActions: [
20-
'api/initialize',
21-
'api/initialize/fulfilled',
22-
'api/setPythonPackage',
23-
'usages/initialize',
24-
'usages/initialize/fulfilled',
25-
'usages/setUsages',
26-
],
27-
// Ignore these paths in the state
28-
ignoredPaths: ['api.pythonPackage', 'usages.usages'],
29-
},
17+
serializableCheck: false,
3018
}),
3119
});
3220

api-editor/gui/src/features/annotations/annotationSlice.ts

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,6 @@ const annotationsSlice = createSlice({
352352

353353
updateQueue(state);
354354
},
355-
// TODO update
356355
mergeAnnotationStore(state, action: PayloadAction<AnnotationStore>) {
357356
for (const annotationType of Object.keys(action.payload)) {
358357
if (annotationType === 'calledAfters' || annotationType === 'groups') {
@@ -966,7 +965,7 @@ export const selectTodo =
966965
(target: string) =>
967966
(state: RootState): TodoAnnotation | undefined =>
968967
selectAnnotationStore(state).todos[target];
969-
export const selectNumberOfAnnotations =
968+
export const selectNumberOfAnnotationsOnTarget =
970969
(target: string) =>
971970
(state: RootState): number => {
972971
return Object.entries(selectAnnotationStore(state)).reduce((acc, [annotationType, annotations]) => {
@@ -979,5 +978,24 @@ export const selectNumberOfAnnotations =
979978
}
980979
}, 0);
981980
};
981+
export const selectAllAnnotationsOnTargets =
982+
(targets: string[]) =>
983+
(state: RootState): Annotation[] =>
984+
targets.flatMap((target) => selectAllAnnotationsOnTarget(target)(state));
985+
const selectAllAnnotationsOnTarget =
986+
(target: string) =>
987+
(state: RootState): Annotation[] => {
988+
return Object.entries(selectAnnotationStore(state)).flatMap(([annotationType, targetToAnnotations]) => {
989+
switch (annotationType) {
990+
case 'completes':
991+
return [];
992+
case 'calledAfters':
993+
case 'groups':
994+
return Object.values(targetToAnnotations[target] ?? {});
995+
default:
996+
return targetToAnnotations[target] ?? [];
997+
}
998+
});
999+
};
9821000
export const selectUsername = (state: RootState): string => selectAnnotationSlice(state).username;
9831001
export const selectUsernameIsValid = (state: RootState): boolean => isValidUsername(selectUsername(state));

api-editor/gui/src/features/packageData/apiSlice.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,24 @@ export const selectFilteredPythonPackage = createSelector(
7070
return filter.applyToPackage(pythonPackage, annotations, usages);
7171
},
7272
);
73-
export const selectNumberOfMatchedNodes = createSelector(
73+
export const selectMatchedNodes = createSelector(
7474
[selectFilteredPythonPackage, selectAnnotationStore, selectUsages, selectFilter],
7575
(pythonPackage, annotations, usages, filter) => {
76-
let result = -1; // We start with -1, since the PythonPackage is always kept but should not be counted
76+
const result = [];
7777
for (const declaration of pythonPackage.descendantsOrSelf()) {
78-
if (filter.shouldKeepDeclaration(declaration, annotations, usages)) {
79-
result++;
78+
if (
79+
!(declaration instanceof PythonPackage) &&
80+
filter.shouldKeepDeclaration(declaration, annotations, usages)
81+
) {
82+
result.push(declaration);
8083
}
8184
}
8285
return result;
8386
},
8487
);
88+
export const selectNumberOfMatchedNodes = createSelector([selectMatchedNodes], (matchedNodes) => {
89+
return matchedNodes.length;
90+
});
8591
export const selectFlatSortedDeclarationList = createSelector(
8692
[selectFilteredPythonPackage, selectSortingMode, selectUsages],
8793
(pythonPackage, sortingMode, usages) => {

api-editor/gui/src/features/packageData/selectionView/StatisticsView.tsx

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

0 commit comments

Comments
 (0)