Options
All
  • Public
  • Public/Protected
  • All
Menu

External 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 sensenet built-in action. Since this sensenet 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. There's a custom middleware included automatically when you create a sensenet store with Store.createSensenetStore. So that we don't have to create separate redux actions for every state of the actions only one for the main request.

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

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

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 '@sensenet/redux';
import { Task } from '@sensenet/default-content-types';

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

  return (
    <div>
      <form onSubmit={e => {
        e.preventDefault()
        if (!input.value.trim()) {
          return
        }
        const content = {
          Name: input.value,
          Status: 'active',
         } as Task

        dispatch(Actions.createContent(content))
        input.value = ''
      } }>
        <input className="textField" ref={node => {
          input = node
        } } />
        <RaisedButton type="submit" primary={true} label="Add Todo" />
      </form>
    </div>
  )
}

Combining your custom redux reducers with sensenet root reducer.

import { combineReducers } from 'redux';
import { Store, Reducers } from '@sensenet/redux';
import { Repository } from '@sensenet/client-core'
import { Root } from './components/Root'
import { listByFilter } from './reducers/filtering'

const sensenet = Reducers.sensenet;
const myReducer = combineReducers({
  sensenet,
  listByFilter
});
const repository = new Repository({ repositoryUrl: 'https://mySensenetSite.com' }, async () => ({ ok: true } as any))
const options = {
repository,
rootReducer: myReducer
} as Store.CreateStoreOptions
const store = Store.createSensenetStore(options);

Index

Functions

Const approve

  • approve<T>(idOrPath: number | string, options?: IODataParams<T>): object
  • Action creator for approving a Content in the Content Repository.

    Type parameters

    • T: IContent

    Parameters

    • idOrPath: number | string

      Id or Path of the Content that should be approved.

    • Optional options: IODataParams<T>

      Options to filter the response.

    Returns object

    Returns the Content and dispatches the next action based on the response.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<IODataResponse<T>>
      • Parameters

        • repository: Repository

        Returns Promise<IODataResponse<T>>

Const changeFieldValue

  • changeFieldValue(name: string, value: any): object
  • Action creator for changing a field value of a content

    Parameters

    • name: string

      Name of the field.

    • value: any

      Value of the field.

    Returns object

    • name: string
    • type: string
    • value: any

Const checkIn

  • checkIn<T>(idOrPath: number | string, checkInComments?: string, options?: IODataParams<T>): object
  • Action creator for checking in a Content in the Content Repository.

    Type parameters

    • T: IContent

    Parameters

    • idOrPath: number | string

      Id or Path of the Content that should be checked in.

    • Default value checkInComments: string = ""

      Comments of the checkin.

    • Optional options: IODataParams<T>

      Options to filter the response.

    Returns object

    Returns the Content and dispatches the next action based on the response.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<IODataResponse<T>>
      • Parameters

        • repository: Repository

        Returns Promise<IODataResponse<T>>

Const checkLoginState

  • checkLoginState(): object
  • Action creator for check user state in a sensenet application.

    Returns object

    Returns a redux action with the properties.

    • type: string

Const checkOut

  • checkOut<T>(idOrPath: number | string, options?: IODataParams<T>): object
  • Action creator for checking out a Content in the Content Repository.

    Type parameters

    • T: IContent

    Parameters

    • idOrPath: number | string

      Id or path of the Content that should be checked out.

    • Optional options: IODataParams<T>

      Options to filter the response.

    Returns object

    Returns the Content and dispatches the next action based on the response.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<IODataResponse<T>>
      • Parameters

        • repository: Repository

        Returns Promise<IODataResponse<T>>

Const clearSelection

  • clearSelection(): object
  • Action creator for clearing the array of selected content

    Returns object

    Returns a redux action.

    • type: string

Const copyBatch

  • copyBatch(items: Array<number | string>, targetPath: string): object
  • Action creator for copying multiple Content in the Content Repository.

    Parameters

    • items: Array<number | string>
    • targetPath: string

      Path of the parent Content where the given Content should be copied.

    Returns object

    Returns the list of the Content and dispatches the next action based on the response.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<IODataBatchResponse<IContent>>
      • Parameters

        • repository: Repository

        Returns Promise<IODataBatchResponse<IContent>>

Const copyContent

  • copyContent(idOrPath: number | string, targetPath: string): object
  • Action creator for copying a Content in the Content Repository.

    Parameters

    • idOrPath: number | string

      Id or path of the Content that should be copied.

    • targetPath: string

      Path of the parent Content where the given Content should be copied.

    Returns object

    Returns the Content and dispatches the next action based on the response.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<IODataBatchResponse<IContent>>
      • Parameters

        • repository: Repository

        Returns Promise<IODataBatchResponse<IContent>>

