mirror of
https://github.com/strapi/strapi.git
synced 2025-08-13 03:07:32 +00:00
Merge branch 'front/dynamic-zones-ctm-ui' of github.com:strapi/strapi into front/dynamic-zones-ctm-ui
This commit is contained in:
commit
d83cbb4539
@ -3,7 +3,7 @@ import { withRouter } from 'react-router';
|
||||
import PropTypes from 'prop-types';
|
||||
import { get, isEmpty, isNull, isObject, toLower, toString } from 'lodash';
|
||||
import moment from 'moment';
|
||||
import { IcoContainer } from 'strapi-helper-plugin';
|
||||
import { IcoContainer, useGlobalContext } from 'strapi-helper-plugin';
|
||||
import useListView from '../../hooks/useListView';
|
||||
|
||||
import CustomInputCheckbox from '../CustomInputCheckbox';
|
||||
@ -73,6 +73,8 @@ function Row({ goTo, isBulkable, row, headers }) {
|
||||
[row, schema]
|
||||
);
|
||||
|
||||
const { emitEvent } = useGlobalContext;
|
||||
|
||||
return (
|
||||
<>
|
||||
{isBulkable && (
|
||||
@ -109,6 +111,7 @@ function Row({ goTo, isBulkable, row, headers }) {
|
||||
{
|
||||
icoType: 'pencil-alt',
|
||||
onClick: () => {
|
||||
emitEvent('willEditEntryFromList');
|
||||
goTo(row.id);
|
||||
},
|
||||
},
|
||||
@ -116,6 +119,7 @@ function Row({ goTo, isBulkable, row, headers }) {
|
||||
id: row.id,
|
||||
icoType: 'trash-alt',
|
||||
onClick: () => {
|
||||
emitEvent('willDeleteEntryFromList');
|
||||
onClickDelete(row.id);
|
||||
},
|
||||
},
|
||||
|
@ -31,7 +31,7 @@ function CustomTable({
|
||||
const colSpanLength = isBulkable ? headers.length + 2 : headers.length + 1;
|
||||
|
||||
const handleGoTo = id => {
|
||||
emitEvent('willEditEntry');
|
||||
emitEvent('willEditEntryFromList');
|
||||
push({
|
||||
pathname: `/plugins/${pluginId}/${slug}/${id}`,
|
||||
search: redirectUrl,
|
||||
|
@ -18,7 +18,7 @@ const Header = () => {
|
||||
const [showWarningCancel, setWarningCancel] = useState(false);
|
||||
const [showWarningDelete, setWarningDelete] = useState(false);
|
||||
|
||||
const { formatMessage } = useGlobalContext();
|
||||
const { formatMessage, emitEvent } = useGlobalContext();
|
||||
const { id } = useParams();
|
||||
const {
|
||||
initialData,
|
||||
@ -99,14 +99,17 @@ const Header = () => {
|
||||
setIsSubmitting();
|
||||
|
||||
try {
|
||||
emitEvent('willDeleteEntry');
|
||||
await request(getRequestUrl(`${slug}/${id}`), {
|
||||
method: 'DELETE',
|
||||
});
|
||||
|
||||
strapi.notification.success(`${pluginId}.success.record.delete`);
|
||||
emitEvent('didDeleteEntry');
|
||||
redirectToPreviousPage();
|
||||
} catch (err) {
|
||||
setIsSubmitting(false);
|
||||
emitEvent('didNotDeleteEntry', { error: err });
|
||||
strapi.notification.error(`${pluginId}.error.record.delete`);
|
||||
}
|
||||
};
|
||||
|
@ -2,7 +2,11 @@ import React, { useEffect, useReducer } from 'react';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import PropTypes from 'prop-types';
|
||||
import { cloneDeep, get, isEmpty, set } from 'lodash';
|
||||
import { request, LoadingIndicatorPage } from 'strapi-helper-plugin';
|
||||
import {
|
||||
request,
|
||||
LoadingIndicatorPage,
|
||||
useGlobalContext,
|
||||
} from 'strapi-helper-plugin';
|
||||
import pluginId from '../../pluginId';
|
||||
import EditViewDataManagerContext from '../../contexts/EditViewDataManager';
|
||||
import createYupSchema from './utils/schema';
|
||||
@ -184,6 +188,8 @@ const EditViewDataManagerProvider = ({
|
||||
});
|
||||
};
|
||||
|
||||
const { emitEvent } = useGlobalContext();
|
||||
|
||||
const handleSubmit = async e => {
|
||||
e.preventDefault();
|
||||
|
||||
@ -222,6 +228,8 @@ const EditViewDataManagerProvider = ({
|
||||
const method = isCreatingEntry ? 'POST' : 'PUT';
|
||||
const endPoint = isCreatingEntry ? slug : `${slug}/${id}`;
|
||||
|
||||
emitEvent(isCreatingEntry ? 'willCreateEntry' : 'willEditEntry');
|
||||
|
||||
try {
|
||||
// Time to actually send the data
|
||||
await request(
|
||||
@ -235,7 +243,7 @@ const EditViewDataManagerProvider = ({
|
||||
false,
|
||||
false
|
||||
);
|
||||
// emitEvent('didSaveEntry');
|
||||
emitEvent(isCreatingEntry ? 'didCreateEntry' : 'didEditEntry');
|
||||
redirectToPreviousPage();
|
||||
} catch (err) {
|
||||
console.log({ err });
|
||||
@ -246,7 +254,9 @@ const EditViewDataManagerProvider = ({
|
||||
);
|
||||
|
||||
setIsSubmitting(false);
|
||||
// emitEvent('didNotSaveEntry', { error: err });
|
||||
emitEvent(isCreatingEntry ? 'didNotCreateEntry' : 'didNotEditEntry', {
|
||||
error: err,
|
||||
});
|
||||
strapi.notification.error(error);
|
||||
}
|
||||
} catch (err) {
|
||||
|
@ -993,6 +993,11 @@
|
||||
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-0.2.25.tgz#6df015905081f2762e5cfddeb7a20d2e9b16c786"
|
||||
integrity sha512-3RuZPDuuPELd7RXtUqTCfed14fcny9UiPOkdr2i+cYxBoTOfQgxcDoq77fHiiHcgWuo1LoBUpvGxFF1H/y7s3Q==
|
||||
|
||||
"@fortawesome/fontawesome-free@^5.11.2":
|
||||
version "5.11.2"
|
||||
resolved "https://registry.npmjs.org/@fortawesome/fontawesome-free/-/fontawesome-free-5.11.2.tgz#8644bc25b19475779a7b7c1fc104bc0a794f4465"
|
||||
integrity sha512-XiUPoS79r1G7PcpnNtq85TJ7inJWe0v+b5oZJZKb0pGHNIV6+UiNeQWiFGmuQ0aj7GEhnD/v9iqxIsjuRKtEnQ==
|
||||
|
||||
"@fortawesome/fontawesome-svg-core@^1.2.22", "@fortawesome/fontawesome-svg-core@^1.2.25":
|
||||
version "1.2.25"
|
||||
resolved "https://registry.yarnpkg.com/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-1.2.25.tgz#24b03391d14f0c6171e8cad7057c687b74049790"
|
||||
|
Loading…
x
Reference in New Issue
Block a user