regions.content = () => (React.createElement(
   composeAll(
     useDeps(mapper)
   )(
     ({store}) => (
       <Provider store={store}>
         {content()}
       </Provider>
     )
   )
 ));
Example #2
0
import {useDeps, composeWithTracker, composeAll} from 'mantra-core';
import {DocHead} from 'meteor/kadira:dochead';
import TeamAdd from '../components/team_add.jsx';

const composer = ({LocalState, clearTeamAdd}, onData) => {
  const error = LocalState.get('TEAM_ADD_ERROR');
  const processing = LocalState.get('TEAM_ADD_PROCESSING');
  onData(null, {processing, error});

  // SEO
  DocHead.setTitle('创建团队');
  DocHead.addMeta({
    name: 'description', content: '创建团队'
  });

  return clearTeamAdd;
};

const depsMapper = (context, actions) => ({
  LocalState: context.LocalState,
  teamAdd: actions.teams.teamAdd,
  clearTeamAdd: actions.teams.clearTeamAdd
});

export default composeAll(
  composeWithTracker(composer),
  useDeps(depsMapper)
)(TeamAdd);
Example #3
0
import {useDeps, composeAll, composeWithTracker, compose} from 'mantra-core';

import FilePage from '../components/file_page.jsx';

export const composer = ({context, albumId}, onData) => {
  const {Meteor, Collections} = context();
  onData(null, {albumId});
};

export const depsMapper = (context, actions) => ({
  context: () => context,
  upload: actions.files.upload,
  setLocalState: actions.core.setLocalState,
});

export default composeAll(
  composeWithTracker(composer),
  useDeps(depsMapper)
)(FilePage);
Example #4
0
import Preview from '../../components/preview/preview.jsx';
import { useDeps, composeWithTracker, composeAll } from 'mantra-core';

export const composer = ({ context, getStringSQLQuery }, onData) => {
  const { LocalState } = context();
  const queryObject = LocalState.get('SQL_QUERY_OBJECT') || {};
  const viewObject = LocalState.get('VIEW_OBJECT') || {};

  viewObject.query = getStringSQLQuery(queryObject);
  onData(null, { queryObject, viewObject });
};

export const depsMapper = (context, actions) => ({
  getStringSQLQuery: actions.console.getStringSQLQuery,
  checkChangingQuery: actions.preview.checkChangingQuery,
  context: () => context,
});

export default composeAll(
  composeWithTracker(composer),
  useDeps(depsMapper)
)(Preview);
Example #5
0
import { useDeps, composeWithTracker, composeAll } from 'mantra-core';
import authComposer from '../libs/auth-composer';
import AuthEnsureUser from '../components/auth-ensure-user';

export const depsMapper = context => ({
  context: () => context,
});

export default composeAll(
  composeWithTracker(authComposer),
  useDeps(depsMapper),
)(AuthEnsureUser);
Example #6
0
import Students from '../components/Students.jsx';
import { _ } from 'lodash';

export const composer = ({context}, onData) => {
  const {LocalState, Collections, FlowRouter} = context();
  var parentId = Meteor.userId();
  let username = LocalState.get('STUDENT_USERNAME');
  if(Meteor.subscribe('studentId', parentId).ready()) {
  	const studentIds = Collections.Students.find({"parentId": parentId}).fetch()[0].students;
    if(username == undefined) {
      const studentId = studentIds[0];
      const student = Meteor.users.find({ _id: studentId }).fetch()[0];
      if(student) {
        username = student.username
        onData(null, {studentIds, username});
      }
      
    }
  	onData(null, {studentIds, username});
  }
};

export const depsMapper = (context, actions) => ({
  edit: actions.challenges.edit,
  context: () => context
});

export default composeAll(
  composeWithTracker(composer),
  useDeps(depsMapper)
)(Students);
import { useDeps, composeAll, composeWithTracker } from 'mantra-core';

