Skip to content

Commit 101fb32

Browse files
[Feature] Custom Redact All functionality (#4966)
* video redact * testing stuff * test * api * custom apply api * added custom note selection function to redactionitem * missing files * cleanup * cleanup * cleanup * cleanup * cleanup * documentation * fix bad commit * api tweaks * api tweaks * missing file Co-authored-by: Kristian Hein <[email protected]>
1 parent d821d9e commit 101fb32

File tree

11 files changed

+75
-2
lines changed

11 files changed

+75
-2
lines changed
Lines changed: 13 additions & 0 deletions
Loading

i18n/translation-en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,7 @@
815815
"redactionItem": {
816816
"regionRedaction": "Region redaction",
817817
"fullPageRedaction": "Full page redaction",
818+
"fullVideoFrameRedaction": "Video Redaction",
818819
"image": "Image"
819820
},
820821
"expand": "Expand",

src/apis/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ import getCustomData from './getCustomData';
162162
import setCustomMeasurementOverlayInfo from './setCustomMeasurementOverlayInfo';
163163
import setNoteTransformFunction from './setNoteTransformFunction';
164164
import setCustomNoteSelectionFunction from './setCustomNoteSelectionFunction';
165+
import setCustomApplyRedactionsHandler from './setCustomApplyRedactionsHandler';
165166
import selectThumbnailPages from './selectThumbnailPages';
166167
import unselectThumbnailPages from './unselectThumbnailPages';
167168
import setSearchResults from './setSearchResults';
@@ -292,6 +293,7 @@ export default store => {
292293
setToolbarGroup: setToolbarGroup(store),
293294
dangerouslySetNoteTransformFunction: setNoteTransformFunction(store),
294295
setCustomNoteSelectionFunction: setCustomNoteSelectionFunction(store),
296+
setCustomApplyRedactionsHandler: setCustomApplyRedactionsHandler(store),
295297
setToolMode,
296298
setZoomLevel,
297299
setZoomList: setZoomList(store),
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import actions from 'actions';
2+
3+
/**
4+
* @callback CustomApplyRedactionsHandler
5+
* @memberof UI
6+
* @param {Array.<Core.Annotations.Annotation>} annotations
7+
* @param {function} originalApplyRedactionsFunction The original applyRedactions function
8+
*/
9+
10+
/**
11+
* @method UI.setCustomApplyRedactionsHandler
12+
* @param {UI.CustomApplyRedactionsHandler} customApplyRedactionsHandler
13+
* The function that will be invoked when clicking on the 'Redact All' button.
14+
* @example
15+
WebViewer(...)
16+
.then(function(instance) {
17+
instance.UI.setCustomApplyRedactionsHandler((annotationsToRedact, originalApplyRedactionsFunction) => {
18+
// custom code
19+
...
20+
originalApplyRedactionsFunction();
21+
})
22+
});
23+
*/
24+
25+
export default store => customApplyRedactionsHandler => {
26+
store.dispatch(actions.setCustomApplyRedactionsHandler(customApplyRedactionsHandler));
27+
};

src/components/RedactionPageGroup/RedactionItem/RedactionItem.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ const RedactionItem = (props) => {
3939
<RedactionTextPreview linesToBreak={2}>
4040
{textPreview}
4141
</RedactionTextPreview>)
42-
} else if (redactionType === redactionTypeMap['FULL_PAGE'] || redactionType === redactionTypeMap['REGION']) {
42+
} else if (
43+
redactionType === redactionTypeMap['FULL_PAGE']
44+
|| redactionType === redactionTypeMap['FULL_VIDEO_FRAME']
45+
|| redactionType === redactionTypeMap['REGION']
46+
) {
4347
redactionPreview = t(label);
4448
} else {
4549
redactionPreview = annotation.getContents();

src/components/RedactionPageGroup/RedactionItem/RedactionItemContainer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ const RedactionItemContainer = (props) => {
1313
const [
1414
dateFormat,
1515
language,
16+
customNoteSelectionFunction,
1617
] = useSelector(
1718
state => [
1819
selectors.getNoteDateFormat(state),
1920
selectors.getCurrentLanguage(state),
21+
selectors.getCustomNoteSelectionFunction(state),
2022
],
2123
shallowEqual,
2224
);
@@ -26,6 +28,7 @@ const RedactionItemContainer = (props) => {
2628
const author = core.getDisplayAuthor(annotation['Author']);
2729

2830
const onRedactionItemSelection = useCallback(() => {
31+
customNoteSelectionFunction && customNoteSelectionFunction(annotation);
2932
core.deselectAllAnnotations();
3033
core.selectAnnotation(annotation);
3134
core.jumpToAnnotation(annotation);

src/components/RedactionPanel/RedactionPanelContainer.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,15 @@ export const RedactionPanelContainer = () => {
1919
isDisabled,
2020
redactionPanelWidth,
2121
isInDesktopOnlyMode,
22+
customApplyRedactionsHandler,
2223
redactionSearchPatterns,
2324
] = useSelector(
2425
state => [
2526
selectors.isElementOpen(state, 'redactionPanel'),
2627
selectors.isElementDisabled(state, 'redactionPanel'),
2728
selectors.getRedactionPanelWidth(state),
2829
selectors.isInDesktopOnlyMode(state),
30+
selectors.getCustomApplyRedactionsHandler(state),
2931
selectors.getRedactionSearchPatterns(state),
3032
], shallowEqual);
3133

@@ -58,7 +60,14 @@ export const RedactionPanelContainer = () => {
5860

5961
const dispatch = useDispatch();
6062
const applyAllRedactions = () => {
61-
dispatch(applyRedactions(redactionAnnotationsList));
63+
const originalApplyRedactions = () => {
64+
dispatch(applyRedactions(redactionAnnotationsList));
65+
};
66+
if (customApplyRedactionsHandler) {
67+
customApplyRedactionsHandler(redactionAnnotationsList, originalApplyRedactions);
68+
} else {
69+
originalApplyRedactions();
70+
}
6271
};
6372
const closeRedactionPanel = () => {
6473
dispatch(actions.closeElement('redactionPanel'));

src/constants/redactionTypes.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export const redactionTypeMap = {
22
REGION: 'region',
33
TEXT: 'text',
44
FULL_PAGE: 'fullPage',
5+
FULL_VIDEO_FRAME: 'fullVideoFrame',
56
CREDIT_CARD: 'creditCard',
67
PHONE: 'phone',
78
IMAGE: 'image',
@@ -17,6 +18,10 @@ export const defaultRedactionTypes = {
1718
icon: 'icon-header-page-manipulation-page-transition-page-by-page-line',
1819
label: 'redactionPanel.redactionItem.fullPageRedaction',
1920
},
21+
[redactionTypeMap['FULL_VIDEO_FRAME']]: {
22+
icon: 'ic-full-frame-video-redact',
23+
name: 'redactionPanel.redactionItem.fullVideoFrameRedaction',
24+
},
2025
[redactionTypeMap['TEXT']]: {
2126
icon: 'icon-form-field-text',
2227
},

src/redux/actions/internalActions.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,11 @@ export const setCustomNoteSelectionFunction = customNoteFunction => ({
429429
type: 'SET_CUSTOM_NOTE_SELECTION_FUNCTION',
430430
payload: { customNoteFunction },
431431
});
432+
export const setCustomApplyRedactionsHandler = customApplyRedactionsHandler => ({
433+
type: 'SET_CUSTOM_APPLY_REDACTIONS_HANDLER',
434+
payload: { customApplyRedactionsHandler },
435+
});
436+
432437
export const setEnableSnapMode = enable => ({
433438
type: 'SET_ENABLE_SNAP_MODE',
434439
payload: { enable },

src/redux/reducers/viewerReducer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,8 @@ export default initialState => (state = initialState, action) => {
406406
return { ...state, noteTransformFunction: payload.noteTransformFunction };
407407
case 'SET_CUSTOM_NOTE_SELECTION_FUNCTION':
408408
return { ...state, customNoteFunction: payload.customNoteFunction };
409+
case 'SET_CUSTOM_APPLY_REDACTIONS_HANDLER':
410+
return { ...state, customApplyRedactionsHandler: payload.customApplyRedactionsHandler };
409411
case 'SET_ANNOTATION_CONTENT_OVERLAY_HANDLER':
410412
return { ...state, annotationContentOverlayHandler: payload.annotationContentOverlayHandler };
411413
case 'SET_CUSTOM_MODAL': {

src/redux/selectors/exposedSelectors.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,8 @@ export const getNoteTransformFunction = state => state.viewer.noteTransformFunct
411411

412412
export const getCustomNoteSelectionFunction = state => state.viewer.customNoteFunction;
413413

414+
export const getCustomApplyRedactionsHandler = state => state.viewer.customApplyRedactionsHandler;
415+
414416
export const isSnapModeEnabled = state => state.viewer.isSnapModeEnabled;
415417

416418
export const getUnreadAnnotationIdSet = state => state.viewer.unreadAnnotationIdSet;

0 commit comments

Comments
 (0)