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