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

Commit 165a8da

Browse files
authored
feat(gui): attribute/constant/optional/required annotations now replace each other (#795)
1 parent f5e6a7d commit 165a8da

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

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

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,10 @@ const annotationsSlice = createSlice({
389389
state.username,
390390
);
391391

392+
delete state.annotations.constants[action.payload.target];
393+
delete state.annotations.optionals[action.payload.target];
394+
delete state.annotations.requireds[action.payload.target];
395+
392396
updateQueue(state);
393397
},
394398
removeAttribute(state, action: PayloadAction<string>) {
@@ -489,6 +493,10 @@ const annotationsSlice = createSlice({
489493
state.username,
490494
);
491495

496+
delete state.annotations.attributes[action.payload.target];
497+
delete state.annotations.optionals[action.payload.target];
498+
delete state.annotations.requireds[action.payload.target];
499+
492500
updateQueue(state);
493501
},
494502
upsertConstants(state, action: PayloadAction<ConstantAnnotation[]>) {
@@ -498,6 +506,10 @@ const annotationsSlice = createSlice({
498506
annotation,
499507
state.username,
500508
);
509+
510+
delete state.annotations.attributes[annotation.target];
511+
delete state.annotations.optionals[annotation.target];
512+
delete state.annotations.requireds[annotation.target];
501513
});
502514

503515
updateQueue(state);
@@ -662,6 +674,10 @@ const annotationsSlice = createSlice({
662674
state.username,
663675
);
664676

677+
delete state.annotations.attributes[action.payload.target];
678+
delete state.annotations.constants[action.payload.target];
679+
delete state.annotations.requireds[action.payload.target];
680+
665681
updateQueue(state);
666682
},
667683
upsertOptionals(state, action: PayloadAction<OptionalAnnotation[]>) {
@@ -671,6 +687,10 @@ const annotationsSlice = createSlice({
671687
annotation,
672688
state.username,
673689
);
690+
691+
delete state.annotations.attributes[annotation.target];
692+
delete state.annotations.constants[annotation.target];
693+
delete state.annotations.requireds[annotation.target];
674694
});
675695

676696
updateQueue(state);
@@ -750,15 +770,23 @@ const annotationsSlice = createSlice({
750770
state.username,
751771
);
752772

773+
delete state.annotations.attributes[action.payload.target];
774+
delete state.annotations.constants[action.payload.target];
775+
delete state.annotations.optionals[action.payload.target];
776+
753777
updateQueue(state);
754778
},
755-
upsertRequireds(state, action: PayloadAction<RequiredAnnotation[]>) {
779+
addRequireds(state, action: PayloadAction<RequiredAnnotation[]>) {
756780
action.payload.forEach((annotation) => {
757781
state.annotations.requireds[annotation.target] = withAuthorAndReviewers(
758782
state.annotations.requireds[annotation.target],
759783
annotation,
760784
state.username,
761785
);
786+
787+
delete state.annotations.attributes[annotation.target];
788+
delete state.annotations.constants[annotation.target];
789+
delete state.annotations.optionals[annotation.target];
762790
});
763791

764792
updateQueue(state);
@@ -931,7 +959,7 @@ export const {
931959
removeRenaming,
932960
reviewRenaming,
933961
addRequired,
934-
upsertRequireds,
962+
addRequireds,
935963
removeRequired,
936964
reviewRequired,
937965
upsertTodo,

api-editor/gui/src/features/annotations/batchforms/RequiredBatchForm.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react';
22
import { useAppDispatch } from '../../../app/hooks';
33
import { PythonDeclaration } from '../../packageData/model/PythonDeclaration';
4-
import { RequiredAnnotation, upsertRequireds } from '../annotationSlice';
4+
import { RequiredAnnotation, addRequireds } from '../annotationSlice';
55
import { PythonParameter } from '../../packageData/model/PythonParameter';
66
import { EmptyBatchForm } from './EmptyBatchForm';
77

@@ -26,7 +26,7 @@ export const RequiredBatchForm: React.FC<RequiredBatchFormProps> = function ({ t
2626
target: targetPath,
2727
});
2828
});
29-
dispatch(upsertRequireds(all));
29+
dispatch(addRequireds(all));
3030
};
3131

3232
// Rendering -------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)