From 32c231806a553bc06e783d8a8cb8e3576e57babe Mon Sep 17 00:00:00 2001 From: nileshgulia1 Date: Mon, 8 Nov 2021 21:42:03 +0530 Subject: [PATCH] update to volto 14 --- package.json | 2 +- .../volto/actions/content/content.js | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 166e6b6..8477a17 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "raven-js": "3.27.2", "recharts": "2.1.6", "react-highlight-words": "^0.16.0", - "react-image-gallery": "1.0.8", + "react-image-gallery": "1.2.7", "react-lazy-load-image-component": "^1.5.0", "react-stickynode": "^2.1.1", "react-toastify": "^5.3.2", diff --git a/src/customizations/volto/actions/content/content.js b/src/customizations/volto/actions/content/content.js index 1df077c..fab0dd7 100644 --- a/src/customizations/volto/actions/content/content.js +++ b/src/customizations/volto/actions/content/content.js @@ -11,6 +11,8 @@ import { ORDER_CONTENT, RESET_CONTENT, UPDATECOLUMNS_CONTENT, + LOCK_CONTENT, + UNLOCK_CONTENT, } from '@plone/volto/constants/ActionTypes'; import { nestContent } from '@plone/volto/helpers'; import config from '@plone/volto/registry'; @@ -199,3 +201,45 @@ export function updateColumnsContent(url, index) { indexcolumns: index, }; } + +/** + * Lock content function. + * @function lockContent + * @param {string} urls Content url(s) + * @returns {Object} Lock content action. + */ +export function lockContent(urls) { + return { + type: LOCK_CONTENT, + mode: 'serial', + request: + typeof urls === 'string' + ? { op: 'post', path: `${urls}/@lock` } + : urls.map((url) => ({ op: 'post', path: `${url}/@lock` })), + }; +} + +/** + * Unlock content function. + * @function unlockContent + * @param {string|Array} urls Content url(s). + * @returns {Object} Unlock content action. + */ +export function unlockContent(urls, force = false) { + return { + type: UNLOCK_CONTENT, + mode: 'serial', + request: + typeof urls === 'string' + ? { + op: 'del', + path: `${urls}/@lock`, + data: force ? { force: true } : {}, + } + : urls.map((url) => ({ + op: 'del', + path: `${url}/@lock`, + data: force ? { force: true } : {}, + })), + }; +}