Options
All
  • Public
  • Public/Protected
  • All
Menu

Module Actions

Module that contains the action creators.

Redux actions are payloads of information that send data from your application to your store. They are the only source of information for the store. You send them to the store using store.dispatch(). Actions are plain JavaScript objects. Actions must have a type property that indicates the type of action being performed.

Learn more about Redux actions here

Following are Redux actions but they're all related with a Sense/Net built-in action. Since this Sense/Net built-in actions are OData actions and functions and they get and set data throught ajax request we have to handle the main steps of their process separately. So there're three separate redux action for every Sense/Net action: one for the request itself and two for the two possible end of an ajax request, success and fail.

All of the JSON responses with content or collection are normalized so you shouldn't care about how to handle nested data structure, normalizr takes JSON and a schema and replaces nested entities with their IDs, gathering all entities in dictionaries. For further information about normalizr check this link.

[{
 Id: 5145,
 DisplayName: 'Some Article',
 Status: ['Active']
}, {
 Id: 5146,
 Displayname: 'Other Article',
 Status: ['Completed']
}]

is normalized to

result: [5145, 5146],
entities: {
 collection: {
     5145: {
         Id: 5145,
         DisplayName: 'Some Article',
         Status: ['Active']
     },
     5146: {
         Id: 5146,
         Displayname: 'Other Article',
         Status: ['Completed']
     }
 }
}

Following module now cover the CRUD operations, so it contains Actions which are related to fetching, creating, deleting and updating Content. Other built-in SenseNet OData Actions and Functions will be the parts of this module too and you are be able to add your custom Actions too by combining your reducers with the built-in ones.

Using built-in redux actions in your views

import * as React from 'react'
import { connect } from 'react-redux'
import { TextField } from 'material-ui/TextField';
import RaisedButton from 'material-ui/RaisedButton';
import { Actions } from 'sn-redux';
import { Content } from './SenseNet/Content';

let AddTodo = ({ dispatch }) => {
  let input

  return (
    <div>
      <form onSubmit={e => {
        e.preventDefault()
        if (!input.value.trim()) {
          return
        }
        const content = new Content({
          Type: 'Task',
          DisplayName: input.value
        });
        content["Status"] = "active";
        const ROOT_URL = 'https://mySite.com/OData.svc/workspaces/Project/budapestprojectworkspace/Tasks';
        dispatch(Actions.createContent(ROOT_URL, content))
        input.value = ''
      } }>
        <input className="textField" ref={node => {
          input = node
        } } />
        <RaisedButton type="submit" primary={true} label="Add Todo" />
      </form>
    </div>
  )
}
AddTodo = connect()(AddTodo)

Combining your custom redux reducers with sn-redux's root reducer.

import { combineReducers } from 'redux';
import { Store, Reducers } from 'sn-redux';
import { Root } from './components/Root'
import { listByFilter } from './reducers/filtering'

const collection = Reducers.collection;
const myReducer = combineReducers({
  collection,
  listByFilter
});

const store = Store.configureStore(myReducer);

Index

Functions

Approve

  • Approve(id: number): object
  • Action creator for approving a Content in the Content Repository.

    Parameters

    • id: number

      Id of the content that should be approved.

    Returns object

    Returns a redux action with the properties type and id.

    • id: number
    • type: string

ApproveFailure

  • ApproveFailure(error: any): object
  • Action creator for the step when approving a Content is failed.

    Parameters

    • error: any

      The catched error object.

    Returns object

    Returns a redux action with the properties type and the error message.

    • message: any
    • type: string

ApproveSuccess

  • ApproveSuccess(response: any): object
  • Action creator for the step when a Content is approved successfully.

    Parameters

    • response: any

      JSON response of the ajax request.

    Returns object

    Returns a redux action with the properties type and the normalized JSON response.

    • response: object
      • entities: any
      • result: any
    • type: string

CheckIn

  • CheckIn(id: number, checkInComment?: string): object
  • Action creator for checking in a Content in the Content Repository.

    Parameters

    • id: number

      Id of the content that should be checked in.

    • Default value checkInComment: string = ""

    Returns object

    Returns a redux action with the properties type, id and checkinComment.

    • checkInComment: string
    • id: number
    • type: string

