@@ -0,0 +1,59 @@
import React from 'react';
import PropTypes from 'prop-types';

import { withMutation } from './withMutation';

function withMutationModalHelper(WrappedComponent) {
class withMutationModalHelperClass extends React.Component {
constructor(props) {
super(props);
this.state = {
modalOpen: false,
};

props.registerCallbacks({
onMutationSuccess: this.handleClose,
});
}

handleOpen = () => {
this.setState({ modalOpen: true });
};

handleClose = () => {
this.setState({ modalOpen: false });
};

handleMutationSuccess = () => {
this.handleClose();
console.log('we are done!!');
};

render() {
const { ...rest } = this.props;

return (
<WrappedComponent
handleOpen={this.handleOpen}
handleClose={this.handleClose}
modalOpen={this.state.modalOpen}
{...rest}
/>
);
}
}
withMutationModalHelperClass.propTypes = {
document: PropTypes.object,
collection: PropTypes.object.isRequired,
registerCallbacks: PropTypes.func.isRequired,
};
withMutationModalHelperClass.defaultProps = {
document: undefined,
};

return withMutationModalHelperClass;
}

const withMutationModalHelperWithHOCs = WrappedComponent => withMutation()(withMutationModalHelper(WrappedComponent));

export { withMutationModalHelperWithHOCs as withMutationModalHelper };
@@ -80,4 +80,4 @@ function withReactiveQuery(query, queryVariables, graphqlOptions) {
return WrappedComponent => graphql(query, config)(withRefetch(WrappedComponent, queryVariables));
}

export default withReactiveQuery;
export { withReactiveQuery };
@@ -1,7 +1,13 @@
import queryManager from './utils/queryManager';
import withReactiveQuery from './HOCs/withReactiveQuery';
import * as components from './components';
import * as HOCs from './HOCs';
import { withFormFields } from './HOCs/withFormFields';

export default {
withReactiveQuery,
queryManager,
components,
HOCs,
withFormFields,
};
@@ -0,0 +1,27 @@
import React from 'react';
import MuiTextField from '@material-ui/core/TextField';
import { withStyles } from '@material-ui/core/styles';
import PropTypes from 'prop-types';
import { withFormFields } from '../HOCs/withFormFields';

/**
* TextField
*/
const textFieldStyles = {
blah: {
fontSize: '1.2em',
fontWeight: 'bold',
},
};
const TextFieldUnstyled = ({ value, classes, ...rest }) => {
if(!value) value = '';
return <MuiTextField value={value} {...rest} />;
};
TextFieldUnstyled.propTypes = {
value: PropTypes.any,
classes: PropTypes.object.isRequired,
};
TextFieldUnstyled.defaultProps = {
value: '',
};
export const TextField = withStyles(textFieldStyles)(withFormFields(TextFieldUnstyled));
@@ -0,0 +1 @@
export * from './FormFields';
@@ -0,0 +1,32 @@
class ConnectionManager {
constructor() {
this.connections = {
default: {
uri: 'http://localhost:1337',
headers: {},
},
};
}

get = (name) => {
const connection = this.connections[name];
if(!connection) {
throw new Error(`Could not find connection named "${name}"`);
}

return connection;
}

getDefault = () => this.connections.default;

configure = (name, config) => {
const existingConfig = this.connections[name] || {};
const mergedConfig = { ...this.connections.default, ...existingConfig, ...config };
this.connections[name] = mergedConfig;
}
}

const instance = new ConnectionManager();
Object.freeze(instance);

export default instance;
@@ -47,8 +47,8 @@
js-tokens "^3.0.0"

"@babel/runtime@^7.0.0-beta.42":
version "7.0.0-beta.54"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.0.0-beta.54.tgz#39ebb42723fe7ca4b3e1b00e967e80138d47cadf"
version "7.0.0-beta.55"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.0.0-beta.55.tgz#0bc33aa5a6ac0b012f37e25b9e6aaa2e489a916b"
dependencies:
core-js "^2.5.7"
regenerator-runtime "^0.12.0"
@@ -85,9 +85,9 @@
lodash "^4.2.0"
to-fast-properties "^2.0.0"

"@material-ui/core@^1.4.0":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-1.4.0.tgz#e535fef84576b096c46e1fb7d6c4c61895155fd3"
"@material-ui/core@^1.4.2":
version "1.4.2"
resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-1.4.2.tgz#8a1282e985d4922a4d2b4f7e287d8a716a2fc108"
dependencies:
"@babel/runtime" "^7.0.0-beta.42"
"@types/jss" "^9.5.3"
@@ -109,13 +109,12 @@
jss-vendor-prefixer "^7.0.0"
keycode "^2.1.9"
normalize-scroll-left "^0.1.2"
popper.js "^1.0.0"
popper.js "^1.14.1"
prop-types "^15.6.0"
react-event-listener "^0.6.0"
react-jss "^8.1.0"
react-transition-group "^2.2.1"
recompose "^0.27.0"
scroll "^2.0.3"
warning "^4.0.1"

