Skip to content

Commit

Permalink
Initial commit for fireform
Browse files Browse the repository at this point in the history
  • Loading branch information
TarikHuber committed Sep 28, 2017
1 parent a4bdc75 commit 1f988f5
Show file tree
Hide file tree
Showing 49 changed files with 60 additions and 1,512 deletions.
429 changes: 13 additions & 416 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion demo/src/components/Drawer/DrawerContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import allLocales from '../../locales';
import firebase from 'firebase';
import { injectIntl } from 'react-intl';
import { withRouter } from 'react-router-dom';
import { withFirebase } from '../../../../src';
import { withFirebase } from 'firekit'

const DrawerContent = (props, context) => {

Expand Down
2 changes: 1 addition & 1 deletion demo/src/components/Drawer/DrawerHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {RMWIcon} from '../Icons';
import {injectIntl} from 'react-intl';
import muiThemeable from 'material-ui/styles/muiThemeable';
import CircularProgress from 'material-ui/CircularProgress';
import { withFirebase } from '../../../../src';
import { withFirebase } from 'firekit'

const DrawerHeader = ({muiTheme, intl, auth, setAuthMenuOpen, fetchUser, dialogs, setDialogIsOpen, firebaseApp}) => {
const styles={
Expand Down
2 changes: 1 addition & 1 deletion demo/src/containers/About/About.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import {injectIntl, intlShape} from 'react-intl';
import { Activity } from '../../containers/Activity';
import { withFirebase } from '../../../../src';
import { withFirebase } from 'firekit'

class About extends Component {

Expand Down
6 changes: 4 additions & 2 deletions demo/src/containers/Companies/Companie.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import firebase from 'firebase';
import FontIcon from 'material-ui/FontIcon';
import FlatButton from 'material-ui/FlatButton';
import Dialog from 'material-ui/Dialog';
import { withFirebase, FireForm } from '../../../../src';
import { withFirebase } from 'firekit';
import FireForm from '../../../../src';

const path='/companies/';

Expand Down Expand Up @@ -56,7 +57,7 @@ class Companie extends Component {

render() {

const {history, intl, setDialogIsOpen, dialogs, match}=this.props;
const {history, intl, setDialogIsOpen, dialogs, match, firebaseApp}=this.props;

const actions = [
<FlatButton
Expand Down Expand Up @@ -86,6 +87,7 @@ class Companie extends Component {
<div style={{margin: 15, display: 'flex'}}>

<FireForm
firebaseApp={firebaseApp}
name={'companie'}
path={`${path}`}
onSubmitSuccess={(values, key)=>{history.push('/companies');}}
Expand Down
2 changes: 1 addition & 1 deletion demo/src/containers/Companies/Companies.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import FontIcon from 'material-ui/FontIcon';
import FloatingActionButton from 'material-ui/FloatingActionButton';
import {withRouter} from 'react-router-dom';
import Avatar from 'material-ui/Avatar';
import { withFirebase } from '../../../../src';
import { withFirebase } from 'firekit'

class Vehicles extends Component {

Expand Down
2 changes: 1 addition & 1 deletion demo/src/containers/MyAccount/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { setDialogIsOpen } from '../../store/dialogs/actions';
import { ImageCropDialog } from '../../containers/ImageCropDialog';
import IconButton from 'material-ui/IconButton';
import { withRouter } from 'react-router-dom';
import { withFirebase } from '../../../../src';
import { withFirebase } from 'firekit'
import {GoogleIcon, FacebookIcon, GitHubIcon, TwitterIcon} from '../../components/Icons';
import muiThemeable from 'material-ui/styles/muiThemeable';
import config from '../../config';
Expand Down
3 changes: 2 additions & 1 deletion demo/src/containers/MyAccount/MyAccount.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import FlatButton from 'material-ui/FlatButton';
import Dialog from 'material-ui/Dialog';
import firebase from 'firebase';
import {formValueSelector } from 'redux-form';
import { withFirebase, FireForm } from '../../../../src';
import { withFirebase } from 'firekit';
import FireForm from '../../../../src';

const path='/users/';

Expand Down
2 changes: 1 addition & 1 deletion demo/src/containers/Root/Root.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import { IntlProvider } from 'react-intl'
import { Routes } from '../../components/Routes';
import firebase from 'firebase';
import { withFirebase } from '../../../../src';
import { withFirebase } from 'firekit'

class Root extends Component {

Expand Down
2 changes: 1 addition & 1 deletion demo/src/containers/SignIn/SignIn.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import firebaseui from 'firebaseui';
import {firebaseAuth} from '../../firebase';
import config from '../../config';
import { withRouter } from 'react-router-dom';
import { withFirebase } from '../../../../src';
import { withFirebase } from 'firekit'

var authUi = new firebaseui.auth.AuthUI(firebaseAuth);

Expand Down
3 changes: 2 additions & 1 deletion demo/src/containers/Tasks/Task.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import firebase from 'firebase';
import FontIcon from 'material-ui/FontIcon';
import FlatButton from 'material-ui/FlatButton';
import Dialog from 'material-ui/Dialog';
import { withFirebase, FireForm } from '../../../../src';
import { withFirebase } from 'firekit';
import FireForm from '../../../../src';

const path='/public_tasks/';

Expand Down
2 changes: 1 addition & 1 deletion demo/src/containers/Tasks/Tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {BottomNavigation} from 'material-ui/BottomNavigation';
import {withRouter} from 'react-router-dom';
import FlatButton from 'material-ui/FlatButton';
import Dialog from 'material-ui/Dialog';
import { withFirebase } from '../../../../src';
import { withFirebase } from 'firekit'

class Tasks extends Component {

Expand Down
2 changes: 1 addition & 1 deletion demo/src/containers/Users/Users.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Avatar from 'material-ui/Avatar';
import FontIcon from 'material-ui/FontIcon';
import {GoogleIcon, FacebookIcon, GitHubIcon, TwitterIcon} from '../../components/Icons';
import IconButton from 'material-ui/IconButton';
import { withFirebase } from '../../../../src';
import { withFirebase } from 'firekit'
import ReactList from 'react-list';

class Users extends Component {
Expand Down
2 changes: 1 addition & 1 deletion demo/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {Component} from 'react'
import {render} from 'react-dom'
import { Provider } from 'react-redux';
import { FirebaseProvider } from '../../src';
import { FirebaseProvider } from 'firekit';
import configureStore from './store';
import { Root } from './containers/Root';
import { addLocalizationData } from './locales';
Expand Down
2 changes: 1 addition & 1 deletion demo/src/store/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { reducer as formReducer } from 'redux-form'
import dialogs from './dialogs/reducer';
import locale from './locale/reducer';
import theme from './theme/reducer';
import firekitReducers from '../../../src';
import firekitReducers from 'firekit';

const reducers = combineReducers({
browser: responsiveStateReducer,
Expand Down
10 changes: 8 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "firekit",
"version": "0.1.31",
"name": "firefrom",
"version": "0.2.0",
"description": "Firebase toolkit for sync with redux",
"main": "lib/index.js",
"module": "es/index.js",
Expand Down Expand Up @@ -28,6 +28,7 @@
"devDependencies": {
"firebase": "^4.4.0",
"firebaseui": "^2.3.0",
"firekit": "^0.1.31",
"github-markdown-css": "^2.8.0",
"immutable": "^3.8.1",
"intl": "^1.2.5",
Expand Down Expand Up @@ -63,9 +64,10 @@
"author": "Tarik Huber",
"homepage": "https://www.react-most-wanted.com/",
"license": "MIT",
"repository": "https://github.com/TarikHuber/firekit",
"repository": "https://github.com/TarikHuber/fireform",
"keywords": [
"react-component",
"react-form",
"firebase",
"redux",
"react"
Expand Down
20 changes: 14 additions & 6 deletions src/components/FireForm.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, {Component} from 'react';
import {connect} from 'react-redux';
import PropTypes from 'prop-types';
import { initialize } from 'redux-form';
import withFirebase from '../withFirebase';

class FireForm extends Component {

Expand Down Expand Up @@ -85,13 +85,13 @@ class FireForm extends Component {
}

componentWillMount(){
const { path, uid, name, firebaseApp} = this.props;
const { path, uid, name, firebaseApp, initialize} = this.props;

if(uid){
firebaseApp.database().ref(`${path}${uid}`).on('value',
snapshot => {
this.setState({initialized: true}, ()=>{
this.props.dispatch(initialize(name, snapshot.val(), true))
initialize(name, snapshot.val(), true)
})
})
}else{
Expand All @@ -101,14 +101,14 @@ class FireForm extends Component {
}

componentWillReceiveProps = (nextProps) => {
const { uid, name, path, firebaseApp } = this.props;
const { uid, name, path, firebaseApp, initialize } = this.props;
const { uid: nextUid } = nextProps;

if(uid && uid!==nextUid){
firebaseApp.database().ref(`${path}${nextUid}`).on('value',
snapshot => {
this.setState({initialized: true}, ()=>{
nextProps.dispatch(initialize(name, snapshot.val(), true))
initialize(name, snapshot.val(), true)
})
})
}
Expand All @@ -133,6 +133,7 @@ class FireForm extends Component {
FireForm.propTypes = {
path: PropTypes.string.isRequired,
name: PropTypes.string.isRequired,
firebaseApp: PropTypes.any.isRequired,
uid: PropTypes.string,
onSubmitSuccess: PropTypes.func,
onDelete: PropTypes.func,
Expand All @@ -141,4 +142,11 @@ FireForm.propTypes = {
};


export default withFirebase(FireForm);
const mapStateToProps = (state) => {
return {
};
};

export default connect(
mapStateToProps, {initialize}
)(FireForm);
25 changes: 0 additions & 25 deletions src/components/FirebaseProvider.js

This file was deleted.

34 changes: 1 addition & 33 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,33 +1 @@
import listsReducer from './store/lists/reducer'
import pathsReducer from './store/paths/reducer'
import authReducer from './store/auth/reducer'
import initializationReducer from './store/initialization/reducer'
import connectionReducer from './store/connection/reducer'
import messagingReducer from './store/messaging/reducer'

const firekitReducers = {
lists: listsReducer,
paths: pathsReducer,
auth: authReducer,
connection: connectionReducer,
messaging: messagingReducer,
initialization: initializationReducer
}

export { default as FirebaseProvider } from './components/FirebaseProvider'
export { default as FireForm } from './components/FireForm'
export { default as withFirebase } from './withFirebase'
export { default as authReducer } from './store/auth/reducer'
export { default as connectionReducer } from './store/connection/reducer'
export { default as messagingReducer } from './store/messaging/reducer'
export { default as listsReducer } from './store/lists/reducer'
export { default as pathsReducer } from './store/paths/reducer'
export { default as initializationReducer } from './store/initialization/reducer'
export { initMessaging, clearMessage } from './store/messaging/actions'
export { clearInitialization } from './store/initialization/actions'
export { initConnection, unsubscribeConnection } from './store/connection/actions'
export { watchAuth, authStateChanged, authError} from './store/auth/actions'
export { watchList, unwatchList, destroyList, unwatchAllLists } from './store/lists/actions'
export { watchPath, unwatchPath, destroyPath, unwatchAllPaths } from './store/paths/actions'

export default firekitReducers
export default from './components/FireForm'
52 changes: 0 additions & 52 deletions src/store/auth/actions.js

This file was deleted.

17 changes: 0 additions & 17 deletions src/store/auth/reducer.js

This file was deleted.

Loading

0 comments on commit 1f988f5

Please sign in to comment.