CheckInFailure

  • CheckInFailure(error: any): object
  • Action creator for the step when checking out a Content is failed.

    Parameters

    • error: any

      The catched error object.

    Returns object

    Returns a redux action with the properties type and the error message.

    • message: any
    • type: string

CheckInSuccess

  • CheckInSuccess(response: any): object
  • Action creator for the step when a Content is checked in successfully.

    Parameters

    • response: any

      JSON response of the ajax request.

    Returns object

    Returns a redux action with the properties type and the normalized JSON response.

    • response: object
      • entities: any
      • result: any
    • type: string

CheckOut

  • CheckOut(id: number): object
  • Action creator for checking out a Content in the Content Repository.

    Parameters

    • id: number

      Id of the content that should be checked out.

    Returns object

    Returns a redux action with the properties type and id .

    • id: number
    • type: string

CheckOutFailure

  • CheckOutFailure(error: any): object
  • Action creator for the step when checking out a Content is failed.

    Parameters

    • error: any

      The catched error object.

    Returns object

    Returns a redux action with the properties type and the error message.

    • message: any
    • type: string

CheckOutSuccess

  • CheckOutSuccess(response: any): object
  • Action creator for the step when a Content is checked out successfully.

    Parameters

    • response: any

      JSON response of the ajax request.

    Returns object

    Returns a redux action with the properties type and the normalized JSON response.

    • response: object
      • entities: any
      • result: any
    • type: string

CreateContent

  • CreateContent(path: string, content: Content): object
  • Action creator for creating a Content in the Content Repository.

    Parameters

    • path: string

      Path of the parent item.

    • content: Content

      Content that have to be created in the Content Respository.

    Returns object

    Returns a redux action with the properties type, path of the parent and content.

    • content: Content
    • path: string
    • type: string

CreateContentFailure

  • CreateContentFailure(error: any): object
  • Action creator for the step when Content creation failed on the server.

    Parameters

    • error: any

      The catched error object.

    Returns object

    Returns a redux action with the properties type and the error message.

    • message: any
    • type: string

CreateContentSuccess

  • CreateContentSuccess(response: any): object
  • Action creator for the step when Content creation on the server ends successfully.

    Parameters

    • response: any

      JSON response of the ajax request.

    Returns object

    Returns a redux action with the properties type and the normalized response.

    • response: object
      • entities: any
      • result: any
    • type: string

Delete

  • Delete(id: number, permanently?: boolean): object
  • Action creator for deleting a Content from the Content Repository.

    Parameters

    • id: number

      Id of the Content that has to be deleted.

    • Default value permanently: boolean = false

      Defines whether the a Content must be moved to the Trash or deleted permanently.

    Returns object

    Returns a redux action with the properties type, id and permanently.

    • id: number
    • permanently: boolean
    • type: string

DeleteBatch

  • DeleteBatch(path: string, ids: string[], permanently?: boolean): object
  • Action creator for deleting multiple Content from the Content Repository.

    Parameters

    • path: string

      Path of the parent Content.

    • ids: string[]

      Array of ids of the Content that should be deleted.

    • Default value permanently: boolean = false

      Defines whether Content must be moved to the Trash or deleted permanently.

    Returns object

    Returns a redux action with the properties type, id and permanently.

    • ids: Array<string>
    • path: string
    • permanently: boolean
    • type: string

DeleteBatchFailure

  • DeleteBatchFailure(error: any): object
  • Action creator for the step when deleting multiple Content is failed.

    Parameters

    • error: any

      The catched error object.

    Returns object

    Returns a redux action with the properties type and the error message.

    • message: any
    • type: string

DeleteBatchSuccess

  • DeleteBatchSuccess(indexes: number[]): object
  • Action creator for the step when multiple Content deleted successfully.

    Parameters

    • indexes: number[]

      Array of indexes of the items in the state collection that should be removed.

    Returns object

    Returns a redux action with the properties type and index.

    • indexes: Array<number>
    • type: string

DeleteFailure

  • DeleteFailure(error: any): object
  • Action creator for the step when deleting a Content is failed.

    Parameters

    • error: any

      The catched error object.

    Returns object

    Returns a redux action with the properties type and the error message.

    • message: any
    • type: string