"@types/async@2.0.49":
@@ -140,8 +139,8 @@
"@types/react" "*"

"@types/react@*":
version "16.4.6"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.4.6.tgz#5024957c6bcef4f02823accf5974faba2e54fada"
version "16.4.7"
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.4.7.tgz#f33f6d759a7e1833befa15224d68942d178a5a3f"
dependencies:
csstype "^2.2.0"

@@ -1172,8 +1171,8 @@ css-vendor@^0.3.8:
is-in-browser "^1.0.2"

csstype@^2.0.0, csstype@^2.2.0, csstype@^2.5.2:
version "2.5.5"
resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.5.5.tgz#4125484a3d42189a863943f23b9e4b80fedfa106"
version "2.5.6"
resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.5.6.tgz#2ae1db2319642d8b80a668d2d025c6196071e788"

damerau-levenshtein@^1.0.4:
version "1.0.4"
@@ -1269,10 +1268,6 @@ dom-helpers@^3.2.1, dom-helpers@^3.3.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/dom-helpers/-/dom-helpers-3.3.1.tgz#fc1a4e15ffdf60ddde03a480a9c0fece821dd4a6"

dom-walk@^0.1.0:
version "0.1.1"
resolved "https://registry.yarnpkg.com/dom-walk/-/dom-walk-0.1.1.tgz#672226dc74c8f799ad35307df936aba11acd6018"

ee-first@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
@@ -1744,13 +1739,6 @@ glob@^7.0.3, glob@^7.0.5, glob@^7.1.2:
once "^1.3.0"
path-is-absolute "^1.0.0"

global@~4.3.0:
version "4.3.2"
resolved "https://registry.yarnpkg.com/global/-/global-4.3.2.tgz#e76989268a6c74c38908b1305b10fc0e394e9d0f"
dependencies:
min-document "^2.19.0"
process "~0.5.1"

globals@^11.0.1, globals@^11.1.0:
version "11.7.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-11.7.0.tgz#a583faa43055b1aca771914bf68258e2fc125673"
@@ -2275,6 +2263,10 @@ locate-path@^2.0.0:
p-locate "^2.0.0"
path-exists "^3.0.0"

lodash.set@^4.3.2:
version "4.3.2"
resolved "https://registry.yarnpkg.com/lodash.set/-/lodash.set-4.3.2.tgz#d8757b1da807dde24816b0d6a84bea1a76230b23"

lodash@^4.17.10, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.3.0:
version "4.17.10"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.10.tgz#1b7793cf7259ea38fb3661d4d38b3260af8ae4e7"
@@ -2350,12 +2342,6 @@ mimic-fn@^1.0.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.2.0.tgz#820c86a39334640e99516928bd03fca88057d022"

min-document@^2.19.0:
version "2.19.0"
resolved "https://registry.yarnpkg.com/min-document/-/min-document-2.19.0.tgz#7bd282e3f5842ed295bb748cdd9f1ffa2c824685"
dependencies:
dom-walk "^0.1.0"

minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
@@ -2685,7 +2671,7 @@ pluralize@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777"

popper.js@^1.0.0:
popper.js@^1.14.1:
version "1.14.3"
resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.14.3.tgz#1438f98d046acf7b4d78cd502bf418ac64d4f095"

@@ -2705,10 +2691,6 @@ process-nextick-args@~2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.0.tgz#a37d732f4271b4ab1ad070d35508e8290788ffaa"

process@~0.5.1:
version "0.5.2"
resolved "https://registry.yarnpkg.com/process/-/process-0.5.2.tgz#1638d8a8e34c2f440a91db95ab9aeb677fc185cf"

progress@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f"
@@ -2741,12 +2723,6 @@ qs@6.5.1:
version "6.5.1"
resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.1.tgz#349cdf6eef89ec45c12d7d5eb3fc0c870343a6d8"

rafl@~1.2.1:
version "1.2.2"
resolved "https://registry.yarnpkg.com/rafl/-/rafl-1.2.2.tgz#fe930f758211020d47e38815f5196a8be4150740"
dependencies:
global "~4.3.0"

randomatic@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/randomatic/-/randomatic-3.0.0.tgz#d35490030eb4f7578de292ce6dfb04a91a128923"
@@ -2787,6 +2763,10 @@ react-apollo@^2.1.9:
lodash "^4.17.10"
prop-types "^15.6.0"

react-dom-server@^0.0.5:
version "0.0.5"
resolved "https://registry.yarnpkg.com/react-dom-server/-/react-dom-server-0.0.5.tgz#75b6c0f5946e08e84db9dda6eca5e48fed25f723"

react-dom@^16.4.1:
version "16.4.1"
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.4.1.tgz#7f8b0223b3a5fbe205116c56deb85de32685dad6"
@@ -3042,12 +3022,6 @@ sax@^1.2.4:
version "1.2.4"
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"

scroll@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/scroll/-/scroll-2.0.3.tgz#0951b785544205fd17753bc3d294738ba16fc2ab"
dependencies:
rafl "~1.2.1"

"semver@2 || 3 || 4 || 5", semver@^5.3.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"