| 1 |
import { __ } from '@wordpress/i18n'; |
| 2 |
import { |
| 3 |
footer, |
| 4 |
header, |
| 5 |
Icon, |
| 6 |
navigation, |
| 7 |
page, |
| 8 |
plugins, |
| 9 |
post, |
| 10 |
reusableBlock, |
| 11 |
styles, |
| 12 |
} from '@wordpress/icons'; |
| 13 |
import classNames from 'classnames'; |
| 14 |
|
| 15 |
const { themeSlug, adminUrl, devbuild, isBlockTheme, useAgentOnboarding } = |
| 16 |
window.extSharedData; |
| 17 |
const { hasCustomizer, editSiteNavigationMenuLink } = window.extAssistData; |
| 18 |
|
| 19 |
const showRestartLaunch = |
| 20 |
devbuild || window.extAssistData.canSeeRestartLaunch || false; |
| 21 |
|
| 22 |
export const QuickLinks = ({ className }) => { |
| 23 |
const quickLinks = [ |
| 24 |
{ |
| 25 |
title: __('Add new page', 'extendify-local'), |
| 26 |
link: `${adminUrl}post-new.php?post_type=page`, |
| 27 |
slug: 'add-new-page', |
| 28 |
icon: page, |
| 29 |
show: true, |
| 30 |
}, |
| 31 |
{ |
| 32 |
title: __('Add new post', 'extendify-local'), |
| 33 |
link: `${adminUrl}post-new.php`, |
| 34 |
slug: 'add-new-post', |
| 35 |
icon: post, |
| 36 |
show: true, |
| 37 |
}, |
| 38 |
{ |
| 39 |
title: __('Explore plugins', 'extendify-local'), |
| 40 |
link: `${adminUrl}plugin-install.php`, |
| 41 |
slug: 'explore-plugins', |
| 42 |
icon: plugins, |
| 43 |
show: true, |
| 44 |
}, |
| 45 |
{ |
| 46 |
title: __('Site style', 'extendify-local'), |
| 47 |
link: `${adminUrl}site-editor.php?path=%2Fwp_global_styles`, |
| 48 |
slug: 'site-style', |
| 49 |
icon: styles, |
| 50 |
show: isBlockTheme, |
| 51 |
}, |
| 52 |
{ |
| 53 |
title: __('Site style', 'extendify-local'), |
| 54 |
link: `${adminUrl}customize.php?return=%2Fwp%2Fwp-admin%2Fadmin.php%3Fpage%3Dextendify-assist`, |
| 55 |
slug: 'site-style-classic', |
| 56 |
icon: styles, |
| 57 |
show: hasCustomizer && !isBlockTheme, |
| 58 |
}, |
| 59 |
{ |
| 60 |
title: __('Edit header', 'extendify-local'), |
| 61 |
link: `${adminUrl}site-editor.php?postId=extendable%2F%2Fheader&postType=wp_template_part&canvas=edit`, |
| 62 |
slug: 'edit-header', |
| 63 |
icon: header, |
| 64 |
show: themeSlug === 'extendable', |
| 65 |
}, |
| 66 |
{ |
| 67 |
title: __('Edit footer', 'extendify-local'), |
| 68 |
link: `${adminUrl}site-editor.php?postId=extendable%2F%2Ffooter&postType=wp_template_part&canvas=edit`, |
| 69 |
slug: 'edit-footer', |
| 70 |
icon: footer, |
| 71 |
show: themeSlug === 'extendable', |
| 72 |
}, |
| 73 |
{ |
| 74 |
title: __('Edit site navigation', 'extendify-local'), |
| 75 |
link: editSiteNavigationMenuLink, |
| 76 |
slug: 'edit-site-navigation', |
| 77 |
icon: navigation, |
| 78 |
show: true, |
| 79 |
}, |
| 80 |
{ |
| 81 |
// translators: "Reset site" refers to the action of resetting the user's WordPress site to a fresh state. |
| 82 |
title: __('Reset site', 'extendify-local'), |
| 83 |
link: useAgentOnboarding |
| 84 |
? `${adminUrl}admin.php?page=extendify-auto-launch` |
| 85 |
: `${adminUrl}admin.php?page=extendify-launch`, |
| 86 |
slug: 'reset-site', |
| 87 |
icon: reusableBlock, |
| 88 |
show: showRestartLaunch && themeSlug === 'extendable', |
| 89 |
}, |
| 90 |
]; |
| 91 |
|
| 92 |
return ( |
| 93 |
<div |
| 94 |
data-test="assist-quick-links-module" |
| 95 |
id="assist-quick-links-module" |
| 96 |
className={classNames( |
| 97 |
className, |
| 98 |
'h-full w-full rounded-sm border border-gray-300 bg-white p-5 text-base lg:p-8', |
| 99 |
)} |
| 100 |
> |
| 101 |
<h2 className="mb-4 mt-0 text-lg font-semibold"> |
| 102 |
{__('Quick Links', 'extendify-local')} |
| 103 |
</h2> |
| 104 |
<div className="grid place-items-start gap-x-6 md:grid-flow-col md:grid-rows-2"> |
| 105 |
{quickLinks |
| 106 |
.filter((item) => item.show) |
| 107 |
.map((item) => ( |
| 108 |
<a |
| 109 |
key={item.slug} |
| 110 |
href={item.link} |
| 111 |
title={item.title} |
| 112 |
data-test={`assist-quick-links-module-${item.slug}`} |
| 113 |
className="flex items-center justify-center py-1.5 text-sm text-gray-800 no-underline hover:text-design-main hover:underline hover:underline-offset-2" |
| 114 |
> |
| 115 |
<Icon |
| 116 |
icon={item.icon} |
| 117 |
className="mr-2 fill-current rtl:ml-2 rtl:mr-auto" |
| 118 |
/> |
| 119 |
<span className="mr-1">{item.title}</span> |
| 120 |
</a> |
| 121 |
))} |
| 122 |
</div> |
| 123 |
</div> |
| 124 |
); |
| 125 |
}; |
| 126 |
|