DeleteSuccess

  • DeleteSuccess(index: number, id: number): object
  • Action creator for the step when Content deleted successfully.

    Parameters

    • index: number

      Index of the item in the state collection.

    • id: number

    Returns object

    Returns a redux action with the properties type and index.

    • id: number
    • index: number
    • type: string

ForceUndoCheckout

  • ForceUndoCheckout(id: number): object
  • Action creator for undoing checkout on a Content in the Content Repository.

    Parameters

    • id: number

      Id of the content that should be checked in.

    Returns object

    Returns a redux action with the properties type and id.

    • id: number
    • type: string

ForceUndoCheckoutFailure

  • ForceUndoCheckoutFailure(error: any): object
  • Action creator for the step when undoing checkout on a Content is failed.

    Parameters

    • error: any

      The catched error object.

    Returns object

    Returns a redux action with the properties type and the error message.

    • message: any
    • type: string

ForceUndoCheckoutSuccess

  • ForceUndoCheckoutSuccess(response: any): object
  • Action creator for the step when a Content is checked-in successfully.

    Parameters

    • response: any

      JSON response of the ajax request.

    Returns object

    Returns a redux action with the properties type and the normalized JSON response.

    • response: object
      • entities: any
      • result: any
    • type: string

Publish

  • Publish(id: number): object
  • Action creator for publishing a Content in the Content Repository.

    Parameters

    • id: number

      Id of the content that should be published.

    Returns object

    Returns a redux action with the properties type and id.

    • id: number
    • type: string

PublishFailure

  • PublishFailure(error: any): object
  • Action creator for the step when publishing a Content is failed.

    Parameters

    • error: any

      The catched error object.

    Returns object

    Returns a redux action with the properties type and the error message.

    • message: any
    • type: string

PublishSuccess

  • PublishSuccess(response: any): object
  • Action creator for the step when a Content is published successfully.

    Parameters

    • response: any

      JSON response of the ajax request.

    Returns object

    Returns a redux action with the properties type and the normalized JSON response.

    • response: object
      • entities: any
      • result: any
    • type: string

ReceiveContent

  • ReceiveContent(response: any, filter: string): object
  • Action creator for the step when a fetching request ends successfully.

    Parameters

    • response: any

      JSON response of the ajax request.

    • filter: string

      String with the url params.

    Returns object

    Returns a redux action with the properties type, normalized response and filter.

    • filter: string
    • response: object
      • entities: any
      • result: any
    • type: string

ReceiveContentFailure

  • ReceiveContentFailure(filter: string, error: any): object
  • Action creator for the step when a fetching request failed.

    Parameters

    • filter: string

      String with the url params.

    • error: any

      The catched error object.

    Returns object

    Returns a redux action with the properties type, filter and errormessage.

    • filter: string
    • message: any
    • type: string

Reject

  • Reject(id: number, rejectReason?: string): object
  • Action creator for rejecting a Content in the Content Repository.

    Parameters

    • id: number

      Id of the content that should be rejected.

    • Default value rejectReason: string = ""

      Reason of rejecting.

    Returns object

    Returns a redux action with the properties type, rejectReason and id.

    • id: number
    • rejectReason: string
    • type: string

RejectFailure

  • RejectFailure(error: any): object
  • Action creator for the step when rejecting a Content is failed.

    Parameters

    • error: any

      The catched error object.

    Returns object

    Returns a redux action with the properties type and the error message.

    • message: any
    • type: string

RejectSuccess

  • RejectSuccess(response: any): object
  • Action creator for the step when a Content is rejected successfully.

    Parameters

    • response: any

      JSON response of the ajax request.

    Returns object

    Returns a redux action with the properties type and the normalized JSON response.

    • response: object
      • entities: any
      • result: any
    • type: string

RequestContent

  • RequestContent(path: string, options?: IODataParams): object
  • Action creator for requesting a content from Sense/Net Content Repository to get its children content.

    Parameters

    • path: string

      Path of the requested parent item.

    • Default value options: IODataParams = {}

      Represents an ODataOptions object based on the IODataOptions interface. Holds the possible url parameters as properties.

    Returns object

    Returns a redux action with the properties type, path and filter.

    • filter: string
    • path: string
    • type: string

