main

mattermost/focalboard

Last updated at: 29/12/2023 09:41

viewLimitDialogWrapper.tsx

TLDR

This file is a component that acts as a wrapper for the ViewLimitModal component, displaying a dialog for viewing limits. It also includes a NotificationBox component to show a success message.

Classes

ViewLimitModalWrapper

This class is a functional component that acts as a wrapper for the ViewLimitModal component. It receives props and uses the useIntl hook from react-intl to handle internationalization. It also maintains a state variable, showNotifyAdminSuccessMsg, to control whether the successNotificationBox should be displayed.

The ViewLimitModalWrapper component renders the ViewLimitModal component and successNotificationBox component conditionally based on the props.show value and showNotifyAdminSuccessMsg state variable, respectively.

END

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import React, {useState} from 'react'

import {useIntl} from 'react-intl'

import CheckIcon from '../../widgets/icons/check'

import NotificationBox from '../../widgets/notificationBox/notificationBox'

import {PublicProps, ViewLimitModal} from './viewLimitDialog'

import './viewLimitDialogWrapper.scss'

type Props = PublicProps & {
    show: boolean
}

const ViewLimitModalWrapper = (props: Props): JSX.Element => {
    const intl = useIntl()
    const [showNotifyAdminSuccessMsg, setShowNotifyAdminSuccessMsg] = useState<boolean>(false)

    const viewLimitDialog = (
        <ViewLimitModal
            onClose={props.onClose}
            showNotifyAdminSuccess={() => setShowNotifyAdminSuccessMsg(true)}
        />
    )

    const successNotificationBox = (
        <NotificationBox
            className='ViewLimitSuccessNotify'
            icon={<CheckIcon/>}
            title={intl.formatMessage({id: 'ViewLimitDialog.notifyAdmin.Success', defaultMessage: 'Your admin has been notified'})}
            onClose={() => setShowNotifyAdminSuccessMsg(false)}
        >
            {null}
        </NotificationBox>
    )

    return (
        <React.Fragment>
            {props.show && viewLimitDialog}
            {showNotifyAdminSuccessMsg && successNotificationBox}
        </React.Fragment>
    )
}

export default ViewLimitModalWrapper