How to use the xadmin.StoreWrap function in xadmin

To help you get started, we’ve selected a few xadmin examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sshwsfc / xadmin / demo / src / App.js View on Github external
render() {
    const { _t } = app.context
    return (
      
        
      
    );
  }
}

export default StoreWrap('test', { 
  data: ({ state }) => ({ title: state.test }),
  event: {
    mount: ({ dispatch }) => dispatch({ type: '@@xadmin/ADD_NOTICE', headline: 'Test', message: 'Test message' })
  }
})(App);
github sshwsfc / xadmin / packages / xadmin-auth / src / components / ForgetPassword.js View on Github external
import React from 'react'
import { StoreWrap, app } from 'xadmin'
import { Model } from 'xadmin-model'
import { C } from 'xadmin-ui'

import { UserForgetPassword } from '../models'

export default StoreWrap('auth.forget_password')(({ onSuccess }) => {
  const { _t } = app.context
  return (
    
      
    
  )
})
github sshwsfc / xadmin / packages / xadmin-auth / src / components / SignIn.js View on Github external
import React from 'react'
import { StoreWrap, app } from 'xadmin'
import { Model } from 'xadmin-model'
import { C } from 'xadmin-ui'

import { UserSignIn } from '../models'

const SignInForm = StoreWrap('auth.sign_in')(({ onSignIn }) => {
  return (
    
      
    
  )
})

export default SignInForm
github sshwsfc / xadmin / packages / xadmin-auth / src / components / ChangePasswordForm.js View on Github external
import React from 'react'
import { StoreWrap, app } from 'xadmin'
import { Model } from 'xadmin-model'
import { Page, C } from 'xadmin-ui'

import { UserChangePassword } from '../models'

export default StoreWrap('auth.change_password')(({ onChange }) => {
  const { _t } = app.context
  return (
    
      
        
      
    
  )
})
github sshwsfc / xadmin / packages / xadmin-plugins / src / notice.js View on Github external
import React from 'react'
import { StoreWrap } from 'xadmin'
import { AlertList } from 'react-bs-notifier'

const Notices = StoreWrap('xadmin.notice')(({ notices, onDismiss }) => {
  return 
})

export default {
  name: 'xadmin.notice',
  blocks: {
    'main': () => 
  },
  mappers: {
    'xadmin.notice': {
      data: ({ state }) => {
        return {
          notices: state.notices
        }
      },
      method: {
github sshwsfc / xadmin / packages / xadmin-form / src / base.js View on Github external
].filter(Boolean).join('.')
          _.set(prev, path, err.message)

          return prev
        }, {})
        errors = validateByFields(errors, values, fields)
        return errors
      }
    })(BaseForm)
    return { WrapForm, fields }
  }, [ formKey, schema ])

  return WrapForm && fields ?  : null
}

const FormWrap = StoreWrap(Connect => (props) => {
  const { state } = props.wrapContext
  return (
    
      { _reduxForm =>  }
    
  )
})

const useForm = (props, select) => {
  const _reduxForm = React.useContext(ReduxFormContext)
  const { dispatch, store, state, ...values } = select ? 
    use('redux', state => select((_reduxForm ? _reduxForm.getFormState(state) : {}) || {})) : use('redux')

  return { ...props, form: _reduxForm, ...values,
    getFormState: React.useCallback(() => (_reduxForm ? _reduxForm.getFormState(store.getState()) : {}) || {}, [ _reduxForm, store ]),
    formState: _reduxForm.getFormState(state) }
github sshwsfc / xadmin / packages / xadmin-auth / src / components / SignUp.js View on Github external
import React from 'react'
import { StoreWrap, app } from 'xadmin'
import { Model } from 'xadmin-model'
import { C } from 'xadmin-ui'

import { UserSignUp } from '../models'

const SignUpForm = StoreWrap('auth.sign_up')(({ onSuccess }) => {
  const { _t } = app.context
  return (
    
      
    
  )
})

export default SignUpForm
github sshwsfc / xadmin / packages / xadmin-model / src / base.js View on Github external
let initial = initialValues
      if(!initial && model.initialValues) {
        initial = _.isFunction(model.initialValues) ? model.initialValues() : model.initialValues
      }
      app.context.store.dispatch({ type: 'INITIALIZE', model, initial })
      setState('INITIALIZE')
    } else if(state == 'DESTROY') {
      app.context.store.dispatch({ type: 'DESTROY', model })
    }
  }, [ state ])
  if(!model || state != 'INITIALIZE') return null

  return {children}
}

const ModelWrap = StoreWrap(Connect => (props) => {
  const { state } = props.wrapContext
  return (
    
      { model =>  }
    
  )
})

const ModelBlock = (props) => (
  
    { model => (
      
        { blocks => {
          const modelBlock = model && model.blocks && model.blocks[props.name]
          if(modelBlock) {
            const mb = modelBlock(props)
github sshwsfc / xadmin / packages / xadmin-antd / src / layout / App.js View on Github external
import React from 'react'
import { StoreWrap, config as _c, Block, app } from 'xadmin'
import { IsAuthenticated } from 'xadmin-auth'
import { Layout, Menu, Breadcrumb, Icon } from 'antd'

const { Header, Content, Footer, Sider } = Layout
const SubMenu = Menu.SubMenu

function itemRender(route, params, routes, paths) {
  const last = routes.indexOf(route) === routes.length - 1
  const click = (to) => () => app.go(to)
  return last ? <span>{route.breadcrumbName}</span> : <a>{route.breadcrumbName}</a>
}

@StoreWrap('main.menu')
class MenuBar extends React.Component {

  render() {
    return (
      
        {items =&gt; (
          <menu mode="{this.props.mode}">
            {items}
          </menu>
        )}
      
    )
  }
}

@IsAuthenticated
github sshwsfc / xadmin / packages / xadmin-bootstrap / src / auth / components / UserMenu.js View on Github external
import React from 'react'
import { NavDropdown } from 'react-bootstrap'

import Icon from 'react-fontawesome'
import { StoreWrap, app, Block } from 'xadmin'

const UserMenu = StoreWrap('auth.user')(({ user, onLogout, onChangePassword }) =&gt; {
  const { _t } = app.context
  return user &amp;&amp; (
     {user.username}} id="basic-nav-dropdown"&gt;
      
      {_t('Change password')}
      {_t('Logout')}
    
  )
})

export default UserMenu