RestoreVersion

  • RestoreVersion(id: number, version: string): object
  • Action creator for restoring the version of a Content in the Content Repository.

    Parameters

    • id: number

      Id of the content that should be checked in.

    • version: string

      Specify which old version to restore

    Returns object

    Returns a redux action with the properties type and id.

    • id: number
    • type: string
    • version: string

RestoreVersionFailure

  • RestoreVersionFailure(error: any): object
  • Action creator for the step when restoring a previous version of a Content is failed.

    Parameters

    • error: any

      The catched error object.

    Returns object

    Returns a redux action with the properties type and the error message.

    • message: any
    • type: string

RestoreVersionSuccess

  • RestoreVersionSuccess(response: any): object
  • Action creator for the step when a Content is restored to a previous version successfully.

    Parameters

    • response: any

      JSON response of the ajax request.

    Returns object

    Returns a redux action with the properties type and the normalized JSON response.

    • response: object
      • entities: any
      • result: any
    • type: string

UndoCheckout

  • UndoCheckout(id: number): object
  • Action creator for undoing checkout on a Content in the Content Repository.

    Parameters

    • id: number

      Id of the content that should be checked in.

    Returns object

    Returns a redux action with the properties type and id.

    • id: number
    • type: string

UndoCheckoutFailure

  • UndoCheckoutFailure(error: any): object
  • Action creator for the step when undoing checkout on a Content is failed.

    Parameters

    • error: any

      The catched error object.

    Returns object

    Returns a redux action with the properties type and the error message.

    • message: any
    • type: string

UndoCheckoutSuccess

  • UndoCheckoutSuccess(response: any): object
  • Action creator for the step when a Content is checked-in successfully.

    Parameters

    • response: any

      JSON response of the ajax request.

    Returns object

    Returns a redux action with the properties type and the normalized JSON response.

    • response: object
      • entities: any
      • result: any
    • type: string

UpdateContent

  • UpdateContent(id: number, fields: Object): object
  • Action creator for updating a Content in the Content Repository.

    Parameters

    • id: number

      Id of the Content that has to be updated.

    • fields: Object

      Object with the field value pairs that have to be modified.

    Returns object

    Returns a redux action with the properties type, id and fields.

    • fields: Object
    • id: number
    • type: string

UpdateContentFailure

  • UpdateContentFailure(error: any): object
  • Action creator for the step when Content modification failed on the server.

    Parameters

    • error: any

      The catched error object.

    Returns object

    Returns a redux action with the properties type and the error message.

    • message: any
    • type: string

UpdateContentSuccess

  • UpdateContentSuccess(response: any): object
  • Action creator for the step when Content modification on the server ends successfully.

    Parameters

    • response: any

      JSON response of the ajax request.

    Returns object

    Returns a redux action with the properties type and the response.

    • response: object
      • entities: any
      • result: any
    • type: string

UserLogin

  • UserLogin(userName: string, password: string): object
  • Action creator for login a user to a Sense/Net portal.

    Parameters

    • userName: string

      Login name of the user.

    • password: string

      Password of the user.

    Returns object

    Returns a redux action with the properties userName and password.

    • password: string
    • type: string
    • userName: string

UserLoginFailure

  • UserLoginFailure(error: any): object
  • Action creator for the step when login of a user is failed.

    Parameters

    • error: any

      The catched error object.

    Returns object

    Returns a redux action with the properties type and the error message.

    • message: any
    • type: string

UserLoginSuccess

  • UserLoginSuccess(response: any): object
  • Action creator for the step when a User is logged in successfully.

    Parameters

    • response: any

      JSON response of the ajax request.

    Returns object

    Returns a redux action with the user as a response.

    • response: any
    • type: string

UserLogout

  • UserLogout(): object
  • Action creator for logout a user from a Sense/Net portal.

    Returns object

    Returns a redux action.

    • type: string

UserLogoutFailure

  • UserLogoutFailure(error: any): object
  • Action creator for the step when logging out of a user is failed.

    Parameters

    • error: any

      The catched error object.

    Returns object

    Returns a redux action with the properties type and the error message.

    • message: any
    • type: string

UserLogoutSuccess

  • UserLogoutSuccess(response: any): object
  • Action creator for the step when a user is logged out successfully.

    Parameters

    • response: any

      JSON response of the ajax request.

    Returns object

    Returns a redux action with a response.

    • type: string

Generated using TypeDoc