|
@@ -17,8 +17,6 @@ import {
|
|
|
DropdownMenu,
|
|
DropdownMenu,
|
|
|
DropdownToggle,
|
|
DropdownToggle,
|
|
|
} from '@/features/ui/components/bootstrap-5/dropdown-menu'
|
|
} from '@/features/ui/components/bootstrap-5/dropdown-menu'
|
|
|
-import { useSendProjectListMB } from '@/features/project-list/components/project-list-events'
|
|
|
|
|
-import type { PortalTemplate } from '../../../../../types/portal-template'
|
|
|
|
|
|
|
|
|
|
type SendTrackingEvent = {
|
|
type SendTrackingEvent = {
|
|
|
dropdownMenu: string
|
|
dropdownMenu: string
|
|
@@ -56,7 +54,7 @@ function NewProjectButton({
|
|
|
useState<Nullable<NewProjectButtonModalVariant>>(null)
|
|
useState<Nullable<NewProjectButtonModalVariant>>(null)
|
|
|
const portalTemplates = getMeta('ol-portalTemplates') || []
|
|
const portalTemplates = getMeta('ol-portalTemplates') || []
|
|
|
const { show: enableAddAffiliationWidget } = useAddAffiliation()
|
|
const { show: enableAddAffiliationWidget } = useAddAffiliation()
|
|
|
- const sendProjectListMB = useSendProjectListMB()
|
|
|
|
|
|
|
+
|
|
|
const sendTrackingEvent = useCallback(
|
|
const sendTrackingEvent = useCallback(
|
|
|
({
|
|
({
|
|
|
dropdownMenu,
|
|
dropdownMenu,
|
|
@@ -105,46 +103,37 @@ function NewProjectButton({
|
|
|
dropdownMenu: dropdownMenuEvent,
|
|
dropdownMenu: dropdownMenuEvent,
|
|
|
dropdownOpen: true,
|
|
dropdownOpen: true,
|
|
|
})
|
|
})
|
|
|
- sendProjectListMB('new-project-click', { item: dropdownMenuEvent })
|
|
|
|
|
|
|
|
|
|
setModal(modalVariant)
|
|
setModal(modalVariant)
|
|
|
},
|
|
},
|
|
|
- [sendProjectListMB, sendTrackingEvent]
|
|
|
|
|
|
|
+ [sendTrackingEvent]
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
const handlePortalTemplateClick = useCallback(
|
|
const handlePortalTemplateClick = useCallback(
|
|
|
- (e: React.MouseEvent, template: PortalTemplate) => {
|
|
|
|
|
|
|
+ (e: React.MouseEvent, institutionTemplateName: string) => {
|
|
|
// avoid invoking the "onClick" callback on the main dropdown button
|
|
// avoid invoking the "onClick" callback on the main dropdown button
|
|
|
e.stopPropagation()
|
|
e.stopPropagation()
|
|
|
|
|
|
|
|
sendTrackingEvent({
|
|
sendTrackingEvent({
|
|
|
dropdownMenu: 'institution-template',
|
|
dropdownMenu: 'institution-template',
|
|
|
dropdownOpen: true,
|
|
dropdownOpen: true,
|
|
|
- institutionTemplateName: template.name,
|
|
|
|
|
- })
|
|
|
|
|
- sendProjectListMB('new-project-click', {
|
|
|
|
|
- item: template.name,
|
|
|
|
|
- destinationURL: template.url,
|
|
|
|
|
|
|
+ institutionTemplateName,
|
|
|
})
|
|
})
|
|
|
},
|
|
},
|
|
|
- [sendProjectListMB, sendTrackingEvent]
|
|
|
|
|
|
|
+ [sendTrackingEvent]
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
const handleStaticTemplateClick = useCallback(
|
|
const handleStaticTemplateClick = useCallback(
|
|
|
- (e: React.MouseEvent, template: { trackingKey: string; url: string }) => {
|
|
|
|
|
|
|
+ (e: React.MouseEvent, templateTrackingKey: string) => {
|
|
|
// avoid invoking the "onClick" callback on the main dropdown button
|
|
// avoid invoking the "onClick" callback on the main dropdown button
|
|
|
e.stopPropagation()
|
|
e.stopPropagation()
|
|
|
|
|
|
|
|
sendTrackingEvent({
|
|
sendTrackingEvent({
|
|
|
- dropdownMenu: template.trackingKey,
|
|
|
|
|
|
|
+ dropdownMenu: templateTrackingKey,
|
|
|
dropdownOpen: true,
|
|
dropdownOpen: true,
|
|
|
})
|
|
})
|
|
|
- sendProjectListMB('new-project-click', {
|
|
|
|
|
- item: template.trackingKey,
|
|
|
|
|
- destinationURL: template.url,
|
|
|
|
|
- })
|
|
|
|
|
},
|
|
},
|
|
|
- [sendProjectListMB, sendTrackingEvent]
|
|
|
|
|
|
|
+ [sendTrackingEvent]
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
const [importProjectFromGithubMenu] = importOverleafModules(
|
|
const [importProjectFromGithubMenu] = importOverleafModules(
|
|
@@ -160,9 +149,6 @@ function NewProjectButton({
|
|
|
<Dropdown
|
|
<Dropdown
|
|
|
className={classnames('new-project-dropdown', className)}
|
|
className={classnames('new-project-dropdown', className)}
|
|
|
onSelect={handleMainButtonClick}
|
|
onSelect={handleMainButtonClick}
|
|
|
- onToggle={nextShow => {
|
|
|
|
|
- if (nextShow) sendProjectListMB('new-project-expand', undefined)
|
|
|
|
|
- }}
|
|
|
|
|
>
|
|
>
|
|
|
<DropdownToggle
|
|
<DropdownToggle
|
|
|
id={id}
|
|
id={id}
|
|
@@ -231,7 +217,9 @@ function NewProjectButton({
|
|
|
<DropdownItem
|
|
<DropdownItem
|
|
|
key={`portal-template-${index}`}
|
|
key={`portal-template-${index}`}
|
|
|
href={`${portalTemplate.url}#templates`}
|
|
href={`${portalTemplate.url}#templates`}
|
|
|
- onClick={e => handlePortalTemplateClick(e, portalTemplate)}
|
|
|
|
|
|
|
+ onClick={e =>
|
|
|
|
|
+ handlePortalTemplateClick(e, portalTemplate.name)
|
|
|
|
|
+ }
|
|
|
aria-label={`${portalTemplate.name} ${t('template')}`}
|
|
aria-label={`${portalTemplate.name} ${t('template')}`}
|
|
|
>
|
|
>
|
|
|
{portalTemplate.name}
|
|
{portalTemplate.name}
|
|
@@ -253,7 +241,9 @@ function NewProjectButton({
|
|
|
<li role="none" key={`new-project-button-template-${index}`}>
|
|
<li role="none" key={`new-project-button-template-${index}`}>
|
|
|
<DropdownItem
|
|
<DropdownItem
|
|
|
href={templateLink.url}
|
|
href={templateLink.url}
|
|
|
- onClick={e => handleStaticTemplateClick(e, templateLink)}
|
|
|
|
|
|
|
+ onClick={e =>
|
|
|
|
|
+ handleStaticTemplateClick(e, templateLink.trackingKey)
|
|
|
|
|
+ }
|
|
|
aria-label={`${templateLink.name} ${t('template')}`}
|
|
aria-label={`${templateLink.name} ${t('template')}`}
|
|
|
>
|
|
>
|
|
|
{templateLink.name === 'view_all'
|
|
{templateLink.name === 'view_all'
|