import React from 'react';
import Posts from "meteor/nova:posts";
import Comments from "meteor/nova:comments";
import Users from 'meteor/nova:users';
import { Callbacks, Utils, registerComponent } from 'meteor/nova:core';
const methodList = Meteor.isServer ? Meteor.server.method_handlers : Meteor.connection._methodHandlers;
const renderFunction = (func, name) => {
const s = func.toString();
const openParen = s.indexOf("(");
const closeParen = s.indexOf(")");
return (
{name}({s.substr(openParen+1, closeParen-openParen-1)})
)
}
const renderCallback = (callbacks, key) => {
if (Array.isArray(callbacks)) {
return (
{key}
{_.map(callbacks, (item, key) => {item.name}
)}
)
} else {
return null
}
}
const Cheatsheet = props => {
return (
Cheatsheet
Users
Helpers (Users.*
)
{_.map(Users, (item, key) => (key[0] !== "_" ? renderFunction(item, key) : null) )}
{_.map(Users.is, renderFunction)}
Methods
{_.map(methodList, (item, key) => (key.indexOf("users.") !== -1 ? renderFunction(item, key) : null))}
Posts
Helpers (Posts.*
)
{_.map(Posts, (item, key) => (key[0] !== "_" ? renderFunction(item, key) : null) )}
Methods
{_.map(methodList, (item, key) => (key.indexOf("posts.") !== -1 ? renderFunction(item, key) : null))}
Comments
Helpers (Comments.*
)
{_.map(Comments, (item, key) => (key[0] !== "_" ? renderFunction(item, key) : null) )}
Methods
{_.map(methodList, (item, key) => (key.indexOf("comments.") !== -1 ? renderFunction(item, key) : null))}
Callbacks
Functions
add()
remove()
run()
runAsync()
Hooks (Callbacks.*
)
{_.map(Callbacks, renderCallback)}
Utils
Helpers (Utils.*
)
{_.map(Utils, renderFunction)}
)
}
registerComponent('Cheatsheet', Cheatsheet);