Download wp-calypso/client/state/ui/reducer.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 2.88 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/ui/reducer.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/ui/reducer.js
-
curl -L -o reducer.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/ui/reducer.js
2.88 kB
| import { withStorageKey } from '@automattic/state-utils'; | |
| import { | |
| SELECTED_SITE_SET, | |
| SECTION_LOADING_SET, | |
| NOTIFICATIONS_PANEL_TOGGLE, | |
| MOST_RECENTLY_SELECTED_SITE_SET, | |
| } from 'calypso/state/action-types'; | |
| import { combineReducers, withSchemaValidation } from 'calypso/state/utils'; | |
| import actionLog from './action-log/reducer'; | |
| import appBannerDismissed from './app-banner-dismissed/reducer'; | |
| import appBannerVisibility from './app-banner-visibility/reducer'; | |
| import checkout from './checkout/reducer'; | |
| import language from './language/reducer'; | |
| import layoutFocus from './layout-focus/reducer'; | |
| import masterbarVisibility from './masterbar-visibility/reducer'; | |
| import mediaModal from './media-modal/reducer'; | |
| import postTypeList from './post-type-list/reducer'; | |
| import preview from './preview/reducer'; | |
| import section from './section/reducer'; | |
| /** | |
| * Tracks the currently selected site ID. | |
| * @param {Object} state Current state | |
| * @param {Object} action Action payload | |
| * @returns {Object} Updated state | |
| */ | |
| export const selectedSiteId = withSchemaValidation( | |
| { type: [ 'number', 'null' ] }, | |
| ( state = null, action ) => { | |
| switch ( action.type ) { | |
| case SELECTED_SITE_SET: | |
| return action.siteId || null; | |
| } | |
| return state; | |
| } | |
| ); | |
| export const mostRecentlySelectedSiteId = withSchemaValidation( | |
| { type: [ 'number', 'null' ] }, | |
| ( state = null, action ) => { | |
| switch ( action.type ) { | |
| case MOST_RECENTLY_SELECTED_SITE_SET: | |
| // Don't set nullish values for this. No selection is not a valid previous selection. | |
| if ( action.siteId ) { | |
| return action.siteId; | |
| } | |
| return state; | |
| } | |
| return state; | |
| } | |
| ); | |
| export const siteSelectionInitialized = withSchemaValidation( | |
| { type: 'boolean' }, | |
| ( state = false, action ) => { | |
| switch ( action.type ) { | |
| case SELECTED_SITE_SET: | |
| return true; | |
| } | |
| return state; | |
| } | |
| ); | |
| export function isSectionLoading( state = false, action ) { | |
| switch ( action.type ) { | |
| case SECTION_LOADING_SET: | |
| return action.isSectionLoading; | |
| } | |
| return state; | |
| } | |
| /** | |
| * Tracks if the notifications panel is open | |
| * @param {Object} state Current state | |
| * @param {Object} action Action payload | |
| * @param {string} action.type The action type identifier. In this case it's looking for NOTIFICATIONS_PANEL_TOGGLE | |
| * @returns {Object} Updated state | |
| */ | |
| export function isNotificationsOpen( state = false, { type } ) { | |
| if ( type === NOTIFICATIONS_PANEL_TOGGLE ) { | |
| return ! state; | |
| } | |
| return state; | |
| } | |
| const reducer = combineReducers( { | |
| actionLog, | |
| appBannerVisibility, | |
| appBannerDismissed, | |
| checkout, | |
| isSectionLoading, | |
| isNotificationsOpen, | |
| language, | |
| layoutFocus, | |
| masterbarVisibility, | |
| mediaModal, | |
| postTypeList, | |
| preview, | |
| mostRecentlySelectedSiteId, | |
| section, | |
| selectedSiteId, | |
| siteSelectionInitialized, | |
| } ); | |
| export { reducer }; | |
| export default withStorageKey( 'ui', reducer ); | |