Skip to content

Commit

Permalink
add groupName to pause and resume keyboard shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
CollinBeczak committed Sep 13, 2023
1 parent d8dc0d9 commit 02f9181
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ const mapDispatchToProps = dispatch => {
removeExternalKeyboardShortcut: (groupName, shortcutName) => {
dispatch(removeKeyboardShortcut(groupName, shortcutName))
},
pauseKeyboardShortcuts: () => {
dispatch(pauseKeyboardShortcuts())
pauseKeyboardShortcuts: (groupName) => {
dispatch(pauseKeyboardShortcuts(groupName))
},
resumeKeyboardShortcuts: () => {
dispatch(resumeKeyboardShortcuts())
resumeKeyboardShortcuts: (groupName) => {
dispatch(resumeKeyboardShortcuts(groupName))
},
textInputActive: textInputActive,
quickKeyHandler: (key, handler, allowModifierKeys=false) => (event => {
Expand Down
5 changes: 3 additions & 2 deletions src/components/TaskConfirmationModal/TaskConfirmationModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import messages from './Messages'
import ErrorTagDropdown from '../ErrorTagDropdown/ErrorTagDropdown'

const shortcutGroup = 'taskConfirmation'
const shortcutAction = 'pause'

const ERROR_TAG_STATUSES = [
TaskReviewStatus.rejected,
Expand Down Expand Up @@ -76,7 +77,7 @@ export class TaskConfirmationModal extends Component {
this.commentInputRef.current.focus()
}

this.props.pauseKeyboardShortcuts()
this.props.pauseKeyboardShortcuts(shortcutAction)
this.props.activateKeyboardShortcut(
shortcutGroup,
this.props.keyboardShortcutGroups.taskConfirmation,
Expand All @@ -92,7 +93,7 @@ export class TaskConfirmationModal extends Component {
componentWillUnmount() {
this.props.deactivateKeyboardShortcut(shortcutGroup, 'confirmSubmit',
this.handleKeyboardShortcuts)
this.props.resumeKeyboardShortcuts()
this.props.resumeKeyboardShortcuts(shortcutAction)
}

handleAddTag = (value) => {
Expand Down
10 changes: 6 additions & 4 deletions src/components/Widgets/TaskMapWidget/TaskMapWidget.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import EditSwitch from './RapidEditor/EditSwitch'
import RapidEditor from './RapidEditor/RapidEditor';
import WithKeyboardShortcuts from '../../HOCs/WithKeyboardShortcuts/WithKeyboardShortcuts'

const shortcutAction = 'pause'

const descriptor = {
widgetKey: 'TaskMapWidget',
label: messages.label,
Expand All @@ -26,7 +28,7 @@ export default class TaskMapWidget extends Component {
}

componentWillUnmount = () => {
this.props.resumeKeyboardShortcuts()
this.props.resumeKeyboardShortcuts(shortcutAction)
}

componentDidUpdate = (prevProps) => {
Expand All @@ -38,16 +40,16 @@ export default class TaskMapWidget extends Component {
this.setState({ counter: this.state.counter + 1 })
}

this.handlePauseShortcuts()
this.handlePauseShortcuts(shortcutAction)
}

handlePauseShortcuts = () => {
const editMode = this.props.getUserAppSetting ? this.props.getUserAppSetting(this.props.user, 'isEditMode') : false;

if (editMode) {
this.props.pauseKeyboardShortcuts()
this.props.pauseKeyboardShortcuts(shortcutAction)
} else {
this.props.resumeKeyboardShortcuts()
this.props.resumeKeyboardShortcuts(shortcutAction)
}
}

Expand Down
9 changes: 6 additions & 3 deletions src/services/KeyboardShortcuts/KeyboardShortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ export const removeKeyboardShortcut = function(groupName, shortcutName) {
}
}

export const pauseKeyboardShortcuts = function() {
export const pauseKeyboardShortcuts = function(groupName) {
return {
type: PAUSE_KEYBOARD_SHORTCUTS,
groupName,
}
}

export const resumeKeyboardShortcuts = function() {
export const resumeKeyboardShortcuts = function(groupName) {
return {
type: RESUME_KEYBOARD_SHORTCUTS,
groupName,
}
}

Expand Down Expand Up @@ -103,7 +105,8 @@ export const currentKeyboardShortcuts = function(state={}, action) {
}
else if (action.type === PAUSE_KEYBOARD_SHORTCUTS) {
// If we're already paused, ignore
if (_isEmpty(state.paused)) {
console.log(state)
if (!_isEmpty(state.paused)) {
return state
}

Expand Down

0 comments on commit 02f9181

Please sign in to comment.