import SignUpBeta from '../components/sign_up_beta.jsx';

export const composer = ({ context, success, error, clearErrors }, onData) => {
  // const {} = context();

  onData(null, { success, error });
  return clearErrors;
};

export const depsMapper = (context, actions) => ({
  context: () => context,
  clearErrors: actions.user.clearErrors,
  betaSignup: actions.users.betaSignUp,
});

export default composeAll(
  composeWithTracker(composer),
  useDeps(depsMapper)
)(SignUpBeta);
  const stepInfo = Store.getState().step.stepInfo;
  const locationInfo = Store.getState().step.locationInfo;
  const businessLocation = Store.getState().step.businessLocation
  onData(null, {error, role, step, stepInfo, locationInfo, businessLocation});

  // function to unsubscribe from Store
  // and clearing error
  const cleanup = () => {
    unsubscribe();
    clearErrors();
  }

  // running cleanup when unmounting the component
  return cleanup;
};

export const depsMapper = (context, actions) => ({
  createUser: actions.register.createUser,
  clearErrors: actions.register.clearErrors,
  changeRole: actions.register.changeRole,
  changeStep: actions.register.changeStep,
  validateRegister: actions.register.validateRegister,
  getGeolocation: actions.register.getGeolocation,
  geocodeVendor: actions.register.geocodeVendor,
  context: () => context
});

export default composeAll(
  compose(composer),
  useDeps(depsMapper)
)(Register);
import {useDeps, composeAll, composeWithTracker, compose} from 'mantra-core';

import ModalHeader from '../components/modal_header.jsx';

export const composer = ({context}, onData) => {
  const {Meteor, Collections} = context();

  onData(null, {});
};

export const depsMapper = (context, actions) => ({
  context: () => context
});

export default composeAll(
  composeWithTracker(composer),
  useDeps(depsMapper)
)(ModalHeader);
  const {Meteor, Collections} = context();

  if(Meteor.subscribe('categoriesList', Meteor.userId()).ready()){

    const categories = Collections.Categories.find({}).fetch().map(function(category){


      category.productCount = Collections.Products.find({category_id: category._id}).count();

      return category;

    });

    onData(null, {
      categories,
    });

  }

};

export const depsMapper = (context, actions) => ({
  categoriesDelete: actions.categories.categoriesDelete,
  context: () => context,
});

export default composeAll(
  composeWithTracker(composer),
  useDeps(depsMapper)
)(CategoriesList);
import CollectionFields from '../components/collection_fields/collection_fields.jsx';
import { useDeps, composeWithTracker, composeAll } from 'mantra-core';

export const composer = ({ context, getSQLQueryObj, prePreviewState, changeCollectionState }, onData) => {
  const { LocalState } = context();
  const { collectionFields, from, join } = LocalState.get('SQL_QUERY_OBJECT') || {};
  if (!from) return changeCollectionState(true);
  onData(null, { collections: { from, join }, collectionFields });
};

export const depsMapper = (context, actions) => ({
  getSQLQueryObj: actions.workplaceState.getSQLQueryObj,
  context: () => context,
});

export default composeAll(
  composeWithTracker(composer),
  useDeps(depsMapper)
)(CollectionFields);
import {useDeps, composeAll, composeWithTracker, compose} from 'mantra-core';

import DashboardView from '../components/dashboard_view.jsx';

export const composer = ({context, user}, onData) => {
  const {Meteor, Collections} = context();
  let companySlug = user.companySlug;

  if (Meteor.subscribe('company', companySlug).ready()) {
    let company = Collections.Companies.findOne({slug: companySlug});

    onData(null, {user, company});
  }
};

export const depsMapper = (context, actions) => ({
  context: () => context
});

