mirror of
https://github.com/strapi/strapi.git
synced 2025-09-10 00:58:36 +00:00
Add footer actions. Needs some refactoring
Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
parent
0309c74b6c
commit
77235f65e1
@ -1,12 +0,0 @@
|
|||||||
import styled from 'styled-components';
|
|
||||||
import { Button } from '@buffetjs/core';
|
|
||||||
|
|
||||||
const CustomButton = styled(Button)`
|
|
||||||
svg {
|
|
||||||
height: 11px;
|
|
||||||
width: 11px;
|
|
||||||
vertical-align: initial;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export default CustomButton;
|
|
@ -26,7 +26,13 @@ const form = {
|
|||||||
sectionTitle: null,
|
sectionTitle: null,
|
||||||
items: [
|
items: [
|
||||||
// FIXME
|
// FIXME
|
||||||
{ type: 'pushRight', size: 6 },
|
{
|
||||||
|
type: 'pushRight',
|
||||||
|
size: 6,
|
||||||
|
// FIXME
|
||||||
|
intlLabel: { id: '', defaultMessage: '' },
|
||||||
|
name: 'pushRight',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'components',
|
name: 'components',
|
||||||
type: 'componentSelect',
|
type: 'componentSelect',
|
||||||
|
@ -20,6 +20,7 @@ import { get, has, isEmpty, set, toLower } from 'lodash';
|
|||||||
import upperFirst from 'lodash/upperFirst';
|
import upperFirst from 'lodash/upperFirst';
|
||||||
import toString from 'lodash/toString';
|
import toString from 'lodash/toString';
|
||||||
import { useSelector, useDispatch, shallowEqual } from 'react-redux';
|
import { useSelector, useDispatch, shallowEqual } from 'react-redux';
|
||||||
|
import AddIcon from '@strapi/icons/AddIcon';
|
||||||
import { Box } from '@strapi/parts/Box';
|
import { Box } from '@strapi/parts/Box';
|
||||||
import { Button } from '@strapi/parts/Button';
|
import { Button } from '@strapi/parts/Button';
|
||||||
import { Divider } from '@strapi/parts/Divider';
|
import { Divider } from '@strapi/parts/Divider';
|
||||||
@ -35,7 +36,6 @@ import useDataManager from '../../hooks/useDataManager';
|
|||||||
import AttributeOptions from '../AttributeOptions';
|
import AttributeOptions from '../AttributeOptions';
|
||||||
import FormModalHeader from '../FormModalHeader';
|
import FormModalHeader from '../FormModalHeader';
|
||||||
|
|
||||||
// import AttributeOption from '../AttributeOption';
|
|
||||||
// import BooleanBox from '../BooleanBox';
|
// import BooleanBox from '../BooleanBox';
|
||||||
// import ComponentIconPicker from '../ComponentIconPicker';
|
// import ComponentIconPicker from '../ComponentIconPicker';
|
||||||
// import CheckboxWithDescription from '../CheckboxWithDescription';
|
// import CheckboxWithDescription from '../CheckboxWithDescription';
|
||||||
@ -384,6 +384,7 @@ const FormModal = () => {
|
|||||||
|
|
||||||
const headers = createHeadersArray(state);
|
const headers = createHeadersArray(state);
|
||||||
|
|
||||||
|
// FIXME rename this constant
|
||||||
const isCreatingContentType = state.modalType === 'contentType';
|
const isCreatingContentType = state.modalType === 'contentType';
|
||||||
const isCreatingComponent = state.modalType === 'component';
|
const isCreatingComponent = state.modalType === 'component';
|
||||||
const isCreatingAttribute = state.modalType === 'attribute';
|
const isCreatingAttribute = state.modalType === 'attribute';
|
||||||
@ -1378,6 +1379,110 @@ const FormModal = () => {
|
|||||||
</TabGroup>
|
</TabGroup>
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
<ModalFooter
|
<ModalFooter
|
||||||
|
// FIXME
|
||||||
|
endActions={
|
||||||
|
<>
|
||||||
|
{(isCreatingContentType || isCreatingComponent) && !isCreating && (
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="danger"
|
||||||
|
onClick={e => {
|
||||||
|
e.preventDefault();
|
||||||
|
deleteData();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{formatMessage({
|
||||||
|
id: getTrad('form.button.delete'),
|
||||||
|
defaultMessage: 'Delete',
|
||||||
|
})}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
{isEditingCategory && (
|
||||||
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="danger"
|
||||||
|
onClick={e => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
deleteCategory(initialData.name);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{formatMessage({
|
||||||
|
id: getTrad('form.button.delete'),
|
||||||
|
defaultMessage: 'Delete',
|
||||||
|
})}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
{isCreating && state.attributeType === 'dynamiczone' && (
|
||||||
|
<Button
|
||||||
|
type={isCreating ? 'submit' : 'button'}
|
||||||
|
variant={
|
||||||
|
(isCreatingContentType ||
|
||||||
|
isCreatingComponent ||
|
||||||
|
isEditingCategory ||
|
||||||
|
(state.modalType === 'addComponentToDynamicZone' &&
|
||||||
|
state.step === '1' &&
|
||||||
|
!isCreatingComponentFromAView)) &&
|
||||||
|
!isCreating
|
||||||
|
? 'default'
|
||||||
|
: 'secondary'
|
||||||
|
}
|
||||||
|
onClick={e => handleSubmit(e, true)}
|
||||||
|
startIcon={
|
||||||
|
(isCreatingAttribute &&
|
||||||
|
!isCreatingComponentFromAView &&
|
||||||
|
state.step !== '1') ||
|
||||||
|
(state.modalType === 'addComponentToDynamicZone' &&
|
||||||
|
isCreatingComponentFromAView) ||
|
||||||
|
(isCreatingComponentFromAView && state.step === '2') ? (
|
||||||
|
<AddIcon />
|
||||||
|
) : null
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{getButtonSubmitMessage()}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
{state.attributeType !== 'dynamiczone' && (
|
||||||
|
<Button
|
||||||
|
type={isCreating ? 'submit' : 'button'}
|
||||||
|
variant={
|
||||||
|
(isCreatingContentType ||
|
||||||
|
isCreatingComponent ||
|
||||||
|
isEditingCategory ||
|
||||||
|
(state.modalType === 'addComponentToDynamicZone' &&
|
||||||
|
state.step === '1' &&
|
||||||
|
!isCreatingComponentFromAView)) &&
|
||||||
|
!isCreating
|
||||||
|
? 'default'
|
||||||
|
: 'secondary'
|
||||||
|
}
|
||||||
|
onClick={e => handleSubmit(e, true)}
|
||||||
|
startIcon={
|
||||||
|
(isCreatingAttribute &&
|
||||||
|
!isCreatingComponentFromAView &&
|
||||||
|
state.step !== '1') ||
|
||||||
|
(state.modalType === 'addComponentToDynamicZone' &&
|
||||||
|
isCreatingComponentFromAView) ||
|
||||||
|
(isCreatingComponentFromAView && state.step === '2') ? (
|
||||||
|
<AddIcon />
|
||||||
|
) : null
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{getButtonSubmitMessage()}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
{isCreatingAttribute && !isInFirstComponentStep && (
|
||||||
|
<Button
|
||||||
|
type={isCreating ? 'button' : 'submit'}
|
||||||
|
onClick={e => {
|
||||||
|
handleSubmit(e, false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{formatMessage({ id: 'form.button.finish', defaultMessage: 'Finish' })}
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
}
|
||||||
startActions={
|
startActions={
|
||||||
<Button variant="tertiary" onClick={handleClosed}>
|
<Button variant="tertiary" onClick={handleClosed}>
|
||||||
{formatMessage({ id: 'app.components.Button.cancel', defaultMessage: 'Cancel' })}
|
{formatMessage({ id: 'app.components.Button.cancel', defaultMessage: 'Cancel' })}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user