mirror of
https://github.com/Unleash/unleash.git
synced 2025-03-18 00:19:49 +01:00
chore: remove share insights button (#7600)
This commit is contained in:
parent
e33e538263
commit
248f879553
@ -4,13 +4,12 @@ import { useFeedback } from 'component/feedbackNew/useFeedback';
|
||||
import ReviewsOutlined from '@mui/icons-material/ReviewsOutlined';
|
||||
import {
|
||||
Button,
|
||||
Typography,
|
||||
styled,
|
||||
Typography,
|
||||
useMediaQuery,
|
||||
useTheme,
|
||||
} from '@mui/material';
|
||||
import { PageHeader } from 'component/common/PageHeader/PageHeader';
|
||||
import { ShareLink } from './ShareLink/ShareLink';
|
||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
|
||||
|
||||
type DashboardHeaderProps = {
|
||||
@ -94,7 +93,6 @@ export const InsightsHeader: VFC<DashboardHeaderProps> = ({ actions }) => {
|
||||
}
|
||||
/>
|
||||
<StyledActionButtons>
|
||||
<ShareLink />
|
||||
<Button
|
||||
startIcon={<ReviewsOutlined />}
|
||||
variant='outlined'
|
||||
|
@ -1,74 +0,0 @@
|
||||
import { type VFC, useEffect, useState } from 'react';
|
||||
import Share from '@mui/icons-material/Share';
|
||||
import { Box, Button, Typography } from '@mui/material';
|
||||
import { Dialogue } from 'component/common/Dialogue/Dialogue';
|
||||
import { LinkField } from 'component/admin/users/LinkField/LinkField';
|
||||
import { useSearchParams } from 'react-router-dom';
|
||||
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
|
||||
|
||||
const createShareLink = () => {
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.set('share', 'true');
|
||||
return url.toString();
|
||||
};
|
||||
|
||||
export const ShareLink: VFC = () => {
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [searchParams, setSearchParams] = useSearchParams();
|
||||
const { trackEvent } = usePlausibleTracker();
|
||||
|
||||
useEffect(() => {
|
||||
if (searchParams.get('share')) {
|
||||
// Remove share query param from URL
|
||||
setSearchParams((params) => {
|
||||
params.delete('share');
|
||||
return params;
|
||||
});
|
||||
|
||||
trackEvent('insights-share', {
|
||||
props: {
|
||||
eventType: 'link-opened',
|
||||
},
|
||||
});
|
||||
}
|
||||
}, [searchParams]);
|
||||
|
||||
const onCopyEvent = () => {
|
||||
trackEvent('insights-share', {
|
||||
props: {
|
||||
eventType: 'link-copied',
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
startIcon={<Share />}
|
||||
variant='outlined'
|
||||
onClick={() => setIsOpen(true)}
|
||||
>
|
||||
Share
|
||||
</Button>
|
||||
<Dialogue
|
||||
open={isOpen}
|
||||
onClick={() => setIsOpen(false)}
|
||||
primaryButtonText='Close'
|
||||
title='Share insights'
|
||||
>
|
||||
<Box>
|
||||
<Typography variant='body1'>
|
||||
Link below will lead to insights dashboard with
|
||||
currently selected filter.
|
||||
</Typography>
|
||||
<LinkField
|
||||
inviteLink={createShareLink()}
|
||||
successTitle='Successfully copied the link.'
|
||||
errorTitle='Could not copy the link.'
|
||||
onCopy={onCopyEvent}
|
||||
/>
|
||||
</Box>
|
||||
</Dialogue>
|
||||
</>
|
||||
);
|
||||
};
|
Loading…
Reference in New Issue
Block a user