export default composeAll(
  composeWithTracker(composer),
  useDeps(depsMapper)
)(DashboardView);
Example #13
0
import Entry from '../components/Entry.jsx';
import {useDeps, composeWithTracker, composeAll} from 'mantra-core';
// Set state, subscribe to 1-Entry & send as variable to composer
// If entries.single subscription is not ready, try via entries sub
export const composer = ({context, entryId}, onData) => {
  const {Meteor, Collections} = context();
  if (Meteor.subscribe('entries.single', entryId).ready()) {
    const entry = Collections.Entries.findOne(entryId);
    onData(null, {entry});
  } else {
    const entry = Collections.Entries.findOne(entryId);
    if (entry) {
      onData(null, {entry});
    } else {
      onData();
    }
  }
};
// Komposer sends Entries collection data to EntryList component
export default composeAll(
  composeWithTracker(composer),
  useDeps()
)(Entry);
Example #14
0
import {useDeps, composeWithTracker, composeAll} from 'mantra-core';
import {_} from 'meteor/underscore';
import QuestionsSelect from '../components/questionsSelect';

export const composer = ({context, clearSelection, questions}, onData) => {
  const {LocalState} = context();
  const currentQuestionSeq = LocalState.get('SELECT_QUESTION') || 0;
  // TODO: Change underscore by lodash or rambda
  const currentQuestion = _.findWhere(questions, {questionSeq: currentQuestionSeq});
  const questionsCount = questions.length;
  onData(null, {currentQuestion, questionsCount});
  return clearSelection;
};

export const depsMapper = (context, actions) => (
  {context: () => context, ...actions.questionsSelect}
);

export default composeAll(
  composeWithTracker(composer),
  useDeps(depsMapper)
)(QuestionsSelect);
Example #15
0
import {useDeps, composeWithTracker, composeAll} from 'mantra-core';
import DocumentHomeStructure from '../components/document_home_structure.jsx';

const composer = ({Meteor, Collections, LocalState}, onData) => {

  onData(null, {});
};

const depsMapper = (context, actions) => ({
  Meteor: context.Meteor,
  FlowRouter: context.FlowRouter,
  Collections: context.Collections,
  LocalState: context.LocalState
});

export default composeAll(
  composeWithTracker(composer),
  useDeps(depsMapper)
)(DocumentHomeStructure);
Example #16
0
        } else  {
            const item = Collections.Items.findOne(itemId);
            const categories = Collections.Categories.find().fetch();
            if (item && categories) {
                onData(null, {item, categories, error});
            } else {
                onData();
            }
        }
    } else {
        if (Meteor.subscribe('categories.namelist').ready()) {
            const categories = Collections.Categories.find().fetch()
            onData(null, {categories, error})
        }
    }

    //卸载组件时 清除错误
    return clearErrors;
};

export const depsMapper = (context, actions) => ({
    create: actions.items.create,
    edit: actions.items.edit,
    clearErrors: actions.items.clearErrors,
    context: () => context
});

export default composeAll(
    composeWithTracker(composer),
    useDeps(depsMapper)
)(EditItem);
Example #17
0
import {useDeps, composeAll, composeWithTracker, compose} from 'mantra-core';

import Toolbar from '../components/toolbar.jsx';

export const composer = ({context}, onData) => {
  onData(null, {});
};

export const depsMapper = (context, actions) => ({
  context: () => context,
  addSlide: actions.slideDecks.addSlide,
  removeSlide: actions.slideDecks.removeSlide
});

export default composeAll(
  composeWithTracker(composer),
  useDeps(depsMapper)
)(Toolbar);
Example #18
0
import {useDeps, composeAll, compose} from 'mantra-core';

import Sidebar from '../components/sidebar.jsx';

export const composer = ({context}, onData) => {
  const {Store} = context();
  const unsub = Store.subscribe(() => {
    onData(null, Store.getState().SidebarReducer);
  });
  onData(null, Store.getState().SidebarReducer);
  const cleanup = () => {
    unsub();
  };
  return cleanup;
};

