Skip to content

Commit

Permalink
feat: export "connect" HOC (#344)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j authored Dec 17, 2018
1 parent e3f9ffe commit c48ce71
Show file tree
Hide file tree
Showing 52 changed files with 86 additions and 75 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import { isEqual } from "lodash";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { getElement } from "webiny-app-cms/editor/selectors";

export default connect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as React from "react";
import { pure } from "recompose";
import { get } from "lodash";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { isEqual } from "lodash";
import { getElement } from "webiny-app-cms/editor/selectors";
import Slate from "./Slate";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as React from "react";
import styled from "react-emotion";
import { getElementProps } from "webiny-app-cms/editor/selectors";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { pure } from "recompose";
import Droppable from "./../Droppable";

Expand Down
3 changes: 2 additions & 1 deletion packages/webiny-app-cms/src/editor/components/Droppable.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// @flow
import React from "react";
import { DropTarget } from "react-dnd";
import { compose, pure } from "recompose";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { getIsDragging } from "webiny-app-cms/editor/selectors";

const defaultVisibility = ({ type, isDragging, item }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { pure } from "recompose";
import { getPlugins } from "webiny-plugins";
import { getUi } from "webiny-app-cms/editor/selectors";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
import React from "react";
import { get } from "dot-prop-immutable";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import styled from "react-emotion";
import { css } from "emotion";
import { compose } from "recompose";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import classSet from "classnames";
import { ActionCreators } from "redux-undo";
import HTML5Backend from "react-dnd-html5-backend";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@flow
import React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import styled from "react-emotion";
import { css } from "emotion";
import { isEqual } from "lodash";
Expand Down
2 changes: 1 addition & 1 deletion packages/webiny-app-cms/src/editor/components/Element.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import * as React from "react";
import { Transition } from "react-transition-group";
import { compose, pure, withHandlers, withProps, setDisplayName } from "recompose";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import isEqual from "lodash/isEqual";
import { getPlugin } from "webiny-plugins";
import { renderPlugins } from "webiny-app/plugins";
Expand Down
47 changes: 25 additions & 22 deletions packages/webiny-app-cms/src/editor/components/OEmbed.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import * as React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { css } from "emotion";
import { isEqual } from "lodash";
import { compose, withHandlers, shouldUpdate, lifecycle } from "recompose";
Expand Down Expand Up @@ -98,30 +98,33 @@ export default compose(
}
}),
withHandlers({
renderEmpty: () => () => {
return <div>You must configure your embed in the settings!</div>;
},
renderEmbed: ({ renderEmbed, ...props }) => () => {
if (typeof renderEmbed === "function") {
return renderEmbed(props);
}
renderEmpty: () =>
function renderEmpty() {
return <div>You must configure your embed in the settings!</div>;
},
renderEmbed: ({ renderEmbed, ...props }) =>
function embedRenderer() {
if (typeof renderEmbed === "function") {
return renderEmbed(props);
}

const { element, data } = props;
const { element, data } = props;

if (data && data.loading) {
return "Loading embed data...";
}
if (data && data.loading) {
return "Loading embed data...";
}

return (
<div
id={element.id}
className={
centerAlign + " cms-editor-dragging--disabled cms-editor-resizing--disabled"
}
dangerouslySetInnerHTML={{ __html: get(element, "data.oembed.html") || "" }}
/>
);
}
return (
<div
id={element.id}
className={
centerAlign +
" cms-editor-dragging--disabled cms-editor-resizing--disabled"
}
dangerouslySetInnerHTML={{ __html: get(element, "data.oembed.html") || "" }}
/>
);
}
}),
lifecycle({
async componentDidMount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import React from "react";
import ReactDOM from "react-dom";
import styled from "react-emotion";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose, pure } from "recompose";
import { get } from "lodash";
import { Editor } from "slate-react";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import * as React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import {
getActiveElementId,
getElement,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose } from "recompose";
import { withActiveElement } from "webiny-app-cms/editor/components";
import { highlightElement, deactivateElement } from "webiny-app-cms/editor/actions";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@flow
import React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import styled from "react-emotion";
import { togglePlugin } from "webiny-app-cms/editor/actions";
import { ButtonFloating } from "webiny-ui/Button";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@flow
import React from "react";
import styled, { keyframes } from "react-emotion";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { pure } from "recompose";
import { Elevation } from "webiny-ui/Elevation";
import { ButtonFloating } from "webiny-ui/Button";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@flow
import * as React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose } from "recompose";
import { Tabs, Tab } from "webiny-ui/Tabs";
import { Icon } from "webiny-ui/Icon";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@flow
import React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose, lifecycle, withHandlers, withState } from "recompose";
import { omit } from "lodash";
import { getPlugins } from "webiny-plugins";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { togglePlugin } from "webiny-app-cms/editor/actions";
import { IconButton } from "webiny-ui/Button";
import { ReactComponent as SettingsIcon } from "./icons/settings.svg";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@flow
import React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose, pure } from "recompose";
import { css } from "emotion";
import { withRouter } from "webiny-app/components";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
//@flow
import React from "react";
import { compose, withState, withProps, withHandlers, pure } from "recompose";
import { get } from "dot-prop-immutable";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { Input } from "webiny-ui/Input";
import { updateRevision } from "webiny-app-cms/editor/actions";
import { getPage } from "webiny-app-cms/editor/selectors";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import * as React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose, withHandlers } from "recompose";
import { cloneDeep } from "lodash";
import { merge } from "dot-prop-immutable";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import * as React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose, withHandlers, withProps } from "recompose";
import { getPlugin } from "webiny-plugins";
import { set } from "dot-prop-immutable";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@flow
import React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose } from "recompose";
import { Tabs, Tab } from "webiny-ui/Tabs";
import { get, set } from "dot-prop-immutable";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose, lifecycle, pure } from "recompose";
import { TopAppBarSecondary, TopAppBarSection } from "webiny-ui/TopAppBar";
import { ButtonDefault, ButtonIcon } from "webiny-ui/Button";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@flow
import React from "react";
import { Transition } from "react-transition-group";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import styled from "react-emotion";
import { Elevation } from "webiny-ui/Elevation";
import { togglePlugin } from "webiny-app-cms/editor/actions";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@flow
import * as React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose, withHandlers } from "recompose";
import { Tabs, Tab } from "webiny-ui/Tabs";
import { get, set } from "dot-prop-immutable";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import * as React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose, withHandlers } from "recompose";
import { getPlugin } from "webiny-plugins";
import { set } from "dot-prop-immutable";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//@flow
import React from "react";
import { css } from "emotion";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose, lifecycle, withHandlers } from "recompose";
import { togglePlugin } from "webiny-app-cms/editor/actions";
import { IconButton } from "webiny-ui/Button";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@flow
import React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose, withProps, withHandlers } from "recompose";
import { Tabs, Tab } from "webiny-ui/Tabs";
import { Grid } from "webiny-ui/Grid";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import * as React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose, withHandlers } from "recompose";
import { getPlugin } from "webiny-plugins";
import { deleteElement } from "webiny-app-cms/editor/actions";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@flow
import React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose } from "recompose";
import { set } from "dot-prop-immutable";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import * as React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose, withState, withHandlers, lifecycle, shouldUpdate } from "recompose";
import { graphql } from "react-apollo";
import { isEqual, cloneDeep } from "lodash";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@flow
import React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose, withHandlers, withProps } from "recompose";
import { Tabs, Tab } from "webiny-ui/Tabs";
import { get, set } from "dot-prop-immutable";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//@flow
import React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose } from "recompose";
import { set } from "dot-prop-immutable";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import * as React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { css } from "emotion";
import { isEqual } from "lodash";
import Element from "webiny-app-cms/editor/components/Element";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import * as React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose, withHandlers } from "recompose";
import { get, set } from "dot-prop-immutable";
import { updateElement } from "webiny-app-cms/editor/actions";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// @flow
import * as React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose } from "recompose";
import { set } from "dot-prop-immutable";
import { get } from "lodash";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// @flow
import * as React from "react";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose } from "recompose";
import { isEqual } from "lodash";
import { get, merge } from "dot-prop-immutable";
Expand All @@ -22,7 +23,7 @@ class LinkSettings extends React.Component<*> {

const newElement = merge(element, attrKey, data);

updateElement({ element: newElement, history });
updateElement({ element: newElement });

if (!isEqual(this.historyUpdated, data)) {
this.historyUpdated = data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import React from "react";
import styled from "react-emotion";
import { css } from "emotion";
import { isEqual } from "lodash";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import { compose, withHandlers, pure } from "recompose";
import { IconButton } from "webiny-ui/Button";
import { ElementStyle, getElementStyleProps } from "webiny-app-cms/render/components/ElementStyle";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// @flow
import * as React from "react";
import { compose, withHandlers } from "recompose";
import { connect } from "react-redux";
import { connect } from "webiny-app-cms/editor/redux";
import isEqual from "lodash/isEqual";
import DropZone from "webiny-app-cms/editor/components/DropZone";
import Element from "webiny-app-cms/editor/components/Element";
Expand Down
Loading

0 comments on commit c48ce71

Please sign in to comment.