From 41a9bfdf6c0db1f0dd88b495990f976a7aec6303 Mon Sep 17 00:00:00 2001 From: Boaz Poolman Date: Thu, 14 Oct 2021 17:13:12 +0200 Subject: [PATCH] refactor(v4): Base admin migration --- admin/src/components/ActionButtons/index.js | 17 ++--- admin/src/components/ConfigDiff/index.js | 63 ++++++++---------- .../ConfigList/ConfigListRow/index.js | 58 ++++++++--------- admin/src/components/ConfigList/index.js | 61 ++++++++++-------- admin/src/components/ConfirmModal/index.js | 64 ++++++++++++------- admin/src/components/Container/index.js | 24 ------- admin/src/components/FirstExport/index.js | 24 ++++--- admin/src/components/Header/index.js | 23 +++---- admin/src/config/constants.js | 2 +- admin/src/config/logger.js | 8 --- admin/src/containers/App/index.js | 7 +- admin/src/containers/ConfigPage/index.js | 6 +- admin/src/helpers/configureStore.js | 22 +------ admin/src/state/actions/Config.js | 16 ++--- yarn.lock | 36 +++++------ 15 files changed, 198 insertions(+), 233 deletions(-) delete mode 100644 admin/src/components/Container/index.js delete mode 100755 admin/src/config/logger.js diff --git a/admin/src/components/ActionButtons/index.js b/admin/src/components/ActionButtons/index.js index 9f6dac3..093ec4f 100644 --- a/admin/src/components/ActionButtons/index.js +++ b/admin/src/components/ActionButtons/index.js @@ -2,7 +2,8 @@ import React, { useState } from 'react'; import styled from 'styled-components'; import { useDispatch } from 'react-redux'; import { isEmpty } from 'lodash'; -import { Button } from '@buffetjs/core'; +import { Button } from '@strapi/parts/Button'; + import ConfirmModal from '../ConfirmModal'; import { exportAllConfig, importAllConfig } from '../../state/actions/Config'; @@ -23,20 +24,20 @@ const ActionButtons = ({ diff }) => { return ( - + )} + endAction={( + + )} /> + ); -} - -export default ConfirmModal; \ No newline at end of file +}; + +export default ConfirmModal; diff --git a/admin/src/components/Container/index.js b/admin/src/components/Container/index.js deleted file mode 100644 index b8dca52..0000000 --- a/admin/src/components/Container/index.js +++ /dev/null @@ -1,24 +0,0 @@ -import styled from 'styled-components'; - -const ContainerFluid = styled.div` - padding: 18px 30px; - > div:first-child { - max-height: 33px; - } - - .buttonOutline { - height: 30px; - padding: 0 15px; - border: 1px solid #dfe0e1; - font-weight: 500; - font-size: 13px; - &:before { - margin-right: 10px; - content: '\f08e'; - font-family: 'FontAwesome'; - font-size: 10px; - } - } -`; - -export default ContainerFluid; diff --git a/admin/src/components/FirstExport/index.js b/admin/src/components/FirstExport/index.js index 18c57fe..4d92dbe 100644 --- a/admin/src/components/FirstExport/index.js +++ b/admin/src/components/FirstExport/index.js @@ -1,6 +1,8 @@ import React, { useState } from 'react'; import { useDispatch } from 'react-redux'; -import { Button } from '@buffetjs/core'; + +import { Button } from '@strapi/parts/Button'; + import { exportAllConfig } from '../../state/actions/Config'; import ConfirmModal from '../ConfirmModal'; @@ -9,25 +11,29 @@ const FirstExport = () => { const [modalIsOpen, setModalIsOpen] = useState(false); return ( -
+ }}> setModalIsOpen(false)} - type={'export'} - onSubmit={() => dispatch(exportAllConfig())} + type="export" + onSubmit={() => dispatch(exportAllConfig())} />

Looks like this is your first time using config-sync for this project.

Make the initial export!

