| Server IP : 52.25.153.185 / Your IP : 216.73.217.117 Web Server : Apache System : Linux ip-172-26-6-158 5.10.0-45-cloud-amd64 #1 SMP Debian 5.10.259-1 (2026-07-02) x86_64 User : daemon ( 1) PHP Version : 8.1.10 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /bitnami/wordpress/wp-content/plugins/code-snippets/js/components/ImportMenu/ |
Upload File : |
import React, { useState } from 'react'
import classnames from 'classnames'
import { __, sprintf } from '@wordpress/i18n'
import { WithRestAPIContext } from '../../hooks/useRestAPI'
import { ScreenMetaSlot } from '../common/ScreenMetaSlot'
import { SubnavTabs, getTabFromQuery } from '../common/SubnavTabs'
import { Toolbar } from '../common/Toolbar'
import { UploadForm } from './UploadForm/UploadForm'
import { MigrateForm } from './MigrateForm/MigrateForm'
import type { SubnavTab} from '../common/SubnavTabs'
import type { ReactNode } from 'react'
const TAB_QUERY_PARAM = 'tab'
interface ImportMenuTab extends SubnavTab<'upload' | 'migrate'> {
content: ReactNode
}
const TABS: ImportMenuTab[] = [
{
name: 'upload',
label: __('Upload snippets', 'code-snippets'),
content: <UploadForm />
},
{
name: 'migrate',
label: __('Migrate from other plugins', 'code-snippets'),
content: <MigrateForm />
}
]
export const ImportMenu: React.FC = () => {
const [currentTab, setCurrentTab] = useState<ImportMenuTab>(() => getTabFromQuery(TABS, TAB_QUERY_PARAM))
return (
<>
<Toolbar />
<SubnavTabs
className="import-type-nav"
ariaLabel={__('Import sources', 'code-snippets')}
tabs={TABS}
currentTab={currentTab}
queryParamName={TAB_QUERY_PARAM}
setCurrentTab={setCurrentTab}
/>
<ScreenMetaSlot />
<div className="snippets-page-header">
<h1>{// translators: %s: label of the currently selected import tab.
sprintf(__('Import: %s', 'code-snippets'), currentTab.label)}</h1>
</div>
<hr className="wp-header-end" />
<WithRestAPIContext>
{TABS.map(tab =>
<div
key={tab.name}
className={classnames('import-snippets-section', { 'active-section': tab.name === currentTab.name })}
>
{tab.content}
</div>)}
</WithRestAPIContext>
</>
)
}