From 2e7406862eae4f6069519cb1980bf6c67f9a3248 Mon Sep 17 00:00:00 2001 From: Shawn Erquhart Date: Tue, 17 Jul 2018 11:37:17 -0400 Subject: [PATCH] fix various bugs --- .babelrc | 17 +++++- package.json | 5 +- packages/netlify-cms-core/package.json | 6 +- .../src/backends/github/API.js | 3 +- .../src/components/Editor/EditorInterface.js | 19 +++--- .../src/components/Editor/EditorToggle.js | 19 +++--- .../src/components/Editor/EditorToolbar.js | 16 +++-- .../MediaLibrary/MediaLibraryHeader.js | 3 + .../netlify-cms-core/src/reducers/medias.js | 2 +- .../src/valueObjects/AssetProxy.js | 4 +- packages/netlify-cms-lib-util/src/index.js | 20 ------ packages/netlify-cms-ui-default/package.json | 2 +- .../netlify-cms-ui-default/src/Dropdown.js | 7 ++- packages/netlify-cms-ui-default/src/Icon.js | 2 +- yarn.lock | 61 ++++++++++++++++--- 15 files changed, 119 insertions(+), 67 deletions(-) delete mode 100644 packages/netlify-cms-lib-util/src/index.js diff --git a/.babelrc b/.babelrc index 59fd1197..909fa218 100644 --- a/.babelrc +++ b/.babelrc @@ -6,8 +6,10 @@ }], ], "plugins": [ - "transform-object-rest-spread", - "transform-class-properties", + "lodash", + ["babel-plugin-transform-builtin-extend", { + "globals": ["Error"] + }], ["transform-runtime", { "useBuiltIns": true, "useESModules": true, @@ -29,7 +31,16 @@ "ValueObjects": "./src/valueObjects/", } }], - "inline-svg", + "transform-export-extensions", + "transform-class-properties", + "transform-object-rest-spread", + ["inline-svg", { + "svgo": { + "plugins": [ + {"removeViewBox": false}, + ], + }, + }], ], "env": { "production": { diff --git a/package.json b/package.json index 0b84af4c..0d0c7f61 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "scripts": { "start": "lerna run --parallel watch", "clean": "cd packages && rimraf */.cache */*.js */*.css */*.svg */*.map", - "reset": "yarn clean && lerna clean --yes && lerna bootstrap && cd packages/netlify-cms-core && yarn link netlify-cms-lib-auth netlify-cms-lib-util netlify-cms-ui-default netlify-cms-editor-component-image react-split-pane" + "reset": "yarn clean && lerna clean --yes && lerna bootstrap && cd packages/netlify-cms-core && yarn link netlify-cms-lib-auth netlify-cms-lib-util netlify-cms-ui-default netlify-cms-editor-component-image" }, "jest": { "moduleNameMapper": { @@ -61,8 +61,11 @@ "babel-plugin-emotion": "^9.2.4", "babel-plugin-inline-import": "^3.0.0", "babel-plugin-inline-svg": "^1.0.0", + "babel-plugin-lodash": "^3.3.4", "babel-plugin-module-resolver": "^3.0.0", + "babel-plugin-transform-builtin-extend": "^1.1.2", "babel-plugin-transform-class-properties": "^6.24.1", + "babel-plugin-transform-export-extensions": "^6.22.0", "babel-plugin-transform-inline-environment-variables": "^0.4.3", "babel-plugin-transform-object-rest-spread": "^6.26.0", "babel-plugin-transform-runtime": "^6.23.0", diff --git a/packages/netlify-cms-core/package.json b/packages/netlify-cms-core/package.json index 19922c2f..0051b1e6 100644 --- a/packages/netlify-cms-core/package.json +++ b/packages/netlify-cms-core/package.json @@ -46,12 +46,12 @@ "mdast-util-definitions": "^1.2.2", "mdast-util-to-string": "^1.0.4", "moment": "^2.11.2", + "netlify-cms-editor-component-image": "file:../netlify-cms-editor-component-image", "netlify-cms-lib-auth": "file:../netlify-cms-lib-auth", "netlify-cms-lib-util": "file:../netlify-cms-lib-util", "netlify-cms-ui-default": "file:../netlify-cms-ui-default", - "netlify-cms-editor-component-image": "file:../netlify-cms-editor-component-image", "prop-types": "^15.5.10", - "react": "15.x || 16.x", + "react": "^16.4.1", "react-aria-menubutton": "^5.1.0", "react-autosuggest": "^9.3.2", "react-datetime": "^2.11.0", @@ -69,7 +69,7 @@ "react-router-redux": "^5.0.0-alpha.8", "react-scroll-sync": "^0.4.0", "react-sortable-hoc": "^0.6.8", - "react-split-pane": "^0.1.81", + "react-split-pane": "^0.1.82", "react-textarea-autosize": "^5.2.0", "react-toggled": "^1.1.2", "react-topbar-progress-indicator": "^2.0.0", diff --git a/packages/netlify-cms-core/src/backends/github/API.js b/packages/netlify-cms-core/src/backends/github/API.js index c58ac576..c528460d 100644 --- a/packages/netlify-cms-core/src/backends/github/API.js +++ b/packages/netlify-cms-core/src/backends/github/API.js @@ -4,7 +4,8 @@ import { uniq, initial, last, get, find, hasIn, partial } from "lodash"; import { filterPromises, resolvePromiseProperties } from "netlify-cms-lib-util/promise"; import AssetProxy from "ValueObjects/AssetProxy"; import { SIMPLE, EDITORIAL_WORKFLOW, status } from "Constants/publishModes"; -import { APIError, EditorialWorkflowError } from "netlify-cms-lib-util"; +import APIError from "netlify-cms-lib-util/APIError"; +import EditorialWorkflowError from "netlify-cms-lib-util/EditorialWorkflowError"; const CMS_BRANCH_PREFIX = 'cms/'; diff --git a/packages/netlify-cms-core/src/components/Editor/EditorInterface.js b/packages/netlify-cms-core/src/components/Editor/EditorInterface.js index fd4e41ba..89d16b4b 100644 --- a/packages/netlify-cms-core/src/components/Editor/EditorInterface.js +++ b/packages/netlify-cms-core/src/components/Editor/EditorInterface.js @@ -16,7 +16,7 @@ const PREVIEW_VISIBLE = 'cms.preview-visible'; const SCROLL_SYNC_ENABLED = 'cms.scroll-sync-enabled'; const styles = { - noPreviewContainer: css` + splitPane: css` ${components.card}; border-radius: 0; height: 100%; @@ -53,18 +53,21 @@ injectGlobal` } } +` + +const StyledSplitPane = styled(SplitPane)` + ${styles.splitPane}; + /** * Quick fix for preview pane not fully displaying in Safari */ - .SplitPane { - .Pane { - height: 100%; - } + .Pane { + height: 100%; } ` const NoPreviewContainer = styled.div` - ${styles.noPreviewContainer}; + ${styles.splitPane}; ` const EditorContainer = styled.div` @@ -202,7 +205,7 @@ class EditorInterface extends Component { const editorWithPreview = (
- - +
); diff --git a/packages/netlify-cms-core/src/components/Editor/EditorToggle.js b/packages/netlify-cms-core/src/components/Editor/EditorToggle.js index b8137e2a..dfce188c 100644 --- a/packages/netlify-cms-core/src/components/Editor/EditorToggle.js +++ b/packages/netlify-cms-core/src/components/Editor/EditorToggle.js @@ -2,30 +2,25 @@ import React from 'react'; import PropTypes from 'prop-types'; import styled from 'react-emotion'; import Icon from 'netlify-cms-ui-default/Icon'; -import { colors, colorsRaw, shadows } from 'netlify-cms-ui-default/styles'; +import { colors, colorsRaw, shadows, buttons } from 'netlify-cms-ui-default/styles'; const EditorToggleButton = styled.button` + ${buttons.button}; ${shadows.dropMiddle}; background-color: ${colorsRaw.white}; - color: ${props => colors[props.active ? `active` : `inactive`]}; + color: ${props => colors[props.isActive ? `active` : `inactive`]}; border-radius: 32px; - display: block; + display: flex; + justify-content: center; + align-items: center; width: 40px; height: 40px; padding: 0; margin-bottom: 12px; - - ${Icon} { - width: 100%; - height: 100%; - display: flex; - justify-content: center; - align-items: center; - } ` const EditorToggle = ({ enabled, active, onClick, icon }) => !enabled ? null : - + ; diff --git a/packages/netlify-cms-core/src/components/Editor/EditorToolbar.js b/packages/netlify-cms-core/src/components/Editor/EditorToolbar.js index 6b628688..03a05c32 100644 --- a/packages/netlify-cms-core/src/components/Editor/EditorToolbar.js +++ b/packages/netlify-cms-core/src/components/Editor/EditorToolbar.js @@ -18,6 +18,7 @@ const styles = { height: 100%; display: flex; align-items: center; + border: 0 solid ${colors.textFieldBorder}; `, } @@ -38,6 +39,7 @@ const ToolbarContainer = styled.div` ` const ToolbarSectionMain = styled.div` + ${styles.toolbarSection}; flex: 10; display: flex; justify-content: space-between; @@ -54,7 +56,6 @@ const ToolbarSubSectionLast = styled(ToolbarSubSectionFirst)` const ToolbarSectionBackLink = styled(Link)` ${styles.toolbarSection}; - border: 0 solid ${colors.textFieldBorder}; border-right-width: 1px; font-weight: normal; padding: 0 20px; @@ -116,6 +117,7 @@ const BackStatusChanged = styled(BackStatus)` ` const ToolbarButton = styled.button` + ${buttons.button}; ${buttons.default}; ${styles.buttonMargin}; display: block; @@ -151,6 +153,12 @@ const StatusButton = styled(StyledDropdownButton)` color: ${colorsRaw.teal}; ` +const StatusDropdownItem = styled(DropdownItem)` + ${Icon} { + color: ${colors.infoText}; + } +` + export default class EditorToolbar extends React.Component { static propTypes = { isPersisting: PropTypes.bool, @@ -265,17 +273,17 @@ export default class EditorToolbar extends React.Component { {isUpdatingStatus ? 'Updating...' : 'Set status'} )} > - onChangeStatus('DRAFT')} icon={currentStatus === status.get('DRAFT') && 'check'} /> - onChangeStatus('PENDING_REVIEW')} icon={currentStatus === status.get('PENDING_REVIEW') && 'check'} /> - onChangeStatus('PENDING_PUBLISH')} icon={currentStatus === status.get('PENDING_PUBLISH') && 'check'} diff --git a/packages/netlify-cms-core/src/components/MediaLibrary/MediaLibraryHeader.js b/packages/netlify-cms-core/src/components/MediaLibrary/MediaLibraryHeader.js index d27a4133..ebfd883d 100644 --- a/packages/netlify-cms-core/src/components/MediaLibrary/MediaLibraryHeader.js +++ b/packages/netlify-cms-core/src/components/MediaLibrary/MediaLibraryHeader.js @@ -15,6 +15,9 @@ const CloseButton = styled.button` border-radius: 50%; background-color: white; padding: 0; + display: flex; + justify-content: center; + align-items: center; ` const LibraryTitle = styled.h1` diff --git a/packages/netlify-cms-core/src/reducers/medias.js b/packages/netlify-cms-core/src/reducers/medias.js index e830b1c2..3127eb6d 100644 --- a/packages/netlify-cms-core/src/reducers/medias.js +++ b/packages/netlify-cms-core/src/reducers/medias.js @@ -1,5 +1,5 @@ import { Map } from 'immutable'; -import { resolvePath } from 'netlify-cms-lib-util'; +import { resolvePath } from 'netlify-cms-lib-util/path'; import { ADD_ASSET, REMOVE_ASSET } from 'Actions/media'; import AssetProxy from 'ValueObjects/AssetProxy'; diff --git a/packages/netlify-cms-core/src/valueObjects/AssetProxy.js b/packages/netlify-cms-core/src/valueObjects/AssetProxy.js index fb82326d..21b9fc6d 100644 --- a/packages/netlify-cms-core/src/valueObjects/AssetProxy.js +++ b/packages/netlify-cms-core/src/valueObjects/AssetProxy.js @@ -1,5 +1,5 @@ -import { resolvePath } from 'netlify-cms-lib-util'; -import { currentBackend } from "Backends/backend"; +import { resolvePath } from 'netlify-cms-lib-util/path'; +import { currentBackend } from 'Backends/backend'; import { getIntegrationProvider } from 'Integrations'; import { selectIntegration } from 'Reducers'; diff --git a/packages/netlify-cms-lib-util/src/index.js b/packages/netlify-cms-lib-util/src/index.js deleted file mode 100644 index edab24d8..00000000 --- a/packages/netlify-cms-lib-util/src/index.js +++ /dev/null @@ -1,20 +0,0 @@ -import localForage from './localForage'; -import { resolvePath, basename, fileExtensionWithSeparator, fileExtension } from './path'; -import { filterPromises, resolvePromiseProperties, then } from './promise'; -import unsentRequest from './unsentRequest'; -import APIError from './APIError'; -import EditorialWorkflowError from './EditorialWorkflowError'; - -export { - localForage, - resolvePath, - basename, - fileExtensionWithSeparator, - fileExtension, - filterPromises, - resolvePromiseProperties, - then, - unsentRequest, - APIError, - EditorialWorkflowError, -}; diff --git a/packages/netlify-cms-ui-default/package.json b/packages/netlify-cms-ui-default/package.json index cf548263..f97a08b2 100644 --- a/packages/netlify-cms-ui-default/package.json +++ b/packages/netlify-cms-ui-default/package.json @@ -16,7 +16,7 @@ "emotion": "^9.1.3", "lodash": "^4.13.1", "prop-types": "^15.5.10", - "react": "15.x || 16.x", + "react": "^16.4.1", "react-aria-menubutton": "^5.1.0", "react-emotion": "^9.2.6", "react-toggled": "^1.1.2", diff --git a/packages/netlify-cms-ui-default/src/Dropdown.js b/packages/netlify-cms-ui-default/src/Dropdown.js index 7ef940ae..edef97e3 100644 --- a/packages/netlify-cms-ui-default/src/Dropdown.js +++ b/packages/netlify-cms-ui-default/src/Dropdown.js @@ -85,10 +85,11 @@ const Dropdown = ({ dropdownWidth = 'auto', dropdownPosition = 'left', dropdownTopOverlap = '0', + className, children, }) => { return ( - handler()}> + handler()} className={className}> {renderButton()} @@ -99,8 +100,8 @@ const Dropdown = ({ ); }; -const DropdownItem = ({ label, icon, iconDirection, onClick }) => ( - +const DropdownItem = ({ label, icon, iconDirection, onClick, className }) => ( + {label} { icon diff --git a/packages/netlify-cms-ui-default/src/Icon.js b/packages/netlify-cms-ui-default/src/Icon.js index 3996e998..8467b1ff 100644 --- a/packages/netlify-cms-ui-default/src/Icon.js +++ b/packages/netlify-cms-ui-default/src/Icon.js @@ -7,7 +7,7 @@ const IconWrapper = styled.span` line-height: 0; width: ${props => props.size}; height: ${props => props.size}; - transform: ${props => `rotation(${props.rotation})`}; + transform: ${props => `rotate(${props.rotation})`}; & path:not(.no-fill), & circle:not(.no-fill), diff --git a/yarn.lock b/yarn.lock index 21d3a1e4..bd976d41 100644 --- a/yarn.lock +++ b/yarn.lock @@ -22,6 +22,13 @@ "@babel/types" "7.0.0-beta.51" lodash "^4.17.5" +"@babel/helper-module-imports@^7.0.0-beta.49": + version "7.0.0-beta.54" + resolved "https://registry.yarnpkg.com/@babel/helper-module-imports/-/helper-module-imports-7.0.0-beta.54.tgz#c2d8e14ff034225bf431356db77ef467b8d35aac" + dependencies: + "@babel/types" "7.0.0-beta.54" + lodash "^4.17.5" + "@babel/highlight@7.0.0-beta.52": version "7.0.0-beta.52" resolved "https://registry.yarnpkg.com/@babel/highlight/-/highlight-7.0.0-beta.52.tgz#ef24931432f06155e7bc39cdb8a6b37b4a28b3d0" @@ -46,6 +53,14 @@ lodash "^4.17.5" to-fast-properties "^2.0.0" +"@babel/types@7.0.0-beta.54", "@babel/types@^7.0.0-beta.49": + version "7.0.0-beta.54" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.0.0-beta.54.tgz#025ad68492fed542c13f14c579a44c848e531063" + dependencies: + esutils "^2.0.2" + lodash "^4.17.5" + to-fast-properties "^2.0.0" + "@emotion/babel-utils@^0.6.4": version "0.6.5" resolved "https://registry.yarnpkg.com/@emotion/babel-utils/-/babel-utils-0.6.5.tgz#34d7844eb532d1175c8fc70175beb74d071bfbeb" @@ -660,6 +675,16 @@ babel-plugin-jest-hoist@^22.4.4: version "22.4.4" resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-22.4.4.tgz#b9851906eab34c7bf6f8c895a2b08bea1a844c0b" +babel-plugin-lodash@^3.3.4: + version "3.3.4" + resolved "https://registry.yarnpkg.com/babel-plugin-lodash/-/babel-plugin-lodash-3.3.4.tgz#4f6844358a1340baed182adbeffa8df9967bc196" + dependencies: + "@babel/helper-module-imports" "^7.0.0-beta.49" + "@babel/types" "^7.0.0-beta.49" + glob "^7.1.1" + lodash "^4.17.10" + require-package-name "^2.0.1" + babel-plugin-macros@^2.0.0: version "2.2.2" resolved "https://registry.yarnpkg.com/babel-plugin-macros/-/babel-plugin-macros-2.2.2.tgz#049c93f4b934453688a6ec38bba529c55bf0fa1f" @@ -688,6 +713,10 @@ babel-plugin-syntax-exponentiation-operator@^6.8.0: version "6.13.0" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-exponentiation-operator/-/babel-plugin-syntax-exponentiation-operator-6.13.0.tgz#9ee7e8337290da95288201a6a57f4170317830de" +babel-plugin-syntax-export-extensions@^6.8.0: + version "6.13.0" + resolved "https://registry.yarnpkg.com/babel-plugin-syntax-export-extensions/-/babel-plugin-syntax-export-extensions-6.13.0.tgz#70a1484f0f9089a4e84ad44bac353c95b9b12721" + babel-plugin-syntax-flow@^6.18.0: version "6.18.0" resolved "https://registry.yarnpkg.com/babel-plugin-syntax-flow/-/babel-plugin-syntax-flow-6.18.0.tgz#4c3ab20a2af26aa20cd25995c398c4eb70310c8d" @@ -712,6 +741,13 @@ babel-plugin-transform-async-to-generator@^6.22.0: babel-plugin-syntax-async-functions "^6.8.0" babel-runtime "^6.22.0" +babel-plugin-transform-builtin-extend@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-builtin-extend/-/babel-plugin-transform-builtin-extend-1.1.2.tgz#5e96fecf58b8fa1ed74efcad88475b2af3c9116e" + dependencies: + babel-runtime "^6.2.0" + babel-template "^6.3.0" + babel-plugin-transform-class-properties@^6.24.1: version "6.24.1" resolved "https://registry.yarnpkg.com/babel-plugin-transform-class-properties/-/babel-plugin-transform-class-properties-6.24.1.tgz#6a79763ea61d33d36f37b611aa9def81a81b46ac" @@ -897,6 +933,13 @@ babel-plugin-transform-exponentiation-operator@^6.22.0: babel-plugin-syntax-exponentiation-operator "^6.8.0" babel-runtime "^6.22.0" +babel-plugin-transform-export-extensions@^6.22.0: + version "6.22.0" + resolved "https://registry.yarnpkg.com/babel-plugin-transform-export-extensions/-/babel-plugin-transform-export-extensions-6.22.0.tgz#53738b47e75e8218589eea946cbbd39109bbe653" + dependencies: + babel-plugin-syntax-export-extensions "^6.8.0" + babel-runtime "^6.22.0" + babel-plugin-transform-flow-strip-types@^6.22.0: version "6.22.0" resolved "https://registry.yarnpkg.com/babel-plugin-transform-flow-strip-types/-/babel-plugin-transform-flow-strip-types-6.22.0.tgz#84cb672935d43714fdc32bce84568d87441cf7cf" @@ -1041,14 +1084,14 @@ babel-register@^6.26.0: mkdirp "^0.5.1" source-map-support "^0.4.15" -babel-runtime@^6.11.6, babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.23.0, babel-runtime@^6.26.0: +babel-runtime@^6.11.6, babel-runtime@^6.18.0, babel-runtime@^6.2.0, babel-runtime@^6.22.0, babel-runtime@^6.23.0, babel-runtime@^6.26.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" dependencies: core-js "^2.4.0" regenerator-runtime "^0.11.0" -babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.26.0: +babel-template@^6.16.0, babel-template@^6.24.1, babel-template@^6.26.0, babel-template@^6.3.0: version "6.26.0" resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02" dependencies: @@ -5055,7 +5098,7 @@ needle@^2.2.0: emotion "^9.1.3" lodash "^4.13.1" prop-types "^15.5.10" - react "15.x || 16.x" + react "^16.4.1" react-aria-menubutton "^5.1.0" react-emotion "^9.2.6" react-toggled "^1.1.2" @@ -6567,9 +6610,9 @@ react-sortable-hoc@^0.6.8: lodash "^4.12.0" prop-types "^15.5.7" -react-split-pane@^0.1.81: - version "0.1.81" - resolved "https://registry.yarnpkg.com/react-split-pane/-/react-split-pane-0.1.81.tgz#b1e8b82e0a6edd10f18fd639a5f512db3cbbb4e6" +react-split-pane@^0.1.82: + version "0.1.82" + resolved "https://registry.yarnpkg.com/react-split-pane/-/react-split-pane-0.1.82.tgz#42fbb9fd4823f05e037de0dab3cd6cf9bf0cf4ea" dependencies: inline-style-prefixer "^3.0.6" prop-types "^15.5.10" @@ -6639,7 +6682,7 @@ react-waypoint@^7.1.0: consolidated-events "^1.1.0" prop-types "^15.0.0" -"react@15.x || 16.x", react@^16.4.1: +react@^16.4.1: version "16.4.1" resolved "https://registry.yarnpkg.com/react/-/react-16.4.1.tgz#de51ba5764b5dbcd1f9079037b862bd26b82fe32" dependencies: @@ -7025,6 +7068,10 @@ require-main-filename@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1" +require-package-name@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/require-package-name/-/require-package-name-2.0.1.tgz#c11e97276b65b8e2923f75dabf5fb2ef0c3841b9" + require-resolve@0.0.2: version "0.0.2" resolved "https://registry.yarnpkg.com/require-resolve/-/require-resolve-0.0.2.tgz#bab410ab1aee2f3f55b79317451dd3428764e6f3"