Download wp-calypso/client/jetpack-cloud/sections/plugin-management/controller.tsx from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 1.35 kB
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/jetpack-cloud/sections/plugin-management/controller.tsx
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/jetpack-cloud/sections/plugin-management/controller.tsx
-
curl -L -o controller.tsx https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/jetpack-cloud/sections/plugin-management/controller.tsx
1.35 kB
| import page, { type Callback, type Context } from '@automattic/calypso-router'; | |
| import JetpackManageSidebar from 'calypso/jetpack-cloud/sections/sidebar-navigation/jetpack-manage'; | |
| import { isAgencyUser } from 'calypso/state/partner-portal/partner/selectors'; | |
| import Header from '../agency-dashboard/header'; | |
| import PluginsOverview from './plugins-overview'; | |
| const redirectIfHasNoAccess = ( context: Context ) => { | |
| const state = context.store.getState(); | |
| const isAgency = isAgencyUser( state ); | |
| if ( ! isAgency ) { | |
| page.redirect( '/' ); | |
| return; | |
| } | |
| }; | |
| const setSidebar = ( context: Context ): void => { | |
| context.secondary = <JetpackManageSidebar path={ context.path } />; | |
| }; | |
| export const pluginManagementContext: Callback = ( context, next ) => { | |
| redirectIfHasNoAccess( context ); | |
| const { site } = context.params; | |
| context.header = <Header />; | |
| // Set secondary context only on multi-site view | |
| if ( ! site ) { | |
| setSidebar( context ); | |
| } | |
| next(); | |
| }; | |
| export const pluginDetailsContext: Callback = ( context, next ) => { | |
| redirectIfHasNoAccess( context ); | |
| const { plugin, site } = context.params; | |
| context.header = <Header />; | |
| // Set secondary context only on multi-site view | |
| if ( ! site ) { | |
| setSidebar( context ); | |
| } | |
| context.primary = <PluginsOverview pluginSlug={ plugin } site={ site } path={ context.path } />; | |
| next(); | |
| }; | |