Skip to content

Commit f85c211

Browse files
committed
[update] resolves #13, change enableNotesPanel to have higher priority than other feature API calls. Also changed naming for priority constants so it's more flexible to have more priorities
1 parent 5ca67f3 commit f85c211

File tree

9 files changed

+33
-32
lines changed

9 files changed

+33
-32
lines changed

src/apis/enableAnnotations.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import core from 'core';
22
import getAnnotationRelatedElements from 'helpers/getAnnotationRelatedElements';
3-
import { LOW_PRIORITY } from 'constants/actionPriority';
3+
import { PRIORITY_ONE } from 'constants/actionPriority';
44
import actions from 'actions';
55

66
export default store => (enable = true) => {
@@ -11,10 +11,10 @@ export default store => (enable = true) => {
1111
];
1212

1313
if (enable) {
14-
store.dispatch(actions.enableElements(elements, LOW_PRIORITY));
14+
store.dispatch(actions.enableElements(elements, PRIORITY_ONE));
1515
core.showAnnotations(core.getAnnotationsList());
1616
} else {
17-
store.dispatch(actions.disableElements(elements, LOW_PRIORITY));
17+
store.dispatch(actions.disableElements(elements, PRIORITY_ONE));
1818
core.hideAnnotations(core.getAnnotationsList());
1919
}
2020
};

src/apis/enableDownload.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { LOW_PRIORITY } from 'constants/actionPriority';
1+
import { PRIORITY_ONE } from 'constants/actionPriority';
22
import actions from 'actions';
33

44
export default store => (enable = true) => {
55
if (enable) {
6-
store.dispatch(actions.enableElement('downloadButton', LOW_PRIORITY));
6+
store.dispatch(actions.enableElement('downloadButton', PRIORITY_ONE));
77
} else {
8-
store.dispatch(actions.disableElement('downloadButton', LOW_PRIORITY));
8+
store.dispatch(actions.disableElement('downloadButton', PRIORITY_ONE));
99
}
1010
};

src/apis/enableFilePicker.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { LOW_PRIORITY } from 'constants/actionPriority';
1+
import { PRIORITY_ONE } from 'constants/actionPriority';
22
import actions from 'actions';
33

44
export default store => (enable = true) => {
55
if (enable) {
6-
store.dispatch(actions.enableElements(['filePickerHandler', 'filePickerButton'], LOW_PRIORITY));
6+
store.dispatch(actions.enableElements(['filePickerHandler', 'filePickerButton'], PRIORITY_ONE));
77
} else {
8-
store.dispatch(actions.disableElements(['filePickerHandler', 'filePickerButton'], LOW_PRIORITY));
8+
store.dispatch(actions.disableElements(['filePickerHandler', 'filePickerButton'], PRIORITY_ONE));
99
}
1010
};

src/apis/enableNotesPanel.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { LOW_PRIORITY } from 'constants/actionPriority';
1+
import { PRIORITY_TWO } from 'constants/actionPriority';
22
import actions from 'actions';
33

44
export default store => (enable = true) => {
55
if (enable) {
6-
store.dispatch(actions.enableElements(['annotationCommentButton', 'notesPanelButton', 'notesPanel'], LOW_PRIORITY));
6+
store.dispatch(actions.enableElements(['annotationCommentButton', 'notesPanelButton', 'notesPanel'], PRIORITY_TWO));
77
store.dispatch(actions.setActiveLeftPanel('notesPanel'));
88
} else {
9-
store.dispatch(actions.disableElements(['annotationCommentButton', 'notesPanelButton', 'notesPanel'], LOW_PRIORITY));
9+
store.dispatch(actions.disableElements(['annotationCommentButton', 'notesPanelButton', 'notesPanel'], PRIORITY_TWO));
1010
store.dispatch(actions.setActiveLeftPanel('thumbnailsPanel'));
1111
}
1212
};

src/apis/enablePrint.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { LOW_PRIORITY } from 'constants/actionPriority';
1+
import { PRIORITY_ONE } from 'constants/actionPriority';
22
import actions from 'actions';
33

44
export default store => (enable = true) => {
@@ -8,8 +8,8 @@ export default store => (enable = true) => {
88
];
99

1010
if (enable) {
11-
store.dispatch(actions.enableElements(elements, LOW_PRIORITY));
11+
store.dispatch(actions.enableElements(elements, PRIORITY_ONE));
1212
} else {
13-
store.dispatch(actions.disableElements(elements, LOW_PRIORITY));
13+
store.dispatch(actions.disableElements(elements, PRIORITY_ONE));
1414
}
1515
};

src/apis/enableTextSelection.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import core from 'core';
2-
import { LOW_PRIORITY } from 'constants/actionPriority';
2+
import { PRIORITY_ONE } from 'constants/actionPriority';
33
import actions from 'actions';
44