- +
); -} - -export default FirstExport; \ No newline at end of file +}; + +export default FirstExport; diff --git a/admin/src/components/Header/index.js b/admin/src/components/Header/index.js index 854481a..c6d9442 100644 --- a/admin/src/components/Header/index.js +++ b/admin/src/components/Header/index.js @@ -5,21 +5,22 @@ */ import React, { memo } from 'react'; -import { Header } from '@buffetjs/custom'; -import { useGlobalContext } from 'strapi-helper-plugin'; +import { useIntl } from 'react-intl'; + +import { HeaderLayout } from '@strapi/parts/Layout'; +import { Box } from '@strapi/parts/Box'; const HeaderComponent = () => { - const { formatMessage } = useGlobalContext(); + const { formatMessage } = useIntl(); - const headerProps = { - title: { - label: formatMessage({ id: 'config-sync.Header.Title' }), - }, - content: formatMessage({ id: 'config-sync.Header.Description' }), - }; - return ( -
+ + + ); }; diff --git a/admin/src/config/constants.js b/admin/src/config/constants.js index 1d32254..de08fe0 100644 --- a/admin/src/config/constants.js +++ b/admin/src/config/constants.js @@ -1 +1 @@ -export const __DEBUG__ = strapi.env === 'development'; +export const __DEBUG__ = true; // TODO: set actual env. diff --git a/admin/src/config/logger.js b/admin/src/config/logger.js deleted file mode 100755 index e6cd0eb..0000000 --- a/admin/src/config/logger.js +++ /dev/null @@ -1,8 +0,0 @@ -const config = { - blacklist: [ - 'REDUX_STORAGE_SAVE', - 'REDUX_STORAGE_LOAD', - ], -}; - -export default config; diff --git a/admin/src/containers/App/index.js b/admin/src/containers/App/index.js index 4675fdb..e908210 100644 --- a/admin/src/containers/App/index.js +++ b/admin/src/containers/App/index.js @@ -7,7 +7,6 @@ import React from 'react'; import { Provider } from 'react-redux'; -import ContainerFluid from '../../components/Container'; import Header from '../../components/Header'; import { store } from "../../helpers/configureStore"; @@ -16,10 +15,8 @@ import ConfigPage from '../ConfigPage'; const App = () => { return ( - -
- - +
+ ); }; diff --git a/admin/src/containers/ConfigPage/index.js b/admin/src/containers/ConfigPage/index.js index d603462..cc933aa 100644 --- a/admin/src/containers/ConfigPage/index.js +++ b/admin/src/containers/ConfigPage/index.js @@ -21,6 +21,6 @@ const ConfigPage = () => { ); -} - -export default ConfigPage; \ No newline at end of file +}; + +export default ConfigPage; diff --git a/admin/src/helpers/configureStore.js b/admin/src/helpers/configureStore.js index bd0fc8e..7c250cf 100755 --- a/admin/src/helpers/configureStore.js +++ b/admin/src/helpers/configureStore.js @@ -1,14 +1,12 @@ import { createStore, applyMiddleware, compose } from 'redux'; -import { createLogger } from 'redux-logger'; import thunkMiddleware from 'redux-thunk'; import { Map } from 'immutable'; import rootReducer from '../state/reducers'; -import loggerConfig from '../config/logger'; import { __DEBUG__ } from '../config/constants'; const configureStore = () => { - let initialStoreState = Map(); + const initialStoreState = Map(); const enhancers = []; const middlewares = [ @@ -27,24 +25,6 @@ const configureStore = () => { if (devtools) { console.info('[setup] ✓ Enabling Redux DevTools Extension'); } - - console.info('[setup] ✓ Enabling state logger'); - const loggerMiddleware = createLogger({ - level: 'info', - collapsed: true, - stateTransformer: (state) => state.toJS(), - predicate: (getState, action) => { - const state = getState(); - - const showBlacklisted = state.getIn(['debug', 'logs', 'blacklisted']); - if (loggerConfig.blacklist.indexOf(action.type) !== -1 && !showBlacklisted) { - return false; - } - - return state.getIn(['debug', 'logs', 'enabled']); - }, - }); - middlewares.push(loggerMiddleware); } const composedEnhancers = devtools || compose; diff --git a/admin/src/state/actions/Config.js b/admin/src/state/actions/Config.js index 6cc1599..e6f26ca 100644 --- a/admin/src/state/actions/Config.js +++ b/admin/src/state/actions/Config.js @@ -4,7 +4,7 @@ * */ -import { request } from 'strapi-helper-plugin'; +import { request } from '@strapi/helper-plugin'; import { Map } from 'immutable'; export function getAllConfigDiff() { @@ -14,11 +14,11 @@ export function getAllConfigDiff() { const configDiff = await request('/config-sync/diff', { method: 'GET' }); dispatch(setConfigDiffInState(configDiff)); dispatch(setLoadingState(false)); - } catch(err) { + } catch (err) { strapi.notification.error('notification.error'); dispatch(setLoadingState(false)); } - } + }; } export const SET_CONFIG_DIFF_IN_STATE = 'SET_CONFIG_DIFF_IN_STATE'; @@ -38,11 +38,11 @@ export function exportAllConfig() { strapi.notification.success(message); dispatch(setLoadingState(false)); - } catch(err) { + } catch (err) { strapi.notification.error('notification.error'); dispatch(setLoadingState(false)); } - } + }; } export function importAllConfig() { @@ -54,11 +54,11 @@ export function importAllConfig() { strapi.notification.success(message); dispatch(setLoadingState(false)); - } catch(err) { + } catch (err) { strapi.notification.error('notification.error'); dispatch(setLoadingState(false)); } - } + }; } export const SET_LOADING_STATE = 'SET_LOADING_STATE'; @@ -67,4 +67,4 @@ export function setLoadingState(value) { type: SET_LOADING_STATE, value, }; -} \ No newline at end of file +} diff --git a/yarn.lock b/yarn.lock index 3d2f262..eb4b970 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1006,9 +1006,9 @@ integrity sha512-XmdEOrKQ8a1Y/yxQFOMbC47G/V2VDO1GvMRnl4O75M4GW/abC5tnfzadQYkqEveqRM1dEJGFFegfPNA2vvx2iw== "@types/node@*": - version "16.10.5" - resolved "https://registry.yarnpkg.com/@types/node/-/node-16.10.5.tgz#7fe4123b061753f1a58a6cd077ff0bb069ee752d" - integrity sha512-9iI3OOlkyOjLQQ9s+itIJNMRepDhB/96jW3fqduJ2FTPQj1dJjw6Q3QCImF9FE1wmdBs5QSun4FjDSFS8d8JLw== + version "16.10.9" + resolved "https://registry.yarnpkg.com/@types/node/-/node-16.10.9.tgz#8f1cdd517972f76a3b928298f4c0747cd6fef25a" + integrity sha512-H9ReOt+yqIJPCutkTYjFjlyK6WEMQYT9hLZMlWtOjFQY2ItppsWZ6RJf8Aw+jz5qTYceuHvFgPIaKOHtLAEWBw== "@types/normalize-package-data@^2.4.0": version "2.4.1" @@ -1041,9 +1041,9 @@ redux "^4.0.0" "@types/react@*", "@types/react@16 || 17": - version "17.0.29" - resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.29.tgz#9535f3fc01a4981ce9cadcf0daa2593c0c2f2251" - integrity sha512-HSenIfBEBZ70BLrrVhtEtHpqaP79waauPtA8XKlczTxL3hXrW/ElGNLTpD1TmqkykgGlOAK55+D3SmUHEirpFw== + version "17.0.30" + resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.30.tgz#2f8e6f5ab6415c091cc5e571942ee9064b17609e" + integrity sha512-3Dt/A8gd3TCXi2aRe84y7cK1K8G+N9CZRDG8kDGguOKa0kf/ZkSwTmVIDPsm/KbQOVMaDJXwhBtuOXxqwdpWVg== dependencies: "@types/prop-types" "*" "@types/scheduler" "*" @@ -1702,9 +1702,9 @@ camelize@^1.0.0: integrity sha1-FkpUg+Yw+kMh5a8HAg5TGDGyYJs= caniuse-lite@^1.0.30001265: - version "1.0.30001265" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001265.tgz#0613c9e6c922e422792e6fcefdf9a3afeee4f8c3" - integrity sha512-YzBnspggWV5hep1m9Z6sZVLOt7vrju8xWooFAgN6BA5qvy98qPAPb7vNUzypFaoh2pb3vlfzbDO8tB57UPGbtw== + version "1.0.30001267" + resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001267.tgz#b1cf2937175afc0570e4615fc2d2f9069fa0ed30" + integrity sha512-r1mjTzAuJ9W8cPBGbbus8E0SKcUP7gn03R14Wk8FlAlqhH9hroy9nLqmpuXlfKEw/oILW+FGz47ipXV2O7x8lg== capture-exit@^2.0.0: version "2.0.0" @@ -2254,9 +2254,9 @@ domexception@^2.0.1: webidl-conversions "^5.0.0" electron-to-chromium@^1.3.867: - version "1.3.867" - resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.867.tgz#7cb484db4b57c28da0b65c51e434c3a1f3f9aa0d" - integrity sha512-WbTXOv7hsLhjJyl7jBfDkioaY++iVVZomZ4dU6TMe/SzucV6mUAs2VZn/AehBwuZMiNEQDaPuTGn22YK5o+aDw== + version "1.3.868" + resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.3.868.tgz#ed835023b57ecf0ba63dfe7d50e16b53758ab1da" + integrity sha512-kZYCHqwJ1ctGrYDlOcWQH+/AftAm/KD4lEnLDNwS0kKwx1x6dU4zv+GuDjsPPOGn/2TjnKBaZjDyjXaoix0q/A== elliptic@^6.5.3: version "6.5.4" @@ -2463,9 +2463,9 @@ eslint-loader@2.1.1: rimraf "^2.6.1" eslint-module-utils@^2.7.0: - version "2.7.0" - resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.7.0.tgz#9e97c12688113401259b39d960e6a1f09f966435" - integrity sha512-hqSE88MmHl3ru9SYvDyGrlo0JwROlf9fiEMplEV7j/EAuq9iSlIlyCFbBT6pdULQBSnBYtYKiMLps+hKkyP7Gg== + version "2.7.1" + resolved "https://registry.yarnpkg.com/eslint-module-utils/-/eslint-module-utils-2.7.1.tgz#b435001c9f8dd4ab7f6d0efcae4b9696d4c24b7c" + integrity sha512-fjoetBXQZq2tSTWZ9yWVl2KuFrTZZH3V+9iD1V1RfpDgxzJR+mPd/KZmMiA8gbPqdBzpNiEHOuT7IYEWxrH0zQ== dependencies: debug "^3.2.7" find-up "^2.1.0" @@ -3656,9 +3656,9 @@ istanbul-lib-source-maps@^4.0.0: source-map "^0.6.1" istanbul-reports@^3.0.2: - version "3.0.4" - resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.0.4.tgz#5c38ce8136edf484c0fcfbf7514aafb0363ed1db" - integrity sha512-bFjUnc95rHjdCR63WMHUS7yfJJh8T9IPSWavvR02hhjVwezWALZ5axF9EqjmwZHpXqkzbgAMP8DmAtiyNxrdrQ== + version "3.0.5" + resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-3.0.5.tgz#a2580107e71279ea6d661ddede929ffc6d693384" + integrity sha512-5+19PlhnGabNWB7kOFnuxT8H3T/iIyQzIbQMxXsURmmvKg86P2sbkrGOT77VnHw0Qr0gc2XzRaRfMZYYbSQCJQ== dependencies: html-escaper "^2.0.0" istanbul-lib-report "^3.0.0"