box-annotations 5.2.1-beta.5 → 5.2.1-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,10 +3,13 @@ import { formatDrawing, isDrawing } from '../../drawing/drawingUtil';
3
3
  import { AnnotationsState } from './types';
4
4
  import {
5
5
  createAnnotationAction,
6
+ createReplyAction,
7
+ deleteAnnotationAction,
6
8
  fetchAnnotationsAction,
7
9
  removeAnnotationAction,
8
10
  setActiveAnnotationIdAction,
9
11
  setIsInitialized,
12
+ updateAnnotationAction,
10
13
  } from './actions';
11
14
  import { setViewModeAction } from '../options/actions';
12
15
 
@@ -14,6 +17,7 @@ const activeAnnotationId = createReducer<AnnotationsState['activeId']>(null, bui
14
17
  builder
15
18
  /* Preview will set the active ID with a an event which will trigger the url change */
16
19
  .addCase(createAnnotationAction.fulfilled, () => null)
20
+ .addCase(deleteAnnotationAction.fulfilled, (state, { payload: id }) => (state === id ? null : state))
17
21
  .addCase(removeAnnotationAction, (state, { payload: id }) => (state === id ? null : state))
18
22
  .addCase(setActiveAnnotationIdAction, (state, { payload: annotationId }) => annotationId)
19
23
  .addCase(setViewModeAction, (state, { payload }) => {
@@ -27,6 +31,7 @@ const annotationsAllIds = createReducer<AnnotationsState['allIds']>([], builder
27
31
  .addCase(createAnnotationAction.fulfilled, (state, { payload: { id } }) => {
28
32
  state.push(id);
29
33
  })
34
+ .addCase(deleteAnnotationAction.fulfilled, (state, { payload: id }) => state.filter(annotationId => annotationId !== id))
30
35
  .addCase(removeAnnotationAction, (state, { payload: id }) => state.filter(annotationId => annotationId !== id))
31
36
  .addCase(fetchAnnotationsAction.fulfilled, (state, { payload }) => {
32
37
  payload.entries.forEach(({ id }) => state.indexOf(id) === -1 && state.push(id));
@@ -38,9 +43,21 @@ const annotationsById = createReducer<AnnotationsState['byId']>({}, builder =>
38
43
  .addCase(createAnnotationAction.fulfilled, (state, { payload }) => {
39
44
  state[payload.id] = isDrawing(payload) ? formatDrawing(payload) : payload;
40
45
  })
46
+ .addCase(createReplyAction.fulfilled, (state, { payload: { annotationId, reply } }) => {
47
+ const annotation = state[annotationId];
48
+ if (annotation) {
49
+ annotation.replies = [...(annotation.replies ?? []), reply];
50
+ }
51
+ })
52
+ .addCase(deleteAnnotationAction.fulfilled, (state, { payload: id }) => {
53
+ delete state[id];
54
+ })
41
55
  .addCase(removeAnnotationAction, (state, { payload: id }) => {
42
56
  delete state[id];
43
57
  })
58
+ .addCase(updateAnnotationAction.fulfilled, (state, { payload }) => {
59
+ state[payload.id] = isDrawing(payload) ? formatDrawing(payload) : payload;
60
+ })
44
61
  .addCase(fetchAnnotationsAction.fulfilled, (state, { payload }) => {
45
62
  payload.entries.forEach(annotation => {
46
63
  state[annotation.id] = isDrawing(annotation) ? formatDrawing(annotation) : annotation;
@@ -9,7 +9,8 @@ import {
9
9
  setViewModeAction,
10
10
  } from './actions';
11
11
 
12
- export const initialState = {
12
+ export const initialState: OptionsState = {
13
+ apiHost: '',
13
14
  features: {},
14
15
  fileId: null,
15
16
  fileVersionId: null,
@@ -17,6 +18,7 @@ export const initialState = {
17
18
  permissions: {},
18
19
  rotation: 0,
19
20
  scale: 1,
21
+ token: '',
20
22
  viewMode: 'annotations' as ViewMode,
21
23
  };
22
24
 
@@ -6,6 +6,7 @@ import { ViewMode } from './types';
6
6
 
7
7
  type State = Pick<AppState, 'options'>;
8
8
 
9
+ export const getApiHost = (state: State): string => state.options.apiHost;
9
10
  export const getFeatures = (state: State): Features => state.options.features;
10
11
  export const getViewMode = (state: State): ViewMode => state.options.viewMode;
11
12
  export const getFileId = (state: State): string | null => state.options.fileId;
@@ -14,5 +15,6 @@ export const getIsCurrentFileVersion = (state: State): boolean => state.options.
14
15
  export const getPermissions = (state: State): Permissions => state.options.permissions;
15
16
  export const getRotation = (state: State): number => state.options.rotation;
16
17
  export const getScale = (state: State): number => state.options.scale;
18
+ export const getToken = (state: State): string => state.options.token;
17
19
  export const isFeatureEnabled = (state: State, featurename: string): boolean =>
18
20
  getProp(getFeatures(state), featurename, false);
@@ -5,6 +5,7 @@ import { Permissions } from '../../@types';
5
5
  export type ViewMode = 'annotations' | 'boundingBoxes';
6
6
 
7
7
  export type OptionsState = {
8
+ apiHost: string;
8
9
  features: Features;
9
10
  fileId: string | null;
10
11
  fileVersionId: string | null;
@@ -12,5 +13,6 @@ export type OptionsState = {
12
13
  permissions: Permissions;
13
14
  rotation: number;
14
15
  scale: number;
16
+ token: string;
15
17
  viewMode: ViewMode;
16
18
  };
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
-
3
- /**
4
- * Placeholder for the threaded annotation reply popup (V2).
5
- * Replaces PopupReply when the isThreadedAnnotation feature flag is enabled.
6
- * Currently renders an empty container — props will be wired up when V2 is implemented.
7
- */
8
- export default function PopupReplyV2(): JSX.Element {
9
- return <div data-testid="popup-reply-v2" />;
10
- }