export const depsMapper = (context, actions) => ({
  context: () => context,
  toggleExpend: actions.sidebar.toggleExpend,
});

export default composeAll(
  compose(composer),
  useDeps(depsMapper)
)(Sidebar);
import {composeAll, composeWithTracker, useDeps} from 'mantra-core';
import {authComposer} from '/client/configs/composers';
import Component from '../components/app_verified_msg';

export const depsMapper = (context, actions) => ({
  resendVerificationEmail: actions.accounts.resendVerificationEmail,
  context: () => context,
});

export default composeAll(
  composeWithTracker(authComposer),
  useDeps(depsMapper)
)(Component);
Example #20
0
File: repos.js Project: fesp21/vym
import {useDeps, composeAll, composeWithTracker, composeWithPromise, compose} from 'mantra-core';

import Repos from '../components/repos.jsx';
import LoadingRepos from '../components/loading_repos.jsx';

export const composer = ({context}, onData) => {
  const {Meteor, Collections} = context();

  if (Meteor.subscribe('collaboratingRepos').ready() &&
      Meteor.subscribe('currentUser').ready()) {
    console.log('composer running');
    let user = Meteor.user();
    let addedRepos = Collections.Repos.find({collaboratorIds: user._id}).fetch();
    console.log('addedRepos', addedRepos);
    onData(null, {
      addedRepos
    });
  }
};

export const depsMapper = (context, actions) => ({
  context: () => context
});

export default composeAll(
  composeWithTracker(composer, LoadingRepos),
  useDeps(depsMapper)
)(Repos);
Example #21
0
import {useDeps, composeAll, composeWithTracker, compose} from 'mantra-core';
import CurrentChallenges from '../components/CurrentChallenges.jsx';
import { _ } from 'lodash';

export const composer = ({context, studentId, operator}, onData) => {
  const {LocalState, Collections, FlowRouter} = context();
  const parentId = Meteor.userId();
  
  if(Meteor.subscribe('challenges.list', parentId).ready()){
  	const challenges = Collections.Challenges.find({ complete: false, studentId: studentId, 'challenge.operator': operator }).fetch();
  	onData(null, {challenges});
  }
};

export const depsMapper = (context, actions) => ({
  create: actions.challenges.create,
  context: () => context
});

export default composeAll(
  composeWithTracker(composer),
  useDeps(depsMapper)
)(CurrentChallenges);
Example #22
0
import ResetPassword from '../components/reset_password.jsx';
import {useDeps, composeAll} from 'mantra-core';

export const composer = ({token}, onData) => {

    onData(null, {token});

};

export const depsMapper = (context, actions) => ({
  handleResetPwd: actions._accounts.handleResetPwd,
  context: () => context
});

export default composeAll(
  useDeps(depsMapper)
)(ResetPassword);
Example #23
0
import {useDeps, composeAll, composeWithTracker, compose} from 'mantra-core';

import NotFound from '../components/not_found.jsx';

export const composer = ({context}, onData) => {
  const {Meteor, Collections} = context();

  onData(null, {});
};

export const depsMapper = (context, actions) => ({
  context: () => context,
  setLocalState: actions.core.setLocalState,
});

export default composeAll(
  composeWithTracker(composer),
  useDeps(depsMapper)
)(NotFound);
"use strict";
var mantra_core_1 = require("mantra-core");
var logged_user_view_1 = require("../components/logged_user_view");
exports.composer = function (_a, onData) {
    var context = _a.context, showUserName = _a.showUserName;
    var Meteor = context.Meteor, i18n = context.i18n;
    onData(null, {
        userName: showUserName ? Meteor.user().profile.name : "",
        context: context
    });
    return null;
};
exports.depsMapper = function (context, actions) { return ({
    signOut: actions.accounts.signOut
}); };
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = mantra_core_1.composeAll(mantra_core_1.composeWithTracker(exports.composer), mantra_core_1.useDeps(exports.depsMapper))(logged_user_view_1.default);
import {useDeps, composeAll, composeWithTracker, compose} from 'mantra-core';

