From 00da5012d8db7e9d5544b45fa36f2267a23cb648 Mon Sep 17 00:00:00 2001 From: Boaz Poolman Date: Sat, 12 Oct 2024 18:46:42 +0200 Subject: [PATCH] fix: modal, dialog & typography styling --- admin/src/components/ActionButtons/index.jsx | 48 ++++---- admin/src/components/ConfigDiff/index.jsx | 57 +++++----- .../ConfigList/ConfigListRow/index.jsx | 14 ++- admin/src/components/ConfigList/index.jsx | 28 ++--- admin/src/components/ConfirmModal/index.jsx | 106 +++++++++--------- admin/src/components/FirstExport/index.jsx | 19 ++-- 6 files changed, 137 insertions(+), 135 deletions(-) diff --git a/admin/src/components/ActionButtons/index.jsx b/admin/src/components/ActionButtons/index.jsx index afe5cfc..3cc94f1 100644 --- a/admin/src/components/ActionButtons/index.jsx +++ b/admin/src/components/ActionButtons/index.jsx @@ -1,8 +1,8 @@ -import React, { useState } from 'react'; +import React from 'react'; import styled from 'styled-components'; import { useDispatch, useSelector } from 'react-redux'; import { isEmpty } from 'lodash'; -import { Button } from '@strapi/design-system'; +import { Button, Typography } from '@strapi/design-system'; import { Map } from 'immutable'; import { getFetchClient, useNotification } from '@strapi/strapi/admin'; import { useIntl } from 'react-intl'; @@ -14,38 +14,32 @@ const ActionButtons = () => { const { post, get } = getFetchClient(); const dispatch = useDispatch(); const { toggleNotification } = useNotification(); - const [modalIsOpen, setModalIsOpen] = useState(false); - const [actionType, setActionType] = useState(''); const partialDiff = useSelector((state) => state.getIn(['config', 'partialDiff'], Map({}))).toJS(); const { formatMessage } = useIntl(); - const closeModal = () => { - setActionType(''); - setModalIsOpen(false); - }; - - const openModal = (type) => { - setActionType(type); - setModalIsOpen(true); - }; - return ( - - - {!isEmpty(partialDiff) && ( -

{Object.keys(partialDiff).length} {Object.keys(partialDiff).length === 1 ? "config change" : "config changes"}

- )} actionType === 'import' ? dispatch(importAllConfig(partialDiff, force, toggleNotification, formatMessage, post, get)) : dispatch(exportAllConfig(partialDiff, toggleNotification, formatMessage, post, get))} + type="import" + trigger={( + + )} + onSubmit={(force) => dispatch(importAllConfig(partialDiff, force, toggleNotification, formatMessage, post, get))} /> + + {formatMessage({ id: 'config-sync.Buttons.Export' })} + + )} + onSubmit={(force) => dispatch(exportAllConfig(partialDiff, toggleNotification, formatMessage, post, get))} + /> + {!isEmpty(partialDiff) && ( + {Object.keys(partialDiff).length} {Object.keys(partialDiff).length === 1 ? "config change" : "config changes"} + )}
); }; diff --git a/admin/src/components/ConfigDiff/index.jsx b/admin/src/components/ConfigDiff/index.jsx index e5adb01..daa0787 100644 --- a/admin/src/components/ConfigDiff/index.jsx +++ b/admin/src/components/ConfigDiff/index.jsx @@ -8,36 +8,39 @@ import { Typography, } from '@strapi/design-system'; -const ConfigDiff = ({ isOpen, onClose, oldValue, newValue, configName }) => { +const ConfigDiff = ({ oldValue, newValue, configName, trigger }) => { const { formatMessage } = useIntl(); - if (!isOpen) return null; return ( - - - - {formatMessage({ id: 'config-sync.ConfigDiff.Title' })} {configName} - - - - - - {formatMessage({ id: 'config-sync.ConfigDiff.SyncDirectory' })} - - - {formatMessage({ id: 'config-sync.ConfigDiff.Database' })} - - - - + + + {trigger} + + + + + {formatMessage({ id: 'config-sync.ConfigDiff.Title' })} {configName} + + + + + + {formatMessage({ id: 'config-sync.ConfigDiff.SyncDirectory' })} + + + {formatMessage({ id: 'config-sync.ConfigDiff.Database' })} + + + + + + + ); }; diff --git a/admin/src/components/ConfigList/ConfigListRow/index.jsx b/admin/src/components/ConfigList/ConfigListRow/index.jsx index 96c7bd3..181168a 100644 --- a/admin/src/components/ConfigList/ConfigListRow/index.jsx +++ b/admin/src/components/ConfigList/ConfigListRow/index.jsx @@ -1,7 +1,7 @@ import React from 'react'; -import { Tr, Td, Checkbox } from '@strapi/design-system'; +import { Tr, Td, Checkbox, Typography } from '@strapi/design-system'; -const CustomRow = ({ row, checked, updateValue }) => { +const CustomRow = ({ row, checked, updateValue, ...props }) => { const { configName, configType, state, onClick } = row; const stateStyle = (stateStr) => { @@ -34,10 +34,14 @@ const CustomRow = ({ row, checked, updateValue }) => { return ( { if (e.target.type !== 'checkbox') { onClick(configType, configName); } + if (props.onClick) { + props.onClick(e); + } }} style={{ cursor: 'pointer' }} > @@ -49,13 +53,13 @@ const CustomRow = ({ row, checked, updateValue }) => { /> -

{configName}

+ {configName} -

{configType}

+ {configType} -

{state}

+ {state} ); diff --git a/admin/src/components/ConfigList/index.jsx b/admin/src/components/ConfigList/index.jsx index 47bf5c0..04cc50b 100644 --- a/admin/src/components/ConfigList/index.jsx +++ b/admin/src/components/ConfigList/index.jsx @@ -117,13 +117,6 @@ const ConfigList = ({ diff, isLoading }) => { return (
- @@ -148,14 +141,21 @@ const ConfigList = ({ diff, isLoading }) => { {rows.map((row, index) => ( - { - checkedItems[index] = !checkedItems[index]; - setCheckedItems([...checkedItems]); - }} + oldValue={originalConfig} + newValue={newConfig} + configName={cName} + trigger={( + { + checkedItems[index] = !checkedItems[index]; + setCheckedItems([...checkedItems]); + }} + /> + )} /> ))} diff --git a/admin/src/components/ConfirmModal/index.jsx b/admin/src/components/ConfirmModal/index.jsx index 162edcc..b17f483 100644 --- a/admin/src/components/ConfirmModal/index.jsx +++ b/admin/src/components/ConfirmModal/index.jsx @@ -10,69 +10,69 @@ import { Checkbox, Divider, Box, + Field, } from '@strapi/design-system'; import { WarningCircle } from '@strapi/icons'; -const ConfirmModal = ({ isOpen, onClose, onSubmit, type }) => { +const ConfirmModal = ({ onClose, onSubmit, type, trigger }) => { const soft = useSelector((state) => state.getIn(['config', 'appEnv', 'config', 'soft'], false)); const [force, setForce] = useState(false); const { formatMessage } = useIntl(); - if (!isOpen) return null; - return ( - - }> - - - - {formatMessage({ id: `config-sync.popUpWarning.warning.${type}_1` })}
- {formatMessage({ id: `config-sync.popUpWarning.warning.${type}_2` })} -
+ + + {trigger} + + + {formatMessage({ id: "config-sync.popUpWarning.Confirmation" })} + + + + + + {formatMessage({ id: `config-sync.popUpWarning.warning.${type}_1` })}
+ {formatMessage({ id: `config-sync.popUpWarning.warning.${type}_2` })} +
+
-
-
- {(soft && type === 'import') && ( - - - - setForce(value)} - value={force} - name="force" - hint="Check this to ignore the soft setting." + {(soft && type === 'import') && ( + + + + + setForce(value)} + value={force} + name="force" + > + {formatMessage({ id: 'config-sync.popUpWarning.force' })} + + + + + + )} + + + + + + + - )} - endAction={( - - )} /> + {formatMessage({ id: `config-sync.popUpWarning.button.${type}` })} + + + +
); }; diff --git a/admin/src/components/FirstExport/index.jsx b/admin/src/components/FirstExport/index.jsx index 151ea35..446468a 100644 --- a/admin/src/components/FirstExport/index.jsx +++ b/admin/src/components/FirstExport/index.jsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React from 'react'; import { useIntl } from 'react-intl'; import { useDispatch } from 'react-redux'; import { getFetchClient, useNotification } from '@strapi/strapi/admin'; @@ -13,20 +13,21 @@ const FirstExport = () => { const { post, get } = getFetchClient(); const { toggleNotification } = useNotification(); const dispatch = useDispatch(); - const [modalIsOpen, setModalIsOpen] = useState(false); const { formatMessage } = useIntl(); return (
- setModalIsOpen(false)} - type="export" - onSubmit={() => dispatch(exportAllConfig([], toggleNotification, formatMessage, post, get))} - /> setModalIsOpen(true)}>{formatMessage({ id: 'config-sync.FirstExport.Button' })}} + action={( + dispatch(exportAllConfig([], toggleNotification, formatMessage, post, get))} + trigger={( + + )} + /> + )} icon={} />