Const createContent

  • createContent<T>(parentPath: string, content: T, contentType: string): object
  • Action creator for creating a Content in the Content Repository.

    Type parameters

    • T: IContent

    Parameters

    • parentPath: string

      Path of the Content where the new Content should be created.

    • content: T

      Content that have to be created in the Content Respository.

    • contentType: string

      Name of the Content Type of the Content.

    Returns object

    Returns the newly created Content and dispatches the next action based on the response.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<IODataResponse<T>>
      • Parameters

        • repository: Repository

        Returns Promise<IODataResponse<T>>

Const deSelectContent

  • deSelectContent(content: any): object
  • Action creator for deselecting a Content

    Parameters

    • content: any

    Returns object

    Returns a redux action.

    • content: any
    • type: string

Const deleteBatch

  • deleteBatch(contentItems: Array<number | string>, permanently?: boolean): object
  • Action creator for deleting multiple Content from the Content Repository.

    Parameters

    • contentItems: Array<number | string>

      Array of ids or paths' of the Content items that should be deleted.

    • Default value permanently: boolean = false

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

    Returns object

    Returns an object with the deleted items or errors and dispatches the next action based on the response.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<IODataBatchResponse<IContent>>
      • Parameters

        • repository: Repository

        Returns Promise<IODataBatchResponse<IContent>>

Const deleteContent

  • deleteContent(idOrPath: number | string, permanently?: boolean): object
  • Action creator for deleting a Content from the Content Repository.

    Parameters

    • idOrPath: number | string

      Id or path of the Content object that should be deleted.

    • Default value permanently: boolean = false

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

    Returns object

    Returns an object with the deleted item or error and dispatches the next action based on the response.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<IODataBatchResponse<IContent>>
      • Parameters

        • repository: Repository

        Returns Promise<IODataBatchResponse<IContent>>

Const forceUndoCheckout

  • forceUndoCheckout<T>(idOrPath: number | string, options?: IODataParams<T>): object
  • Action creator for force undoing checkout on a Content in the Content Repository.

    Type parameters

    • T: IContent

    Parameters

    • idOrPath: number | string

      Id or Path of the Content on which force undo checkout be called.

    • Optional options: IODataParams<T>

      Options to filter the response.

    Returns object

    Returns the Content and dispatches the next action based on the response.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<IODataResponse<T>>
      • Parameters

        • repository: Repository

        Returns Promise<IODataResponse<T>>

Const getSchema

  • getSchema(typeName: string): object
  • Action creator for loading schema of a given type

    Parameters

    • typeName: string

      Name of the Content Type.

    Returns object

    • type: string
    • payload: function
      • payload(repository: Repository): Schema
      • Parameters

        • repository: Repository

        Returns Schema

Const loadContent

  • loadContent<T>(idOrPath: number | string, options?: IODataParams<T>): object
  • Action creator for loading a content from sensenet Content Repository.

    Type parameters

    • T: IContent

    Parameters

    • idOrPath: number | string

      Id or path of the requested item.

    • Default value options: IODataParams<T> = {}

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

    Returns object

    Returns the Content while dispatches the next action based on the response.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<IODataResponse<T>>
      • Parameters

        • repository: Repository

        Returns Promise<IODataResponse<T>>

Const loadContentActions

  • loadContentActions(idOrPath: number | string, scenario?: string): object
  • Action creator for loading Actions of a Content from sensenet Content Repository.

    Parameters

    • idOrPath: number | string

      Id or path of the requested Content.

    • Optional scenario: string

      The Actions should be in the given Scenario

    Returns object

    Returns the list of actions and dispatches the next action based on the response.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<object>
      • Parameters

        • repository: Repository

        Returns Promise<object>

Const loadRepository

  • loadRepository(repositoryConfig: any): object
  • Action creator for load repository config.

    Parameters

    • repositoryConfig: any

      The repository config object.

    Returns object

    Returns a redux action.

    • repository: any
    • type: string

Const moveBatch

  • moveBatch(items: Array<number | string>, targetPath: string): object
  • Action creator for moving multiple Content in the Content Repository.

    Parameters

    • items: Array<number | string>
    • targetPath: string

      Path of the parent Content where the given Content should be moved.

    Returns object

    Returns the list of the Content and dispatches the next action based on the response.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<IODataBatchResponse<IContent>>
      • Parameters

        • repository: Repository

        Returns Promise<IODataBatchResponse<IContent>>

Const moveContent

  • moveContent(idOrPath: number | string, targetPath: string): object
  • Action creator for moving a Content in the Content Repository.

    Parameters

    • idOrPath: number | string

      Id or path of the Content that should be moved.

    • targetPath: string

      Path of the parent Content where the given Content should be moved.

    Returns object

    Returns the Content and dispatches the next action based on the response.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<IODataBatchResponse<IContent>>
      • Parameters

        • repository: Repository

        Returns Promise<IODataBatchResponse<IContent>>

Const publish

  • publish<T>(idOrPath: number | string, options?: IODataParams<T>): object
  • Action creator for publishing a Content in the Content Repository.

    Type parameters

    • T: IContent

    Parameters

    • idOrPath: number | string

      Id or Path of the Content that should be published.

    • Optional options: IODataParams<T>

      Options to filter the response.

    Returns object

    Returns the Content and dispatches the next action based on the response.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<IODataResponse<T>>
      • Parameters

        • repository: Repository

        Returns Promise<IODataResponse<T>>

