sn-redux is a convention driven way of building sensenet ECM applications using Redux. It contains all the action types, actions and reducers for built-in sensenet Actions and Functions.
sn-redux gives you a standard set of:
Get the latest stable version with npm
npm install --save sn-redux
or from the GitHub repository and place the downloaded source into your project. If you want to use only the transpiled JavaScript modules, you can find them in the dist/src folder and import them like
var SN = require('/pathtomodule/sn-redux');
If you want to use the module types you can find them in the src folder. Import them the following way:
import { Actions } from 'sn-redux';
import { Content, ContentTypes, Repository } 'sn-client-js';
let repository = new Repository.SnRepository({
RepositoryUrl: 'http://path-to-your-portal.com',
});
const content = Content.Create({ Id: 123 }, ContentTypes.Task, repository);
store.dispatch(Actions.Delete(content, false));
To install the latest stable version
npm install --save sn-redux
Create your sensenet ECM portal Repository to use. You can configure your Store to use this repository, when calling Store.ConfigureStore
import { Repository } from 'sn-client-js';
let repository = new Repository.SnRepository({
RepositoryUrl: 'http://path-to-your-portal.com',
});
const store = Store.configureStore(
myRootReducer,
myRootEpic, // If not set, the default will be 'Epics.rootEpic'
[middleware1, middleware2], // If not set, only the epicMiddleware will be used
persistedState, // Optional
repository // Optional. If not provided, a Repository with default values will be used
);
To enable your external app to send request against your sensenet ECM portal change your Portal.settings. For further information about cross-origin resource sharing in sensenet ECM check this article.
Check your sensenet ECM portal's web.config and if the ODataServiceToken is set, you can pass to your Repository as a config value on client side.
let repository = new Repository.SnRepository({
RepositoryUrl: 'http://path-to-your-portal.com',
ODataToken: 'MyODataServiceToken'
});
var Content = require('sn-client-js').Content;
var Repository = require('sn-client-js').Repository;
var ContentTypes = require('sn-client-js').ContentTypes;
var Actions = require('sn-redux').Actions;
let repository = new Repository.SnRepository({
RepositoryUrl: 'http://path-to-your-portal.com',
});
var content = Content.Create({ Id: 123 }, ContentTypes.Task, repository);
store.dispatch(Actions.Delete(123, false));
import { Actions } 'sn-redux';
import { Content, ContentTypes, Repository } 'sn-client-js';
let repository = new Repository.SnRepository({
RepositoryUrl: 'http://path-to-your-portal.com',
});
const content = Content.Create({ Id: 123 }, ContentTypes.Task, repository);
store.dispatch(Actions.Delete(content, false));
Building the project, running all the unit tests and the ts linter and get the code coverage report, use:
npm run build
To execute all unit tests and generate coverage reports, use:
npm t
import { combineReducers } from 'redux';
import { Reducers } from 'sn-redux';
const sensenet = Reducers.sensenet;
const myReducer = combineReducers({
sensenet,
listByFilter
});
import { Store } from 'sn-redux';
import { Repository } from 'sn-client-js';
let repository = new Repository.SnRepository({
RepositoryUrl: 'http://path-to-your-portal.com',
});
const store = Store.configureStore(
myRootReducer,
myRootEpic, // If not set, the default will be 'Epics.rootEpic'
[middleware1, middleware2], // If not set, only the epicMiddleware will be used
persistedState, // Optional
repository // Optional. If not provided, a Repository with default values will be used
);
import { Content, Repository, ContentTypes } from 'sn-client-js';
import { Actions } from 'sn-redux';
let repository = new Repository.SnRepository({
RepositoryUrl: 'http://path-to-your-portal.com',
});
const parentPath = '/workspaces/Project/budapestprojectworkspace/tasks';
const content = Content.Create({
DisplayName: 'My first task'
}, ContentTypes.Task, repository);
dispatch(Actions.CreateContent(content))
Generated using TypeDoc