From de02d2dc73e437c34cba2499dafa36d1ba4f5b99 Mon Sep 17 00:00:00 2001 From: Tiberiu Ichim Date: Tue, 10 Jan 2023 18:16:54 +0200 Subject: [PATCH 01/53] Checkpoint --- src/components/index.js | 1 + src/components/manage/Form/Form.jsx | 24 +++++++++++- src/components/manage/Form/SaveAsDraft.jsx | 43 ++++++++++++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 src/components/manage/Form/SaveAsDraft.jsx diff --git a/src/components/index.js b/src/components/index.js index eec24b73a0..389b879112 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -126,6 +126,7 @@ export ManageTranslations from '@plone/volto/components/manage/Multilingual/Mana export Form from '@plone/volto/components/manage/Form/Form'; export BlocksToolbar from '@plone/volto/components/manage/Form/BlocksToolbar'; export UndoToolbar from '@plone/volto/components/manage/Form/UndoToolbar'; +export SaveAsDraft from '@plone/volto/components/manage/Form/SaveAsDraft'; export Field from '@plone/volto/components/manage/Form/Field'; export SearchTags from '@plone/volto/components/theme/Search/SearchTags'; export CommentEditModal from '@plone/volto/components/theme/Comments/CommentEditModal'; diff --git a/src/components/manage/Form/Form.jsx b/src/components/manage/Form/Form.jsx index b8093386cd..6dc932a056 100644 --- a/src/components/manage/Form/Form.jsx +++ b/src/components/manage/Form/Form.jsx @@ -39,11 +39,20 @@ import { } from 'semantic-ui-react'; import { v4 as uuid } from 'uuid'; import { toast } from 'react-toastify'; -import { BlocksToolbar, UndoToolbar } from '@plone/volto/components'; +import { + BlocksToolbar, + UndoToolbar, + SaveAsDraft, +} from '@plone/volto/components'; import { setSidebarTab } from '@plone/volto/actions'; import { compose } from 'redux'; import config from '@plone/volto/registry'; +export function getFormId(props) { + const { isEditForm, pathname, type } = props; + return isEditForm ? `form-edit-${pathname}` : `form-other-${type}`; +} + /** * Form container class. * @class Form @@ -560,6 +569,19 @@ class Form extends Component { } onSelectBlock={this.onSelectBlock} /> + {!!this.props.type && ( + + this.setState({ + formData: state, + selected: null, + multiSelected: null, + }) + } + /> + )} { + const jstate = JSON.stringify(state); + if (!checked) { + // on mount, we check if saved session exists + setChecked(true); + const saved = sessionStorage.getItem(id); + console.log('saved', saved); + if (saved !== state) { + // eslint-disable-next-line no-alert + const load = window.confirm('Autosave found, load it?'); + if (load) { + onRestore(JSON.parse(saved)); + } else { + sessionStorage.removeItem(id); + } + } + } else { + ref.current && clearTimeout(ref.current); + ref.current = setTimeout(() => { + sessionStorage.setItem(id, JSON.stringify(state)); + }, 300); + } + return () => { + const saved = sessionStorage.getItem(id); + if (saved !== jstate) { + sessionStorage.setItem(id, JSON.stringify(state)); + } + ref.current && clearTimeout(ref.current); + }; + }, [state, id, checked, onRestore]); + + return null; +} From aa9fbb760e8760992a1da822b1e278a4b058d5f1 Mon Sep 17 00:00:00 2001 From: Tiberiu Ichim Date: Tue, 10 Jan 2023 18:32:19 +0200 Subject: [PATCH 02/53] Checkpoint --- src/components/manage/Form/Form.jsx | 18 +++++++++++++----- src/components/manage/Form/SaveAsDraft.jsx | 2 +- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/components/manage/Form/Form.jsx b/src/components/manage/Form/Form.jsx index 6dc932a056..0f00229ae4 100644 --- a/src/components/manage/Form/Form.jsx +++ b/src/components/manage/Form/Form.jsx @@ -543,7 +543,15 @@ class Form extends Component { */ render() { const { settings } = config; - const { schema: originalSchema, onCancel, onSubmit } = this.props; + const { + schema: originalSchema, + onCancel, + onSubmit, + isEditForm, + pathname, + type, + } = this.props; + const enableSaveDraft = !!type && isEditForm; const { formData } = this.state; const schema = this.removeBlocksLayoutFields(originalSchema); @@ -569,15 +577,15 @@ class Form extends Component { } onSelectBlock={this.onSelectBlock} /> - {!!this.props.type && ( + {enableSaveDraft && ( this.setState({ formData: state, - selected: null, - multiSelected: null, + selected: [], + multiSelected: [], }) } /> diff --git a/src/components/manage/Form/SaveAsDraft.jsx b/src/components/manage/Form/SaveAsDraft.jsx index fd55b825b6..f0555f3f63 100644 --- a/src/components/manage/Form/SaveAsDraft.jsx +++ b/src/components/manage/Form/SaveAsDraft.jsx @@ -15,7 +15,7 @@ export default function SaveAsDraft(props) { setChecked(true); const saved = sessionStorage.getItem(id); console.log('saved', saved); - if (saved !== state) { + if (saved && saved !== state) { // eslint-disable-next-line no-alert const load = window.confirm('Autosave found, load it?'); if (load) { From 4ad4b424f42de4dfcbdaef238ff2b75c5dc59ef7 Mon Sep 17 00:00:00 2001 From: Tiberiu Ichim Date: Wed, 11 Jan 2023 11:43:55 +0200 Subject: [PATCH 03/53] Use localStorage --- src/components/manage/Form/Form.jsx | 14 ++++++-------- src/components/manage/Form/SaveAsDraft.jsx | 10 +++++----- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/components/manage/Form/Form.jsx b/src/components/manage/Form/Form.jsx index 0f00229ae4..1b73e0a415 100644 --- a/src/components/manage/Form/Form.jsx +++ b/src/components/manage/Form/Form.jsx @@ -3,6 +3,7 @@ * @module components/manage/Form/Form */ +import isEqual from 'react-fast-compare'; import { BlocksForm, Field, Icon, Toast } from '@plone/volto/components'; import { difference, @@ -248,14 +249,11 @@ class Form extends Component { }); } - if (this.props.onChangeFormData) { - if ( - // TODO: use fast-deep-equal - JSON.stringify(prevState?.formData) !== - JSON.stringify(this.state.formData) - ) { - this.props.onChangeFormData(this.state.formData); - } + if ( + this.props.onChangeFormData && + !isEqual(prevState?.formData, this.state.formData) + ) { + this.props.onChangeFormData(this.state.formData); } } diff --git a/src/components/manage/Form/SaveAsDraft.jsx b/src/components/manage/Form/SaveAsDraft.jsx index f0555f3f63..5ddada12e6 100644 --- a/src/components/manage/Form/SaveAsDraft.jsx +++ b/src/components/manage/Form/SaveAsDraft.jsx @@ -13,7 +13,7 @@ export default function SaveAsDraft(props) { if (!checked) { // on mount, we check if saved session exists setChecked(true); - const saved = sessionStorage.getItem(id); + const saved = localStorage.getItem(id); console.log('saved', saved); if (saved && saved !== state) { // eslint-disable-next-line no-alert @@ -21,19 +21,19 @@ export default function SaveAsDraft(props) { if (load) { onRestore(JSON.parse(saved)); } else { - sessionStorage.removeItem(id); + localStorage.removeItem(id); } } } else { ref.current && clearTimeout(ref.current); ref.current = setTimeout(() => { - sessionStorage.setItem(id, JSON.stringify(state)); + localStorage.setItem(id, JSON.stringify(state)); }, 300); } return () => { - const saved = sessionStorage.getItem(id); + const saved = localStorage.getItem(id); if (saved !== jstate) { - sessionStorage.setItem(id, JSON.stringify(state)); + localStorage.setItem(id, JSON.stringify(state)); } ref.current && clearTimeout(ref.current); }; From a622d7fc17ea0f40075116fa415ffe3c56ac7906 Mon Sep 17 00:00:00 2001 From: Tiberiu Ichim Date: Wed, 11 Jan 2023 17:01:26 +0200 Subject: [PATCH 04/53] Checkpoint --- src/components/manage/Form/Form.jsx | 51 ++++---- src/components/manage/Form/SaveAsDraft.jsx | 132 ++++++++++++++------- 2 files changed, 112 insertions(+), 71 deletions(-) diff --git a/src/components/manage/Form/Form.jsx b/src/components/manage/Form/Form.jsx index 1b73e0a415..b2fc2cd0df 100644 --- a/src/components/manage/Form/Form.jsx +++ b/src/components/manage/Form/Form.jsx @@ -40,19 +40,12 @@ import { } from 'semantic-ui-react'; import { v4 as uuid } from 'uuid'; import { toast } from 'react-toastify'; -import { - BlocksToolbar, - UndoToolbar, - SaveAsDraft, -} from '@plone/volto/components'; +import { BlocksToolbar, UndoToolbar } from '@plone/volto/components'; import { setSidebarTab } from '@plone/volto/actions'; import { compose } from 'redux'; import config from '@plone/volto/registry'; -export function getFormId(props) { - const { isEditForm, pathname, type } = props; - return isEditForm ? `form-edit-${pathname}` : `form-other-${type}`; -} +import withSaveAsDraft from './SaveAsDraft'; /** * Form container class. @@ -230,6 +223,16 @@ class Form extends Component { * @param {Object} prevProps */ async componentDidUpdate(prevProps, prevState) { + // schema was just received async and plugged as prop + if (!prevProps.schema && this.props.schema) { + const oldFormData = this.props.checkSavedDraft(this.state.formData); + + if (oldFormData) { + this.setState({ formData: oldFormData }); + } + return; + } + let { requestError } = this.props; let errors = {}; let activeIndex = 0; @@ -255,6 +258,7 @@ class Form extends Component { ) { this.props.onChangeFormData(this.state.formData); } + this.props.onSaveDraft(this.state.formData); } /** @@ -422,6 +426,7 @@ class Form extends Component { formData: this.props.formData, }); } + // this.props.onCancelDraft(); this.props.onCancel(event); } @@ -471,6 +476,9 @@ class Form extends Component { } else { // Get only the values that have been modified (Edit forms), send all in case that // it's an add form + + this.props.onCancelDraft(); + if (this.props.isEditForm) { this.props.onSubmit(this.getOnlyFormModifiedValues()); } else { @@ -541,15 +549,8 @@ class Form extends Component { */ render() { const { settings } = config; - const { - schema: originalSchema, - onCancel, - onSubmit, - isEditForm, - pathname, - type, - } = this.props; - const enableSaveDraft = !!type && isEditForm; + const { schema: originalSchema, onCancel, onSubmit } = this.props; + const { formData } = this.state; const schema = this.removeBlocksLayoutFields(originalSchema); @@ -575,19 +576,6 @@ class Form extends Component { } onSelectBlock={this.onSelectBlock} /> - {enableSaveDraft && ( - - this.setState({ - formData: state, - selected: [], - multiSelected: [], - }) - } - /> - )} { - const jstate = JSON.stringify(state); - if (!checked) { - // on mount, we check if saved session exists - setChecked(true); - const saved = localStorage.getItem(id); - console.log('saved', saved); - if (saved && saved !== state) { - // eslint-disable-next-line no-alert - const load = window.confirm('Autosave found, load it?'); - if (load) { - onRestore(JSON.parse(saved)); - } else { - localStorage.removeItem(id); - } - } - } else { - ref.current && clearTimeout(ref.current); - ref.current = setTimeout(() => { - localStorage.setItem(id, JSON.stringify(state)); - }, 300); +import hoistNonReactStatics from 'hoist-non-react-statics'; +import isEqual from 'react-fast-compare'; + +function getDisplayName(WrappedComponent) { + return WrappedComponent.displayName || WrappedComponent.name || 'Component'; +} + +const mapSchemaToData = (schema, data) => { + const dataKeys = Object.keys(data); + return Object.assign( + {}, + ...Object.keys(schema.properties) + .filter((k) => dataKeys.includes(k)) + .map((k) => ({ [k]: data[k] })), + ); +}; + +export default function withSaveAsDraft(options) { + const { forwardRef } = options; + + return (WrappedComponent) => { + function WithSaveAsDraft(props) { + const { type, pathname, schema, isEditForm } = props; + + const id = `form-edit-${type}-${pathname}`; + const ref = React.useRef(); + + const checkSavedDraft = React.useCallback( + (state) => { + if (!schema && !isEditForm) return; + const saved = localStorage.getItem(id); + if (saved) { + const formData = mapSchemaToData(schema, state); + const savedData = JSON.parse(saved); + console.log('saved', isEqual(formData, savedData)); + if (!isEqual(formData, savedData)) { + // eslint-disable-next-line no-alert + const rewrite = window.confirm('Autosave found, load it?'); + if (rewrite) { + localStorage.removeItem(id); + return savedData; + } else { + localStorage.removeItem(id); + } + } + } + }, + [id, schema, isEditForm], + ); + + const onSaveDraft = React.useCallback( + (state) => { + if (!schema) return; + ref.current && clearTimeout(ref.current); + ref.current = setTimeout(() => { + const formData = mapSchemaToData(schema, state); + localStorage.setItem(id, JSON.stringify(formData)); + }, 300); + }, + [id, schema], + ); + + const onCancelDraft = React.useCallback(() => { + if (!schema) return; + localStorage.removeItem(id); + }, [id, schema]); + + return ( + + ); } - return () => { - const saved = localStorage.getItem(id); - if (saved !== jstate) { - localStorage.setItem(id, JSON.stringify(state)); - } - ref.current && clearTimeout(ref.current); - }; - }, [state, id, checked, onRestore]); - - return null; + + WithSaveAsDraft.displayName = `WithSaveAsDraft(${getDisplayName( + WrappedComponent, + )})`; + + if (forwardRef) { + return hoistNonReactStatics( + React.forwardRef((props, ref) => ( + + )), + WrappedComponent, + ); + } + + return hoistNonReactStatics(WithSaveAsDraft, WrappedComponent); + }; } From 4c93dab09f6b1228df043b913be3944cbc12e0f0 Mon Sep 17 00:00:00 2001 From: Tiberiu Ichim Date: Wed, 11 Jan 2023 18:41:43 +0200 Subject: [PATCH 05/53] Checkpoint --- src/components/manage/Form/Form.jsx | 13 ++++++++++++- src/components/manage/Form/SaveAsDraft.jsx | 1 - 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/manage/Form/Form.jsx b/src/components/manage/Form/Form.jsx index b2fc2cd0df..c871cd82c7 100644 --- a/src/components/manage/Form/Form.jsx +++ b/src/components/manage/Form/Form.jsx @@ -258,7 +258,8 @@ class Form extends Component { ) { this.props.onChangeFormData(this.state.formData); } - this.props.onSaveDraft(this.state.formData); + + if (prevProps.schema) this.props.onSaveDraft(this.state.formData); } /** @@ -306,6 +307,16 @@ class Form extends Component { */ componentDidMount() { this.setState({ isClient: true }); + + // schema was just received async and plugged as prop + if (this.props.schema) { + const oldFormData = this.props.checkSavedDraft(this.state.formData); + + if (oldFormData) { + this.setState({ formData: oldFormData }); + } + return; + } } static getDerivedStateFromProps(props, state) { diff --git a/src/components/manage/Form/SaveAsDraft.jsx b/src/components/manage/Form/SaveAsDraft.jsx index 921ef21f1f..39168a9b68 100644 --- a/src/components/manage/Form/SaveAsDraft.jsx +++ b/src/components/manage/Form/SaveAsDraft.jsx @@ -33,7 +33,6 @@ export default function withSaveAsDraft(options) { if (saved) { const formData = mapSchemaToData(schema, state); const savedData = JSON.parse(saved); - console.log('saved', isEqual(formData, savedData)); if (!isEqual(formData, savedData)) { // eslint-disable-next-line no-alert const rewrite = window.confirm('Autosave found, load it?'); From 4c0ff4d8d7b9f3d2326f7830cc6948685c9e0f55 Mon Sep 17 00:00:00 2001 From: Tiberiu Ichim Date: Wed, 11 Jan 2023 19:47:53 +0200 Subject: [PATCH 06/53] Move hoc to helpers --- src/components/index.js | 1 - src/components/manage/Form/Form.jsx | 3 +-- .../Form/SaveAsDraft.jsx => helpers/Utils/saveAsDraft.js} | 2 +- src/helpers/index.js | 1 + 4 files changed, 3 insertions(+), 4 deletions(-) rename src/{components/manage/Form/SaveAsDraft.jsx => helpers/Utils/saveAsDraft.js} (98%) diff --git a/src/components/index.js b/src/components/index.js index 389b879112..eec24b73a0 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -126,7 +126,6 @@ export ManageTranslations from '@plone/volto/components/manage/Multilingual/Mana export Form from '@plone/volto/components/manage/Form/Form'; export BlocksToolbar from '@plone/volto/components/manage/Form/BlocksToolbar'; export UndoToolbar from '@plone/volto/components/manage/Form/UndoToolbar'; -export SaveAsDraft from '@plone/volto/components/manage/Form/SaveAsDraft'; export Field from '@plone/volto/components/manage/Form/Field'; export SearchTags from '@plone/volto/components/theme/Search/SearchTags'; export CommentEditModal from '@plone/volto/components/theme/Comments/CommentEditModal'; diff --git a/src/components/manage/Form/Form.jsx b/src/components/manage/Form/Form.jsx index c871cd82c7..f70504c75b 100644 --- a/src/components/manage/Form/Form.jsx +++ b/src/components/manage/Form/Form.jsx @@ -11,6 +11,7 @@ import { getBlocksFieldname, getBlocksLayoutFieldname, messages, + withSaveAsDraft, } from '@plone/volto/helpers'; import aheadSVG from '@plone/volto/icons/ahead.svg'; import clearSVG from '@plone/volto/icons/clear.svg'; @@ -45,8 +46,6 @@ import { setSidebarTab } from '@plone/volto/actions'; import { compose } from 'redux'; import config from '@plone/volto/registry'; -import withSaveAsDraft from './SaveAsDraft'; - /** * Form container class. * @class Form diff --git a/src/components/manage/Form/SaveAsDraft.jsx b/src/helpers/Utils/saveAsDraft.js similarity index 98% rename from src/components/manage/Form/SaveAsDraft.jsx rename to src/helpers/Utils/saveAsDraft.js index 39168a9b68..88294ce955 100644 --- a/src/components/manage/Form/SaveAsDraft.jsx +++ b/src/helpers/Utils/saveAsDraft.js @@ -16,7 +16,7 @@ const mapSchemaToData = (schema, data) => { ); }; -export default function withSaveAsDraft(options) { +export function withSaveAsDraft(options) { const { forwardRef } = options; return (WrappedComponent) => { diff --git a/src/helpers/index.js b/src/helpers/index.js index 7644f21041..0fec30bc9e 100644 --- a/src/helpers/index.js +++ b/src/helpers/index.js @@ -103,6 +103,7 @@ export { useDetectClickOutside } from './Utils/useDetectClickOutside'; export { useEvent } from './Utils/useEvent'; export { usePrevious } from './Utils/usePrevious'; export { usePagination } from './Utils/usePagination'; +export { withSaveAsDraft } from './Utils/saveAsDraft'; export useUndoManager from './UndoManager/useUndoManager'; export { getCookieOptions } from './Cookies/cookies'; export { getWidgetView } from './Widget/widget'; From 4fd716a7071be65e839333dc89e91534afae5e12 Mon Sep 17 00:00:00 2001 From: Tiberiu Ichim Date: Thu, 12 Jan 2023 09:29:40 +0200 Subject: [PATCH 07/53] Allow any form to be saved --- src/components/manage/Form/Form.jsx | 2 +- src/helpers/Utils/saveAsDraft.js | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/components/manage/Form/Form.jsx b/src/components/manage/Form/Form.jsx index f70504c75b..9899e95235 100644 --- a/src/components/manage/Form/Form.jsx +++ b/src/components/manage/Form/Form.jsx @@ -307,7 +307,7 @@ class Form extends Component { componentDidMount() { this.setState({ isClient: true }); - // schema was just received async and plugged as prop + // schema already exists in redux store if (this.props.schema) { const oldFormData = this.props.checkSavedDraft(this.state.formData); diff --git a/src/helpers/Utils/saveAsDraft.js b/src/helpers/Utils/saveAsDraft.js index 88294ce955..8878c48525 100644 --- a/src/helpers/Utils/saveAsDraft.js +++ b/src/helpers/Utils/saveAsDraft.js @@ -16,19 +16,31 @@ const mapSchemaToData = (schema, data) => { ); }; +const getFormId = (props) => { + const { type, pathname, isEditForm } = props; + + const id = isEditForm + ? ['form', type, pathname].join('-') + : type + ? ['form', 'add', type].join('-') + : ['form', pathname].join('-'); + + return id; +}; + export function withSaveAsDraft(options) { const { forwardRef } = options; return (WrappedComponent) => { function WithSaveAsDraft(props) { - const { type, pathname, schema, isEditForm } = props; + const { schema } = props; + const id = getFormId(props); - const id = `form-edit-${type}-${pathname}`; const ref = React.useRef(); const checkSavedDraft = React.useCallback( (state) => { - if (!schema && !isEditForm) return; + if (!schema) return; const saved = localStorage.getItem(id); if (saved) { const formData = mapSchemaToData(schema, state); @@ -45,7 +57,7 @@ export function withSaveAsDraft(options) { } } }, - [id, schema, isEditForm], + [id, schema], ); const onSaveDraft = React.useCallback( From 5db579834e9d66bfa5a84746efe71b60fad10687 Mon Sep 17 00:00:00 2001 From: Tiberiu Ichim Date: Thu, 12 Jan 2023 22:21:38 +0200 Subject: [PATCH 08/53] Simplify --- src/helpers/Utils/saveAsDraft.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/helpers/Utils/saveAsDraft.js b/src/helpers/Utils/saveAsDraft.js index 8878c48525..93c95e0879 100644 --- a/src/helpers/Utils/saveAsDraft.js +++ b/src/helpers/Utils/saveAsDraft.js @@ -48,12 +48,8 @@ export function withSaveAsDraft(options) { if (!isEqual(formData, savedData)) { // eslint-disable-next-line no-alert const rewrite = window.confirm('Autosave found, load it?'); - if (rewrite) { - localStorage.removeItem(id); - return savedData; - } else { - localStorage.removeItem(id); - } + localStorage.removeItem(id); + return rewrite ? savedData : null; } } }, From bdd7a6422ac982d83221b8109a120b90c30e93c2 Mon Sep 17 00:00:00 2001 From: Tiberiu Ichim Date: Thu, 12 Jan 2023 22:26:29 +0200 Subject: [PATCH 09/53] Don't lose data that's outside schema --- src/components/manage/Form/Form.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/components/manage/Form/Form.jsx b/src/components/manage/Form/Form.jsx index 9899e95235..856ab6477f 100644 --- a/src/components/manage/Form/Form.jsx +++ b/src/components/manage/Form/Form.jsx @@ -227,7 +227,9 @@ class Form extends Component { const oldFormData = this.props.checkSavedDraft(this.state.formData); if (oldFormData) { - this.setState({ formData: oldFormData }); + this.setState((state) => ({ + formData: { ...state.formData, ...oldFormData }, + })); } return; } @@ -312,7 +314,9 @@ class Form extends Component { const oldFormData = this.props.checkSavedDraft(this.state.formData); if (oldFormData) { - this.setState({ formData: oldFormData }); + this.setState((state) => ({ + formData: { ...state.formData, ...oldFormData }, + })); } return; } From 142146c7e8b3692dc9218440339c7c9d2c012412 Mon Sep 17 00:00:00 2001 From: Tiberiu Ichim Date: Thu, 12 Jan 2023 22:33:19 +0200 Subject: [PATCH 10/53] Simplify --- src/helpers/Utils/saveAsDraft.js | 63 +++++++++++++++----------------- 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/src/helpers/Utils/saveAsDraft.js b/src/helpers/Utils/saveAsDraft.js index 93c95e0879..b34b906a56 100644 --- a/src/helpers/Utils/saveAsDraft.js +++ b/src/helpers/Utils/saveAsDraft.js @@ -38,48 +38,43 @@ export function withSaveAsDraft(options) { const ref = React.useRef(); - const checkSavedDraft = React.useCallback( - (state) => { - if (!schema) return; - const saved = localStorage.getItem(id); - if (saved) { - const formData = mapSchemaToData(schema, state); - const savedData = JSON.parse(saved); - if (!isEqual(formData, savedData)) { - // eslint-disable-next-line no-alert - const rewrite = window.confirm('Autosave found, load it?'); - localStorage.removeItem(id); - return rewrite ? savedData : null; + const api = React.useMemo( + () => ({ + checkSavedDraft(state) { + if (!schema) return; + const saved = localStorage.getItem(id); + if (saved) { + const formData = mapSchemaToData(schema, state); + const savedData = JSON.parse(saved); + if (!isEqual(formData, savedData)) { + // eslint-disable-next-line no-alert + const rewrite = window.confirm('Autosave found, load it?'); + localStorage.removeItem(id); + return rewrite ? savedData : null; + } } - } - }, + }, + onSaveDraft(state) { + if (!schema) return; + ref.current && clearTimeout(ref.current); + ref.current = setTimeout(() => { + const formData = mapSchemaToData(schema, state); + localStorage.setItem(id, JSON.stringify(formData)); + }, 300); + }, + onCancelDraft() { + if (!schema) return; + localStorage.removeItem(id); + }, + }), [id, schema], ); - const onSaveDraft = React.useCallback( - (state) => { - if (!schema) return; - ref.current && clearTimeout(ref.current); - ref.current = setTimeout(() => { - const formData = mapSchemaToData(schema, state); - localStorage.setItem(id, JSON.stringify(formData)); - }, 300); - }, - [id, schema], - ); - - const onCancelDraft = React.useCallback(() => { - if (!schema) return; - localStorage.removeItem(id); - }, [id, schema]); - return ( ); } From ca0fe2e4433cf922bf53af0c720270a2ba7d1844 Mon Sep 17 00:00:00 2001 From: Tiberiu Ichim Date: Thu, 12 Jan 2023 22:38:09 +0200 Subject: [PATCH 11/53] Simplify --- src/helpers/Utils/saveAsDraft.js | 68 +++++++++++++++++--------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/src/helpers/Utils/saveAsDraft.js b/src/helpers/Utils/saveAsDraft.js index b34b906a56..2990dac99b 100644 --- a/src/helpers/Utils/saveAsDraft.js +++ b/src/helpers/Utils/saveAsDraft.js @@ -28,6 +28,37 @@ const getFormId = (props) => { return id; }; +const draftApi = (id, schema, timer) => ({ + checkSavedDraft(state) { + if (!schema) return; + const saved = localStorage.getItem(id); + if (saved) { + const formData = mapSchemaToData(schema, state); + const savedData = JSON.parse(saved); + if (!isEqual(formData, savedData)) { + // eslint-disable-next-line no-alert + const rewrite = window.confirm('Autosave found, load it?'); + localStorage.removeItem(id); + return rewrite ? savedData : null; + } + } + }, + + onSaveDraft(state) { + if (!schema) return; + timer.current && clearTimeout(timer.current); + timer.current = setTimeout(() => { + const formData = mapSchemaToData(schema, state); + localStorage.setItem(id, JSON.stringify(formData)); + }, 300); + }, + + onCancelDraft() { + if (!schema) return; + localStorage.removeItem(id); + }, +}); + export function withSaveAsDraft(options) { const { forwardRef } = options; @@ -35,40 +66,13 @@ export function withSaveAsDraft(options) { function WithSaveAsDraft(props) { const { schema } = props; const id = getFormId(props); - const ref = React.useRef(); - const api = React.useMemo( - () => ({ - checkSavedDraft(state) { - if (!schema) return; - const saved = localStorage.getItem(id); - if (saved) { - const formData = mapSchemaToData(schema, state); - const savedData = JSON.parse(saved); - if (!isEqual(formData, savedData)) { - // eslint-disable-next-line no-alert - const rewrite = window.confirm('Autosave found, load it?'); - localStorage.removeItem(id); - return rewrite ? savedData : null; - } - } - }, - onSaveDraft(state) { - if (!schema) return; - ref.current && clearTimeout(ref.current); - ref.current = setTimeout(() => { - const formData = mapSchemaToData(schema, state); - localStorage.setItem(id, JSON.stringify(formData)); - }, 300); - }, - onCancelDraft() { - if (!schema) return; - localStorage.removeItem(id); - }, - }), - [id, schema], - ); + const api = React.useMemo(() => draftApi(id, schema, ref), [ + id, + schema, + ref, + ]); return ( Date: Thu, 12 Jan 2023 22:39:16 +0200 Subject: [PATCH 12/53] Simplify --- src/helpers/Utils/saveAsDraft.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/helpers/Utils/saveAsDraft.js b/src/helpers/Utils/saveAsDraft.js index 2990dac99b..321e48ec41 100644 --- a/src/helpers/Utils/saveAsDraft.js +++ b/src/helpers/Utils/saveAsDraft.js @@ -67,12 +67,7 @@ export function withSaveAsDraft(options) { const { schema } = props; const id = getFormId(props); const ref = React.useRef(); - - const api = React.useMemo(() => draftApi(id, schema, ref), [ - id, - schema, - ref, - ]); + const api = React.useMemo(() => draftApi(id, schema, ref), [id, schema]); return ( Date: Wed, 28 Jun 2023 16:13:55 +0300 Subject: [PATCH 13/53] feat: check for stale data, intl messages, fix double mount bug, handle add new content, handle comments (#4903) --- locales/ca/LC_MESSAGES/volto.po | 18 ++ locales/de/LC_MESSAGES/volto.po | 18 ++ locales/en/LC_MESSAGES/volto.po | 18 ++ locales/es/LC_MESSAGES/volto.po | 18 ++ locales/eu/LC_MESSAGES/volto.po | 18 ++ locales/fi/LC_MESSAGES/volto.po | 18 ++ locales/fr/LC_MESSAGES/volto.po | 18 ++ locales/it/LC_MESSAGES/volto.po | 18 ++ locales/ja/LC_MESSAGES/volto.po | 18 ++ locales/nl/LC_MESSAGES/volto.po | 18 ++ locales/pt/LC_MESSAGES/volto.po | 18 ++ locales/pt_BR/LC_MESSAGES/volto.po | 18 ++ locales/ro/LC_MESSAGES/volto.po | 18 ++ locales/volto.pot | 20 +- locales/zh_CN/LC_MESSAGES/volto.po | 18 ++ news/4168.feature | 3 + src/components/manage/Form/Form.jsx | 44 ++-- src/components/manage/Form/Form.test.jsx | 39 +-- .../Form/__snapshots__/Form.test.jsx.snap | 139 +++++----- .../theme/Comments/Comments.test.jsx | 6 +- src/helpers/Utils/saveAsDraft.js | 169 +++++++++++- src/helpers/Utils/withSaveAsDraft.js | 244 ++++++++++++++++++ src/helpers/index.js | 3 +- theme/themes/pastanaga/extras/main.less | 16 ++ 24 files changed, 816 insertions(+), 119 deletions(-) create mode 100644 news/4168.feature create mode 100644 src/helpers/Utils/withSaveAsDraft.js diff --git a/locales/ca/LC_MESSAGES/volto.po b/locales/ca/LC_MESSAGES/volto.po index 4bf4b148d1..a0e28ab714 100644 --- a/locales/ca/LC_MESSAGES/volto.po +++ b/locales/ca/LC_MESSAGES/volto.po @@ -406,6 +406,12 @@ msgstr "Ascendent" msgid "Assignments" msgstr "" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Autosave found +msgid "Autosave found" +msgstr "" + #: components/manage/Controlpanels/AddonsControlpanel # defaultMessage: Available msgid "Available" @@ -1075,6 +1081,12 @@ msgstr "Realment voleu suprimir l'usuari {username}?" msgid "Do you really want to delete this item?" msgstr "Realment voleu suprimir aquest element?" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Do you want to load it? +msgid "Do you want to load it?" +msgstr "" + #: components/manage/Multilingual/TranslationObject #: components/manage/Sidebar/Sidebar # defaultMessage: Document @@ -3511,6 +3523,12 @@ msgstr "El procés de registre ha estat satisfactori. Si us plau, comproveu la v msgid "The site configuration is outdated and needs to be upgraded." msgstr "" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? +msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +msgstr "" + #: components/manage/Toolbar/More # defaultMessage: The working copy was discarded msgid "The working copy was discarded" diff --git a/locales/de/LC_MESSAGES/volto.po b/locales/de/LC_MESSAGES/volto.po index f316a86a30..23a5ea4993 100644 --- a/locales/de/LC_MESSAGES/volto.po +++ b/locales/de/LC_MESSAGES/volto.po @@ -403,6 +403,12 @@ msgstr "Aufsteigend" msgid "Assignments" msgstr "Zuweisungen" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Autosave found +msgid "Autosave found" +msgstr "" + #: components/manage/Controlpanels/AddonsControlpanel # defaultMessage: Available msgid "Available" @@ -1072,6 +1078,12 @@ msgstr "Möchten Sie den Nutzer {username} wirklich löschen?" msgid "Do you really want to delete this item?" msgstr "Möchten Sie den Artikel wirklich löschen?" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Do you want to load it? +msgid "Do you want to load it?" +msgstr "" + #: components/manage/Multilingual/TranslationObject #: components/manage/Sidebar/Sidebar # defaultMessage: Document @@ -3508,6 +3520,12 @@ msgstr "Bitte prüfen Sie Ihr E-Mail Postfach. Sie sollten eine E-Mail erhalten msgid "The site configuration is outdated and needs to be upgraded." msgstr "Die Seitenkonfiguration ist veraltet und muss aktualisiert werden." +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? +msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +msgstr "" + #: components/manage/Toolbar/More # defaultMessage: The working copy was discarded msgid "The working copy was discarded" diff --git a/locales/en/LC_MESSAGES/volto.po b/locales/en/LC_MESSAGES/volto.po index 08c9c94371..f5656dd4d9 100644 --- a/locales/en/LC_MESSAGES/volto.po +++ b/locales/en/LC_MESSAGES/volto.po @@ -397,6 +397,12 @@ msgstr "" msgid "Assignments" msgstr "" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Autosave found +msgid "Autosave found" +msgstr "" + #: components/manage/Controlpanels/AddonsControlpanel # defaultMessage: Available msgid "Available" @@ -1066,6 +1072,12 @@ msgstr "" msgid "Do you really want to delete this item?" msgstr "" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Do you want to load it? +msgid "Do you want to load it?" +msgstr "" + #: components/manage/Multilingual/TranslationObject #: components/manage/Sidebar/Sidebar # defaultMessage: Document @@ -3502,6 +3514,12 @@ msgstr "" msgid "The site configuration is outdated and needs to be upgraded." msgstr "" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? +msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +msgstr "" + #: components/manage/Toolbar/More # defaultMessage: The working copy was discarded msgid "The working copy was discarded" diff --git a/locales/es/LC_MESSAGES/volto.po b/locales/es/LC_MESSAGES/volto.po index 6d18f20d8c..11913ade30 100644 --- a/locales/es/LC_MESSAGES/volto.po +++ b/locales/es/LC_MESSAGES/volto.po @@ -408,6 +408,12 @@ msgstr "Ascendente" msgid "Assignments" msgstr "Tareas" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Autosave found +msgid "Autosave found" +msgstr "" + #: components/manage/Controlpanels/AddonsControlpanel # defaultMessage: Available msgid "Available" @@ -1077,6 +1083,12 @@ msgstr "¿Esta seguro que quiere eliminar el usuario {username}?" msgid "Do you really want to delete this item?" msgstr "¿Usted realmente quiere eliminar este elemento?" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Do you want to load it? +msgid "Do you want to load it?" +msgstr "" + #: components/manage/Multilingual/TranslationObject #: components/manage/Sidebar/Sidebar # defaultMessage: Document @@ -3513,6 +3525,12 @@ msgstr "El registro fue exitoso. Por favor, verifique su bandeja de entrada para msgid "The site configuration is outdated and needs to be upgraded." msgstr "La configuración del sitio está anticuada y debe ser actualizada." +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? +msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +msgstr "" + #: components/manage/Toolbar/More # defaultMessage: The working copy was discarded msgid "The working copy was discarded" diff --git a/locales/eu/LC_MESSAGES/volto.po b/locales/eu/LC_MESSAGES/volto.po index 6f2565e6d5..7ff268a583 100644 --- a/locales/eu/LC_MESSAGES/volto.po +++ b/locales/eu/LC_MESSAGES/volto.po @@ -404,6 +404,12 @@ msgstr "Goraka" msgid "Assignments" msgstr "Esleipenak" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Autosave found +msgid "Autosave found" +msgstr "" + #: components/manage/Controlpanels/AddonsControlpanel # defaultMessage: Available msgid "Available" @@ -1073,6 +1079,12 @@ msgstr "{username} erabiltzailea ezabatu egin nahi duzu?" msgid "Do you really want to delete this item?" msgstr "Elementu hau ezabatu egin nahi duzu?" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Do you want to load it? +msgid "Do you want to load it?" +msgstr "" + #: components/manage/Multilingual/TranslationObject #: components/manage/Sidebar/Sidebar # defaultMessage: Document @@ -3509,6 +3521,12 @@ msgstr "Izen-emate prozesua ondo egin duzu. Begiratu zure eposta, kontua aktibat msgid "The site configuration is outdated and needs to be upgraded." msgstr "Atariaren konfigurazioa zaharkituta dago eta eguneratu egin behar da." +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? +msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +msgstr "" + #: components/manage/Toolbar/More # defaultMessage: The working copy was discarded msgid "The working copy was discarded" diff --git a/locales/fi/LC_MESSAGES/volto.po b/locales/fi/LC_MESSAGES/volto.po index 791c210c1e..6cfe6baffa 100644 --- a/locales/fi/LC_MESSAGES/volto.po +++ b/locales/fi/LC_MESSAGES/volto.po @@ -408,6 +408,12 @@ msgstr "Nouseva" msgid "Assignments" msgstr "Tehtävät" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Autosave found +msgid "Autosave found" +msgstr "" + #: components/manage/Controlpanels/AddonsControlpanel # defaultMessage: Available msgid "Available" @@ -1077,6 +1083,12 @@ msgstr "Haluatko varmasti poistaa käyttäjän {username}?" msgid "Do you really want to delete this item?" msgstr "Haluatko varmasti poistaa tämän sisällön?" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Do you want to load it? +msgid "Do you want to load it?" +msgstr "" + #: components/manage/Multilingual/TranslationObject #: components/manage/Sidebar/Sidebar # defaultMessage: Document @@ -3513,6 +3525,12 @@ msgstr "Rekisteröinti onnistui. Tarkista, saitko sähköpostiisi ohjeet käytt msgid "The site configuration is outdated and needs to be upgraded." msgstr "Sivuston konfiguraatio on vanhentunut ja se pitää päivittää." +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? +msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +msgstr "" + #: components/manage/Toolbar/More # defaultMessage: The working copy was discarded msgid "The working copy was discarded" diff --git a/locales/fr/LC_MESSAGES/volto.po b/locales/fr/LC_MESSAGES/volto.po index c4a007b100..adcd55957d 100644 --- a/locales/fr/LC_MESSAGES/volto.po +++ b/locales/fr/LC_MESSAGES/volto.po @@ -414,6 +414,12 @@ msgstr "Ascendant" msgid "Assignments" msgstr "Affectations" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Autosave found +msgid "Autosave found" +msgstr "" + #: components/manage/Controlpanels/AddonsControlpanel # defaultMessage: Available msgid "Available" @@ -1083,6 +1089,12 @@ msgstr "Voulez-vous vraiment supprimer l'utilisateur {username} ?" msgid "Do you really want to delete this item?" msgstr "Voulez-vous vraiment supprimer cet élément ?" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Do you want to load it? +msgid "Do you want to load it?" +msgstr "" + #: components/manage/Multilingual/TranslationObject #: components/manage/Sidebar/Sidebar # defaultMessage: Document @@ -3519,6 +3531,12 @@ msgstr "Le processus d'inscription a réussi. Veuillez vérifier votre boîte e- msgid "The site configuration is outdated and needs to be upgraded." msgstr "La configuration du site nécessite une mise à niveau." +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? +msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +msgstr "" + #: components/manage/Toolbar/More # defaultMessage: The working copy was discarded msgid "The working copy was discarded" diff --git a/locales/it/LC_MESSAGES/volto.po b/locales/it/LC_MESSAGES/volto.po index d63d8a20f0..5f87eaa90f 100644 --- a/locales/it/LC_MESSAGES/volto.po +++ b/locales/it/LC_MESSAGES/volto.po @@ -397,6 +397,12 @@ msgstr "Crescente" msgid "Assignments" msgstr "" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Autosave found +msgid "Autosave found" +msgstr "" + #: components/manage/Controlpanels/AddonsControlpanel # defaultMessage: Available msgid "Available" @@ -1066,6 +1072,12 @@ msgstr "Vuoi veramente eliminare l'utente {username}?" msgid "Do you really want to delete this item?" msgstr "Vuoi veramente eliminare questo elemento?" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Do you want to load it? +msgid "Do you want to load it?" +msgstr "" + #: components/manage/Multilingual/TranslationObject #: components/manage/Sidebar/Sidebar # defaultMessage: Document @@ -3502,6 +3514,12 @@ msgstr "La registrazione è avvenuta correttamente. Per favore controlla la tua msgid "The site configuration is outdated and needs to be upgraded." msgstr "" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? +msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +msgstr "" + #: components/manage/Toolbar/More # defaultMessage: The working copy was discarded msgid "The working copy was discarded" diff --git a/locales/ja/LC_MESSAGES/volto.po b/locales/ja/LC_MESSAGES/volto.po index a8a6fbea17..e084736c0c 100644 --- a/locales/ja/LC_MESSAGES/volto.po +++ b/locales/ja/LC_MESSAGES/volto.po @@ -405,6 +405,12 @@ msgstr "昇順" msgid "Assignments" msgstr "" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Autosave found +msgid "Autosave found" +msgstr "" + #: components/manage/Controlpanels/AddonsControlpanel # defaultMessage: Available msgid "Available" @@ -1074,6 +1080,12 @@ msgstr "ユーザ {username} を削除してよろしいですか?" msgid "Do you really want to delete this item?" msgstr "このアイテムを削除してよろしいですか?" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Do you want to load it? +msgid "Do you want to load it?" +msgstr "" + #: components/manage/Multilingual/TranslationObject #: components/manage/Sidebar/Sidebar # defaultMessage: Document @@ -3510,6 +3522,12 @@ msgstr "The registration process has been successful. Please check your e-mail i msgid "The site configuration is outdated and needs to be upgraded." msgstr "" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? +msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +msgstr "" + #: components/manage/Toolbar/More # defaultMessage: The working copy was discarded msgid "The working copy was discarded" diff --git a/locales/nl/LC_MESSAGES/volto.po b/locales/nl/LC_MESSAGES/volto.po index e575532f1a..2c7aab5b33 100644 --- a/locales/nl/LC_MESSAGES/volto.po +++ b/locales/nl/LC_MESSAGES/volto.po @@ -416,6 +416,12 @@ msgstr "Oplopend" msgid "Assignments" msgstr "" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Autosave found +msgid "Autosave found" +msgstr "" + #: components/manage/Controlpanels/AddonsControlpanel # defaultMessage: Available msgid "Available" @@ -1085,6 +1091,12 @@ msgstr "" msgid "Do you really want to delete this item?" msgstr "Weet u zeker dat u dit item wilt verwijderen?" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Do you want to load it? +msgid "Do you want to load it?" +msgstr "" + #: components/manage/Multilingual/TranslationObject #: components/manage/Sidebar/Sidebar # defaultMessage: Document @@ -3521,6 +3533,12 @@ msgstr "" msgid "The site configuration is outdated and needs to be upgraded." msgstr "" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? +msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +msgstr "" + #: components/manage/Toolbar/More # defaultMessage: The working copy was discarded msgid "The working copy was discarded" diff --git a/locales/pt/LC_MESSAGES/volto.po b/locales/pt/LC_MESSAGES/volto.po index 2f445ad4fd..0a8076c82c 100644 --- a/locales/pt/LC_MESSAGES/volto.po +++ b/locales/pt/LC_MESSAGES/volto.po @@ -405,6 +405,12 @@ msgstr "Ascendente" msgid "Assignments" msgstr "" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Autosave found +msgid "Autosave found" +msgstr "" + #: components/manage/Controlpanels/AddonsControlpanel # defaultMessage: Available msgid "Available" @@ -1074,6 +1080,12 @@ msgstr "Quer mesmo eliminar o utilizador {username}?" msgid "Do you really want to delete this item?" msgstr "Quer mesmo eliminar este item?" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Do you want to load it? +msgid "Do you want to load it?" +msgstr "" + #: components/manage/Multilingual/TranslationObject #: components/manage/Sidebar/Sidebar # defaultMessage: Document @@ -3510,6 +3522,12 @@ msgstr "O processo de registo foi bem sucedido. Por favor verifique no seu e-mai msgid "The site configuration is outdated and needs to be upgraded." msgstr "" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? +msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +msgstr "" + #: components/manage/Toolbar/More # defaultMessage: The working copy was discarded msgid "The working copy was discarded" diff --git a/locales/pt_BR/LC_MESSAGES/volto.po b/locales/pt_BR/LC_MESSAGES/volto.po index bd0ee20da5..f5180488ff 100644 --- a/locales/pt_BR/LC_MESSAGES/volto.po +++ b/locales/pt_BR/LC_MESSAGES/volto.po @@ -407,6 +407,12 @@ msgstr "Ascendente" msgid "Assignments" msgstr "Atribuições" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Autosave found +msgid "Autosave found" +msgstr "" + #: components/manage/Controlpanels/AddonsControlpanel # defaultMessage: Available msgid "Available" @@ -1076,6 +1082,12 @@ msgstr "Você realmente quer excluir o usuário {username}?" msgid "Do you really want to delete this item?" msgstr "Você realmente quer excluir este item?" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Do you want to load it? +msgid "Do you want to load it?" +msgstr "" + #: components/manage/Multilingual/TranslationObject #: components/manage/Sidebar/Sidebar # defaultMessage: Document @@ -3512,6 +3524,12 @@ msgstr "O processo de registro foi bem sucedido. Verifique sua caixa de entrada msgid "The site configuration is outdated and needs to be upgraded." msgstr "A configuração do site está desatualizada e precisa ser atualizada." +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? +msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +msgstr "" + #: components/manage/Toolbar/More # defaultMessage: The working copy was discarded msgid "The working copy was discarded" diff --git a/locales/ro/LC_MESSAGES/volto.po b/locales/ro/LC_MESSAGES/volto.po index f2411286fc..884a82fa59 100644 --- a/locales/ro/LC_MESSAGES/volto.po +++ b/locales/ro/LC_MESSAGES/volto.po @@ -397,6 +397,12 @@ msgstr "Crescător" msgid "Assignments" msgstr "" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Autosave found +msgid "Autosave found" +msgstr "" + #: components/manage/Controlpanels/AddonsControlpanel # defaultMessage: Available msgid "Available" @@ -1066,6 +1072,12 @@ msgstr "Doriți cu adevărat să ștergeți utilizatorul {username}?" msgid "Do you really want to delete this item?" msgstr "Doriți cu adevărat să ștergeți acest articol?" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Do you want to load it? +msgid "Do you want to load it?" +msgstr "" + #: components/manage/Multilingual/TranslationObject #: components/manage/Sidebar/Sidebar # defaultMessage: Document @@ -3502,6 +3514,12 @@ msgstr "Procesul de înregistrare a avut succes. Vă rugăm să verificați căs msgid "The site configuration is outdated and needs to be upgraded." msgstr "" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? +msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +msgstr "" + #: components/manage/Toolbar/More # defaultMessage: The working copy was discarded msgid "The working copy was discarded" diff --git a/locales/volto.pot b/locales/volto.pot index 7cb0cc5731..dd2c20fa40 100644 --- a/locales/volto.pot +++ b/locales/volto.pot @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: Plone\n" -"POT-Creation-Date: 2023-06-13T20:41:58.672Z\n" +"POT-Creation-Date: 2023-06-23T13:01:43.970Z\n" "Last-Translator: Plone i18n \n" "Language-Team: Plone i18n \n" "MIME-Version: 1.0\n" @@ -399,6 +399,12 @@ msgstr "" msgid "Assignments" msgstr "" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Autosave found +msgid "Autosave found" +msgstr "" + #: components/manage/Controlpanels/AddonsControlpanel # defaultMessage: Available msgid "Available" @@ -1068,6 +1074,12 @@ msgstr "" msgid "Do you really want to delete this item?" msgstr "" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Do you want to load it? +msgid "Do you want to load it?" +msgstr "" + #: components/manage/Multilingual/TranslationObject #: components/manage/Sidebar/Sidebar # defaultMessage: Document @@ -3504,6 +3516,12 @@ msgstr "" msgid "The site configuration is outdated and needs to be upgraded." msgstr "" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? +msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +msgstr "" + #: components/manage/Toolbar/More # defaultMessage: The working copy was discarded msgid "The working copy was discarded" diff --git a/locales/zh_CN/LC_MESSAGES/volto.po b/locales/zh_CN/LC_MESSAGES/volto.po index 98779199d8..3a4475ac5e 100644 --- a/locales/zh_CN/LC_MESSAGES/volto.po +++ b/locales/zh_CN/LC_MESSAGES/volto.po @@ -403,6 +403,12 @@ msgstr "上升" msgid "Assignments" msgstr "分配" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Autosave found +msgid "Autosave found" +msgstr "" + #: components/manage/Controlpanels/AddonsControlpanel # defaultMessage: Available msgid "Available" @@ -1072,6 +1078,12 @@ msgstr "确定要删除这个用户 {username}吗?" msgid "Do you really want to delete this item?" msgstr "确定要删除这个条目吗" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: Do you want to load it? +msgid "Do you want to load it?" +msgstr "" + #: components/manage/Multilingual/TranslationObject #: components/manage/Sidebar/Sidebar # defaultMessage: Document @@ -3508,6 +3520,12 @@ msgstr "注册过程成功完成。请在您的电子邮箱中查看有关如何 msgid "The site configuration is outdated and needs to be upgraded." msgstr "网站配置已过时,需要升级。" +#: helpers/Utils/saveAsDraft +#: helpers/Utils/withSaveAsDraft +# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? +msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +msgstr "" + #: components/manage/Toolbar/More # defaultMessage: The working copy was discarded msgid "The working copy was discarded" diff --git a/news/4168.feature b/news/4168.feature new file mode 100644 index 0000000000..ff2a7f54db --- /dev/null +++ b/news/4168.feature @@ -0,0 +1,3 @@ +Add Auto-Save option. It will save a copy of the form, even comments even for adding a new content item. It detects if local data is less recent than server data. +Saving the form will delete the local data for the specific form. +User can choose to not load the local data and this will also delete the local data. diff --git a/src/components/manage/Form/Form.jsx b/src/components/manage/Form/Form.jsx index a24449c474..ede15a59db 100644 --- a/src/components/manage/Form/Form.jsx +++ b/src/components/manage/Form/Form.jsx @@ -11,8 +11,8 @@ import { getBlocksFieldname, getBlocksLayoutFieldname, messages, - withSaveAsDraft, } from '@plone/volto/helpers'; +import withSaveAsDraft from '@plone/volto/helpers/Utils/withSaveAsDraft'; import aheadSVG from '@plone/volto/icons/ahead.svg'; import clearSVG from '@plone/volto/icons/clear.svg'; import { @@ -217,6 +217,18 @@ class Form extends Component { this.onTabChange = this.onTabChange.bind(this); this.onBlurField = this.onBlurField.bind(this); this.onClickInput = this.onClickInput.bind(this); + this.updateFormDataWithSaved = this.updateFormDataWithSaved.bind(this); + } + + /** + * Function sent as callback to saveAsDraft when user + * choses to load local data + * @param {Object} savedFormData + */ + updateFormDataWithSaved(savedFormData) { + if (savedFormData) { + this.setState({ formData: savedFormData }); + } } /** @@ -228,14 +240,10 @@ class Form extends Component { async componentDidUpdate(prevProps, prevState) { // schema was just received async and plugged as prop if (!prevProps.schema && this.props.schema) { - const oldFormData = this.props.checkSavedDraft(this.state.formData); - - if (oldFormData) { - this.setState((state) => ({ - formData: { ...state.formData, ...oldFormData }, - })); - } - return; + this.props.checkSavedDraft( + this.state.formData, + this.updateFormDataWithSaved, + ); } let { requestError } = this.props; @@ -264,7 +272,10 @@ class Form extends Component { this.props.onChangeFormData(this.state.formData); } - if (prevProps.schema) this.props.onSaveDraft(this.state.formData); + // on each formData update it will save the form to the localStorage + if (!isEqual(prevState?.formData, this.state.formData)) { + this.props.onSaveDraft(this.state.formData); + } } /** @@ -309,6 +320,8 @@ class Form extends Component { } } + // !! componentDidMount is called twice for Add + // first call will ignore are setState passed through callbacks /** * Component did mount * @method componentDidMount @@ -319,13 +332,10 @@ class Form extends Component { // schema already exists in redux store if (this.props.schema) { - const oldFormData = this.props.checkSavedDraft(this.state.formData); - - if (oldFormData) { - this.setState((state) => ({ - formData: { ...state.formData, ...oldFormData }, - })); - } + this.props.checkSavedDraft( + this.state.formData, + this.updateFormDataWithSaved, + ); return; } } diff --git a/src/components/manage/Form/Form.test.jsx b/src/components/manage/Form/Form.test.jsx index 16e2362b65..96165f1ff6 100644 --- a/src/components/manage/Form/Form.test.jsx +++ b/src/components/manage/Form/Form.test.jsx @@ -2,6 +2,7 @@ import React from 'react'; import renderer from 'react-test-renderer'; import configureStore from 'redux-mock-store'; import { Provider } from 'react-intl-redux'; +import { MemoryRouter } from 'react-router-dom'; import Form from './Form'; @@ -19,26 +20,30 @@ describe('Form', () => { messages: {}, }, }); + const route = '/some-route'; const component = renderer.create( -
+ {}} - onCancel={() => {}} - /> + required: [], + }} + requestError={errorMessage} + onSubmit={() => {}} + onCancel={() => {}} + /> + + , , ); const json = component.toJSON(); diff --git a/src/components/manage/Form/__snapshots__/Form.test.jsx.snap b/src/components/manage/Form/__snapshots__/Form.test.jsx.snap index 1cf0e7b027..47ab796dd8 100644 --- a/src/components/manage/Form/__snapshots__/Form.test.jsx.snap +++ b/src/components/manage/Form/__snapshots__/Form.test.jsx.snap @@ -1,84 +1,87 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Form renders a form component 1`] = ` -
- -
-
-
-
- - + viewBox="" + xmlns="" + /> + + +
-
-
- -
+ + + , + ",", +] `; diff --git a/src/components/theme/Comments/Comments.test.jsx b/src/components/theme/Comments/Comments.test.jsx index 3c05f87ada..eb0ed140a7 100644 --- a/src/components/theme/Comments/Comments.test.jsx +++ b/src/components/theme/Comments/Comments.test.jsx @@ -2,6 +2,7 @@ import React from 'react'; import renderer from 'react-test-renderer'; import configureStore from 'redux-mock-store'; import { Provider } from 'react-intl-redux'; +import { MemoryRouter } from 'react-router-dom'; import Comments from './Comments'; @@ -58,9 +59,12 @@ describe('Comments', () => { messages: {}, }, }); + const route = '/some-route'; const component = renderer.create( - + + + , ); const json = component.toJSON(); diff --git a/src/helpers/Utils/saveAsDraft.js b/src/helpers/Utils/saveAsDraft.js index 321e48ec41..1d03014c29 100644 --- a/src/helpers/Utils/saveAsDraft.js +++ b/src/helpers/Utils/saveAsDraft.js @@ -1,6 +1,29 @@ import React from 'react'; import hoistNonReactStatics from 'hoist-non-react-statics'; import isEqual from 'react-fast-compare'; +import { toast } from 'react-toastify'; +import { Toast, Icon } from '@plone/volto/components'; +import { Button } from 'semantic-ui-react'; +import checkSVG from '@plone/volto/icons/check.svg'; +import clearSVG from '@plone/volto/icons/clear.svg'; +import { useIntl, defineMessages } from 'react-intl'; + +const messages = defineMessages({ + autoSaveFound: { + id: 'Autosave found', + defaultMessage: 'Autosave found', + }, + loadData: { + id: 'Do you want to load it?', + defaultMessage: 'Do you want to load it?', + }, + loadExpiredData: { + id: + 'The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?', + defaultMessage: + 'The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?', + }, +}); function getDisplayName(WrappedComponent) { return WrappedComponent.displayName || WrappedComponent.name || 'Component'; @@ -16,46 +39,158 @@ const mapSchemaToData = (schema, data) => { ); }; +// will be used to avoid using the first mount call if there is a second call +let mountTime; + const getFormId = (props) => { const { type, pathname, isEditForm } = props; - const id = isEditForm ? ['form', type, pathname].join('-') : type - ? ['form', 'add', type].join('-') + ? ['form', pathname, type].join('-') : ['form', pathname].join('-'); return id; }; -const draftApi = (id, schema, timer) => ({ - checkSavedDraft(state) { +/** + * Toast content that has OK and Cancel buttons + * @param {function} onUpdate + * @param {function} onClose + * @param {string} userMessage + * @returns + */ +const ConfirmAutoSave = ({ onUpdate, onClose, userMessage }) => { + const handleClickOK = () => onUpdate(); + const handleClickCancel = () => onClose(); + + return ( +
+
{userMessage}
+ + +
+ ); +}; + +/** + * Will remove localStorage item using debounce + * @param {string} id + * @param {number} timerForDeletion + */ +const clearStorage = (id, timerForDeletion) => { + timerForDeletion.current && clearTimeout(timerForDeletion.current); + timerForDeletion.current = setTimeout(() => { + localStorage.removeItem(id); + }, 500); +}; + +/** + * Stale if server date is more recent + * @param {string} serverModifiedDate + * @param {string} autoSaveDate + * @returns {Boolean} + */ +const autoSaveFoundIsStale = (serverModifiedDate, autoSaveDate) => { + const result = !serverModifiedDate + ? false + : new Date(serverModifiedDate) > new Date(autoSaveDate); + return result; +}; + +const draftApi = (id, schema, timer, timerForDeletion, intl) => ({ + // - since Add Content Type will call componentDidMount twice, we will + // use the second call (using debounce)- the first will ignore any setState comands; + // - Delete local data only if user confirms Cancel + // - Will tell user that it has local stored data, even if its less recent than the server data + checkSavedDraft(state, updateCallback) { if (!schema) return; const saved = localStorage.getItem(id); + if (saved) { const formData = mapSchemaToData(schema, state); - const savedData = JSON.parse(saved); - if (!isEqual(formData, savedData)) { + // includes autoSaveDate + const foundSavedData = JSON.parse(saved); + // includes only form data found in schema (no autoSaveDate) + const foundSavedSchemaData = mapSchemaToData(schema, foundSavedData); + + if (!isEqual(formData, foundSavedSchemaData)) { // eslint-disable-next-line no-alert - const rewrite = window.confirm('Autosave found, load it?'); - localStorage.removeItem(id); - return rewrite ? savedData : null; + // cancel existing setTimeout to avoid using first call if + // successive calls are made + mountTime && clearTimeout(mountTime); + mountTime = setTimeout(() => { + toast.info( + updateCallback(foundSavedSchemaData)} + onClose={() => clearStorage(id, timerForDeletion)} + userMessage={ + autoSaveFoundIsStale( + state.modified, + foundSavedData.autoSaveDate, + ) + ? intl.formatMessage(messages.loadExpiredData) + : intl.formatMessage(messages.loadData) + } + /> + } + />, + ); + }, 300); } } }, - + // use debounce mode onSaveDraft(state) { if (!schema) return; timer.current && clearTimeout(timer.current); timer.current = setTimeout(() => { const formData = mapSchemaToData(schema, state); - localStorage.setItem(id, JSON.stringify(formData)); + const saved = localStorage.getItem(id); + const newData = JSON.parse(saved); + + localStorage.setItem( + id, + JSON.stringify({ + ...newData, + ...formData, + autoSaveDate: new Date(), + }), + ); }, 300); }, onCancelDraft() { if (!schema) return; - localStorage.removeItem(id); + clearStorage(id, timerForDeletion); }, }); @@ -65,9 +200,17 @@ export function withSaveAsDraft(options) { return (WrappedComponent) => { function WithSaveAsDraft(props) { const { schema } = props; + const intl = useIntl(); const id = getFormId(props); const ref = React.useRef(); - const api = React.useMemo(() => draftApi(id, schema, ref), [id, schema]); + const ref2 = React.useRef(); + const api = React.useMemo(() => draftApi(id, schema, ref, ref2, intl), [ + id, + schema, + ref, + ref2, + intl, + ]); return ( { + if (!data) return {}; + const dataKeys = Object.keys(data); + return Object.assign( + {}, + ...Object.keys(schema.properties) + .filter((k) => dataKeys.includes(k)) + .map((k) => ({ [k]: data[k] })), + ); +}; + +// will be used to avoid using the first mount call if there is a second call +let mountTime; + +const getFormId = (props, location) => { + const { type, pathname = location.pathname, isEditForm, schema } = props; + const id = isEditForm + ? ['form', type, pathname].join('-') + : type + ? ['form', pathname, type].join('-') + : schema?.properties?.comment + ? ['form', pathname, 'comment'].join('-') + : ['form', pathname].join('-'); + + return id; +}; + +/** + * Toast content that has OK and Cancel buttons + * @param {function} onUpdate + * @param {function} onClose + * @param {string} userMessage + * @returns + */ +const ConfirmAutoSave = ({ onUpdate, onClose, userMessage }) => { + const handleClickOK = () => onUpdate(); + const handleClickCancel = () => onClose(); + + return ( +
+
{userMessage}
+ + +
+ ); +}; + +/** + * Will remove localStorage item using debounce + * @param {string} id + * @param {number} timerForDeletion + */ +const clearStorage = (id, timerForDeletion) => { + timerForDeletion.current && clearTimeout(timerForDeletion.current); + timerForDeletion.current = setTimeout(() => { + localStorage.removeItem(id); + }, 500); +}; + +/** + * Stale if server date is more recent + * @param {string} serverModifiedDate + * @param {string} autoSaveDate + * @returns {Boolean} + */ +const autoSaveFoundIsStale = (serverModifiedDate, autoSaveDate) => { + const result = !serverModifiedDate + ? false + : new Date(serverModifiedDate) > new Date(autoSaveDate); + return result; +}; + +const draftApi = (id, schema, timer, timerForDeletion, intl) => ({ + // - since Add Content Type will call componentDidMount twice, we will + // use the second call (using debounce)- the first will ignore any setState comands; + // - Delete local data only if user confirms Cancel + // - Will tell user that it has local stored data, even if its less recent than the server data + checkSavedDraft(state, updateCallback) { + if (!schema) return; + const saved = localStorage.getItem(id); + + if (saved) { + const formData = mapSchemaToData(schema, state); + // includes autoSaveDate + const foundSavedData = JSON.parse(saved); + // includes only form data found in schema (no autoSaveDate) + const foundSavedSchemaData = mapSchemaToData(schema, foundSavedData); + + if (!isEqual(formData, foundSavedSchemaData)) { + // eslint-disable-next-line no-alert + // cancel existing setTimeout to avoid using first call if + // successive calls are made + mountTime && clearTimeout(mountTime); + mountTime = setTimeout(() => { + toast.info( + updateCallback(foundSavedSchemaData)} + onClose={() => clearStorage(id, timerForDeletion)} + userMessage={ + autoSaveFoundIsStale( + state.modified, + foundSavedData.autoSaveDate, + ) + ? intl.formatMessage(messages.loadExpiredData) + : intl.formatMessage(messages.loadData) + } + /> + } + />, + ); + }, 300); + } + } + }, + // use debounce mode + onSaveDraft(state) { + if (!schema) return; + timer.current && clearTimeout(timer.current); + timer.current = setTimeout(() => { + const formData = mapSchemaToData(schema, state); + const saved = localStorage.getItem(id); + const newData = JSON.parse(saved); + + localStorage.setItem( + id, + JSON.stringify({ + ...newData, + ...formData, + autoSaveDate: new Date(), + }), + ); + }, 300); + }, + + onCancelDraft() { + if (!schema) return; + clearStorage(id, timerForDeletion); + }, +}); + +export default function withSaveAsDraft(options) { + const { forwardRef } = options; + + return (WrappedComponent) => { + function WithSaveAsDraft(props) { + const { schema } = props; + const intl = useIntl(); + const location = useLocation(); + const id = getFormId(props, location); + const ref = React.useRef(); + const ref2 = React.useRef(); + const api = React.useMemo(() => draftApi(id, schema, ref, ref2, intl), [ + id, + schema, + ref, + ref2, + intl, + ]); + + return ( + + ); + } + + WithSaveAsDraft.displayName = `WithSaveAsDraft(${getDisplayName( + WrappedComponent, + )})`; + + if (forwardRef) { + return hoistNonReactStatics( + React.forwardRef((props, ref) => ( + + )), + WrappedComponent, + ); + } + + return hoistNonReactStatics(WithSaveAsDraft, WrappedComponent); + }; +} diff --git a/src/helpers/index.js b/src/helpers/index.js index 06881a5972..261c57f298 100644 --- a/src/helpers/index.js +++ b/src/helpers/index.js @@ -109,9 +109,8 @@ export { userHasRoles } from './User/User'; // export { injectLazyLibs } from './Loadable/Loadable'; export { useDetectClickOutside } from './Utils/useDetectClickOutside'; export { useEvent } from './Utils/useEvent'; -export { usePrevious } from './Utils/usePrevious'; export { usePagination } from './Utils/usePagination'; -export { withSaveAsDraft } from './Utils/saveAsDraft'; +export { usePrevious } from './Utils/usePrevious'; export useUndoManager from './UndoManager/useUndoManager'; export { getCookieOptions } from './Cookies/cookies'; export { getWidgetView } from './Widget/widget'; diff --git a/theme/themes/pastanaga/extras/main.less b/theme/themes/pastanaga/extras/main.less index 4d294b67ea..ec1ca0c624 100644 --- a/theme/themes/pastanaga/extras/main.less +++ b/theme/themes/pastanaga/extras/main.less @@ -389,6 +389,22 @@ button { } } +.toast-box-center { + display: flex; + align-items: center; + justify-content: center; + + .save.toast-box { + background: transparent; + color: #007eb1; + + .circled.toast-box-blue-icon { + color: #007eb1; + } + } +} + + .users-control-panel .table { overflow-x: scroll; From 8244b3234c08d4c2dfab5d24a56d14ff42cb73f1 Mon Sep 17 00:00:00 2001 From: ALEXANDRU MEDESAN Date: Thu, 29 Jun 2023 11:32:44 +0300 Subject: [PATCH 14/53] chore: helper index add usePrevious --- src/helpers/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/helpers/index.js b/src/helpers/index.js index b1cccd8813..633c3da5c1 100644 --- a/src/helpers/index.js +++ b/src/helpers/index.js @@ -110,6 +110,7 @@ export { userHasRoles } from './User/User'; // export { injectLazyLibs } from './Loadable/Loadable'; export { useDetectClickOutside } from './Utils/useDetectClickOutside'; export { useEvent } from './Utils/useEvent'; +export { usePrevious } from './Utils/usePrevious'; export { usePagination } from './Utils/usePagination'; export { default as useUndoManager } from './UndoManager/useUndoManager'; export { getCookieOptions } from './Cookies/cookies'; From 0bd277cc754676bcb837cd29b83b5e9154c67cdd Mon Sep 17 00:00:00 2001 From: ALEXANDRU MEDESAN Date: Thu, 29 Jun 2023 12:46:35 +0300 Subject: [PATCH 15/53] fix: force click blocks-grid --- cypress/tests/core/blocks/blocks-grid.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cypress/tests/core/blocks/blocks-grid.js b/cypress/tests/core/blocks/blocks-grid.js index 27c9190c4f..bb80e74ef3 100644 --- a/cypress/tests/core/blocks/blocks-grid.js +++ b/cypress/tests/core/blocks/blocks-grid.js @@ -44,7 +44,7 @@ context('Blocks Acceptance Tests', () => { cy.get('button[aria-label="Add block in position 1"]').click(); cy.get('.blocks-chooser [aria-label="Unfold Text blocks"]').click(); - cy.get('.blocks-chooser .text .button.slate').click(); + cy.get('.blocks-chooser .text .button.slate').click({ force: true }); cy.getSlateEditorSelectorAndType( '.block.gridBlock.selected .slate-editor [contenteditable=true]', 'Colorless green ideas sleep furiously.', @@ -86,7 +86,7 @@ context('Blocks Acceptance Tests', () => { cy.get('button[aria-label="Add block in position 1"]').click(); cy.get('.blocks-chooser [aria-label="Unfold Text blocks"]').click(); - cy.get('.blocks-chooser .text .button.slate').click(); + cy.get('.blocks-chooser .text .button.slate').click({ force: true }); cy.scrollTo('top'); cy.getSlateEditorSelectorAndType( From 48537532861fde8912184f90e200c52c10b09b14 Mon Sep 17 00:00:00 2001 From: ALEXANDRU MEDESAN Date: Tue, 4 Jul 2023 17:51:55 +0300 Subject: [PATCH 16/53] chore: remove old saveAsDraft file --- src/helpers/Utils/saveAsDraft.js | 239 ------------------------------- 1 file changed, 239 deletions(-) delete mode 100644 src/helpers/Utils/saveAsDraft.js diff --git a/src/helpers/Utils/saveAsDraft.js b/src/helpers/Utils/saveAsDraft.js deleted file mode 100644 index 1d03014c29..0000000000 --- a/src/helpers/Utils/saveAsDraft.js +++ /dev/null @@ -1,239 +0,0 @@ -import React from 'react'; -import hoistNonReactStatics from 'hoist-non-react-statics'; -import isEqual from 'react-fast-compare'; -import { toast } from 'react-toastify'; -import { Toast, Icon } from '@plone/volto/components'; -import { Button } from 'semantic-ui-react'; -import checkSVG from '@plone/volto/icons/check.svg'; -import clearSVG from '@plone/volto/icons/clear.svg'; -import { useIntl, defineMessages } from 'react-intl'; - -const messages = defineMessages({ - autoSaveFound: { - id: 'Autosave found', - defaultMessage: 'Autosave found', - }, - loadData: { - id: 'Do you want to load it?', - defaultMessage: 'Do you want to load it?', - }, - loadExpiredData: { - id: - 'The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?', - defaultMessage: - 'The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?', - }, -}); - -function getDisplayName(WrappedComponent) { - return WrappedComponent.displayName || WrappedComponent.name || 'Component'; -} - -const mapSchemaToData = (schema, data) => { - const dataKeys = Object.keys(data); - return Object.assign( - {}, - ...Object.keys(schema.properties) - .filter((k) => dataKeys.includes(k)) - .map((k) => ({ [k]: data[k] })), - ); -}; - -// will be used to avoid using the first mount call if there is a second call -let mountTime; - -const getFormId = (props) => { - const { type, pathname, isEditForm } = props; - const id = isEditForm - ? ['form', type, pathname].join('-') - : type - ? ['form', pathname, type].join('-') - : ['form', pathname].join('-'); - - return id; -}; - -/** - * Toast content that has OK and Cancel buttons - * @param {function} onUpdate - * @param {function} onClose - * @param {string} userMessage - * @returns - */ -const ConfirmAutoSave = ({ onUpdate, onClose, userMessage }) => { - const handleClickOK = () => onUpdate(); - const handleClickCancel = () => onClose(); - - return ( -
-
{userMessage}
- - -
- ); -}; - -/** - * Will remove localStorage item using debounce - * @param {string} id - * @param {number} timerForDeletion - */ -const clearStorage = (id, timerForDeletion) => { - timerForDeletion.current && clearTimeout(timerForDeletion.current); - timerForDeletion.current = setTimeout(() => { - localStorage.removeItem(id); - }, 500); -}; - -/** - * Stale if server date is more recent - * @param {string} serverModifiedDate - * @param {string} autoSaveDate - * @returns {Boolean} - */ -const autoSaveFoundIsStale = (serverModifiedDate, autoSaveDate) => { - const result = !serverModifiedDate - ? false - : new Date(serverModifiedDate) > new Date(autoSaveDate); - return result; -}; - -const draftApi = (id, schema, timer, timerForDeletion, intl) => ({ - // - since Add Content Type will call componentDidMount twice, we will - // use the second call (using debounce)- the first will ignore any setState comands; - // - Delete local data only if user confirms Cancel - // - Will tell user that it has local stored data, even if its less recent than the server data - checkSavedDraft(state, updateCallback) { - if (!schema) return; - const saved = localStorage.getItem(id); - - if (saved) { - const formData = mapSchemaToData(schema, state); - // includes autoSaveDate - const foundSavedData = JSON.parse(saved); - // includes only form data found in schema (no autoSaveDate) - const foundSavedSchemaData = mapSchemaToData(schema, foundSavedData); - - if (!isEqual(formData, foundSavedSchemaData)) { - // eslint-disable-next-line no-alert - // cancel existing setTimeout to avoid using first call if - // successive calls are made - mountTime && clearTimeout(mountTime); - mountTime = setTimeout(() => { - toast.info( - updateCallback(foundSavedSchemaData)} - onClose={() => clearStorage(id, timerForDeletion)} - userMessage={ - autoSaveFoundIsStale( - state.modified, - foundSavedData.autoSaveDate, - ) - ? intl.formatMessage(messages.loadExpiredData) - : intl.formatMessage(messages.loadData) - } - /> - } - />, - ); - }, 300); - } - } - }, - // use debounce mode - onSaveDraft(state) { - if (!schema) return; - timer.current && clearTimeout(timer.current); - timer.current = setTimeout(() => { - const formData = mapSchemaToData(schema, state); - const saved = localStorage.getItem(id); - const newData = JSON.parse(saved); - - localStorage.setItem( - id, - JSON.stringify({ - ...newData, - ...formData, - autoSaveDate: new Date(), - }), - ); - }, 300); - }, - - onCancelDraft() { - if (!schema) return; - clearStorage(id, timerForDeletion); - }, -}); - -export function withSaveAsDraft(options) { - const { forwardRef } = options; - - return (WrappedComponent) => { - function WithSaveAsDraft(props) { - const { schema } = props; - const intl = useIntl(); - const id = getFormId(props); - const ref = React.useRef(); - const ref2 = React.useRef(); - const api = React.useMemo(() => draftApi(id, schema, ref, ref2, intl), [ - id, - schema, - ref, - ref2, - intl, - ]); - - return ( - - ); - } - - WithSaveAsDraft.displayName = `WithSaveAsDraft(${getDisplayName( - WrappedComponent, - )})`; - - if (forwardRef) { - return hoistNonReactStatics( - React.forwardRef((props, ref) => ( - - )), - WrappedComponent, - ); - } - - return hoistNonReactStatics(WithSaveAsDraft, WrappedComponent); - }; -} From ace8963c9d83fe086ca42c25325ece49eb74804d Mon Sep 17 00:00:00 2001 From: ALEXANDRU MEDESAN Date: Wed, 5 Jul 2023 13:10:24 +0300 Subject: [PATCH 17/53] chore: fix comments --- src/components/manage/Form/Form.jsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/manage/Form/Form.jsx b/src/components/manage/Form/Form.jsx index ede15a59db..a0cec913a4 100644 --- a/src/components/manage/Form/Form.jsx +++ b/src/components/manage/Form/Form.jsx @@ -321,7 +321,8 @@ class Form extends Component { } // !! componentDidMount is called twice for Add - // first call will ignore are setState passed through callbacks + // setState passed through callback (updateFormDataWithSaved) is ignored for the first call + // only for the second call it will execute the setState /** * Component did mount * @method componentDidMount From 1190514e8a67c1163b5ee94a58766067d45d9299 Mon Sep 17 00:00:00 2001 From: ALEXANDRU MEDESAN Date: Wed, 5 Jul 2023 13:34:45 +0300 Subject: [PATCH 18/53] chore: add cypress test for autosave --- cypress/tests/core/basic/autosave.js | 235 +++++++++++++++++++++++++++ 1 file changed, 235 insertions(+) create mode 100644 cypress/tests/core/basic/autosave.js diff --git a/cypress/tests/core/basic/autosave.js b/cypress/tests/core/basic/autosave.js new file mode 100644 index 0000000000..3c06e27061 --- /dev/null +++ b/cypress/tests/core/basic/autosave.js @@ -0,0 +1,235 @@ +describe('createContent Tests', () => { + beforeEach(() => { + cy.autologin(); + cy.createContent({ + contentType: 'Document', + contentId: 'comments-page', + contentTitle: 'Comments Page', + allow_discussion: true, + }); + cy.setRegistry( + 'plone.app.discussion.interfaces.IDiscussionSettings.globally_enabled', + true, + ); + cy.createContent({ + contentType: 'Document', + contentId: 'my-first-page', + contentTitle: 'My First Page', + allow_discussion: true, + }); + cy.createContent({ + contentType: 'Document', + contentId: 'my-second-page', + contentTitle: 'My Second Page', + }); + }); + + it('As editor I can autosave when editing a content item', () => { + cy.visit('/my-first-page'); + cy.waitForResourceToLoad('@navigation'); + cy.waitForResourceToLoad('@breadcrumbs'); + cy.waitForResourceToLoad('@actions'); + cy.waitForResourceToLoad('@types'); + + cy.log('adding a text block on the first page'); + + cy.waitForResourceToLoad('my-first-page'); + cy.navigate('/my-first-page/edit'); + cy.getSlateEditorAndType('My first text').contains('My first text'); + cy.wait(1000); + + cy.visit('/my-second-page'); + cy.waitForResourceToLoad('@navigation'); + cy.waitForResourceToLoad('@breadcrumbs'); + cy.waitForResourceToLoad('@actions'); + cy.waitForResourceToLoad('@types'); + cy.waitForResourceToLoad('my-second-page'); + + cy.log('adding a text block on the second page'); + cy.navigate('/my-second-page/edit'); + + cy.getSlateEditorAndType('My second text').contains('My second text'); + cy.wait(1000); + + cy.log('visit first page and start editing'); + + cy.visit('/my-first-page'); + cy.navigate('/my-first-page/edit'); + cy.wait(1000); + + cy.findByRole('alert') + .get('.toast-inner-content') + .contains('Autosave found') + .get('button.ui.icon.button.save.toast-box') + .eq(0) + .click(); + + cy.wait(1000); + + cy.getSlate().contains('My first text'); + + cy.log('visit second page and start editing'); + + cy.visit('/my-second-page'); + cy.navigate('/my-second-page/edit'); + cy.wait(1000); + + cy.findByRole('alert') + .get('.toast-inner-content') + .contains('Autosave found') + .get('button.ui.icon.button.save.toast-box') + .eq(0) + .click(); + + cy.wait(1000); + + cy.getSlate().contains('My second text'); + cy.reload(); + + cy.log( + 'test is cancel load data will delete from storage (toast does not show)', + ); + cy.findByRole('alert') + .get('.toast-inner-content') + .contains('Autosave found') + .get('button.ui.icon.button.save.toast-box') + .eq(1) + .click(); + + cy.wait(1000); + cy.reload(); + + cy.wait(1000); + + cy.contains('Autosave found').should('not.exist'); + }); + + it('As editor I can autosave when adding a content item', function () { + cy.visit('/'); + + cy.log( + 'adding a Document content type and refresh to verify if content is autosaved and retrieved', + ); + cy.get('#toolbar-add').click().get('#toolbar-add-document').click(); + cy.getSlateTitle().type('Page 1 title'); + cy.getSlateEditorAndType('Page 1 content').contains('Page 1 content'); + cy.wait(1000); + cy.reload(); + + cy.log('test if autosaved toast shows retrieved data and click OK to load'); + cy.findByRole('alert') + .get('.toast-inner-content') + .contains('Autosave found') + .get('button.ui.icon.button.save.toast-box') + .eq(0) + .click(); + + cy.wait(1000); + + cy.log('test if autosaved data is loaded'); + cy.getSlateTitle().contains('Page 1 title'); + cy.getSlate().contains('Page 1 content'); + + cy.log( + 'test if draft is autosaved after I cancel adding a new page content type', + ); + + cy.get('button.button.cancel').click(); + + cy.wait(1000); + + cy.get('#toolbar-add').click().get('#toolbar-add-document').click(); + + cy.findByRole('alert') + .get('.toast-inner-content') + .contains('Autosave found') + .get('button.ui.icon.button.save.toast-box') + .eq(0) + .click(); + + cy.wait(1000); + cy.getSlateTitle().contains('Page 1 title'); + cy.getSlate().contains('Page 1 content'); + + cy.wait(1000); + + cy.log('test if page content type is added as new page after Toolbar Save'); + + cy.get('#toolbar-save').focus().click(); + cy.navigate('/page-1-title'); + cy.contains('Page 1 title'); + + cy.log('test draft is deleted from local storage after save'); + + cy.visit('/'); + cy.get('#toolbar-add').click().get('#toolbar-add-document').click(); + + cy.wait(1000); + + cy.contains('Autosave found').should('not.exist'); + }); + + it('As editor I can autosave comments', function () { + cy.log('adding a coment and refresh,'); + cy.visit('/comments-page'); + cy.get('textarea[id="field-comment"]').clear().type('This is a comment'); + cy.wait(1000); + cy.reload(); + + cy.log('test if comment is retrieved from local storage'); + + cy.findByRole('alert') + .get('.toast-inner-content') + .contains('Autosave found') + .get('button.ui.icon.button.save.toast-box') + .eq(0) + .click(); + + cy.get('#field-comment').contains('This is a comment'); + + cy.wait(1000); + cy.reload(); + + cy.log( + 'test if comment is deleted from local storage after selecting Cancel in the Autosave toast', + ); + + cy.findByRole('alert') + .get('.toast-inner-content') + .contains('Autosave found') + .get('button.ui.icon.button.save.toast-box') + .eq(1) + .click(); + + cy.wait(1000); + cy.reload(); + cy.contains('Autosave found').should('not.exist'); + + cy.log('adding another comment and save it'); + + cy.get('textarea[id="field-comment"]') + .clear() + .type('This is a another comment'); + cy.wait(1000); + cy.reload(); + + cy.findByRole('alert') + .get('.toast-inner-content') + .contains('Autosave found') + .get('button.ui.icon.button.save.toast-box') + .eq(0) + .click(); + + cy.wait(1000); + + cy.get('button[type="submit"').click(); + + cy.get('.comment').contains('This is a another comment'); + + cy.log('test if the local storage comment was deleted after submit'); + + cy.wait(1000); + cy.reload(); + cy.contains('Autosave found').should('not.exist'); + }); +}); From 8bbd5113a8275929ca203a81e7d67446c908d6b2 Mon Sep 17 00:00:00 2001 From: ALEXANDRU MEDESAN Date: Thu, 6 Jul 2023 13:51:23 +0300 Subject: [PATCH 19/53] chore: add docs user manual --- docs/source/user-manual/autosave.md | 43 +++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 docs/source/user-manual/autosave.md diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md new file mode 100644 index 0000000000..63b1762133 --- /dev/null +++ b/docs/source/user-manual/autosave.md @@ -0,0 +1,43 @@ +--- +myst: + html_meta: + "description": "User manual for how Volto autosaves data in Plone 6 frontend." + "property=og:description": "User manual for how Volto autosaves data in Plone 6 frontend." + "property=og:title": "How to autosave content in Volto for edit, add and comments" + "keywords": "Volto, Plone, frontend, React, User manual, autosave" +--- + +(autosave-content-label)= + +# Autosave content +Autosave feature allows you to load locally saved data in case of accidental close, refresh, close or change page. +- It uses localstorage and clears the data once either the Form is saved or you cancel loading the local data. +- If local data is found for the specific content a toast is shown that allows you to either load (OK) or discard (Cancel). +- If local data is stale, it will still show the toast, but it will specify that the found data is less recent than the server one. + +(autosave-edit-mode-label)= +## Autosave edit mode +A local copy of the form is saved in localStorage when the users start to edit, not at simply opening the page in edit mode. +Changing the form will update the localStorage with a new complete copy of the Form. +In case of closing the tab, refreshing, changing the page, cancelling edit, when revisiting the page in edit mode, it will show a toast for the found data. +Data is saved with an unique id: +```js + const id = isEditForm + ? ['form', type, pathname].join('-') // edit + : type + ? ['form', pathname, type].join('-') // add + : schema?.properties?.comment + ? ['form', pathname, 'comment'].join('-') // comments + : ['form', pathname].join('-'); +``` +Local data for the current content will be deleted in case of saving the Form or choosing cancel from the toast. + +(autosave-add-content-label)= +## Autosave add new content +When adding a new content, a copy of the form will be saved in localStorage, similar to edit mode, but since the content hasn't been saved, we don't have an id, in this case the content type will be used. +Since it also uses the path to create the id, the local data will be loaded again, in case of exiting without saving, only if adding the same content, in the same path. + +(autosave-comments-label)= +## Autosave comments +Comments are also saved locally even though we are not in edit mode or add. +After loading local data if comment is submitted, it will deleted from localStorage. \ No newline at end of file From cd5039051943473fc4bcf9e1e71eb1b938770076 Mon Sep 17 00:00:00 2001 From: ALEXANDRU MEDESAN Date: Thu, 6 Jul 2023 13:52:44 +0300 Subject: [PATCH 20/53] chore: i18n --- locales/ca/LC_MESSAGES/volto.po | 3 --- locales/de/LC_MESSAGES/volto.po | 3 --- locales/en/LC_MESSAGES/volto.po | 3 --- locales/es/LC_MESSAGES/volto.po | 3 --- locales/eu/LC_MESSAGES/volto.po | 3 --- locales/fi/LC_MESSAGES/volto.po | 3 --- locales/fr/LC_MESSAGES/volto.po | 3 --- locales/it/LC_MESSAGES/volto.po | 3 --- locales/ja/LC_MESSAGES/volto.po | 3 --- locales/nl/LC_MESSAGES/volto.po | 3 --- locales/pt/LC_MESSAGES/volto.po | 3 --- locales/pt_BR/LC_MESSAGES/volto.po | 3 --- locales/ro/LC_MESSAGES/volto.po | 3 --- locales/volto.pot | 5 +---- locales/zh_CN/LC_MESSAGES/volto.po | 3 --- 15 files changed, 1 insertion(+), 46 deletions(-) diff --git a/locales/ca/LC_MESSAGES/volto.po b/locales/ca/LC_MESSAGES/volto.po index 2bcf90104b..7149d11c16 100644 --- a/locales/ca/LC_MESSAGES/volto.po +++ b/locales/ca/LC_MESSAGES/volto.po @@ -416,7 +416,6 @@ msgstr "Ascendent" msgid "Assignments" msgstr "" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Autosave found msgid "Autosave found" @@ -1096,7 +1095,6 @@ msgstr "Realment voleu suprimir l'usuari {username}?" msgid "Do you really want to delete this item?" msgstr "Realment voleu suprimir aquest element?" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Do you want to load it? msgid "Do you want to load it?" @@ -3559,7 +3557,6 @@ msgstr "El procés de registre ha estat satisfactori. Si us plau, comproveu la v msgid "The site configuration is outdated and needs to be upgraded." msgstr "" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" diff --git a/locales/de/LC_MESSAGES/volto.po b/locales/de/LC_MESSAGES/volto.po index 01604250fb..5daf8f9305 100644 --- a/locales/de/LC_MESSAGES/volto.po +++ b/locales/de/LC_MESSAGES/volto.po @@ -413,7 +413,6 @@ msgstr "Aufsteigend" msgid "Assignments" msgstr "Zuweisungen" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Autosave found msgid "Autosave found" @@ -1093,7 +1092,6 @@ msgstr "Möchten Sie den Nutzer {username} wirklich löschen?" msgid "Do you really want to delete this item?" msgstr "Möchten Sie den Artikel wirklich löschen?" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Do you want to load it? msgid "Do you want to load it?" @@ -3556,7 +3554,6 @@ msgstr "Bitte prüfen Sie Ihr E-Mail Postfach. Sie sollten eine E-Mail erhalten msgid "The site configuration is outdated and needs to be upgraded." msgstr "Die Seitenkonfiguration ist veraltet und muss aktualisiert werden." -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" diff --git a/locales/en/LC_MESSAGES/volto.po b/locales/en/LC_MESSAGES/volto.po index 3fed5f7cc7..91ae5cfaeb 100644 --- a/locales/en/LC_MESSAGES/volto.po +++ b/locales/en/LC_MESSAGES/volto.po @@ -407,7 +407,6 @@ msgstr "" msgid "Assignments" msgstr "" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Autosave found msgid "Autosave found" @@ -1087,7 +1086,6 @@ msgstr "" msgid "Do you really want to delete this item?" msgstr "" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Do you want to load it? msgid "Do you want to load it?" @@ -3550,7 +3548,6 @@ msgstr "" msgid "The site configuration is outdated and needs to be upgraded." msgstr "" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" diff --git a/locales/es/LC_MESSAGES/volto.po b/locales/es/LC_MESSAGES/volto.po index b1a7f8f4ab..0ab2785271 100644 --- a/locales/es/LC_MESSAGES/volto.po +++ b/locales/es/LC_MESSAGES/volto.po @@ -418,7 +418,6 @@ msgstr "Ascendente" msgid "Assignments" msgstr "Tareas" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Autosave found msgid "Autosave found" @@ -1098,7 +1097,6 @@ msgstr "¿Esta seguro que quiere eliminar el usuario {username}?" msgid "Do you really want to delete this item?" msgstr "¿Usted realmente quiere eliminar este elemento?" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Do you want to load it? msgid "Do you want to load it?" @@ -3561,7 +3559,6 @@ msgstr "El registro fue exitoso. Por favor, verifique su bandeja de entrada para msgid "The site configuration is outdated and needs to be upgraded." msgstr "La configuración del sitio está anticuada y debe ser actualizada." -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" diff --git a/locales/eu/LC_MESSAGES/volto.po b/locales/eu/LC_MESSAGES/volto.po index 67388a0c51..81932da485 100644 --- a/locales/eu/LC_MESSAGES/volto.po +++ b/locales/eu/LC_MESSAGES/volto.po @@ -414,7 +414,6 @@ msgstr "Goraka" msgid "Assignments" msgstr "Esleipenak" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Autosave found msgid "Autosave found" @@ -1094,7 +1093,6 @@ msgstr "{username} erabiltzailea ezabatu egin nahi duzu?" msgid "Do you really want to delete this item?" msgstr "Elementu hau ezabatu egin nahi duzu?" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Do you want to load it? msgid "Do you want to load it?" @@ -3557,7 +3555,6 @@ msgstr "Izen-emate prozesua ondo egin duzu. Begiratu zure eposta, kontua aktibat msgid "The site configuration is outdated and needs to be upgraded." msgstr "Atariaren konfigurazioa zaharkituta dago eta eguneratu egin behar da." -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" diff --git a/locales/fi/LC_MESSAGES/volto.po b/locales/fi/LC_MESSAGES/volto.po index 86e4372b90..8ccf7694d6 100644 --- a/locales/fi/LC_MESSAGES/volto.po +++ b/locales/fi/LC_MESSAGES/volto.po @@ -418,7 +418,6 @@ msgstr "Nouseva" msgid "Assignments" msgstr "Tehtävät" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Autosave found msgid "Autosave found" @@ -1098,7 +1097,6 @@ msgstr "Haluatko varmasti poistaa käyttäjän {username}?" msgid "Do you really want to delete this item?" msgstr "Haluatko varmasti poistaa tämän sisällön?" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Do you want to load it? msgid "Do you want to load it?" @@ -3561,7 +3559,6 @@ msgstr "Rekisteröinti onnistui. Tarkista, saitko sähköpostiisi ohjeet käytt msgid "The site configuration is outdated and needs to be upgraded." msgstr "Sivuston konfiguraatio on vanhentunut ja se pitää päivittää." -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" diff --git a/locales/fr/LC_MESSAGES/volto.po b/locales/fr/LC_MESSAGES/volto.po index c86ee9726c..883e4e177d 100644 --- a/locales/fr/LC_MESSAGES/volto.po +++ b/locales/fr/LC_MESSAGES/volto.po @@ -424,7 +424,6 @@ msgstr "Ascendant" msgid "Assignments" msgstr "Affectations" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Autosave found msgid "Autosave found" @@ -1104,7 +1103,6 @@ msgstr "Voulez-vous vraiment supprimer l'utilisateur {username} ?" msgid "Do you really want to delete this item?" msgstr "Voulez-vous vraiment supprimer cet élément ?" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Do you want to load it? msgid "Do you want to load it?" @@ -3567,7 +3565,6 @@ msgstr "Le processus d'inscription a réussi. Veuillez vérifier votre boîte e- msgid "The site configuration is outdated and needs to be upgraded." msgstr "La configuration du site nécessite une mise à niveau." -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" diff --git a/locales/it/LC_MESSAGES/volto.po b/locales/it/LC_MESSAGES/volto.po index 9a40626473..ccf92670f7 100644 --- a/locales/it/LC_MESSAGES/volto.po +++ b/locales/it/LC_MESSAGES/volto.po @@ -407,7 +407,6 @@ msgstr "Crescente" msgid "Assignments" msgstr "" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Autosave found msgid "Autosave found" @@ -1087,7 +1086,6 @@ msgstr "Vuoi veramente eliminare l'utente {username}?" msgid "Do you really want to delete this item?" msgstr "Vuoi veramente eliminare questo elemento?" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Do you want to load it? msgid "Do you want to load it?" @@ -3550,7 +3548,6 @@ msgstr "La registrazione è avvenuta correttamente. Per favore controlla la tua msgid "The site configuration is outdated and needs to be upgraded." msgstr "" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" diff --git a/locales/ja/LC_MESSAGES/volto.po b/locales/ja/LC_MESSAGES/volto.po index 98eb908353..09d33311ae 100644 --- a/locales/ja/LC_MESSAGES/volto.po +++ b/locales/ja/LC_MESSAGES/volto.po @@ -415,7 +415,6 @@ msgstr "昇順" msgid "Assignments" msgstr "" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Autosave found msgid "Autosave found" @@ -1095,7 +1094,6 @@ msgstr "ユーザ {username} を削除してよろしいですか?" msgid "Do you really want to delete this item?" msgstr "このアイテムを削除してよろしいですか?" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Do you want to load it? msgid "Do you want to load it?" @@ -3558,7 +3556,6 @@ msgstr "The registration process has been successful. Please check your e-mail i msgid "The site configuration is outdated and needs to be upgraded." msgstr "" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" diff --git a/locales/nl/LC_MESSAGES/volto.po b/locales/nl/LC_MESSAGES/volto.po index 1113d99ddc..19905b5cc0 100644 --- a/locales/nl/LC_MESSAGES/volto.po +++ b/locales/nl/LC_MESSAGES/volto.po @@ -426,7 +426,6 @@ msgstr "Oplopend" msgid "Assignments" msgstr "" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Autosave found msgid "Autosave found" @@ -1106,7 +1105,6 @@ msgstr "" msgid "Do you really want to delete this item?" msgstr "Weet u zeker dat u dit item wilt verwijderen?" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Do you want to load it? msgid "Do you want to load it?" @@ -3569,7 +3567,6 @@ msgstr "" msgid "The site configuration is outdated and needs to be upgraded." msgstr "" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" diff --git a/locales/pt/LC_MESSAGES/volto.po b/locales/pt/LC_MESSAGES/volto.po index 5f2d9a04d4..5f9edfff6c 100644 --- a/locales/pt/LC_MESSAGES/volto.po +++ b/locales/pt/LC_MESSAGES/volto.po @@ -415,7 +415,6 @@ msgstr "Ascendente" msgid "Assignments" msgstr "" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Autosave found msgid "Autosave found" @@ -1095,7 +1094,6 @@ msgstr "Quer mesmo eliminar o utilizador {username}?" msgid "Do you really want to delete this item?" msgstr "Quer mesmo eliminar este item?" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Do you want to load it? msgid "Do you want to load it?" @@ -3558,7 +3556,6 @@ msgstr "O processo de registo foi bem sucedido. Por favor verifique no seu e-mai msgid "The site configuration is outdated and needs to be upgraded." msgstr "" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" diff --git a/locales/pt_BR/LC_MESSAGES/volto.po b/locales/pt_BR/LC_MESSAGES/volto.po index 4e8a5fcf90..36eed3ca93 100644 --- a/locales/pt_BR/LC_MESSAGES/volto.po +++ b/locales/pt_BR/LC_MESSAGES/volto.po @@ -417,7 +417,6 @@ msgstr "Ascendente" msgid "Assignments" msgstr "Atribuições" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Autosave found msgid "Autosave found" @@ -1097,7 +1096,6 @@ msgstr "Você realmente quer excluir o usuário {username}?" msgid "Do you really want to delete this item?" msgstr "Você realmente quer excluir este item?" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Do you want to load it? msgid "Do you want to load it?" @@ -3560,7 +3558,6 @@ msgstr "O processo de registro foi bem sucedido. Verifique sua caixa de entrada msgid "The site configuration is outdated and needs to be upgraded." msgstr "A configuração do site está desatualizada e precisa ser atualizada." -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" diff --git a/locales/ro/LC_MESSAGES/volto.po b/locales/ro/LC_MESSAGES/volto.po index d1655023b4..7e12bfc909 100644 --- a/locales/ro/LC_MESSAGES/volto.po +++ b/locales/ro/LC_MESSAGES/volto.po @@ -407,7 +407,6 @@ msgstr "Crescător" msgid "Assignments" msgstr "" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Autosave found msgid "Autosave found" @@ -1087,7 +1086,6 @@ msgstr "Doriți cu adevărat să ștergeți utilizatorul {username}?" msgid "Do you really want to delete this item?" msgstr "Doriți cu adevărat să ștergeți acest articol?" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Do you want to load it? msgid "Do you want to load it?" @@ -3550,7 +3548,6 @@ msgstr "Procesul de înregistrare a avut succes. Vă rugăm să verificați căs msgid "The site configuration is outdated and needs to be upgraded." msgstr "" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" diff --git a/locales/volto.pot b/locales/volto.pot index 46524ad296..2a343ea10e 100644 --- a/locales/volto.pot +++ b/locales/volto.pot @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: Plone\n" -"POT-Creation-Date: 2023-06-26T13:50:20.280Z\n" +"POT-Creation-Date: 2023-07-06T10:52:17.587Z\n" "Last-Translator: Plone i18n \n" "Language-Team: Plone i18n \n" "MIME-Version: 1.0\n" @@ -409,7 +409,6 @@ msgstr "" msgid "Assignments" msgstr "" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Autosave found msgid "Autosave found" @@ -1089,7 +1088,6 @@ msgstr "" msgid "Do you really want to delete this item?" msgstr "" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Do you want to load it? msgid "Do you want to load it?" @@ -3552,7 +3550,6 @@ msgstr "" msgid "The site configuration is outdated and needs to be upgraded." msgstr "" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" diff --git a/locales/zh_CN/LC_MESSAGES/volto.po b/locales/zh_CN/LC_MESSAGES/volto.po index 7bc66d30c5..614e67382e 100644 --- a/locales/zh_CN/LC_MESSAGES/volto.po +++ b/locales/zh_CN/LC_MESSAGES/volto.po @@ -413,7 +413,6 @@ msgstr "上升" msgid "Assignments" msgstr "分配" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Autosave found msgid "Autosave found" @@ -1093,7 +1092,6 @@ msgstr "确定要删除这个用户 {username}吗?" msgid "Do you really want to delete this item?" msgstr "确定要删除这个条目吗" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: Do you want to load it? msgid "Do you want to load it?" @@ -3556,7 +3554,6 @@ msgstr "注册过程成功完成。请在您的电子邮箱中查看有关如何 msgid "The site configuration is outdated and needs to be upgraded." msgstr "网站配置已过时,需要升级。" -#: helpers/Utils/saveAsDraft #: helpers/Utils/withSaveAsDraft # defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" From 12c0edc0222ba5013233e004e5d2272c1c5066d2 Mon Sep 17 00:00:00 2001 From: rexalex Date: Tue, 18 Jul 2023 12:08:52 +0300 Subject: [PATCH 21/53] Update docs/source/user-manual/autosave.md Co-authored-by: Steve Piercy --- docs/source/user-manual/autosave.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index 63b1762133..a6a185408f 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -2,7 +2,7 @@ myst: html_meta: "description": "User manual for how Volto autosaves data in Plone 6 frontend." - "property=og:description": "User manual for how Volto autosaves data in Plone 6 frontend." + "property=og:description": "User manual for how Volto autosaves data in Plone 6." "property=og:title": "How to autosave content in Volto for edit, add and comments" "keywords": "Volto, Plone, frontend, React, User manual, autosave" --- From d4e2a599532ffa97f3f191bb8b959748d9803e1f Mon Sep 17 00:00:00 2001 From: rexalex Date: Tue, 18 Jul 2023 12:10:10 +0300 Subject: [PATCH 22/53] Update docs/source/user-manual/autosave.md Co-authored-by: Steve Piercy --- docs/source/user-manual/autosave.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index a6a185408f..907a182e6e 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -3,7 +3,7 @@ myst: html_meta: "description": "User manual for how Volto autosaves data in Plone 6 frontend." "property=og:description": "User manual for how Volto autosaves data in Plone 6." - "property=og:title": "How to autosave content in Volto for edit, add and comments" + "property=og:title": "How to autosave content in Volto for edit, add, and comments" "keywords": "Volto, Plone, frontend, React, User manual, autosave" --- From 920904cb7a822837e5c46657be10e02e4f816700 Mon Sep 17 00:00:00 2001 From: rexalex Date: Tue, 18 Jul 2023 12:10:38 +0300 Subject: [PATCH 23/53] Update docs/source/user-manual/autosave.md Co-authored-by: Steve Piercy --- docs/source/user-manual/autosave.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index 907a182e6e..8cf4a208e0 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -10,7 +10,8 @@ myst: (autosave-content-label)= # Autosave content -Autosave feature allows you to load locally saved data in case of accidental close, refresh, close or change page. + +The autosave feature allows you to load locally saved data, in case of accidental browser close, refresh, quit, or change page. - It uses localstorage and clears the data once either the Form is saved or you cancel loading the local data. - If local data is found for the specific content a toast is shown that allows you to either load (OK) or discard (Cancel). - If local data is stale, it will still show the toast, but it will specify that the found data is less recent than the server one. From 7eae3e22083f761f1a7c47e0a5e65665d9954ed5 Mon Sep 17 00:00:00 2001 From: rexalex Date: Tue, 18 Jul 2023 12:10:59 +0300 Subject: [PATCH 24/53] Update docs/source/user-manual/autosave.md Co-authored-by: Steve Piercy --- docs/source/user-manual/autosave.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index 8cf4a208e0..12b0befae0 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -12,7 +12,8 @@ myst: # Autosave content The autosave feature allows you to load locally saved data, in case of accidental browser close, refresh, quit, or change page. -- It uses localstorage and clears the data once either the Form is saved or you cancel loading the local data. +It uses the [`localStorage` property](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). +It clears the data once either the form is saved or you cancel loading the local data. - If local data is found for the specific content a toast is shown that allows you to either load (OK) or discard (Cancel). - If local data is stale, it will still show the toast, but it will specify that the found data is less recent than the server one. From bd034e53eedde778344f79d9737f52b165055dea Mon Sep 17 00:00:00 2001 From: rexalex Date: Tue, 18 Jul 2023 12:11:26 +0300 Subject: [PATCH 25/53] Update docs/source/user-manual/autosave.md Co-authored-by: Steve Piercy --- docs/source/user-manual/autosave.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index 12b0befae0..332e89b805 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -14,7 +14,7 @@ myst: The autosave feature allows you to load locally saved data, in case of accidental browser close, refresh, quit, or change page. It uses the [`localStorage` property](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). It clears the data once either the form is saved or you cancel loading the local data. -- If local data is found for the specific content a toast is shown that allows you to either load (OK) or discard (Cancel). +If local data is found for the specific content, a toast is shown that allows you to either load ({guilabel}`OK`) or discard ({guilabel}`Cancel`). - If local data is stale, it will still show the toast, but it will specify that the found data is less recent than the server one. (autosave-edit-mode-label)= From 13073fe2d7355df07e36c22f71f08e70375311e8 Mon Sep 17 00:00:00 2001 From: rexalex Date: Tue, 18 Jul 2023 12:11:33 +0300 Subject: [PATCH 26/53] Update docs/source/user-manual/autosave.md Co-authored-by: Steve Piercy --- docs/source/user-manual/autosave.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index 332e89b805..6a23962dd5 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -15,7 +15,7 @@ The autosave feature allows you to load locally saved data, in case of accidenta It uses the [`localStorage` property](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). It clears the data once either the form is saved or you cancel loading the local data. If local data is found for the specific content, a toast is shown that allows you to either load ({guilabel}`OK`) or discard ({guilabel}`Cancel`). -- If local data is stale, it will still show the toast, but it will specify that the found data is less recent than the server one. +If local data is stale, it will still show the toast, but it will specify that the found data is less recent than the server one. (autosave-edit-mode-label)= ## Autosave edit mode From 93fcf16c018d8a11a6c679a3f188e9bc99566ee9 Mon Sep 17 00:00:00 2001 From: rexalex Date: Tue, 18 Jul 2023 12:11:54 +0300 Subject: [PATCH 27/53] Update docs/source/user-manual/autosave.md Co-authored-by: Steve Piercy --- docs/source/user-manual/autosave.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index 6a23962dd5..8ab5d8da4d 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -19,7 +19,7 @@ If local data is stale, it will still show the toast, but it will specify that t (autosave-edit-mode-label)= ## Autosave edit mode -A local copy of the form is saved in localStorage when the users start to edit, not at simply opening the page in edit mode. +A local copy of the form is saved in `localStorage` when you start to edit, not when you merely open the page in edit mode. Changing the form will update the localStorage with a new complete copy of the Form. In case of closing the tab, refreshing, changing the page, cancelling edit, when revisiting the page in edit mode, it will show a toast for the found data. Data is saved with an unique id: From 4487691951b3ef797ba2084176dcd2aa8f270822 Mon Sep 17 00:00:00 2001 From: rexalex Date: Tue, 18 Jul 2023 12:12:04 +0300 Subject: [PATCH 28/53] Update docs/source/user-manual/autosave.md Co-authored-by: Steve Piercy --- docs/source/user-manual/autosave.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index 8ab5d8da4d..ed4df20e2f 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -20,7 +20,7 @@ If local data is stale, it will still show the toast, but it will specify that t (autosave-edit-mode-label)= ## Autosave edit mode A local copy of the form is saved in `localStorage` when you start to edit, not when you merely open the page in edit mode. -Changing the form will update the localStorage with a new complete copy of the Form. +Changing the form will update the `localStorage` with a new complete copy of the Form. In case of closing the tab, refreshing, changing the page, cancelling edit, when revisiting the page in edit mode, it will show a toast for the found data. Data is saved with an unique id: ```js From f4f3e2773ab30b2b942e358e06d4b3ceff7a254e Mon Sep 17 00:00:00 2001 From: rexalex Date: Tue, 18 Jul 2023 12:12:12 +0300 Subject: [PATCH 29/53] Update docs/source/user-manual/autosave.md Co-authored-by: Steve Piercy --- docs/source/user-manual/autosave.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index ed4df20e2f..6bc1ba575e 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -21,7 +21,7 @@ If local data is stale, it will still show the toast, but it will specify that t ## Autosave edit mode A local copy of the form is saved in `localStorage` when you start to edit, not when you merely open the page in edit mode. Changing the form will update the `localStorage` with a new complete copy of the Form. -In case of closing the tab, refreshing, changing the page, cancelling edit, when revisiting the page in edit mode, it will show a toast for the found data. +In case you close the tab, quit, refresh, change the page, or cancel edit, when you revisit the page in edit mode, it will display a toast for the found data. Data is saved with an unique id: ```js const id = isEditForm From fb766a45867d6874f96e85bd9b4fc03edcd2a49f Mon Sep 17 00:00:00 2001 From: rexalex Date: Tue, 18 Jul 2023 12:12:20 +0300 Subject: [PATCH 30/53] Update docs/source/user-manual/autosave.md Co-authored-by: Steve Piercy --- docs/source/user-manual/autosave.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index 6bc1ba575e..da69033db8 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -22,7 +22,7 @@ If local data is stale, it will still show the toast, but it will specify that t A local copy of the form is saved in `localStorage` when you start to edit, not when you merely open the page in edit mode. Changing the form will update the `localStorage` with a new complete copy of the Form. In case you close the tab, quit, refresh, change the page, or cancel edit, when you revisit the page in edit mode, it will display a toast for the found data. -Data is saved with an unique id: +Data is saved with a unique id: ```js const id = isEditForm ? ['form', type, pathname].join('-') // edit From 1fa4956e33c6f91135283c6de44b2cbb3cfcb9ad Mon Sep 17 00:00:00 2001 From: rexalex Date: Tue, 18 Jul 2023 12:12:30 +0300 Subject: [PATCH 31/53] Update docs/source/user-manual/autosave.md Co-authored-by: Steve Piercy --- docs/source/user-manual/autosave.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index da69033db8..566ba1dd0e 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -32,7 +32,7 @@ Data is saved with a unique id: ? ['form', pathname, 'comment'].join('-') // comments : ['form', pathname].join('-'); ``` -Local data for the current content will be deleted in case of saving the Form or choosing cancel from the toast. +Local data for the current content will be deleted, when you save the form or choose {guilabel}`Cancel` from the toast. (autosave-add-content-label)= ## Autosave add new content From 3367322d82037be84b19ca5a26072aac326440b7 Mon Sep 17 00:00:00 2001 From: rexalex Date: Tue, 18 Jul 2023 12:12:40 +0300 Subject: [PATCH 32/53] Update docs/source/user-manual/autosave.md Co-authored-by: Steve Piercy --- docs/source/user-manual/autosave.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index 566ba1dd0e..6ef29d55f3 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -35,7 +35,7 @@ Data is saved with a unique id: Local data for the current content will be deleted, when you save the form or choose {guilabel}`Cancel` from the toast. (autosave-add-content-label)= -## Autosave add new content +## Autosave new content When adding a new content, a copy of the form will be saved in localStorage, similar to edit mode, but since the content hasn't been saved, we don't have an id, in this case the content type will be used. Since it also uses the path to create the id, the local data will be loaded again, in case of exiting without saving, only if adding the same content, in the same path. From ce4a9b0a6ee90cdaf8007d92c5f29420c2dd3580 Mon Sep 17 00:00:00 2001 From: rexalex Date: Tue, 18 Jul 2023 12:12:48 +0300 Subject: [PATCH 33/53] Update docs/source/user-manual/autosave.md Co-authored-by: Steve Piercy --- docs/source/user-manual/autosave.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index 6ef29d55f3..3a367d8238 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -34,7 +34,8 @@ Data is saved with a unique id: ``` Local data for the current content will be deleted, when you save the form or choose {guilabel}`Cancel` from the toast. -(autosave-add-content-label)= +(autosave-new-content-label)= + ## Autosave new content When adding a new content, a copy of the form will be saved in localStorage, similar to edit mode, but since the content hasn't been saved, we don't have an id, in this case the content type will be used. Since it also uses the path to create the id, the local data will be loaded again, in case of exiting without saving, only if adding the same content, in the same path. From 04304e7aa8ce79695cac484d8bd507ffb13baa75 Mon Sep 17 00:00:00 2001 From: rexalex Date: Tue, 18 Jul 2023 12:13:04 +0300 Subject: [PATCH 34/53] Update docs/source/user-manual/autosave.md Co-authored-by: Steve Piercy --- docs/source/user-manual/autosave.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index 3a367d8238..d8aad6d039 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -37,7 +37,9 @@ Local data for the current content will be deleted, when you save the form or ch (autosave-new-content-label)= ## Autosave new content -When adding a new content, a copy of the form will be saved in localStorage, similar to edit mode, but since the content hasn't been saved, we don't have an id, in this case the content type will be used. +When adding content, a copy of the form will be saved in `localStorage`, similar to edit mode. +But since the content hasn't been saved yet, we don't have an ID. +In this case the content type will be used. Since it also uses the path to create the id, the local data will be loaded again, in case of exiting without saving, only if adding the same content, in the same path. (autosave-comments-label)= From 461212bcad410f6e14e500086fab442fa0707fb4 Mon Sep 17 00:00:00 2001 From: rexalex Date: Tue, 18 Jul 2023 12:13:11 +0300 Subject: [PATCH 35/53] Update docs/source/user-manual/autosave.md Co-authored-by: Steve Piercy --- docs/source/user-manual/autosave.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index d8aad6d039..7dabdae3f8 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -40,7 +40,7 @@ Local data for the current content will be deleted, when you save the form or ch When adding content, a copy of the form will be saved in `localStorage`, similar to edit mode. But since the content hasn't been saved yet, we don't have an ID. In this case the content type will be used. -Since it also uses the path to create the id, the local data will be loaded again, in case of exiting without saving, only if adding the same content, in the same path. +Since it also uses the path to create the ID, the local data will be loaded again if you exit without saving, and only if you add the same content in the same path. (autosave-comments-label)= ## Autosave comments From 026dc07affea7851bf01a4f6a59060429bf8d986 Mon Sep 17 00:00:00 2001 From: rexalex Date: Tue, 18 Jul 2023 12:13:22 +0300 Subject: [PATCH 36/53] Update docs/source/user-manual/autosave.md Co-authored-by: Steve Piercy --- docs/source/user-manual/autosave.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index 7dabdae3f8..aa7a3d005e 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -44,5 +44,5 @@ Since it also uses the path to create the ID, the local data will be loaded agai (autosave-comments-label)= ## Autosave comments -Comments are also saved locally even though we are not in edit mode or add. +Comments are also saved locally, even though you are not in edit or add mode. After loading local data if comment is submitted, it will deleted from localStorage. \ No newline at end of file From 36dbe08ae0d300267d6fbfaab17353fce2faf409 Mon Sep 17 00:00:00 2001 From: rexalex Date: Tue, 18 Jul 2023 12:13:32 +0300 Subject: [PATCH 37/53] Update docs/source/user-manual/autosave.md Co-authored-by: Steve Piercy --- docs/source/user-manual/autosave.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index aa7a3d005e..7921ff226c 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -45,4 +45,4 @@ Since it also uses the path to create the ID, the local data will be loaded agai (autosave-comments-label)= ## Autosave comments Comments are also saved locally, even though you are not in edit or add mode. -After loading local data if comment is submitted, it will deleted from localStorage. \ No newline at end of file +After loading local data, if a comment is submitted, it will be deleted from `localStorage`. \ No newline at end of file From cde5090b81581dc0284967cf6eab1087a89b3d06 Mon Sep 17 00:00:00 2001 From: rexalex Date: Wed, 19 Jul 2023 14:21:40 +0300 Subject: [PATCH 38/53] Update docs/source/user-manual/autosave.md Co-authored-by: Steve Piercy --- docs/source/user-manual/autosave.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index 7921ff226c..fd07829c64 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -20,7 +20,7 @@ If local data is stale, it will still show the toast, but it will specify that t (autosave-edit-mode-label)= ## Autosave edit mode A local copy of the form is saved in `localStorage` when you start to edit, not when you merely open the page in edit mode. -Changing the form will update the `localStorage` with a new complete copy of the Form. +Changing the form will update the `localStorage` with a new complete copy of the form. In case you close the tab, quit, refresh, change the page, or cancel edit, when you revisit the page in edit mode, it will display a toast for the found data. Data is saved with a unique id: ```js From 26adfb3aad029334bbdb91da7578366b72320550 Mon Sep 17 00:00:00 2001 From: rexalex Date: Wed, 19 Jul 2023 14:22:36 +0300 Subject: [PATCH 39/53] Update docs/source/user-manual/autosave.md Co-authored-by: Steve Piercy --- docs/source/user-manual/autosave.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index fd07829c64..be0b9a635e 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -1,7 +1,7 @@ --- myst: html_meta: - "description": "User manual for how Volto autosaves data in Plone 6 frontend." + "description": "User manual for how Volto autosaves data in Plone 6." "property=og:description": "User manual for how Volto autosaves data in Plone 6." "property=og:title": "How to autosave content in Volto for edit, add, and comments" "keywords": "Volto, Plone, frontend, React, User manual, autosave" From 874d76420a88073ff90fe332cf179154cdb9d824 Mon Sep 17 00:00:00 2001 From: ALEXANDRU MEDESAN Date: Wed, 19 Jul 2023 14:31:52 +0300 Subject: [PATCH 40/53] chore: add an entry to docs/source/user-manual/index.md for autosave --- docs/source/user-manual/index.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/source/user-manual/index.md b/docs/source/user-manual/index.md index ec4756aca8..a6f9bfdc0b 100644 --- a/docs/source/user-manual/index.md +++ b/docs/source/user-manual/index.md @@ -31,4 +31,5 @@ Note that the audience for these sources may be a Developer, not an Editor, and blocks copy-paste-blocks +autosave ``` From dee32a3ce12a1173e9e94154ac52a691be5c3102 Mon Sep 17 00:00:00 2001 From: ALEXANDRU MEDESAN Date: Wed, 26 Jul 2023 10:25:12 +0300 Subject: [PATCH 41/53] chore: fix cypress --- cypress/tests/core/basic/autosave.js | 3 +-- cypress/tests/core/blocks/blocks-grid.js | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/cypress/tests/core/basic/autosave.js b/cypress/tests/core/basic/autosave.js index 3c06e27061..794fcaa0d5 100644 --- a/cypress/tests/core/basic/autosave.js +++ b/cypress/tests/core/basic/autosave.js @@ -15,7 +15,6 @@ describe('createContent Tests', () => { contentType: 'Document', contentId: 'my-first-page', contentTitle: 'My First Page', - allow_discussion: true, }); cy.createContent({ contentType: 'Document', @@ -170,7 +169,7 @@ describe('createContent Tests', () => { }); it('As editor I can autosave comments', function () { - cy.log('adding a coment and refresh,'); + cy.log('adding a comment and refresh,'); cy.visit('/comments-page'); cy.get('textarea[id="field-comment"]').clear().type('This is a comment'); cy.wait(1000); diff --git a/cypress/tests/core/blocks/blocks-grid.js b/cypress/tests/core/blocks/blocks-grid.js index 4ecf5d964a..d7973ab0af 100644 --- a/cypress/tests/core/blocks/blocks-grid.js +++ b/cypress/tests/core/blocks/blocks-grid.js @@ -46,9 +46,8 @@ context('Blocks Acceptance Tests', () => { cy.get('button[aria-label="Add block in position 1"]').click(); cy.get('.blocks-chooser [aria-label="Unfold Text blocks"]').click(); - cy.get('.blocks-chooser .text .button.slate').click({ force: true }); cy.wait(200); - cy.get('.blocks-chooser .text .button.slate').click(); + cy.get('.blocks-chooser .text .button.slate').click({ force: true }); cy.getSlateEditorSelectorAndType( '.block.gridBlock.selected .slate-editor [contenteditable=true]', 'Colorless green ideas sleep furiously.', @@ -90,9 +89,8 @@ context('Blocks Acceptance Tests', () => { cy.get('button[aria-label="Add block in position 1"]').click(); cy.get('.blocks-chooser [aria-label="Unfold Text blocks"]').click(); - cy.get('.blocks-chooser .text .button.slate').click({ force: true }); cy.wait(200); - cy.get('.blocks-chooser .text .button.slate').click(); + cy.get('.blocks-chooser .text .button.slate').click({ force: true }); cy.scrollTo('top'); cy.getSlateEditorSelectorAndType( From d25c43d522cdd369a2303d1efdef6a998da5974f Mon Sep 17 00:00:00 2001 From: ALEXANDRU MEDESAN Date: Wed, 26 Jul 2023 16:02:31 +0300 Subject: [PATCH 42/53] chore: remove waitForResourceToLoad from tests --- cypress/tests/core/basic/autosave.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/cypress/tests/core/basic/autosave.js b/cypress/tests/core/basic/autosave.js index 794fcaa0d5..a382f272f3 100644 --- a/cypress/tests/core/basic/autosave.js +++ b/cypress/tests/core/basic/autosave.js @@ -25,24 +25,14 @@ describe('createContent Tests', () => { it('As editor I can autosave when editing a content item', () => { cy.visit('/my-first-page'); - cy.waitForResourceToLoad('@navigation'); - cy.waitForResourceToLoad('@breadcrumbs'); - cy.waitForResourceToLoad('@actions'); - cy.waitForResourceToLoad('@types'); cy.log('adding a text block on the first page'); - cy.waitForResourceToLoad('my-first-page'); cy.navigate('/my-first-page/edit'); cy.getSlateEditorAndType('My first text').contains('My first text'); cy.wait(1000); cy.visit('/my-second-page'); - cy.waitForResourceToLoad('@navigation'); - cy.waitForResourceToLoad('@breadcrumbs'); - cy.waitForResourceToLoad('@actions'); - cy.waitForResourceToLoad('@types'); - cy.waitForResourceToLoad('my-second-page'); cy.log('adding a text block on the second page'); cy.navigate('/my-second-page/edit'); From 4067a3e908f77c08d89739d6f09d323f01514680 Mon Sep 17 00:00:00 2001 From: ALEXANDRU MEDESAN Date: Tue, 1 Aug 2023 19:16:56 +0300 Subject: [PATCH 43/53] chore: autosave cypress delay --- cypress/tests/core/basic/autosave.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cypress/tests/core/basic/autosave.js b/cypress/tests/core/basic/autosave.js index a382f272f3..6e0683794e 100644 --- a/cypress/tests/core/basic/autosave.js +++ b/cypress/tests/core/basic/autosave.js @@ -145,8 +145,9 @@ describe('createContent Tests', () => { cy.log('test if page content type is added as new page after Toolbar Save'); cy.get('#toolbar-save').focus().click(); - cy.navigate('/page-1-title'); + cy.wait(2000); cy.contains('Page 1 title'); + cy.wait(1000); cy.log('test draft is deleted from local storage after save'); From 5879990167bc831b8bcfad7ebe8dbe24401f0015 Mon Sep 17 00:00:00 2001 From: rexalex Date: Thu, 14 Sep 2023 13:45:10 +0300 Subject: [PATCH 44/53] Update src/helpers/Utils/withSaveAsDraft.js Co-authored-by: Steve Piercy --- src/helpers/Utils/withSaveAsDraft.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/Utils/withSaveAsDraft.js b/src/helpers/Utils/withSaveAsDraft.js index 7607598e3c..f4f0d0e5a5 100644 --- a/src/helpers/Utils/withSaveAsDraft.js +++ b/src/helpers/Utils/withSaveAsDraft.js @@ -22,7 +22,7 @@ const messages = defineMessages({ id: 'The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?', defaultMessage: - 'The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?', + 'The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)', }, }); From 4752ef0ad13718d73d08cf7203afee574ffa26eb Mon Sep 17 00:00:00 2001 From: rexalex Date: Thu, 14 Sep 2023 13:45:22 +0300 Subject: [PATCH 45/53] Update src/helpers/Utils/withSaveAsDraft.js Co-authored-by: Steve Piercy --- src/helpers/Utils/withSaveAsDraft.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/Utils/withSaveAsDraft.js b/src/helpers/Utils/withSaveAsDraft.js index f4f0d0e5a5..3fe97cc612 100644 --- a/src/helpers/Utils/withSaveAsDraft.js +++ b/src/helpers/Utils/withSaveAsDraft.js @@ -20,7 +20,7 @@ const messages = defineMessages({ }, loadExpiredData: { id: - 'The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?', + 'The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)', defaultMessage: 'The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)', }, From 1ce23bec1288b15abf0db89900676cb4d98a6b13 Mon Sep 17 00:00:00 2001 From: rexalex Date: Thu, 14 Sep 2023 13:45:31 +0300 Subject: [PATCH 46/53] Update src/helpers/Utils/withSaveAsDraft.js Co-authored-by: Steve Piercy --- src/helpers/Utils/withSaveAsDraft.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/Utils/withSaveAsDraft.js b/src/helpers/Utils/withSaveAsDraft.js index 3fe97cc612..7a246f8fed 100644 --- a/src/helpers/Utils/withSaveAsDraft.js +++ b/src/helpers/Utils/withSaveAsDraft.js @@ -16,7 +16,7 @@ const messages = defineMessages({ }, loadData: { id: 'Do you want to load it?', - defaultMessage: 'Do you want to load it?', + defaultMessage: 'Do you want to load the autosaved content?', }, loadExpiredData: { id: From f5824e4eeedced742f9c563c9d1ae99591438cb5 Mon Sep 17 00:00:00 2001 From: rexalex Date: Thu, 14 Sep 2023 13:45:42 +0300 Subject: [PATCH 47/53] Update src/helpers/Utils/withSaveAsDraft.js Co-authored-by: Steve Piercy --- src/helpers/Utils/withSaveAsDraft.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/Utils/withSaveAsDraft.js b/src/helpers/Utils/withSaveAsDraft.js index 7a246f8fed..20a7ff7773 100644 --- a/src/helpers/Utils/withSaveAsDraft.js +++ b/src/helpers/Utils/withSaveAsDraft.js @@ -15,7 +15,7 @@ const messages = defineMessages({ defaultMessage: 'Autosave found', }, loadData: { - id: 'Do you want to load it?', + id: 'Do you want to load the autosaved content?', defaultMessage: 'Do you want to load the autosaved content?', }, loadExpiredData: { From 1db3c45947fa31949b137128ba05eade1bd1720d Mon Sep 17 00:00:00 2001 From: rexalex Date: Thu, 14 Sep 2023 13:45:51 +0300 Subject: [PATCH 48/53] Update src/helpers/Utils/withSaveAsDraft.js Co-authored-by: Steve Piercy --- src/helpers/Utils/withSaveAsDraft.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/Utils/withSaveAsDraft.js b/src/helpers/Utils/withSaveAsDraft.js index 20a7ff7773..566c6c22fd 100644 --- a/src/helpers/Utils/withSaveAsDraft.js +++ b/src/helpers/Utils/withSaveAsDraft.js @@ -12,7 +12,7 @@ import { useLocation } from 'react-router-dom'; const messages = defineMessages({ autoSaveFound: { id: 'Autosave found', - defaultMessage: 'Autosave found', + defaultMessage: 'Autosaved content found', }, loadData: { id: 'Do you want to load the autosaved content?', From aa676b5c642eceafc90cd5e6b9c411640125e12a Mon Sep 17 00:00:00 2001 From: rexalex Date: Thu, 14 Sep 2023 13:46:00 +0300 Subject: [PATCH 49/53] Update src/helpers/Utils/withSaveAsDraft.js Co-authored-by: Steve Piercy --- src/helpers/Utils/withSaveAsDraft.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helpers/Utils/withSaveAsDraft.js b/src/helpers/Utils/withSaveAsDraft.js index 566c6c22fd..209e764cc0 100644 --- a/src/helpers/Utils/withSaveAsDraft.js +++ b/src/helpers/Utils/withSaveAsDraft.js @@ -11,7 +11,7 @@ import { useLocation } from 'react-router-dom'; const messages = defineMessages({ autoSaveFound: { - id: 'Autosave found', + id: 'Autosaved content found', defaultMessage: 'Autosaved content found', }, loadData: { From 18dcdce97ea713101f561c978bdb0631673d2d87 Mon Sep 17 00:00:00 2001 From: Victor Fernandez de Alba Date: Fri, 15 Sep 2023 16:48:48 +0200 Subject: [PATCH 50/53] Fix tests, run i18n --- cypress/tests/core/basic/autosave.js | 24 ++++++++++++------------ locales/ca/LC_MESSAGES/volto.po | 12 ++++++------ locales/de/LC_MESSAGES/volto.po | 12 ++++++------ locales/en/LC_MESSAGES/volto.po | 12 ++++++------ locales/es/LC_MESSAGES/volto.po | 12 ++++++------ locales/eu/LC_MESSAGES/volto.po | 12 ++++++------ locales/fi/LC_MESSAGES/volto.po | 12 ++++++------ locales/fr/LC_MESSAGES/volto.po | 12 ++++++------ locales/it/LC_MESSAGES/volto.po | 12 ++++++------ locales/ja/LC_MESSAGES/volto.po | 12 ++++++------ locales/nl/LC_MESSAGES/volto.po | 12 ++++++------ locales/pt/LC_MESSAGES/volto.po | 12 ++++++------ locales/pt_BR/LC_MESSAGES/volto.po | 12 ++++++------ locales/ro/LC_MESSAGES/volto.po | 12 ++++++------ locales/volto.pot | 14 +++++++------- locales/zh_CN/LC_MESSAGES/volto.po | 12 ++++++------ 16 files changed, 103 insertions(+), 103 deletions(-) diff --git a/cypress/tests/core/basic/autosave.js b/cypress/tests/core/basic/autosave.js index 6e0683794e..ecba88512f 100644 --- a/cypress/tests/core/basic/autosave.js +++ b/cypress/tests/core/basic/autosave.js @@ -48,7 +48,7 @@ describe('createContent Tests', () => { cy.findByRole('alert') .get('.toast-inner-content') - .contains('Autosave found') + .contains('Autosaved content found') .get('button.ui.icon.button.save.toast-box') .eq(0) .click(); @@ -65,7 +65,7 @@ describe('createContent Tests', () => { cy.findByRole('alert') .get('.toast-inner-content') - .contains('Autosave found') + .contains('Autosaved content found') .get('button.ui.icon.button.save.toast-box') .eq(0) .click(); @@ -80,7 +80,7 @@ describe('createContent Tests', () => { ); cy.findByRole('alert') .get('.toast-inner-content') - .contains('Autosave found') + .contains('Autosaved content found') .get('button.ui.icon.button.save.toast-box') .eq(1) .click(); @@ -90,7 +90,7 @@ describe('createContent Tests', () => { cy.wait(1000); - cy.contains('Autosave found').should('not.exist'); + cy.contains('Autosaved content found').should('not.exist'); }); it('As editor I can autosave when adding a content item', function () { @@ -108,7 +108,7 @@ describe('createContent Tests', () => { cy.log('test if autosaved toast shows retrieved data and click OK to load'); cy.findByRole('alert') .get('.toast-inner-content') - .contains('Autosave found') + .contains('Autosaved content found') .get('button.ui.icon.button.save.toast-box') .eq(0) .click(); @@ -131,7 +131,7 @@ describe('createContent Tests', () => { cy.findByRole('alert') .get('.toast-inner-content') - .contains('Autosave found') + .contains('Autosaved content found') .get('button.ui.icon.button.save.toast-box') .eq(0) .click(); @@ -156,7 +156,7 @@ describe('createContent Tests', () => { cy.wait(1000); - cy.contains('Autosave found').should('not.exist'); + cy.contains('Autosaved content found').should('not.exist'); }); it('As editor I can autosave comments', function () { @@ -170,7 +170,7 @@ describe('createContent Tests', () => { cy.findByRole('alert') .get('.toast-inner-content') - .contains('Autosave found') + .contains('Autosaved content found') .get('button.ui.icon.button.save.toast-box') .eq(0) .click(); @@ -186,14 +186,14 @@ describe('createContent Tests', () => { cy.findByRole('alert') .get('.toast-inner-content') - .contains('Autosave found') + .contains('Autosaved content found') .get('button.ui.icon.button.save.toast-box') .eq(1) .click(); cy.wait(1000); cy.reload(); - cy.contains('Autosave found').should('not.exist'); + cy.contains('Autosaved content found').should('not.exist'); cy.log('adding another comment and save it'); @@ -205,7 +205,7 @@ describe('createContent Tests', () => { cy.findByRole('alert') .get('.toast-inner-content') - .contains('Autosave found') + .contains('Autosaved content found') .get('button.ui.icon.button.save.toast-box') .eq(0) .click(); @@ -220,6 +220,6 @@ describe('createContent Tests', () => { cy.wait(1000); cy.reload(); - cy.contains('Autosave found').should('not.exist'); + cy.contains('Autosaved content found').should('not.exist'); }); }); diff --git a/locales/ca/LC_MESSAGES/volto.po b/locales/ca/LC_MESSAGES/volto.po index 00a2f94405..aa9b326296 100644 --- a/locales/ca/LC_MESSAGES/volto.po +++ b/locales/ca/LC_MESSAGES/volto.po @@ -417,8 +417,8 @@ msgid "Assignments" msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Autosave found -msgid "Autosave found" +# defaultMessage: Autosaved content found +msgid "Autosaved content found" msgstr "" #: components/manage/Controlpanels/AddonsControlpanel @@ -1103,8 +1103,8 @@ msgid "Do you really want to delete this item?" msgstr "Realment voleu suprimir aquest element?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load it? -msgid "Do you want to load it?" +# defaultMessage: Do you want to load the autosaved content? +msgid "Do you want to load the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3627,8 +3627,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? -msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/de/LC_MESSAGES/volto.po b/locales/de/LC_MESSAGES/volto.po index 236368e307..521cbab756 100644 --- a/locales/de/LC_MESSAGES/volto.po +++ b/locales/de/LC_MESSAGES/volto.po @@ -414,8 +414,8 @@ msgid "Assignments" msgstr "Zuweisungen" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Autosave found -msgid "Autosave found" +# defaultMessage: Autosaved content found +msgid "Autosaved content found" msgstr "" #: components/manage/Controlpanels/AddonsControlpanel @@ -1100,8 +1100,8 @@ msgid "Do you really want to delete this item?" msgstr "Möchten Sie den Artikel wirklich löschen?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load it? -msgid "Do you want to load it?" +# defaultMessage: Do you want to load the autosaved content? +msgid "Do you want to load the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3624,8 +3624,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "Die Seitenkonfiguration ist veraltet und muss aktualisiert werden." #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? -msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/en/LC_MESSAGES/volto.po b/locales/en/LC_MESSAGES/volto.po index 1c21c3f510..a78007de0e 100644 --- a/locales/en/LC_MESSAGES/volto.po +++ b/locales/en/LC_MESSAGES/volto.po @@ -408,8 +408,8 @@ msgid "Assignments" msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Autosave found -msgid "Autosave found" +# defaultMessage: Autosaved content found +msgid "Autosaved content found" msgstr "" #: components/manage/Controlpanels/AddonsControlpanel @@ -1094,8 +1094,8 @@ msgid "Do you really want to delete this item?" msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load it? -msgid "Do you want to load it?" +# defaultMessage: Do you want to load the autosaved content? +msgid "Do you want to load the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3618,8 +3618,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? -msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/es/LC_MESSAGES/volto.po b/locales/es/LC_MESSAGES/volto.po index b0f7c04789..9bd10f04c7 100644 --- a/locales/es/LC_MESSAGES/volto.po +++ b/locales/es/LC_MESSAGES/volto.po @@ -419,8 +419,8 @@ msgid "Assignments" msgstr "Tareas" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Autosave found -msgid "Autosave found" +# defaultMessage: Autosaved content found +msgid "Autosaved content found" msgstr "" #: components/manage/Controlpanels/AddonsControlpanel @@ -1105,8 +1105,8 @@ msgid "Do you really want to delete this item?" msgstr "¿Usted realmente quiere eliminar este elemento?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load it? -msgid "Do you want to load it?" +# defaultMessage: Do you want to load the autosaved content? +msgid "Do you want to load the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3629,8 +3629,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "La configuración del sitio está anticuada y debe ser actualizada." #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? -msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/eu/LC_MESSAGES/volto.po b/locales/eu/LC_MESSAGES/volto.po index 47b8dec10e..5d5e1b36c9 100644 --- a/locales/eu/LC_MESSAGES/volto.po +++ b/locales/eu/LC_MESSAGES/volto.po @@ -415,8 +415,8 @@ msgid "Assignments" msgstr "Esleipenak" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Autosave found -msgid "Autosave found" +# defaultMessage: Autosaved content found +msgid "Autosaved content found" msgstr "" #: components/manage/Controlpanels/AddonsControlpanel @@ -1101,8 +1101,8 @@ msgid "Do you really want to delete this item?" msgstr "Elementu hau ezabatu egin nahi duzu?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load it? -msgid "Do you want to load it?" +# defaultMessage: Do you want to load the autosaved content? +msgid "Do you want to load the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3625,8 +3625,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "Atariaren konfigurazioa zaharkituta dago eta eguneratu egin behar da." #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? -msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/fi/LC_MESSAGES/volto.po b/locales/fi/LC_MESSAGES/volto.po index 30c8401636..1f5887dc11 100644 --- a/locales/fi/LC_MESSAGES/volto.po +++ b/locales/fi/LC_MESSAGES/volto.po @@ -419,8 +419,8 @@ msgid "Assignments" msgstr "Tehtävät" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Autosave found -msgid "Autosave found" +# defaultMessage: Autosaved content found +msgid "Autosaved content found" msgstr "" #: components/manage/Controlpanels/AddonsControlpanel @@ -1105,8 +1105,8 @@ msgid "Do you really want to delete this item?" msgstr "Haluatko varmasti poistaa tämän sisällön?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load it? -msgid "Do you want to load it?" +# defaultMessage: Do you want to load the autosaved content? +msgid "Do you want to load the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3629,8 +3629,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "Sivuston konfiguraatio on vanhentunut ja se pitää päivittää." #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? -msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/fr/LC_MESSAGES/volto.po b/locales/fr/LC_MESSAGES/volto.po index ce4edfbf95..ff722410b1 100644 --- a/locales/fr/LC_MESSAGES/volto.po +++ b/locales/fr/LC_MESSAGES/volto.po @@ -425,8 +425,8 @@ msgid "Assignments" msgstr "Affectations" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Autosave found -msgid "Autosave found" +# defaultMessage: Autosaved content found +msgid "Autosaved content found" msgstr "" #: components/manage/Controlpanels/AddonsControlpanel @@ -1111,8 +1111,8 @@ msgid "Do you really want to delete this item?" msgstr "Voulez-vous vraiment supprimer cet élément ?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load it? -msgid "Do you want to load it?" +# defaultMessage: Do you want to load the autosaved content? +msgid "Do you want to load the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3635,8 +3635,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "La configuration du site nécessite une mise à niveau." #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? -msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/it/LC_MESSAGES/volto.po b/locales/it/LC_MESSAGES/volto.po index 9b348366de..fd69cfb62c 100644 --- a/locales/it/LC_MESSAGES/volto.po +++ b/locales/it/LC_MESSAGES/volto.po @@ -408,8 +408,8 @@ msgid "Assignments" msgstr "Assegnazione" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Autosave found -msgid "Autosave found" +# defaultMessage: Autosaved content found +msgid "Autosaved content found" msgstr "" #: components/manage/Controlpanels/AddonsControlpanel @@ -1094,8 +1094,8 @@ msgid "Do you really want to delete this item?" msgstr "Vuoi veramente eliminare questo elemento?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load it? -msgid "Do you want to load it?" +# defaultMessage: Do you want to load the autosaved content? +msgid "Do you want to load the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3618,8 +3618,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "La configurazione del sito è obsoleta e deve essere aggiornata." #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? -msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/ja/LC_MESSAGES/volto.po b/locales/ja/LC_MESSAGES/volto.po index 634089a93f..6ac6612101 100644 --- a/locales/ja/LC_MESSAGES/volto.po +++ b/locales/ja/LC_MESSAGES/volto.po @@ -416,8 +416,8 @@ msgid "Assignments" msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Autosave found -msgid "Autosave found" +# defaultMessage: Autosaved content found +msgid "Autosaved content found" msgstr "" #: components/manage/Controlpanels/AddonsControlpanel @@ -1102,8 +1102,8 @@ msgid "Do you really want to delete this item?" msgstr "このアイテムを削除してよろしいですか?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load it? -msgid "Do you want to load it?" +# defaultMessage: Do you want to load the autosaved content? +msgid "Do you want to load the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3626,8 +3626,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? -msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/nl/LC_MESSAGES/volto.po b/locales/nl/LC_MESSAGES/volto.po index bd05029726..1f80f13e87 100644 --- a/locales/nl/LC_MESSAGES/volto.po +++ b/locales/nl/LC_MESSAGES/volto.po @@ -427,8 +427,8 @@ msgid "Assignments" msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Autosave found -msgid "Autosave found" +# defaultMessage: Autosaved content found +msgid "Autosaved content found" msgstr "" #: components/manage/Controlpanels/AddonsControlpanel @@ -1113,8 +1113,8 @@ msgid "Do you really want to delete this item?" msgstr "Weet u zeker dat u dit item wilt verwijderen?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load it? -msgid "Do you want to load it?" +# defaultMessage: Do you want to load the autosaved content? +msgid "Do you want to load the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3637,8 +3637,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? -msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/pt/LC_MESSAGES/volto.po b/locales/pt/LC_MESSAGES/volto.po index 735e19c686..8f1daa9efc 100644 --- a/locales/pt/LC_MESSAGES/volto.po +++ b/locales/pt/LC_MESSAGES/volto.po @@ -416,8 +416,8 @@ msgid "Assignments" msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Autosave found -msgid "Autosave found" +# defaultMessage: Autosaved content found +msgid "Autosaved content found" msgstr "" #: components/manage/Controlpanels/AddonsControlpanel @@ -1102,8 +1102,8 @@ msgid "Do you really want to delete this item?" msgstr "Quer mesmo eliminar este item?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load it? -msgid "Do you want to load it?" +# defaultMessage: Do you want to load the autosaved content? +msgid "Do you want to load the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3626,8 +3626,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? -msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/pt_BR/LC_MESSAGES/volto.po b/locales/pt_BR/LC_MESSAGES/volto.po index 9dea719ba4..04727eceb6 100644 --- a/locales/pt_BR/LC_MESSAGES/volto.po +++ b/locales/pt_BR/LC_MESSAGES/volto.po @@ -418,8 +418,8 @@ msgid "Assignments" msgstr "Atribuições" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Autosave found -msgid "Autosave found" +# defaultMessage: Autosaved content found +msgid "Autosaved content found" msgstr "" #: components/manage/Controlpanels/AddonsControlpanel @@ -1104,8 +1104,8 @@ msgid "Do you really want to delete this item?" msgstr "Você realmente quer excluir este item?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load it? -msgid "Do you want to load it?" +# defaultMessage: Do you want to load the autosaved content? +msgid "Do you want to load the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3628,8 +3628,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "A configuração do site está desatualizada e precisa ser atualizada." #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? -msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/ro/LC_MESSAGES/volto.po b/locales/ro/LC_MESSAGES/volto.po index aaa63d018b..ef27d9473e 100644 --- a/locales/ro/LC_MESSAGES/volto.po +++ b/locales/ro/LC_MESSAGES/volto.po @@ -408,8 +408,8 @@ msgid "Assignments" msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Autosave found -msgid "Autosave found" +# defaultMessage: Autosaved content found +msgid "Autosaved content found" msgstr "" #: components/manage/Controlpanels/AddonsControlpanel @@ -1094,8 +1094,8 @@ msgid "Do you really want to delete this item?" msgstr "Doriți cu adevărat să ștergeți acest articol?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load it? -msgid "Do you want to load it?" +# defaultMessage: Do you want to load the autosaved content? +msgid "Do you want to load the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3618,8 +3618,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? -msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/volto.pot b/locales/volto.pot index 5b8ba56455..50d8a5f3ce 100644 --- a/locales/volto.pot +++ b/locales/volto.pot @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: Plone\n" -"POT-Creation-Date: 2023-08-10T11:08:51.764Z\n" +"POT-Creation-Date: 2023-09-15T14:47:53.011Z\n" "Last-Translator: Plone i18n \n" "Language-Team: Plone i18n \n" "MIME-Version: 1.0\n" @@ -410,8 +410,8 @@ msgid "Assignments" msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Autosave found -msgid "Autosave found" +# defaultMessage: Autosaved content found +msgid "Autosaved content found" msgstr "" #: components/manage/Controlpanels/AddonsControlpanel @@ -1096,8 +1096,8 @@ msgid "Do you really want to delete this item?" msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load it? -msgid "Do you want to load it?" +# defaultMessage: Do you want to load the autosaved content? +msgid "Do you want to load the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3620,8 +3620,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? -msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/zh_CN/LC_MESSAGES/volto.po b/locales/zh_CN/LC_MESSAGES/volto.po index a5f26dcb38..90329cca88 100644 --- a/locales/zh_CN/LC_MESSAGES/volto.po +++ b/locales/zh_CN/LC_MESSAGES/volto.po @@ -414,8 +414,8 @@ msgid "Assignments" msgstr "分配" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Autosave found -msgid "Autosave found" +# defaultMessage: Autosaved content found +msgid "Autosaved content found" msgstr "" #: components/manage/Controlpanels/AddonsControlpanel @@ -1100,8 +1100,8 @@ msgid "Do you really want to delete this item?" msgstr "确定要删除这个条目吗" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load it? -msgid "Do you want to load it?" +# defaultMessage: Do you want to load the autosaved content? +msgid "Do you want to load the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3624,8 +3624,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "网站配置已过时,需要升级。" #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version found is less recent than the server, do you want to load it (you can undo if you change your mind)? -msgid "The version found is less recent than the server, do you want to load it (you can undo if you change your mind)?" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More From 5c225357ad93cd4214a24cb681c4faa685d9977b Mon Sep 17 00:00:00 2001 From: ALEXANDRU MEDESAN Date: Tue, 26 Sep 2023 11:23:37 +0300 Subject: [PATCH 51/53] fix: eslint --- src/helpers/Utils/withSaveAsDraft.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/helpers/Utils/withSaveAsDraft.js b/src/helpers/Utils/withSaveAsDraft.js index 209e764cc0..13609fc4cf 100644 --- a/src/helpers/Utils/withSaveAsDraft.js +++ b/src/helpers/Utils/withSaveAsDraft.js @@ -19,8 +19,7 @@ const messages = defineMessages({ defaultMessage: 'Do you want to load the autosaved content?', }, loadExpiredData: { - id: - 'The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)', + id: 'The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)', defaultMessage: 'The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)', }, @@ -209,13 +208,10 @@ export default function withSaveAsDraft(options) { const id = getFormId(props, location); const ref = React.useRef(); const ref2 = React.useRef(); - const api = React.useMemo(() => draftApi(id, schema, ref, ref2, intl), [ - id, - schema, - ref, - ref2, - intl, - ]); + const api = React.useMemo( + () => draftApi(id, schema, ref, ref2, intl), + [id, schema, ref, ref2, intl], + ); return ( Date: Tue, 26 Sep 2023 23:52:36 -0700 Subject: [PATCH 52/53] Replace "load" with "restore". Add "autosave" to Vale's Plone dictionary. --- docs/source/user-manual/autosave.md | 28 +++++++++++++++++++--------- locales/ca/LC_MESSAGES/volto.po | 8 ++++---- locales/de/LC_MESSAGES/volto.po | 8 ++++---- locales/en/LC_MESSAGES/volto.po | 8 ++++---- locales/es/LC_MESSAGES/volto.po | 8 ++++---- locales/eu/LC_MESSAGES/volto.po | 8 ++++---- locales/fi/LC_MESSAGES/volto.po | 12 ++++++------ locales/fr/LC_MESSAGES/volto.po | 8 ++++---- locales/it/LC_MESSAGES/volto.po | 8 ++++---- locales/ja/LC_MESSAGES/volto.po | 8 ++++---- locales/nl/LC_MESSAGES/volto.po | 8 ++++---- locales/pt/LC_MESSAGES/volto.po | 10 +++++----- locales/pt_BR/LC_MESSAGES/volto.po | 8 ++++---- locales/ro/LC_MESSAGES/volto.po | 8 ++++---- locales/volto.pot | 12 ++++++------ locales/zh_CN/LC_MESSAGES/volto.po | 8 ++++---- news/4168.feature | 2 +- src/helpers/Utils/withSaveAsDraft.js | 8 ++++---- styles/Vocab/Plone/accept.txt | 1 + 19 files changed, 90 insertions(+), 79 deletions(-) diff --git a/docs/source/user-manual/autosave.md b/docs/source/user-manual/autosave.md index be0b9a635e..278a0992a9 100644 --- a/docs/source/user-manual/autosave.md +++ b/docs/source/user-manual/autosave.md @@ -3,26 +3,30 @@ myst: html_meta: "description": "User manual for how Volto autosaves data in Plone 6." "property=og:description": "User manual for how Volto autosaves data in Plone 6." - "property=og:title": "How to autosave content in Volto for edit, add, and comments" - "keywords": "Volto, Plone, frontend, React, User manual, autosave" + "property=og:title": "How to autosave content in Volto when editing, adding, or commenting on content." + "keywords": "Volto, Plone, frontend, React, User manual, autosave, restore" --- (autosave-content-label)= # Autosave content -The autosave feature allows you to load locally saved data, in case of accidental browser close, refresh, quit, or change page. +The autosave feature allows you to restore locally saved data, in case of accidental browser close, refresh, quit, or change page. It uses the [`localStorage` property](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). -It clears the data once either the form is saved or you cancel loading the local data. -If local data is found for the specific content, a toast is shown that allows you to either load ({guilabel}`OK`) or discard ({guilabel}`Cancel`). -If local data is stale, it will still show the toast, but it will specify that the found data is less recent than the server one. +It clears the data when either the form is saved or you cancel restoring the local data. +If local data is found for the specific content, a toast is shown that allows you to either restore ({guilabel}`OK`) or discard ({guilabel}`Cancel`) it. +If local data is older than data on the server, it will still show the toast, but it will specify that the found local data is older than the server data. + (autosave-edit-mode-label)= + ## Autosave edit mode + A local copy of the form is saved in `localStorage` when you start to edit, not when you merely open the page in edit mode. Changing the form will update the `localStorage` with a new complete copy of the form. -In case you close the tab, quit, refresh, change the page, or cancel edit, when you revisit the page in edit mode, it will display a toast for the found data. +In case you close the tab, quit, refresh, change the page, or cancel editing, when you revisit the page in edit mode, it will display a toast for the found data. Data is saved with a unique id: + ```js const id = isEditForm ? ['form', type, pathname].join('-') // edit @@ -32,17 +36,23 @@ Data is saved with a unique id: ? ['form', pathname, 'comment'].join('-') // comments : ['form', pathname].join('-'); ``` + Local data for the current content will be deleted, when you save the form or choose {guilabel}`Cancel` from the toast. + (autosave-new-content-label)= ## Autosave new content + When adding content, a copy of the form will be saved in `localStorage`, similar to edit mode. But since the content hasn't been saved yet, we don't have an ID. In this case the content type will be used. -Since it also uses the path to create the ID, the local data will be loaded again if you exit without saving, and only if you add the same content in the same path. +Since it also uses the path to create the ID, the local data will be restored if you exit without saving, and only if you add the same content in the same path. + (autosave-comments-label)= + ## Autosave comments + Comments are also saved locally, even though you are not in edit or add mode. -After loading local data, if a comment is submitted, it will be deleted from `localStorage`. \ No newline at end of file +After restoring local data, if a comment is submitted, it will be deleted from `localStorage`. diff --git a/locales/ca/LC_MESSAGES/volto.po b/locales/ca/LC_MESSAGES/volto.po index 326d3a45ab..032336dabd 100644 --- a/locales/ca/LC_MESSAGES/volto.po +++ b/locales/ca/LC_MESSAGES/volto.po @@ -1103,8 +1103,8 @@ msgid "Do you really want to delete this item?" msgstr "Realment voleu suprimir aquest element?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load the autosaved content? -msgid "Do you want to load the autosaved content?" +# defaultMessage: Do you want to restore the autosaved content? +msgid "Do you want to restore the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3628,8 +3628,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) -msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/de/LC_MESSAGES/volto.po b/locales/de/LC_MESSAGES/volto.po index 09a809230b..9db0ae882b 100644 --- a/locales/de/LC_MESSAGES/volto.po +++ b/locales/de/LC_MESSAGES/volto.po @@ -1100,8 +1100,8 @@ msgid "Do you really want to delete this item?" msgstr "Möchten Sie den Artikel wirklich löschen?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load the autosaved content? -msgid "Do you want to load the autosaved content?" +# defaultMessage: Do you want to restore the autosaved content? +msgid "Do you want to restore the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3625,8 +3625,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "Die Seitenkonfiguration ist veraltet und muss aktualisiert werden." #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) -msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/en/LC_MESSAGES/volto.po b/locales/en/LC_MESSAGES/volto.po index e63e5b86c2..a52c647b95 100644 --- a/locales/en/LC_MESSAGES/volto.po +++ b/locales/en/LC_MESSAGES/volto.po @@ -1094,8 +1094,8 @@ msgid "Do you really want to delete this item?" msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load the autosaved content? -msgid "Do you want to load the autosaved content?" +# defaultMessage: Do you want to restore the autosaved content? +msgid "Do you want to restore the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3619,8 +3619,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) -msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/es/LC_MESSAGES/volto.po b/locales/es/LC_MESSAGES/volto.po index 15b78f8fba..8fb60d836d 100644 --- a/locales/es/LC_MESSAGES/volto.po +++ b/locales/es/LC_MESSAGES/volto.po @@ -1105,8 +1105,8 @@ msgid "Do you really want to delete this item?" msgstr "¿Usted realmente quiere eliminar este elemento?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load the autosaved content? -msgid "Do you want to load the autosaved content?" +# defaultMessage: Do you want to restore the autosaved content? +msgid "Do you want to restore the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3630,8 +3630,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "La configuración del sitio está anticuada y debe ser actualizada." #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) -msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/eu/LC_MESSAGES/volto.po b/locales/eu/LC_MESSAGES/volto.po index 4a10b6fc33..ff5a037063 100644 --- a/locales/eu/LC_MESSAGES/volto.po +++ b/locales/eu/LC_MESSAGES/volto.po @@ -1101,8 +1101,8 @@ msgid "Do you really want to delete this item?" msgstr "Elementu hau ezabatu egin nahi duzu?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load the autosaved content? -msgid "Do you want to load the autosaved content?" +# defaultMessage: Do you want to restore the autosaved content? +msgid "Do you want to restore the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3626,8 +3626,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "Atariaren konfigurazioa zaharkituta dago eta eguneratu egin behar da." #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) -msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/fi/LC_MESSAGES/volto.po b/locales/fi/LC_MESSAGES/volto.po index fae99dd97b..d46bd4da1b 100644 --- a/locales/fi/LC_MESSAGES/volto.po +++ b/locales/fi/LC_MESSAGES/volto.po @@ -1,9 +1,9 @@ -# +# # Translators: # Petri Savolainen , 2020 # Asko Soukka , 2020 # Rikupekka Oksanen , 2022 -# +# msgid "" msgstr "" "Project-Id-Version: Plone\n" @@ -1105,8 +1105,8 @@ msgid "Do you really want to delete this item?" msgstr "Haluatko varmasti poistaa tämän sisällön?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load the autosaved content? -msgid "Do you want to load the autosaved content?" +# defaultMessage: Do you want to restore the autosaved content? +msgid "Do you want to restore the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3630,8 +3630,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "Sivuston konfiguraatio on vanhentunut ja se pitää päivittää." #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) -msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/fr/LC_MESSAGES/volto.po b/locales/fr/LC_MESSAGES/volto.po index 0d47e946d7..cc7254db8d 100644 --- a/locales/fr/LC_MESSAGES/volto.po +++ b/locales/fr/LC_MESSAGES/volto.po @@ -1111,8 +1111,8 @@ msgid "Do you really want to delete this item?" msgstr "Voulez-vous vraiment supprimer cet élément ?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load the autosaved content? -msgid "Do you want to load the autosaved content?" +# defaultMessage: Do you want to restore the autosaved content? +msgid "Do you want to restore the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3636,8 +3636,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "La configuration du site nécessite une mise à niveau." #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) -msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/it/LC_MESSAGES/volto.po b/locales/it/LC_MESSAGES/volto.po index 985b5d7da2..caf5809759 100644 --- a/locales/it/LC_MESSAGES/volto.po +++ b/locales/it/LC_MESSAGES/volto.po @@ -1094,8 +1094,8 @@ msgid "Do you really want to delete this item?" msgstr "Vuoi veramente eliminare questo elemento?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load the autosaved content? -msgid "Do you want to load the autosaved content?" +# defaultMessage: Do you want to restore the autosaved content? +msgid "Do you want to restore the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3619,8 +3619,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "La configurazione del sito è obsoleta e deve essere aggiornata." #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) -msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/ja/LC_MESSAGES/volto.po b/locales/ja/LC_MESSAGES/volto.po index 6f8d07c02e..a67ab2e6ab 100644 --- a/locales/ja/LC_MESSAGES/volto.po +++ b/locales/ja/LC_MESSAGES/volto.po @@ -1102,8 +1102,8 @@ msgid "Do you really want to delete this item?" msgstr "このアイテムを削除してよろしいですか?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load the autosaved content? -msgid "Do you want to load the autosaved content?" +# defaultMessage: Do you want to restore the autosaved content? +msgid "Do you want to restore the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3627,8 +3627,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) -msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/nl/LC_MESSAGES/volto.po b/locales/nl/LC_MESSAGES/volto.po index de557d628b..b7a93374bd 100644 --- a/locales/nl/LC_MESSAGES/volto.po +++ b/locales/nl/LC_MESSAGES/volto.po @@ -1113,8 +1113,8 @@ msgid "Do you really want to delete this item?" msgstr "Weet u zeker dat u dit item wilt verwijderen?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load the autosaved content? -msgid "Do you want to load the autosaved content?" +# defaultMessage: Do you want to restore the autosaved content? +msgid "Do you want to restore the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3638,8 +3638,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) -msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/pt/LC_MESSAGES/volto.po b/locales/pt/LC_MESSAGES/volto.po index b697447bdd..4888ff6046 100644 --- a/locales/pt/LC_MESSAGES/volto.po +++ b/locales/pt/LC_MESSAGES/volto.po @@ -1,6 +1,6 @@ # Translators: # Emanuel de Jesus , 2019 -# +# msgid "" msgstr "" "Project-Id-Version: Plone\n" @@ -1102,8 +1102,8 @@ msgid "Do you really want to delete this item?" msgstr "Quer mesmo eliminar este item?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load the autosaved content? -msgid "Do you want to load the autosaved content?" +# defaultMessage: Do you want to restore the autosaved content? +msgid "Do you want to restore the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3627,8 +3627,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) -msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/pt_BR/LC_MESSAGES/volto.po b/locales/pt_BR/LC_MESSAGES/volto.po index 0a0a9fb95c..61103974c3 100644 --- a/locales/pt_BR/LC_MESSAGES/volto.po +++ b/locales/pt_BR/LC_MESSAGES/volto.po @@ -1104,8 +1104,8 @@ msgid "Do you really want to delete this item?" msgstr "Você realmente quer excluir este item?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load the autosaved content? -msgid "Do you want to load the autosaved content?" +# defaultMessage: Do you want to restore the autosaved content? +msgid "Do you want to restore the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3629,8 +3629,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "A configuração do site está desatualizada e precisa ser atualizada." #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) -msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/ro/LC_MESSAGES/volto.po b/locales/ro/LC_MESSAGES/volto.po index c69554a9d3..d3721fd455 100644 --- a/locales/ro/LC_MESSAGES/volto.po +++ b/locales/ro/LC_MESSAGES/volto.po @@ -1094,8 +1094,8 @@ msgid "Do you really want to delete this item?" msgstr "Doriți cu adevărat să ștergeți acest articol?" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load the autosaved content? -msgid "Do you want to load the autosaved content?" +# defaultMessage: Do you want to restore the autosaved content? +msgid "Do you want to restore the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3619,8 +3619,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) -msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/volto.pot b/locales/volto.pot index 59c1cb5304..88e5713b11 100644 --- a/locales/volto.pot +++ b/locales/volto.pot @@ -39,7 +39,7 @@ msgid "Action changed" msgstr "" #: components/manage/Controlpanels/Rules/ConfigureRule -# defaultMessage: Action: +# defaultMessage: Action: msgid "Action: " msgstr "" @@ -688,7 +688,7 @@ msgid "Condition changed" msgstr "" #: components/manage/Controlpanels/Rules/ConfigureRule -# defaultMessage: Condition: +# defaultMessage: Condition: msgid "Condition: " msgstr "" @@ -1096,8 +1096,8 @@ msgid "Do you really want to delete this item?" msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load the autosaved content? -msgid "Do you want to load the autosaved content?" +# defaultMessage: Do you want to restore the autosaved content? +msgid "Do you want to restore the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3623,8 +3623,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "" #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) -msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/locales/zh_CN/LC_MESSAGES/volto.po b/locales/zh_CN/LC_MESSAGES/volto.po index 673e70e0c4..fd6f8fde48 100644 --- a/locales/zh_CN/LC_MESSAGES/volto.po +++ b/locales/zh_CN/LC_MESSAGES/volto.po @@ -1100,8 +1100,8 @@ msgid "Do you really want to delete this item?" msgstr "确定要删除这个条目吗" #: helpers/Utils/withSaveAsDraft -# defaultMessage: Do you want to load the autosaved content? -msgid "Do you want to load the autosaved content?" +# defaultMessage: Do you want to restore the autosaved content? +msgid "Do you want to restore the autosaved content?" msgstr "" #: components/manage/Multilingual/TranslationObject @@ -3625,8 +3625,8 @@ msgid "The site configuration is outdated and needs to be upgraded." msgstr "网站配置已过时,需要升级。" #: helpers/Utils/withSaveAsDraft -# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.) -msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)" +# defaultMessage: The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.) +msgid "The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.)" msgstr "" #: components/manage/Toolbar/More diff --git a/news/4168.feature b/news/4168.feature index ff2a7f54db..e300fa6602 100644 --- a/news/4168.feature +++ b/news/4168.feature @@ -1,3 +1,3 @@ Add Auto-Save option. It will save a copy of the form, even comments even for adding a new content item. It detects if local data is less recent than server data. Saving the form will delete the local data for the specific form. -User can choose to not load the local data and this will also delete the local data. +User can choose to not restore the local data and this will also delete the local data. @tiberiuichim @rexalex @stevepiercy diff --git a/src/helpers/Utils/withSaveAsDraft.js b/src/helpers/Utils/withSaveAsDraft.js index 13609fc4cf..8b6fa87c94 100644 --- a/src/helpers/Utils/withSaveAsDraft.js +++ b/src/helpers/Utils/withSaveAsDraft.js @@ -15,13 +15,13 @@ const messages = defineMessages({ defaultMessage: 'Autosaved content found', }, loadData: { - id: 'Do you want to load the autosaved content?', - defaultMessage: 'Do you want to load the autosaved content?', + id: 'Do you want to restore the autosaved content?', + defaultMessage: 'Do you want to restore the autosaved content?', }, loadExpiredData: { - id: 'The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)', + id: 'The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.)', defaultMessage: - 'The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to load the autosaved content? (You can undo the autosaved content and revert to the server version.)', + 'The version of the autosaved content I found in your browser is older than that stored on the server. Do you want to restore the autosaved content? (You can undo the autosaved content and revert to the server version.)', }, }); diff --git a/styles/Vocab/Plone/accept.txt b/styles/Vocab/Plone/accept.txt index c523e05d3e..40ab3e53de 100644 --- a/styles/Vocab/Plone/accept.txt +++ b/styles/Vocab/Plone/accept.txt @@ -2,6 +2,7 @@ -{0,1}volto-{0,1} `plone.restapi` `plone.volto` +[Aa]utosave [Aa]sync [Bb]ackend JavaScript From 531d5d8052f6dc355c84f0072cb0986874b41b69 Mon Sep 17 00:00:00 2001 From: Steve Piercy Date: Wed, 27 Sep 2023 00:17:47 -0700 Subject: [PATCH 53/53] Attempt to clean up i18n errors in CI. --- locales/fi/LC_MESSAGES/volto.po | 3 +-- locales/pt/LC_MESSAGES/volto.po | 2 +- locales/volto.pot | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/locales/fi/LC_MESSAGES/volto.po b/locales/fi/LC_MESSAGES/volto.po index 500d802b27..60fcc403c4 100644 --- a/locales/fi/LC_MESSAGES/volto.po +++ b/locales/fi/LC_MESSAGES/volto.po @@ -1,9 +1,8 @@ -# +# Translation of plone.pot to Finnish # Translators: # Petri Savolainen , 2020 # Asko Soukka , 2020 # Rikupekka Oksanen , 2022 -# msgid "" msgstr "" "Project-Id-Version: Plone\n" diff --git a/locales/pt/LC_MESSAGES/volto.po b/locales/pt/LC_MESSAGES/volto.po index 2e3b793aee..51251de395 100644 --- a/locales/pt/LC_MESSAGES/volto.po +++ b/locales/pt/LC_MESSAGES/volto.po @@ -1,6 +1,6 @@ +# Translation of plone.pot to Portuguese # Translators: # Emanuel de Jesus , 2019 -# msgid "" msgstr "" "Project-Id-Version: Plone\n" diff --git a/locales/volto.pot b/locales/volto.pot index 2d4f6f931d..75669458e6 100644 --- a/locales/volto.pot +++ b/locales/volto.pot @@ -1,7 +1,7 @@ msgid "" msgstr "" "Project-Id-Version: Plone\n" -"POT-Creation-Date: 2023-09-26T10:20:03.552Z\n" +"POT-Creation-Date: 2023-09-27T06:57:49.909Z\n" "Last-Translator: Plone i18n \n" "Language-Team: Plone i18n \n" "MIME-Version: 1.0\n"