How to use the immutadot/core/set.set function in immutadot

To help you get started, we’ve selected a few immutadot examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Zenika / marcel / backoffice / src / dashboard / reducer.js View on Github external
if (!pluginsToRemove.lenght) return pluginInstances

        const cleanedPluginInstances = omit(pluginInstances, pluginsToRemove)
        return reduce(pluginsToRemove, removeChilds, cleanedPluginInstances)
      }

      return flow(
        update(`pluginInstances`, pluginInstances => removeChilds(pluginInstances, instanceId)),
        unset(`pluginInstances.${instanceId}`),
        pull(
          parent
            ? `pluginInstances.${parent.plugin}.props.${parent.prop}.value`
            : `dashboards.${selectedDashboard}.plugins`,
          instanceId,
        ),
        set(`selectedPlugin`, parent && parent.plugin),
      )(state)
    }
    case actions.CHANGE_PROP: {
      const { instanceId, prop, value } = action.payload
      return set(state, `pluginInstances.${instanceId}.props.${prop.name}.value`, value)
    }
    case actions.SAVE_LAYOUT: {
      const { layout } = action.payload
      const { selectedDashboard } = state
      return selectedDashboard ? update(state, `pluginInstances`, updatePlugins(layout)) : state
    }
    case actions.UPDATE_CONFIG: {
      const { selectedDashboard } = state
      const { property, value } = action.payload
      const parsedValue = parseFloat(value)
      return selectedDashboard
github Zenika / marcel / backoffice / src / user / reducer.js View on Github external
}
    case userActions.DELETE_USER_SUCCESS: {
      const { id } = action.payload
      return unset(state, `users.${id}`)
    }
    case userActions.EDIT_USER: {
      const { user } = action.payload
      const currentUser = { ...user, confirmPassword: '' }
      return set(state, 'currentUser', currentUser)
    }
    case userActions.UPDATE_CURRENT_USER_PROPERTY: {
      const { property, value } = action.payload
      return set(state, `currentUser.${property}`, value)
    }
    case userActions.RESET_CURRENT_USER: {
      return set(state, 'currentUser', initialState.currentUser)
    }
    default:
      return state
  }
}
github Zenika / marcel / backoffice / src / user / reducer.js View on Github external
case userActions.ADD_USER_SUCCESS: {
      const { user } = action.payload
      return set(state, `users.${user.id}`, user)
    }
    case userActions.UPDATE_USER_SUCCESS: {
      const { user } = action.payload
      return set(state, `users.${user.id}`, user)
    }
    case userActions.DELETE_USER_SUCCESS: {
      const { id } = action.payload
      return unset(state, `users.${id}`)
    }
    case userActions.EDIT_USER: {
      const { user } = action.payload
      const currentUser = { ...user, confirmPassword: '' }
      return set(state, 'currentUser', currentUser)
    }
    case userActions.UPDATE_CURRENT_USER_PROPERTY: {
      const { property, value } = action.payload
      return set(state, `currentUser.${property}`, value)
    }
    case userActions.RESET_CURRENT_USER: {
      return set(state, 'currentUser', initialState.currentUser)
    }
    default:
      return state
  }
}
github Zenika / marcel / backoffice / src / auth / reducer.js View on Github external
case actions.CHANGE_LOGIN: {
      return { ...state, login: action.payload.login }
    }
    case actions.CHANGE_PASSWORD: {
      return { ...state, password: action.payload.password }
    }
    case actions.RESET_FORM: {
      return initialForm
    }
    case actions.UPDATE_CONNECTED_USER_SUCCESS: {
      const { user } = action.payload
      return user
    }
    case actions.UPDATE_CONNECTED_USER_PROPERTY: {
      const { property, value } = action.payload
      return set(state, property, value)
    }
    default:
      return state
  }
}
github Zenika / marcel / backoffice / src / clients / reducer.js View on Github external
const clients = (state = initialState, action) => {
  switch (action.type) {
    case loadersActions.LOAD_CLIENTS_SUCCESSED: {
      return { ...state, clients: action.payload.clients }
    }
    case actions.CLIENT_ASSOCIATION_STARTED: {
      return set(state, `loading.${action.payload.client.id}`, true)
    }
    case actions.CLIENT_ASSOCIATION_SUCCESS: {
      const { client } = action.payload
      return flow(
        unset(`loading.${client.id}`),
        set(`clients.${client.id}`, client),
      )(state)
    }
    case actions.CLIENT_ASSOCIATION_FAILED: {
      const { client } = action.payload
      return unset(state, `loading.${client.id}`)
    }
    case actions.REQUIRE_CLIENT_ASSOCIATION: {
      const { client } = action.payload
      return { ...state, associating: client }
    }
    case actions.CONFIRM_CLIENT_ASSOCIATION:
    case actions.CANCEL_CLIENT_ASSOCIATION: {
      return { ...state, associating: null }
    }
    default:
      return state
github Zenika / marcel / backoffice / src / dashboard / reducer.js View on Github external
set('deletingDashboard', null),
            unset(`dashboards.${deletingDashboard}`),
          )(state)
        : { ...state, deletingDashboard: null }
    }
    case actions.CANCEL_DASHBOARD_DELETION: {
      return { ...state, deletingDashboard: null }
    }
    case actions.DELETE_DASHBOARD: {
      return unset(state, `dashboards.${action.payload.dashboardId}`)
    }
    case actions.ADD_DASHBOARD: {
      const { dashboard } = action.payload
      return flow(
        set(`dashboards.${dashboard.id}`, dashboard),
        set('selectedDashboard', dashboard.id),
      )(state)
    }
    case actions.ADD_SUB_PLUGIN: {
      const { selectedPlugin } = state
      if (!selectedPlugin) return state

      const { propName, plugin } = action.payload
      const instanceId = uuid()

      return flow(
        set(`pluginInstances.${instanceId}`, {
          ...plugin,
          x: 0,
          y: 0,
          cols: 1,
          rows: 1,
github Zenika / marcel / backoffice / src / dashboard / reducer.js View on Github external
)(state)
    }
    case actions.REORDER_SUB_PLUGINS: {
      const {
        instanceIds,
        parent: { plugin, prop },
      } = action.payload
      return set(state, `pluginInstances.${plugin}.props.${prop}.value`, instanceIds)
    }
    case actions.ADD_PLUGIN: {
      const instanceId = uuid()
      const { selectedDashboard } = state
      return selectedDashboard
        ? flow(
            set('selectedPlugin', instanceId),
            set(`pluginInstances.${instanceId}`, {
              ...action.payload.plugin,
              x: action.payload.x,
              y: action.payload.y,
              cols: 1,
              rows: 1,
              instanceId,
            }),
            push(`dashboards.${selectedDashboard}.plugins`, instanceId),
          )(state)
        : state
    }
    case actions.DELETE_PLUGIN: {
      const { plugin } = action.payload
      const { selectedDashboard } = state
      if (!selectedDashboard) return state
github Zenika / marcel / backoffice / src / dashboard / reducer.js View on Github external
return { ...state, selectedPlugin: action.payload.instanceId }
    }
    case actions.SELECT_DASHBOARD: {
      return { ...state, selectedDashboard: action.payload.dashboardId }
    }
    case actions.UNSELECT_DASHBOARD: {
      return { ...state, selectedDashboard: null, selectedPlugin: null }
    }
    case actions.REQUIRE_DASHBOARD_DELETION: {
      return { ...state, deletingDashboard: action.payload.dashboardId }
    }
    case actions.DASHBOARD_DELETED: {
      const { deletingDashboard } = state
      return deletingDashboard
        ? flow(
            set('deletingDashboard', null),
            unset(`dashboards.${deletingDashboard}`),
          )(state)
        : { ...state, deletingDashboard: null }
    }
    case actions.CANCEL_DASHBOARD_DELETION: {
      return { ...state, deletingDashboard: null }
    }
    case actions.DELETE_DASHBOARD: {
      return unset(state, `dashboards.${action.payload.dashboardId}`)
    }
    case actions.ADD_DASHBOARD: {
      const { dashboard } = action.payload
      return flow(
        set(`dashboards.${dashboard.id}`, dashboard),
        set('selectedDashboard', dashboard.id),
      )(state)
github Zenika / marcel / backoffice / src / dashboard / reducer.js View on Github external
x: 0,
          y: 0,
          cols: 1,
          rows: 1,
          instanceId,
          parent: { plugin: selectedPlugin, prop: propName },
        }),
        push(`pluginInstances.${selectedPlugin}.props.${propName}.value`, instanceId),
      )(state)
    }
    case actions.REORDER_SUB_PLUGINS: {
      const {
        instanceIds,
        parent: { plugin, prop },
      } = action.payload
      return set(state, `pluginInstances.${plugin}.props.${prop}.value`, instanceIds)
    }
    case actions.ADD_PLUGIN: {
      const instanceId = uuid()
      const { selectedDashboard } = state
      return selectedDashboard
        ? flow(
            set('selectedPlugin', instanceId),
            set(`pluginInstances.${instanceId}`, {
              ...action.payload.plugin,
              x: action.payload.x,
              y: action.payload.y,
              cols: 1,
              rows: 1,
              instanceId,
            }),
            push(`dashboards.${selectedDashboard}.plugins`, instanceId),
github Zenika / marcel / backoffice / src / dashboard / reducer.js View on Github external
case actions.ADD_DASHBOARD: {
      const { dashboard } = action.payload
      return flow(
        set(`dashboards.${dashboard.id}`, dashboard),
        set('selectedDashboard', dashboard.id),
      )(state)
    }
    case actions.ADD_SUB_PLUGIN: {
      const { selectedPlugin } = state
      if (!selectedPlugin) return state

      const { propName, plugin } = action.payload
      const instanceId = uuid()

      return flow(
        set(`pluginInstances.${instanceId}`, {
          ...plugin,
          x: 0,
          y: 0,
          cols: 1,
          rows: 1,
          instanceId,
          parent: { plugin: selectedPlugin, prop: propName },
        }),
        push(`pluginInstances.${selectedPlugin}.props.${propName}.value`, instanceId),
      )(state)
    }
    case actions.REORDER_SUB_PLUGINS: {
      const {
        instanceIds,
        parent: { plugin, prop },
      } = action.payload