mirror of
				https://github.com/Unleash/unleash.git
				synced 2025-10-27 11:02:16 +01:00 
			
		
		
		
	Chore: add zendesk btn to error dialog (#6187)
Adds the option for a 3rd button in the Dialogue component Adds a button to open our zendesk support page Closes # [1-2024](https://linear.app/unleash/issue/1-2024/review-the-ui-error-dialog) <img width="1677" alt="Screenshot 2024-02-09 at 11 18 20" src="https://github.com/Unleash/unleash/assets/104830839/bf69c9c2-456f-4b83-b80e-d72f0d678331"> --------- Signed-off-by: andreas-unleash <andreas@getunleash.ai>
This commit is contained in:
		
							parent
							
								
									6d26c79fa7
								
							
						
					
					
						commit
						3e4f31b588
					
				@ -55,6 +55,7 @@ interface IDialogue {
 | 
				
			|||||||
    disabledPrimaryButton?: boolean;
 | 
					    disabledPrimaryButton?: boolean;
 | 
				
			||||||
    formId?: string;
 | 
					    formId?: string;
 | 
				
			||||||
    permissionButton?: React.JSX.Element;
 | 
					    permissionButton?: React.JSX.Element;
 | 
				
			||||||
 | 
					    customButton?: React.JSX.Element;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const Dialogue: React.FC<IDialogue> = ({
 | 
					export const Dialogue: React.FC<IDialogue> = ({
 | 
				
			||||||
@ -71,6 +72,7 @@ export const Dialogue: React.FC<IDialogue> = ({
 | 
				
			|||||||
    fullWidth = false,
 | 
					    fullWidth = false,
 | 
				
			||||||
    formId,
 | 
					    formId,
 | 
				
			||||||
    permissionButton,
 | 
					    permissionButton,
 | 
				
			||||||
 | 
					    customButton,
 | 
				
			||||||
}) => {
 | 
					}) => {
 | 
				
			||||||
    const handleClick = formId
 | 
					    const handleClick = formId
 | 
				
			||||||
        ? (e: React.SyntheticEvent) => {
 | 
					        ? (e: React.SyntheticEvent) => {
 | 
				
			||||||
@ -136,6 +138,11 @@ export const Dialogue: React.FC<IDialogue> = ({
 | 
				
			|||||||
                            </Button>
 | 
					                            </Button>
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    />
 | 
					                    />
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    <ConditionallyRender
 | 
				
			||||||
 | 
					                        condition={Boolean(customButton)}
 | 
				
			||||||
 | 
					                        show={customButton}
 | 
				
			||||||
 | 
					                    />
 | 
				
			||||||
                </StyledDialogActions>
 | 
					                </StyledDialogActions>
 | 
				
			||||||
            </StyledDialogBody>
 | 
					            </StyledDialogBody>
 | 
				
			||||||
        </StyledDialog>
 | 
					        </StyledDialog>
 | 
				
			||||||
 | 
				
			|||||||
@ -1,18 +1,28 @@
 | 
				
			|||||||
import { useEffect, VFC } from 'react';
 | 
					import React, { useEffect, VFC } from 'react';
 | 
				
			||||||
import { useNavigate } from 'react-router-dom';
 | 
					import { useNavigate } from 'react-router-dom';
 | 
				
			||||||
import { Box } from '@mui/material';
 | 
					import { Box, Button } from '@mui/material';
 | 
				
			||||||
import { Dialogue } from 'component/common/Dialogue/Dialogue';
 | 
					import { Dialogue } from 'component/common/Dialogue/Dialogue';
 | 
				
			||||||
import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
 | 
					import { ConditionallyRender } from 'component/common/ConditionallyRender/ConditionallyRender';
 | 
				
			||||||
import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
 | 
					import { usePlausibleTracker } from 'hooks/usePlausibleTracker';
 | 
				
			||||||
 | 
					import useUiConfig from '../../../hooks/api/getters/useUiConfig/useUiConfig';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface IErrorProps {
 | 
					interface IErrorProps {
 | 
				
			||||||
    error: Error;
 | 
					    error: Error;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const ZendeskButton = () => {
 | 
				
			||||||
 | 
					    const openZendeskSupport = () => {
 | 
				
			||||||
 | 
					        window?.open('https://getunleash.zendesk.com', '_blank');
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    return <Button onClick={openZendeskSupport}>Open a ticket</Button>;
 | 
				
			||||||
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// biome-ignore lint/suspicious/noShadowRestrictedNames: <explanation>
 | 
					// biome-ignore lint/suspicious/noShadowRestrictedNames: <explanation>
 | 
				
			||||||
export const Error: VFC<IErrorProps> = ({ error }) => {
 | 
					export const Error: VFC<IErrorProps> = ({ error }) => {
 | 
				
			||||||
    const navigate = useNavigate();
 | 
					    const navigate = useNavigate();
 | 
				
			||||||
    const { trackEvent } = usePlausibleTracker();
 | 
					    const { trackEvent } = usePlausibleTracker();
 | 
				
			||||||
 | 
					    const { isOss } = useUiConfig();
 | 
				
			||||||
 | 
					    const showZendeskButton = !isOss();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    useEffect(() => {
 | 
					    useEffect(() => {
 | 
				
			||||||
        const { message, stack = 'unknown' } = error;
 | 
					        const { message, stack = 'unknown' } = error;
 | 
				
			||||||
@ -41,6 +51,12 @@ export const Error: VFC<IErrorProps> = ({ error }) => {
 | 
				
			|||||||
                    window?.location?.reload();
 | 
					                    window?.location?.reload();
 | 
				
			||||||
                }}
 | 
					                }}
 | 
				
			||||||
                maxWidth='xl'
 | 
					                maxWidth='xl'
 | 
				
			||||||
 | 
					                customButton={
 | 
				
			||||||
 | 
					                    <ConditionallyRender
 | 
				
			||||||
 | 
					                        condition={showZendeskButton}
 | 
				
			||||||
 | 
					                        show={<ZendeskButton />}
 | 
				
			||||||
 | 
					                    />
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
            >
 | 
					            >
 | 
				
			||||||
                <Box component='pre' sx={{ color: 'error.main' }}>
 | 
					                <Box component='pre' sx={{ color: 'error.main' }}>
 | 
				
			||||||
                    {error.message}
 | 
					                    {error.message}
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user