Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
67f3384
Return file snapshot on upload (#88)
urbantumbleweed Mar 24, 2017
5edc780
feat(react-native): react-native and boilerplate support (#90)
prescottprue Mar 24, 2017
2d1bbb7
Added XMLHttpRequest to tests (to fix firebase auth issue)
Mar 24, 2017
0ffacb0
react-native complete example started.
Mar 24, 2017
224de4e
Firebase showing up in react-native example.
Mar 24, 2017
78f3ed4
Home now displays auth in a string.
Mar 25, 2017
2b2f429
react-native now working with firebase js library
prescottprue Mar 25, 2017
cc0ad58
Switched to ReactNative instead of rn
prescottprue Mar 25, 2017
d65aa2f
Version v1.4.0-beta (#97)
prescottprue Mar 26, 2017
04039a2
Version v1.4.0 Beta 2 (#100)
prescottprue Mar 28, 2017
5042759
Version v1.4.0 Beta 3 (#101)
prescottprue Mar 28, 2017
27d64e7
Merge branch 'master' into v1.4.0
prescottprue Mar 30, 2017
acd14f9
Merge branch 'master' into v1.4.0
Apr 1, 2017
c960361
Version 1.4.0 Beta 4 (#105)
prescottprue Apr 3, 2017
459c222
Version v1.4.0 Release Candidate 1 (#110)
prescottprue Apr 5, 2017
23bb32a
Form utils added to example.
prescottprue Apr 10, 2017
bc64cf5
Roadmap updated with info on nested populates and updateProfile method.
Apr 15, 2017
b3c87bd
Merge branch 'master' into v1.4.0
Apr 15, 2017
d4b86d1
Server side rendering notes added.
Apr 26, 2017
d7943f5
Merge branch 'master' into v1.4.0
May 5, 2017
36de200
Support for custom auth parameters added.
May 5, 2017
6b2826c
Merge branch 'master' into v1.4.0
May 5, 2017
e478d03
notParsed query parameter. isLoaded returns true issue (#121)
May 5, 2017
85e968e
Use prop-types package instead of the bundled prop-types (#122)
petetnt May 5, 2017
7dbe7b2
key: true lists support for profileParamsToPopulate (#123)
fej-snikduj May 5, 2017
ff11deb
Fixed typos in material-example
May 6, 2017
e89e381
Fixed the last of the "react" typos within material example.
May 6, 2017
3655517
Firebase updated to v3.9.0. More material example updates.
prescottprue May 6, 2017
4e629a9
Lint removed.
prescottprue May 6, 2017
e53dc19
More lint removal from material-ui example.
prescottprue May 6, 2017
caa9bd4
Added message to clarify home container.
prescottprue May 6, 2017
c964724
Not populated delete working in material-ui example
prescottprue May 6, 2017
c92a563
Pull request template updated. Roadmap updated with react-native-fire…
prescottprue May 16, 2017
90489f6
SSR and Auth sections added to recipes. Roadmap updated for coming v1…
prescottprue May 16, 2017
4404433
Merge branch 'master' into v1.4.0
prescottprue May 16, 2017
12df1e8
Auth Recipes cleaned up.
prescottprue May 16, 2017
b49e98f
Version v1.4.0-rc.3 (#128) (#134)
prescottprue May 16, 2017
d86b06d
Exposing Firebase messaging added to roadmap for v1.5.0.
May 16, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Firebase updated to v3.9.0. More material example updates.
* Material example updates
  * /projects is now protected route
  * pushWithMeta is used in projects
  * comments updated
  • Loading branch information
prescottprue committed May 6, 2017
commit 36555175fca33cf1493bdd73ec38ef2566f979b2
17 changes: 17 additions & 0 deletions docs/api/compose.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ Middleware that handles configuration (placed in redux's
changes. Argument Pattern: `(authData, firebase, dispatch)`
- `config.onRedirectResult` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Function run when redirect
result is returned. Argument Pattern: `(authData, firebase, dispatch)`
- `config.customAuthParameters` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object for setting which

customAuthParameters are passed to external auth providers.
- `config.profileFactory` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Factory for modifying how user profile is saved.
- `config.uploadFileDataFactory` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** Factory for modifying
how file meta data is written during file uploads
Expand Down Expand Up @@ -63,4 +66,18 @@ const createStoreWithFirebase = compose(
const store = createStoreWithFirebase(rootReducer, initialState)
```

_Custom Auth Parameters_

```javascript
// Follow Setup example with the following config:
const config = {
customAuthParameters: {
google: {
// prompts user to select account on every google login
prompt: 'select_account'
}
}
}
```

Returns **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** That accepts a component a returns a wrapped version of component
6 changes: 4 additions & 2 deletions docs/api/helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Detect whether items are loaded yet or not
**Examples**

```javascript
import React, { Component, PropTypes } from 'react'
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { firebaseConnect, isLoaded, dataToJS } from 'react-redux-firebase'
```
Expand All @@ -28,7 +29,8 @@ Detect whether items are empty or not
**Examples**

```javascript
import React, { Component, PropTypes } from 'react'
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { firebaseConnect, isEmpty, dataToJS } from 'react-redux-firebase'
```
Expand Down
14 changes: 12 additions & 2 deletions docs/queries.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Limit query results to include a range starting at a specific number

**Internal Method**: [ `limitToLast`](https://firebase.google.com/docs/reference/js/firebase.database.Query#limitToLast)

#### Example
#### Examples

1. Starting at the fifth item
```js
Expand All @@ -146,6 +146,9 @@ Limit query results to include a range starting at a specific number
```

## endAt

#### Examples
1. Usage with startAt
```js
@firebaseConnect([
'todos#orderByChild=added&startAt=1&endAt=5'
Expand All @@ -156,6 +159,14 @@ Limit query results to include a range starting at a specific number
## equalTo
Limit query results with parameter equal to previous query method (i.e when used with orderByChild, it limits results with child equal to provided value). Internally runs [Firebase's `equalTo`](https://firebase.google.com/docs/reference/js/firebase.database.Query#equalTo).

### Parsing
The following are internally parsed:
* `null`
* `boolean`
* `number`

This means the actual value will be parsed instead of the string containing the value. If you do not want this to happen, look at the `notParsed` query parameter below.

#### Examples
1. Order by child parameter
```js
Expand All @@ -171,7 +182,6 @@ Can be used to keep internal parsing from happening. Useful when attempting to s

#### Examples
1. Order by child parameter equal to a number string. Equivalent of searching for `'123'` (where as not using `notParsed` would search for children equal to `123`)

```js
@firebaseConnect([
{
Expand Down
2 changes: 1 addition & 1 deletion examples/complete/material/src/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const firebase = {
export const reduxFirebase = {
userProfile: 'users', // root that user profiles are written to
enableLogging: false, // enable/disable Firebase Database Logging
updateProfileOnLogin: false // enable/disable updating of profile on login
updateProfileOnLogin: false, // enable/disable updating of profile on login
// profileDecorator: (userData) => ({ email: userData.email }) // customize format of user profile
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class TodoItem extends Component {
{todo.text}
</span><br />
<span className='TodoItem-Owner'>
{
Owner: {
isObject(todo.owner)
? todo.owner.displayName || todo.owner.username
: todo.owner || 'No Owner'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
firebaseConnect,
isLoaded,
pathToJS,
dataToJS,
// orderedToJS, // needed for ordered list
populatedDataToJS // needed for populated list
// dataToJS, // needed for full list and once
orderedToJS, // needed for ordered list
// populatedDataToJS // needed for populated list
} from 'react-redux-firebase'
import CircularProgress from 'material-ui/CircularProgress'
import Snackbar from 'material-ui/Snackbar'
Expand All @@ -20,23 +20,22 @@ import TodoItem from '../components/TodoItem'
import NewTodoPanel from '../components/NewTodoPanel'
import classes from './HomeContainer.scss'

const populates = [
{ child: 'owner', root: 'users', keyProp: 'key' }
]
// const populates = [{ child: 'owner', root: 'users', keyProp: 'uid' }]

@firebaseConnect([
// 'todos' // sync full list of todos
// { path: '/projects', type: 'once' } // for loading once instead of binding
// { path: 'todos', queryParams: ['limitToFirst=20'] } // limit to first 20
{ path: 'todos', populates } // populate
// { path: 'todos', queryParams: ['orderByChild=text'] }, // list todos alphabetically
// { path: 'todos', type: 'once' } // for loading once instead of binding
{ path: 'todos', queryParams: ['orderByKey', 'limitToLast=8'] } // limit to first 20
// { path: 'todos', populates } // populate
// { path: 'todos', queryParams: ['orderByKey', 'limitToLast=5'] }, // get five most recent (array will need to be inverted)
])
@connect(
({firebase}) => ({
auth: pathToJS(firebase, 'auth'),
account: pathToJS(firebase, 'profile'),
// todos: dataToJS(firebase, 'todos')
todos: populatedDataToJS(firebase, '/todos', populates), // if populating
// todos: orderedToJS(firebase, 'todos'), // if using ordering such as orderByChild
// todos: populatedDataToJS(firebase, '/todos', populates), // if populating
todos: orderedToJS(firebase, 'todos'), // if using ordering such as orderByChild
})
)
export default class Home extends Component {
Expand Down Expand Up @@ -72,10 +71,12 @@ export default class Home extends Component {
if (!auth || !auth.uid) {
return this.setState({ error: 'You must be Logged into Delete' })
}
if (todos[id].owner !== auth.uid) {
return this.setState({ error: 'You must own todo to delete' })
}
firebase.remove(`/todos/${id}`)
return this.setState({ error: 'Delete example requires using populate' })
// only works if populated
// if (todos[id].owner.uid !== auth.uid) {
// return this.setState({ error: 'You must own todo to delete' })
// }
// firebase.remove(`/todos/${id}`)
}

handleAdd = (newTodo) => {
Expand All @@ -85,15 +86,16 @@ export default class Home extends Component {
} else {
newTodo.owner = 'Anonymous'
}
// using this.props.firebase.pushWithMeta would attach createdBy and createdAt
// attach a timestamp
newTodo.createdAt = this.props.firebase.database.ServerValue.TIMESTAMP
// using this.props.firebase.pushWithMeta here instead would automatically attach createdBy and createdAt
return this.props.firebase.push('/todos', newTodo)
}

render () {
const { todos } = this.props
const { error } = this.state
console.log('todos:', todos)

console.log('this.props.account', this.props.account)
return (
<div className={classes.container} style={{ color: Theme.palette.primary2Color }}>
{
Expand All @@ -115,6 +117,10 @@ export default class Home extends Component {
redux-firebasev3.firebaseio.com
</a>
</span>
<span style={{ marginTop: '2rem' }}>
<strong>Note: </strong>
old data is removed
</span>
</div>
<div className={classes.todos}>
<NewTodoPanel
Expand All @@ -129,7 +135,8 @@ export default class Home extends Component {
<List className={classes.list}>
{
todos &&
map(todos, (todo, id) => (
// todos list is reversed so the most recent is first
map(todos.reverse(), (todo, id) => (
<TodoItem
key={id}
id={id}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@ import {
isEmpty
} from 'react-redux-firebase'
import { LIST_PATH } from 'constants'
import { UserIsAuthenticated } from 'utils/router'
import LoadingSpinner from 'components/LoadingSpinner'
import ProjectTile from '../components/ProjectTile/ProjectTile'
import NewProjectTile from '../components/NewProjectTile/NewProjectTile'
import NewProjectDialog from '../components/NewProjectDialog/NewProjectDialog'
import LoadingSpinner from 'components/LoadingSpinner'
import classes from './ProjectsContainer.scss'

const populates = [
{ child: 'createdBy', root: 'users', keyProp: 'uid' }
]

@UserIsAuthenticated
@firebaseConnect([
{ path: 'projects', populates }
// 'projects#populate=owner:users' // string equivalent
Expand Down Expand Up @@ -50,10 +52,7 @@ export default class Projects extends Component {

newSubmit = (newProject) => {
const { auth, firebase: { push } } = this.props
if (auth.uid) {
newProject.owner = auth.uid
}
push('projects', newProject)
return pushWithMeta('projects', newProject)
.then(() => this.setState({ newProjectModal: false }))
.catch(err => {
// TODO: Show Snackbar
Expand All @@ -62,7 +61,7 @@ export default class Projects extends Component {
}

deleteProject = (key) => {
this.props.firebase.remove(`projects/${key}`)
return this.props.firebase.remove(`projects/${key}`)
.then(() => {
// TODO: Show snackbar
})
Expand All @@ -86,7 +85,6 @@ export default class Projects extends Component {
const { projects, auth } = this.props
const { newProjectModal } = this.state


return (
<div className={classes.container}>
{
Expand Down
Loading