Const rejectContent

  • rejectContent<T>(idOrPath: number | string, rejectReason?: string, options?: IODataParams<T>): object
  • Action creator for rejecting a Content in the Content Repository.

    Type parameters

    • T: IContent

    Parameters

    • idOrPath: number | string

      Id or Path of the Content that should be rejected.

    • Default value rejectReason: string = ""

      Reason of rejecting.

    • Optional options: IODataParams<T>

      Options to filter the response.

    Returns object

    Returns the Content and dispatches the next action based on the response.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<IODataResponse<T>>
      • Parameters

        • repository: Repository

        Returns Promise<IODataResponse<T>>

Const requestContent

  • requestContent<T>(path: string, options?: IODataParams<T>): object
  • Action creator for requesting a content from sensenet Content Repository to get its children content.

    Type parameters

    • T: IContent

    Parameters

    • path: string

      path of the requested parent item.

    • Default value options: IODataParams<T> = {}

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

    Returns object

    Returns normalized data while dispatches the next action based on the response.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<object>
      • Parameters

        • repository: Repository

        Returns Promise<object>

Const restoreVersion

  • restoreVersion<T>(idOrPath: number | string, version: string, options?: IODataParams<T>): object
  • Action creator for restoring the version of a Content in the Content Repository.

    Type parameters

    • T: IContent

    Parameters

    • idOrPath: number | string

      Id or Path of the Content that should be checked in.

    • version: string

      Specify which old version to restore.

    • Optional options: IODataParams<T>

      Options to filter the response.

    Returns object

    Returns the Content and dispatches the next action based on the response.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<IODataResponse<T>>
      • Parameters

        • repository: Repository

        Returns Promise<IODataResponse<T>>

Const selectContent

  • selectContent(content: any): object
  • Action creator for selecting a Content

    Parameters

    • content: any

    Returns object

    Returns a redux action.

    • content: any
    • type: string

Const undoCheckout

  • undoCheckout<T>(idOrPath: number | string, options?: IODataParams<T>): object
  • Action creator for undoing checkout on a Content in the Content Repository.

    Type parameters

    • T: IContent

    Parameters

    • idOrPath: number | string

      Id or Path of the Content on which undo checkout be called.

    • Optional options: IODataParams<T>

      Options to filter the response.

    Returns object

    Returns the Content and dispatches the next action based on the response.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<IODataResponse<T>>
      • Parameters

        • repository: Repository

        Returns Promise<IODataResponse<T>>

Const updateContent

  • updateContent<T>(idOrPath: number | string, content: Partial<T>): object
  • Action creator for creating a Content in the Content Repository.

    Type parameters

    • T: IContent

    Parameters

    • idOrPath: number | string

      Id or path of the Content.

    • content: Partial<T>

      Content with the patchable Fields.

    Returns object

    Returns the modified Content and dispatches the next action based on the response.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<IODataResponse<T>>
      • Parameters

        • repository: Repository

        Returns Promise<IODataResponse<T>>

Const uploadRequest

  • uploadRequest<T>(parentPath: string, file: any, contentType?: any, overwrite?: boolean, body?: any, propertyName?: string): object
  • Action creator for uploading a Content into the Content Repository.

    Type parameters

    • T: IContent

    Parameters

    • parentPath: string
    • file: any

      The file that should be uploaded

    • Optional contentType: any
    • Default value overwrite: boolean = true
    • Optional body: any
    • Default value propertyName: string = "Binary"

    Returns object

    Returns a redux action with the properties type, content, file, contentType, overwrite, body and propertyName.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<T>
      • Parameters

        • repository: Repository

        Returns Promise<T>

Const userChanged

  • userChanged(user: any): object
  • Action creator for user changes.

    Parameters

    • user: any

      User that should be checked.

    Returns object

    Returns a redux action with the properties.

    • type: string
    • user: any

Const userLogin

  • userLogin(userName: string, password: string): object
  • Action creator for login a user to a sensenet 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.

    • type: string
    • payload: function
      • payload(repository: any): Promise<any>
      • Parameters

        • repository: any

        Returns Promise<any>

Const userLoginGoogle

  • userLoginGoogle(provider: GoogleOauthProvider, token?: string): object
  • Action creator for login a user to a sensenet portal with her google account.

    Parameters

    • provider: GoogleOauthProvider
    • Optional token: string

    Returns object

    Returns a redux action.

    • type: string
    • payload: function
      • payload(repository: Repository): Promise<boolean>
      • Parameters

        • repository: Repository

        Returns Promise<boolean>

Const userLogout

  • userLogout(): object
  • Action creator for logout a user from a sensenet portal.

    Returns object

    Returns a redux action.

    • type: string
    • payload: function
      • payload(repository: any): Promise<any>
      • Parameters

        • repository: any

        Returns Promise<any>

Generated using TypeDoc