Download wp-calypso/apps/notifications/src/panel/state/ui/reducer.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.46 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/apps/notifications/src/panel/state/ui/reducer.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/apps/notifications/src/panel/state/ui/reducer.js
-
curl -L -o reducer.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/apps/notifications/src/panel/state/ui/reducer.js
1.46 kB
| import { combineReducers } from 'redux'; | |
| import { | |
| NOTES_LOADED, | |
| NOTES_LOADING, | |
| SELECT_NOTE, | |
| SET_IS_SHOWING, | |
| SET_FILTER, | |
| ENABLE_KEYBOARD_SHORTCUTS, | |
| DISABLE_KEYBOARD_SHORTCUTS, | |
| } from '../action-types'; | |
| export const isLoading = ( state = true, { type } ) => { | |
| if ( NOTES_LOADING === type ) { | |
| return true; | |
| } | |
| if ( NOTES_LOADED === type ) { | |
| return false; | |
| } | |
| return state; | |
| }; | |
| export const isPanelOpen = ( state = false, { type, isShowing } ) => | |
| SET_IS_SHOWING === type ? isShowing : state; | |
| export const selectedNoteId = ( state = null, { type, noteId } ) => { | |
| if ( SELECT_NOTE === type ) { | |
| return noteId; | |
| } | |
| if ( SET_FILTER === type ) { | |
| return null; | |
| } | |
| return state; | |
| }; | |
| export const keyboardShortcutsAreEnabled = ( state = false, action ) => { | |
| switch ( action.type ) { | |
| case ENABLE_KEYBOARD_SHORTCUTS: { | |
| return true; | |
| } | |
| case DISABLE_KEYBOARD_SHORTCUTS: { | |
| return false; | |
| } | |
| } | |
| return state; | |
| }; | |
| // eslint-disable-next-line no-shadow | |
| export const filterName = ( state = 'all', { type, filterName } ) => | |
| SET_FILTER === type ? filterName : state; | |
| export const shortcutsPopoverIsOpen = ( state = false, { type } ) => { | |
| switch ( type ) { | |
| case 'TOGGLE_SHORTCUTS_POPOVER': | |
| return ! state; | |
| case 'CLOSE_SHORTCUTS_POPOVER': | |
| return false; | |
| default: | |
| return state; | |
| } | |
| }; | |
| export default combineReducers( { | |
| isLoading, | |
| isPanelOpen, | |
| selectedNoteId, | |
| filterName, | |
| keyboardShortcutsAreEnabled, | |
| shortcutsPopoverIsOpen, | |
| } ); | |