import MockSubscribeButton from '../components/mock_feature_button.jsx';

export const composer = ({context}, onData) => {
  const {Meteor, Collections} = context();

  onData(null, {});
};

export const depsMapper = (context, actions) => ({
  context: () => context,
  recordClick: actions.analytics.recordClick
});

export default composeAll(
  composeWithTracker(composer),
  useDeps(depsMapper)
)(MockSubscribeButton);
Example #26
0
export const composer = ({context}, onData) => {
  const {Meteor, Store} = context();
  const loggedIn = Meteor.userId() || false;

  if (!loggedIn){
    Store.dispatch(push("/login"));;
  }

  if (Meteor.subscribe('users.collection').ready()) {
    const collection = Meteor.users.find().fetch();
    onData(null, {loggedIn, collection});
  }
};

export const depsMapper = (context, actions) => ({
  context: () => context
});

const mapStateToProps = (state) => {
  return {
    i18n: state.i18n,
  }
};

export default composeAll(
  connect(mapStateToProps),
  composeWithTracker(composer),
  useDeps(depsMapper)
)(Collection);
Example #27
0
import { useDeps, composeWithTracker, composeAll } from 'mantra-core';
import React from 'react';
import Loading from '/client/modules/core/components/partial/loading.jsx';
import Chart from '../components/chart';

export const composer = ({ context, chartId }, onData) => {
  const { Meteor, Collections } = context();
  if (Meteor.subscribe('charts.published', chartId).ready()) {
    const chart = Collections.Charts.findOne({ _id: chartId });
    if (chart) onData(null, { chart });
    else onData(null, {});
  }
};

export const depsMapper = (context) => ({
  context: () => context,
});

export default composeAll(
  composeWithTracker(composer, () => <Loading />),
  useDeps(depsMapper)
)(Chart);
  if (!LocalState.get('LOGIN_ERROR')) {
    LocalState.set('LOGIN_ERROR', '')
  }

  // if (!LocalState.get('USER_INPUT_VALUE')) {
  //   LocalState.set('USER_INPUT_VALUE', '')
  // }

  const inputVal = LocalState.get('USER_INPUT_VALUE')
  const passVal = LocalState.get('USER_PASS_VALUE')
  const error = LocalState.get('LOGIN_ERROR')

  console.log(`from composer: inputVal: ${inputVal}`)
  onData(null, {inputVal, passVal, error});

};

export const depsMapper = (context, actions) => ({
  context: () => context,
  loginUser: actions.users.login,
  logout: actions.users.logout,
  goCreate: actions.users.goCreate,
  inputValue: actions.users.inputValue,
  passValue: actions.users.passValue
});

export default composeAll(
  composeWithTracker(composer),
  useDeps(depsMapper)
)(InputLogin);
Example #29
0
import { useDeps, composeWithTracker, composeAll } from 'mantra-core';
import Profile from '../components/profile';

export const composer = ({ context }, onData) => {
  const { Meteor } = context();
  const data = {};
  const user = Meteor.user();

  if (user) {
    const { username, emails } = user;
    Object.assign(data, { username, email: emails[0].address });
    onData(null, data);
  }
};

export const depsMapper = context => ({
  context: () => context,
});

export default composeAll(
  composeWithTracker(composer),
  useDeps(depsMapper),
)(Profile);
Example #30
0
import CategoryList from '../components/CategoryList.jsx';
import {useDeps, composeWithTracker, composeAll} from 'mantra-core';

export const composer = ({context}, onData) => {
    const {Meteor, Collections} = context();
    if (Meteor.subscribe('categories.list').ready()) {
        const categories = Collections.Categories.find({}).fetch();
        onData(null, {categories});
    }
};

export default composeAll(
    composeWithTracker(composer),
    useDeps()
)(CategoryList);