Merge branch 'front/dynamic-zones-ctm-ui' of github.com:strapi/strapi into front/dynamic-zones-ctm-ui

This commit is contained in:
Virginie Ky 2019-11-28 19:24:10 +01:00
commit a2e6427749
6 changed files with 21 additions and 12 deletions

View File

@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { ButtonDropdown } from 'reactstrap';
import { FormattedMessage } from 'react-intl';
import { LayoutIcon } from 'strapi-helper-plugin';
import { LayoutIcon, useGlobalContext } from 'strapi-helper-plugin';
import pluginId from '../../pluginId';
import InputCheckbox from '../InputCheckbox';
import DropdownItemLink from './DropdownItemLink';
@ -21,6 +21,8 @@ const DisplayedFieldsDropdown = ({
slug,
toggle,
}) => {
const { emitEvent } = useGlobalContext();
return (
<DropdownWrapper>
<ButtonDropdown isOpen={isOpen} toggle={toggle} direction="down">
@ -28,7 +30,10 @@ const DisplayedFieldsDropdown = ({
<Toggle isopen={isOpen.toString()} />
<MenuDropdown isopen={isOpen.toString()}>
<DropdownItemLink>
<LayoutWrapper to={`${slug}/ctm-configurations/list-settings`}>
<LayoutWrapper
to={`${slug}/ctm-configurations/list-settings`}
onClick={() => emitEvent('willEditListLayout')}
>
<LayoutIcon />
<FormattedMessage id="app.links.configure-view" />
</LayoutWrapper>

View File

@ -187,16 +187,12 @@ const EditSettingsView = ({
delete body.uid;
delete body.isComponent;
emitEvent('willSaveContentTypeLayout');
await request(getRequestUrl(`${type}/${slug || componentSlug}`), {
method: 'PUT',
body,
signal,
});
emitEvent('didSaveContentTypeLayout');
dispatch({
type: 'SUBMIT_SUCCEEDED',
});
@ -209,7 +205,7 @@ const EditSettingsView = ({
deleteLayouts();
}
emitEvent('didSaveContentTypeLayout');
emitEvent('didEditEditSettings');
} catch (err) {
strapi.notification.error('notification.error');
}

View File

@ -42,6 +42,8 @@ const EditViewDataManagerProvider = ({
const { signal } = abortController;
const isCreatingEntry = id === 'create';
const { emitEvent } = useGlobalContext();
useEffect(() => {
if (!isLoading) {
checkFormErrors();
@ -111,6 +113,7 @@ const EditViewDataManagerProvider = ({
componentUid,
shouldCheckErrors = false
) => {
emitEvent('addComponentToDynamicZone');
dispatch({
type: 'ADD_COMPONENT_TO_DYNAMIC_ZONE',
keys: keys.split('.'),
@ -188,8 +191,6 @@ const EditViewDataManagerProvider = ({
});
};
const { emitEvent } = useGlobalContext();
const handleSubmit = async e => {
e.preventDefault();
@ -270,6 +271,7 @@ const EditViewDataManagerProvider = ({
};
const moveComponentDown = (dynamicZoneName, currentIndex) => {
emitEvent('changeComponentsOrder');
dispatch({
type: 'MOVE_COMPONENT_DOWN',
dynamicZoneName,
@ -277,6 +279,7 @@ const EditViewDataManagerProvider = ({
});
};
const moveComponentUp = (dynamicZoneName, currentIndex) => {
emitEvent('changeComponentsOrder');
dispatch({
type: 'MOVE_COMPONENT_UP',
dynamicZoneName,
@ -309,6 +312,7 @@ const EditViewDataManagerProvider = ({
};
const removeComponentFromDynamicZone = (dynamicZoneName, index) => {
emitEvent('removeComponentFromDynamicZone');
dispatch({
type: 'REMOVE_COMPONENT_FROM_DYNAMIC_ZONE',
dynamicZoneName,

View File

@ -151,7 +151,7 @@ const ListSettingsView = ({ deleteLayout, models, slug }) => {
type: 'SUBMIT_SUCCEEDED',
});
deleteLayout(slug);
emitEvent('didSaveContentTypeLayout');
emitEvent('didEditListSettings');
} catch (err) {
strapi.notification.error('notification.error');
}

View File

@ -109,12 +109,16 @@ function ListView({
const toggleLabelPickerState = () => {
if (!isLabelPickerOpen) {
emitEvent('willChangeDisplayedFields');
emitEvent('willChangeListFieldsSettings');
}
setLabelPickerState(prevState => !prevState);
};
const toggleFilterPickerState = () => {
if (!isFilterPickerOpen) {
emitEvent('willFilterEntries');
}
setFilterPickerState(prevState => !prevState);
};

View File

@ -38,7 +38,7 @@ const getInjectedComponents = (
{...compo.props}
key={compo.key}
onClick={() => {
emitEvent('willEditContentTypeFromEditView');
emitEvent('willEditEditLayout');
}}
/>
);