diff --git a/docs/source/configuration/settings-reference.md b/docs/source/configuration/settings-reference.md index b8601cffef..56272835a2 100644 --- a/docs/source/configuration/settings-reference.md +++ b/docs/source/configuration/settings-reference.md @@ -177,7 +177,16 @@ contentMetadataTagsImageField The OpenGraph image that will represent this content item, will be used in the metadata HEAD tag as og:image for SEO purposes. Defaults to image. See the OpenGraph Protocol for more details. hasWorkingCopySupport - This setting will enable working copy support in your site. You need to install the `plone.app.iterate` add-on in your Plone site in order to make it working. + ```{versionremoved} Volto 18.8.0 + This setting is unnecessary since Volto 18.8.0. + Working copy support is now based on whether the `plone.app.iterate` add-on is installed in the backend. + ``` + + For Plone sites using a Volto version prior to 18.8.0, this setting enables working copy support. + + ```{seealso} + See {doc}`workingcopy` for configuration. + ``` controlpanels Register a component as control panel. diff --git a/docs/source/configuration/workingcopy.md b/docs/source/configuration/workingcopy.md index c559729c1a..c536c62cc0 100644 --- a/docs/source/configuration/workingcopy.md +++ b/docs/source/configuration/workingcopy.md @@ -9,17 +9,9 @@ myst: # Working copy support -Volto provide support for Plone's Working Copy feature. You need to install `plone.app.iterate` add-on in your Plone site that comes available by default. You can do that in Plone's control panel or using the `GenericSetup` facility. - -## Volto configuration - -You need to enable working copy support in Volto's configuration object: - -```js -import config from '@plone/volto/registry' - -config.settings.hasWorkingCopySupport = true; -``` +Volto supports Plone's working copy feature. +To enable it, you need to install the add-on `plone.app.iterate` in your Plone site. +You can do that either in Plone's {guilabel}`Add-ons` control panel or using the `GenericSetup` facility. ## Features @@ -29,3 +21,17 @@ Volto working copy support features include: - Work on the working copy - "Check in" the working copy by applying the changes into the original (baseline) object - Cancel the working copy if required + +## Volto configuration + +```{versionremoved} Volto 18.8.0 +This setting is no longer used. +``` + +If you have an older version of Volto, you also need to enable working copy support in Volto's configuration object as follows. + +```js +import config from '@plone/volto/registry' + +config.settings.hasWorkingCopySupport = true; +``` diff --git a/packages/coresandbox/src/index.ts b/packages/coresandbox/src/index.ts index ec4979d483..6bb16df1e8 100644 --- a/packages/coresandbox/src/index.ts +++ b/packages/coresandbox/src/index.ts @@ -180,12 +180,6 @@ export const multilingualFixture = (config: ConfigType) => { return config; }; -export const workingCopyFixture = (config: ConfigType) => { - config.settings.hasWorkingCopySupport = true; - - return config; -}; - // We extend the block types with the custom ones declare module '@plone/types' { export interface BlocksConfigData { diff --git a/packages/seven/Makefile b/packages/seven/Makefile index b012ee8899..cdaeadb163 100644 --- a/packages/seven/Makefile +++ b/packages/seven/Makefile @@ -259,7 +259,7 @@ working-copy-acceptance-backend-start: ## Start backend acceptance server for wo .PHONY: working-copy-acceptance-frontend-prod-start working-copy-acceptance-frontend-prod-start: build-deps ## Start acceptance frontend in production mode for working copy tests - ADDONS=@plone/volto-coresandbox:workingCopyFixture PLONE_API_PATH=http://127.0.0.1:55001/plone pnpm build && pnpm start:prod + PLONE_API_PATH=http://127.0.0.1:55001/plone pnpm build && pnpm start:prod .PHONY: working-copy-acceptance-test working-copy-acceptance-test: ## Start Cypress in interactive mode for working copy tests diff --git a/packages/seven/news/6393.internal b/packages/seven/news/6393.internal new file mode 100644 index 0000000000..2ebcfed3a1 --- /dev/null +++ b/packages/seven/news/6393.internal @@ -0,0 +1 @@ +Update Makefile. @davisagli diff --git a/packages/types/news/6393.bugfix b/packages/types/news/6393.bugfix new file mode 100644 index 0000000000..fffeba7f7e --- /dev/null +++ b/packages/types/news/6393.bugfix @@ -0,0 +1 @@ +Remove `hasWorkingCopySupport` setting. @davisagli diff --git a/packages/types/src/config/Settings.d.ts b/packages/types/src/config/Settings.d.ts index 2053fde0f5..4437f3d01e 100644 --- a/packages/types/src/config/Settings.d.ts +++ b/packages/types/src/config/Settings.d.ts @@ -87,7 +87,6 @@ export interface SettingsConfig { showSelfRegistration: boolean; contentMetadataTagsImageField: string; - hasWorkingCopySupport: boolean; maxUndoLevels: number; addonsInfo: unknown; workflowMapping: unknown; diff --git a/packages/volto/Makefile b/packages/volto/Makefile index ebeeec82d5..c6f2ec636b 100644 --- a/packages/volto/Makefile +++ b/packages/volto/Makefile @@ -252,7 +252,7 @@ working-copy-acceptance-backend-start: ## Start backend acceptance server for wo .PHONY: working-copy-acceptance-frontend-prod-start working-copy-acceptance-frontend-prod-start: build-deps ## Start acceptance frontend in production mode for working copy tests - ADDONS=@plone/volto-coresandbox:workingCopyFixture RAZZLE_API_PATH=http://127.0.0.1:55001/plone pnpm build && pnpm start:prod + RAZZLE_API_PATH=http://127.0.0.1:55001/plone pnpm build && pnpm start:prod .PHONY: working-copy-acceptance-test working-copy-acceptance-test: ## Start Cypress in interactive mode for working copy tests diff --git a/packages/volto/cypress/tests/workingCopy/create.js b/packages/volto/cypress/tests/workingCopy/create.js index 55b737e07f..b76d116862 100644 --- a/packages/volto/cypress/tests/workingCopy/create.js +++ b/packages/volto/cypress/tests/workingCopy/create.js @@ -59,7 +59,7 @@ describe('Working Copy Tests - Create', () => { cy.findByText('View working copy'); }); - it('Portal root does not have create option', function () { + it('Portal root has create option', function () { cy.visit('/'); cy.get('#toolbar-more').click(); cy.get('.menu-more').contains('Create working copy').should('not.exist'); diff --git a/packages/volto/news/5284.feature b/packages/volto/news/5284.feature new file mode 100644 index 0000000000..7c5cd61759 --- /dev/null +++ b/packages/volto/news/5284.feature @@ -0,0 +1 @@ +Show the working copy actions (checkin/checkout) based on whether they are enabled in the backend, instead of the `hasWorkingCopySupport` setting. @wesleybl, @davisagli diff --git a/packages/volto/src/components/manage/Toolbar/More.jsx b/packages/volto/src/components/manage/Toolbar/More.jsx index 07d8bc7c5d..c2864026b1 100644 --- a/packages/volto/src/components/manage/Toolbar/More.jsx +++ b/packages/volto/src/components/manage/Toolbar/More.jsx @@ -191,6 +191,13 @@ const More = (props) => { id: 'redirection', }); + const workingCopyCheckoutAction = find(actions.object_buttons, { + id: 'iterate_checkout', + }); + const workingCopyCheckinAction = find(actions.object_buttons, { + id: 'iterate_checkin', + }); + const dateOptions = { year: 'numeric', month: 'long', @@ -320,125 +327,114 @@ const More = (props) => { )} - {config.settings.hasWorkingCopySupport && - content['@type'] !== 'Plone Site' && ( - <> - {!content.working_copy && ( - -
  • - -
  • -
    - )} - {content.working_copy && content.working_copy_of && ( - -
  • - +
  • +
    + )} + {workingCopyCheckinAction && ( + +
  • + -
  • -
  • - -
  • -
    - )} - {content.working_copy && !content.working_copy_of && ( - -
  • - props.closeMenu()} - > - {intl.formatMessage(messages.viewWorkingCopy)} - - -
  • -
    - )} - - )} + + + +
  • + +
  • + + )} + {content.working_copy && !content.working_copy_of && ( + +
  • + props.closeMenu()} + > + {intl.formatMessage(messages.viewWorkingCopy)} + + +
  • +
    + )} {editAction && config.settings.isMultilingual && (
  • diff --git a/packages/volto/src/components/manage/Toolbar/More.test.jsx b/packages/volto/src/components/manage/Toolbar/More.test.jsx index 7ddb508e69..1befbf1894 100644 --- a/packages/volto/src/components/manage/Toolbar/More.test.jsx +++ b/packages/volto/src/components/manage/Toolbar/More.test.jsx @@ -1,10 +1,8 @@ -import React from 'react'; import configureStore from 'redux-mock-store'; import { Provider } from 'react-intl-redux'; import { MemoryRouter } from 'react-router-dom'; import { PluggablesProvider } from '@plone/volto/components/manage/Pluggable'; import { waitFor, render } from '@testing-library/react'; -import config from '@plone/volto/registry'; import More from './More'; @@ -162,26 +160,4 @@ describe('Toolbar More component', () => { await waitFor(() => {}); expect(container).toMatchSnapshot(); }); - it('renders a Toolbar More component with manage content (working copy)', async () => { - config.settings.hasWorkingCopySupport = true; - - const { container } = render( - - - - {}} - theToolbar={{ - current: { getBoundingClientRect: () => ({ width: '320' }) }, - }} - closeMenu={() => {}} - /> - - - , - ); - await waitFor(() => {}); - expect(container).toMatchSnapshot(); - }); }); diff --git a/packages/volto/src/components/manage/Toolbar/__snapshots__/More.test.jsx.snap b/packages/volto/src/components/manage/Toolbar/__snapshots__/More.test.jsx.snap index da818c4054..42ca733d97 100644 --- a/packages/volto/src/components/manage/Toolbar/__snapshots__/More.test.jsx.snap +++ b/packages/volto/src/components/manage/Toolbar/__snapshots__/More.test.jsx.snap @@ -110,138 +110,3 @@ exports[`Toolbar More component renders a Toolbar More component 1`] = ` `; - -exports[`Toolbar More component renders a Toolbar More component with manage content (working copy) 1`] = ` -
    - -
    -`; diff --git a/packages/volto/src/components/manage/WorkingCopyToastsFactory/WorkingCopyToastsFactory.jsx b/packages/volto/src/components/manage/WorkingCopyToastsFactory/WorkingCopyToastsFactory.jsx index 07cc48d57d..50434ffe4d 100644 --- a/packages/volto/src/components/manage/WorkingCopyToastsFactory/WorkingCopyToastsFactory.jsx +++ b/packages/volto/src/components/manage/WorkingCopyToastsFactory/WorkingCopyToastsFactory.jsx @@ -7,7 +7,6 @@ import { defineMessages, useIntl } from 'react-intl'; import Toast from '@plone/volto/components/manage/Toast/Toast'; import { flattenToAppURL } from '@plone/volto/helpers/Url/Url'; import FormattedDate from '@plone/volto/components/theme/FormattedDate/FormattedDate'; -import config from '@plone/volto/registry'; import useDeepCompareEffect from 'use-deep-compare-effect'; const messages = defineMessages({ @@ -39,48 +38,28 @@ const WorkingCopyToastsFactory = (props) => { }; useDeepCompareEffect(() => { - if (content && config.settings.hasWorkingCopySupport) { - if (working_copy) { - let toastMessage, toastTitle; - if (content.working_copy_of) { - // I'm a working copy - toastMessage = messages.thisIsAWorkingCopyOf; - toastTitle = ( - - {content.working_copy_of?.title} - - ); - } else { - // I'm a baseline - toastMessage = messages.workingCopyIs; - toastTitle = ( - - {working_copy?.title} - - ); - } - if (toast.isActive('workingcopyinfo')) { - toast.update('workingcopyinfo', { - render: ( - - ), - })} - /> - ), - }); - } else { - toast.info( + if (working_copy) { + let toastMessage, toastTitle; + if (content.working_copy_of) { + // I'm a working copy + toastMessage = messages.thisIsAWorkingCopyOf; + toastTitle = ( + + {content.working_copy_of?.title} + + ); + } else { + // I'm a baseline + toastMessage = messages.workingCopyIs; + toastTitle = ( + + {working_copy?.title} + + ); + } + if (toast.isActive('workingcopyinfo')) { + toast.update('workingcopyinfo', { + render: ( { /> ), })} - />, - { - toastId: 'workingcopyinfo', - autoClose: false, - closeButton: false, - transition: null, - }, - ); - } + /> + ), + }); + } else { + toast.info( + + ), + })} + />, + { + toastId: 'workingcopyinfo', + autoClose: false, + closeButton: false, + transition: null, + }, + ); } - if (!working_copy) { - if (toast.isActive('workingcopyinfo')) { - toast.dismiss('workingcopyinfo'); - } + } + if (!working_copy) { + if (toast.isActive('workingcopyinfo')) { + toast.dismiss('workingcopyinfo'); } } }, [pathname, content, title, working_copy, intl, lang, dateOptions]); diff --git a/packages/volto/src/config/index.js b/packages/volto/src/config/index.js index 0c8f57d0b6..27fc225463 100644 --- a/packages/volto/src/config/index.js +++ b/packages/volto/src/config/index.js @@ -163,7 +163,6 @@ let config = { showSelfRegistration: false, contentMetadataTagsImageField: 'image', contentPropertiesSchemaEnhancer: null, - hasWorkingCopySupport: false, maxUndoLevels: 200, // undo history size for the main form addonsInfo: addonsInfo, workflowMapping,