mirror of
https://github.com/strapi/strapi.git
synced 2025-08-08 08:46:42 +00:00
apply PR review
Signed-off-by: Ky <virginie.ky@gmail.com>
This commit is contained in:
parent
c02abe90fc
commit
def471ef5f
@ -1,11 +1,11 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { PageFooter, useQuery } from 'strapi-helper-plugin';
|
import { PageFooter, useQuery } from 'strapi-helper-plugin';
|
||||||
import { generatePageFromStart, generateStartFromPage } from '../../utils';
|
import { generatePageFromStart, generateStartFromPage } from '../../../utils';
|
||||||
|
|
||||||
import List from '../List';
|
import List from '../../../components/List';
|
||||||
import ListEmpty from '../ListEmpty';
|
import ListEmpty from '../../../components/ListEmpty';
|
||||||
import Padded from '../Padded';
|
import Padded from '../../../components/Padded';
|
||||||
|
|
||||||
const HomePageList = ({
|
const HomePageList = ({
|
||||||
areResultsEmptyWithSettings,
|
areResultsEmptyWithSettings,
|
@ -2,13 +2,13 @@ import React, { useEffect, useState } from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { useDebounce } from '@buffetjs/hooks';
|
import { useDebounce } from '@buffetjs/hooks';
|
||||||
import { HeaderSearch, useGlobalContext, useQuery } from 'strapi-helper-plugin';
|
import { HeaderSearch, useGlobalContext, useQuery } from 'strapi-helper-plugin';
|
||||||
import { getTrad, getFileModelTimestamps } from '../../utils';
|
import { getTrad, getFileModelTimestamps } from '../../../utils';
|
||||||
|
|
||||||
import ControlsWrapper from '../ControlsWrapper';
|
import ControlsWrapper from '../../../components/ControlsWrapper';
|
||||||
import Filters from '../Filters';
|
import Filters from '../../../components/Filters';
|
||||||
import Padded from '../Padded';
|
import Padded from '../../../components/Padded';
|
||||||
import SelectAll from '../SelectAll';
|
import SelectAll from '../../../components/SelectAll';
|
||||||
import SortPicker from '../SortPicker';
|
import SortPicker from '../../../components/SortPicker';
|
||||||
|
|
||||||
const HomePageSettings = ({
|
const HomePageSettings = ({
|
||||||
areAllCheckboxesSelected,
|
areAllCheckboxesSelected,
|
@ -4,8 +4,8 @@ import { isEmpty } from 'lodash';
|
|||||||
import { useLocation } from 'react-router-dom';
|
import { useLocation } from 'react-router-dom';
|
||||||
import { generateFiltersFromSearch, useQuery } from 'strapi-helper-plugin';
|
import { generateFiltersFromSearch, useQuery } from 'strapi-helper-plugin';
|
||||||
|
|
||||||
import HomePageSettings from '../HomePageSettings';
|
import HomePageSettings from './HomePageSettings';
|
||||||
import HomePageList from '../HomePageList';
|
import HomePageList from './HomePageList';
|
||||||
|
|
||||||
const HomePageContent = ({
|
const HomePageContent = ({
|
||||||
data,
|
data,
|
@ -1,7 +1,6 @@
|
|||||||
import React, { useReducer, useState, useEffect } from 'react';
|
import React, { useReducer, useRef, useState, useEffect } from 'react';
|
||||||
import { includes, toString, isEqual, intersectionWith } from 'lodash';
|
import { includes, toString, isEqual, intersectionWith } from 'lodash';
|
||||||
import { useHistory, useLocation } from 'react-router-dom';
|
import { useHistory, useLocation } from 'react-router-dom';
|
||||||
import { useIsMounted } from '@buffetjs/hooks';
|
|
||||||
import { Header } from '@buffetjs/custom';
|
import { Header } from '@buffetjs/custom';
|
||||||
import {
|
import {
|
||||||
PopUpWarning,
|
PopUpWarning,
|
||||||
@ -14,7 +13,7 @@ import {
|
|||||||
} from 'strapi-helper-plugin';
|
} from 'strapi-helper-plugin';
|
||||||
import { formatFileForEditing, getRequestUrl, getTrad, getFileModelTimestamps } from '../../utils';
|
import { formatFileForEditing, getRequestUrl, getTrad, getFileModelTimestamps } from '../../utils';
|
||||||
import Container from '../../components/Container';
|
import Container from '../../components/Container';
|
||||||
import HomePageContent from '../../components/HomePageContent';
|
import HomePageContent from './HomePageContent';
|
||||||
import Padded from '../../components/Padded';
|
import Padded from '../../components/Padded';
|
||||||
import ModalStepper from '../ModalStepper';
|
import ModalStepper from '../ModalStepper';
|
||||||
import { generateStringFromParams, getHeaderLabel } from './utils';
|
import { generateStringFromParams, getHeaderLabel } from './utils';
|
||||||
@ -33,11 +32,15 @@ const HomePage = () => {
|
|||||||
const [modalInitialStep, setModalInitialStep] = useState('browse');
|
const [modalInitialStep, setModalInitialStep] = useState('browse');
|
||||||
const { push } = useHistory();
|
const { push } = useHistory();
|
||||||
const { search } = useLocation();
|
const { search } = useLocation();
|
||||||
const isMounted = useIsMounted();
|
const isMounted = useRef(true);
|
||||||
const { data, dataCount, dataToDelete, isLoading } = reducerState.toJS();
|
const { data, dataCount, dataToDelete, isLoading } = reducerState.toJS();
|
||||||
const pluginName = formatMessage({ id: getTrad('plugin.name') });
|
const pluginName = formatMessage({ id: getTrad('plugin.name') });
|
||||||
const paramsKeys = ['_limit', '_start', '_q', '_sort'];
|
const paramsKeys = ['_limit', '_start', '_q', '_sort'];
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
return () => (isMounted.current = false);
|
||||||
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchListData();
|
fetchListData();
|
||||||
|
|
||||||
@ -52,7 +55,7 @@ const HomePage = () => {
|
|||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (isMounted) {
|
if (isMounted.current) {
|
||||||
strapi.notification.error('notification.error');
|
strapi.notification.error('notification.error');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,7 +76,7 @@ const HomePage = () => {
|
|||||||
|
|
||||||
return Promise.resolve(data);
|
return Promise.resolve(data);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (isMounted) {
|
if (isMounted.current) {
|
||||||
dispatch({ type: 'GET_DATA_ERROR' });
|
dispatch({ type: 'GET_DATA_ERROR' });
|
||||||
strapi.notification.error('notification.error');
|
strapi.notification.error('notification.error');
|
||||||
}
|
}
|
||||||
@ -93,7 +96,7 @@ const HomePage = () => {
|
|||||||
|
|
||||||
return Promise.resolve(count);
|
return Promise.resolve(count);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
if (isMounted) {
|
if (isMounted.current) {
|
||||||
dispatch({ type: 'GET_DATA_ERROR' });
|
dispatch({ type: 'GET_DATA_ERROR' });
|
||||||
strapi.notification.error('notification.error');
|
strapi.notification.error('notification.error');
|
||||||
}
|
}
|
||||||
@ -107,7 +110,7 @@ const HomePage = () => {
|
|||||||
|
|
||||||
const [data, count] = await Promise.all([fetchData(), fetchDataCount()]);
|
const [data, count] = await Promise.all([fetchData(), fetchDataCount()]);
|
||||||
|
|
||||||
if (isMounted) {
|
if (isMounted.current) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'GET_DATA_SUCCEEDED',
|
type: 'GET_DATA_SUCCEEDED',
|
||||||
data,
|
data,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user