55
export default store => (enable = true) => {
66
if (enable) {
7-
store.dispatch(actions.enableElement('textPopup', LOW_PRIORITY));
7+
store.dispatch(actions.enableElement('textPopup', PRIORITY_ONE));
88
} else {
99
core.clearSelection();
1010
core.setToolMode('AnnotationEdit');
1111
store.dispatch(actions.closeElement('textPopup'));
12-
store.dispatch(actions.disableElement('textPopup', LOW_PRIORITY));
12+
store.dispatch(actions.disableElement('textPopup', PRIORITY_ONE));
1313
}
1414

1515
window.Tools.Tool.ENABLE_TEXT_SELECTION = enable;

src/apis/getActions.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import core from 'core';
2-
import { HIGH_PRIORITY } from 'constants/actionPriority';
2+
import { PRIORITY_THREE } from 'constants/actionPriority';
33
import * as exposedActions from 'actions/exposedActions';
44
import actions from 'actions';
55
import selectors from 'selectors';
66

77
export default store => ({
88
...mapExposedActions(store),
9-
disableElement: dataElement => store.dispatch(actions.disableElement(dataElement, HIGH_PRIORITY)),
10-
disableElements: dataElements => store.dispatch(actions.disableElements(dataElements, HIGH_PRIORITY)),
11-
enableElement: dataElement => store.dispatch(actions.enableElement(dataElement, HIGH_PRIORITY)),
12-
enableElements: dataElements => store.dispatch(actions.enableElements(dataElements, HIGH_PRIORITY)),
9+
disableElement: dataElement => store.dispatch(actions.disableElement(dataElement, PRIORITY_THREE)),
10+
disableElements: dataElements => store.dispatch(actions.disableElements(dataElements, PRIORITY_THREE)),
11+
enableElement: dataElement => store.dispatch(actions.enableElement(dataElement, PRIORITY_THREE)),
12+
enableElements: dataElements => store.dispatch(actions.enableElements(dataElements, PRIORITY_THREE)),
1313
focusNote: id => {
1414
const state = store.getState();
1515
const annotation = core.getAnnotationById(id);

src/constants/actionPriority.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
export const HIGH_PRIORITY = 2;
2-
export const LOW_PRIORITY = 1;
1+
export const PRIORITY_THREE = 3;
2+
export const PRIORITY_TWO = 2;
3+
export const PRIORITY_ONE = 1;

src/helpers/setDefaultDisabledElements.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import core from 'core';
22
import getHashParams from 'helpers/getHashParams';
33
import getAnnotationRelatedElements from 'helpers/getAnnotationRelatedElements';
4-
import { HIGH_PRIORITY, LOW_PRIORITY } from 'constants/actionPriority';
4+
import { PRIORITY_THREE, PRIORITY_ONE } from 'constants/actionPriority';
55
import actions from 'actions';
66

77
export default store => {
@@ -19,7 +19,7 @@ export default store => {
1919
const disableElementsPassedByConstructor = (state, dispatch) => {
2020
if (state.advanced.defaultDisabledElements) {
2121
const elements = state.advanced.defaultDisabledElements.split(',');
22-
dispatch(actions.disableElements(elements, HIGH_PRIORITY));
22+
dispatch(actions.disableElements(elements, PRIORITY_THREE));
2323
}
2424
};
2525

@@ -30,7 +30,7 @@ const disableElementsIfReadOnly = (state, dispatch) => {
3030
...getAnnotationRelatedElements(state)
3131
];
3232

33-
dispatch(actions.disableElements(elements, LOW_PRIORITY));
33+
dispatch(actions.disableElements(elements, PRIORITY_ONE));
3434
core.setToolMode('AnnotationEdit');
3535
}
3636
};
@@ -44,7 +44,7 @@ const disableElementsIfAnnotationDisabled = (state, dispatch) => {
4444
...getAnnotationRelatedElements(state),
4545
];
4646

47-
dispatch(actions.disableElements(elements, LOW_PRIORITY));
47+
dispatch(actions.disableElements(elements, PRIORITY_ONE));
4848
}
4949
};
5050

@@ -57,7 +57,7 @@ const disableElementsIfFilePickerDisabled = dispatch => {
5757
'filePickerButton',
5858
];
5959

60-
dispatch(actions.disableElements(elements, LOW_PRIORITY));
60+
dispatch(actions.disableElements(elements, PRIORITY_ONE));
6161
}
6262
};
6363

@@ -71,14 +71,14 @@ const disableElementsIfHideAnnotationPanel = dispatch => {
7171
'annotationCommentButton'
7272
];
7373

74-
dispatch(actions.disableElements(elements, LOW_PRIORITY));
74+
dispatch(actions.disableElements(elements, PRIORITY_ONE));
7575
}
7676
};
7777

7878
const disableElementsIfToolBarDisabled = dispatch => {
7979
const toolBarDisabled = !getHashParams('toolbar', true);
8080

8181
if (toolBarDisabled) {
82-
dispatch(actions.disableElement('header', LOW_PRIORITY));
82+
dispatch(actions.disableElement('header', PRIORITY_ONE));
8383
}
8484
};

0 commit comments

Comments
 (0)