/** * * ListView * */ import React, { useEffect, useReducer, useRef, useState } from 'react'; import { useHistory, useLocation } from 'react-router-dom'; import { Header, List } from '@buffetjs/custom'; import { Button } from '@buffetjs/core'; import { Plus } from '@buffetjs/icons'; import { omit } from 'lodash'; import { useIntl } from 'react-intl'; import { request, ListButton, PopUpWarning, useUserPermissions, LoadingIndicatorPage, } from 'strapi-helper-plugin'; import adminPermissions from '../../../permissions'; import PageTitle from '../../../components/SettingsPageTitle'; import { EmptyList, ListRow } from '../../../components/Webhooks'; import Wrapper from './Wrapper'; import reducer, { initialState } from './reducer'; function ListView() { const { isLoading, allowedActions: { canCreate, canRead, canUpdate, canDelete }, } = useUserPermissions(adminPermissions.settings.webhooks); const isMounted = useRef(true); const { formatMessage } = useIntl(); const [showModal, setShowModal] = useState(false); const [reducerState, dispatch] = useReducer(reducer, initialState); const { push } = useHistory(); const { pathname } = useLocation(); const { webhooks, webhooksToDelete, webhookToDelete } = reducerState.toJS(); useEffect(() => { isMounted.current = true; return () => { isMounted.current = false; }; }, []); useEffect(() => { if (canRead) { fetchData(); } }, [canRead]); const getWebhookIndex = id => webhooks.findIndex(webhook => webhook.id === id); // New button const addBtnLabel = formatMessage({ id: 'Settings.webhooks.list.button.add', }); const newButtonProps = { label: addBtnLabel, onClick: () => handleGoTo('create'), color: 'primary', type: 'button', icon: , Component: props => { if (canCreate) { return