mirror of
https://github.com/strapi/strapi.git
synced 2025-09-21 14:31:16 +00:00
Merge branch 'main' into chore/tracking-edit-field-name
This commit is contained in:
commit
882eccae19
@ -2,7 +2,7 @@ import React, { useRef, useState } from 'react';
|
||||
import styled from 'styled-components';
|
||||
import PropTypes from 'prop-types';
|
||||
import { useIntl } from 'react-intl';
|
||||
import { NavLink as RouterNavLink } from 'react-router-dom';
|
||||
import { NavLink as RouterNavLink, useLocation } from 'react-router-dom';
|
||||
import { Divider } from '@strapi/design-system/Divider';
|
||||
import {
|
||||
MainNav,
|
||||
@ -19,7 +19,7 @@ import { Typography } from '@strapi/design-system/Typography';
|
||||
import { Stack } from '@strapi/design-system/Stack';
|
||||
import Write from '@strapi/icons/Write';
|
||||
import Exit from '@strapi/icons/Exit';
|
||||
import { auth, usePersistentState, useAppInfos } from '@strapi/helper-plugin';
|
||||
import { auth, usePersistentState, useAppInfos, useTracking } from '@strapi/helper-plugin';
|
||||
import useConfigurations from '../../hooks/useConfigurations';
|
||||
|
||||
const LinkUserWrapper = styled(Box)`
|
||||
@ -59,6 +59,8 @@ const LeftMenu = ({ generalSectionLinks, pluginsSectionLinks }) => {
|
||||
const [condensed, setCondensed] = usePersistentState('navbar-condensed', false);
|
||||
const { userDisplayName } = useAppInfos();
|
||||
const { formatMessage } = useIntl();
|
||||
const { trackUsage } = useTracking();
|
||||
const { pathname } = useLocation();
|
||||
|
||||
const initials = userDisplayName
|
||||
.split(' ')
|
||||
@ -82,6 +84,10 @@ const LeftMenu = ({ generalSectionLinks, pluginsSectionLinks }) => {
|
||||
}
|
||||
};
|
||||
|
||||
const handleClickOnLink = (destination = null) => {
|
||||
trackUsage('willNavigate', { from: pathname, to: destination });
|
||||
};
|
||||
|
||||
const menuTitle = formatMessage({
|
||||
id: 'app.components.LeftMenu.navbrand.title',
|
||||
defaultMessage: 'Strapi Dashboard',
|
||||
@ -110,7 +116,12 @@ const LeftMenu = ({ generalSectionLinks, pluginsSectionLinks }) => {
|
||||
<Divider />
|
||||
|
||||
<NavSections>
|
||||
<NavLink as={RouterNavLink} to="/content-manager" icon={<Write />}>
|
||||
<NavLink
|
||||
as={RouterNavLink}
|
||||
to="/content-manager"
|
||||
icon={<Write />}
|
||||
onClick={() => handleClickOnLink('/content-manager')}
|
||||
>
|
||||
{formatMessage({ id: 'global.content-manager', defaultMessage: 'Content manager' })}
|
||||
</NavLink>
|
||||
|
||||
@ -125,7 +136,13 @@ const LeftMenu = ({ generalSectionLinks, pluginsSectionLinks }) => {
|
||||
const Icon = link.icon;
|
||||
|
||||
return (
|
||||
<NavLink as={RouterNavLink} to={link.to} key={link.to} icon={<Icon />}>
|
||||
<NavLink
|
||||
as={RouterNavLink}
|
||||
to={link.to}
|
||||
key={link.to}
|
||||
icon={<Icon />}
|
||||
onClick={() => handleClickOnLink(link.to)}
|
||||
>
|
||||
{formatMessage(link.intlLabel)}
|
||||
</NavLink>
|
||||
);
|
||||
@ -152,6 +169,7 @@ const LeftMenu = ({ generalSectionLinks, pluginsSectionLinks }) => {
|
||||
to={link.to}
|
||||
key={link.to}
|
||||
icon={<LinkIcon />}
|
||||
onClick={() => handleClickOnLink(link.to)}
|
||||
>
|
||||
{formatMessage(link.intlLabel)}
|
||||
</NavLink>
|
||||
|
@ -229,14 +229,14 @@ FormApiTokenContainer.propTypes = {
|
||||
values: PropTypes.shape({
|
||||
name: PropTypes.string,
|
||||
description: PropTypes.string,
|
||||
lifespan: PropTypes.string,
|
||||
lifespan: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
type: PropTypes.string,
|
||||
}).isRequired,
|
||||
isCreating: PropTypes.bool.isRequired,
|
||||
apiToken: PropTypes.shape({
|
||||
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
type: PropTypes.string,
|
||||
lifespan: PropTypes.number,
|
||||
lifespan: PropTypes.string,
|
||||
name: PropTypes.string,
|
||||
accessKey: PropTypes.string,
|
||||
permissions: PropTypes.array,
|
||||
|
@ -50,7 +50,7 @@ FormBody.propTypes = {
|
||||
apiToken: PropTypes.shape({
|
||||
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
type: PropTypes.string,
|
||||
lifespan: PropTypes.number,
|
||||
lifespan: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
name: PropTypes.string,
|
||||
accessKey: PropTypes.string,
|
||||
permissions: PropTypes.array,
|
||||
|
@ -69,7 +69,7 @@ FormHead.propTypes = {
|
||||
apiToken: PropTypes.shape({
|
||||
id: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
type: PropTypes.string,
|
||||
lifespan: PropTypes.number,
|
||||
lifespan: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
||||
name: PropTypes.string,
|
||||
accessKey: PropTypes.string,
|
||||
permissions: PropTypes.array,
|
||||
|
Loading…
x
Reference in New Issue
Block a user