How to use the immutadot/array/push.push 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
}
    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

      const { instanceId, parent } = plugin

      const removeChilds = (pluginInstances, instanceId) => {
        const plugin = pluginInstances[instanceId]
        if (!plugin) return pluginInstances

        const pluginListProps = pickBy(plugin.props, { type: 'pluginList' })
        const pluginsToRemove = flatten(map(values(pluginListProps), 'value'))
github Zenika / marcel / backoffice / src / dashboard / reducer.js View on Github external
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
      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}`, {