@plone/volto 19.0.0-alpha.0 → 19.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +2 -0
- package/.eslintrc +37 -0
- package/CHANGELOG.md +274 -2
- package/README.md +3 -6
- package/cypress/docker/prefixed-rules.yml +26 -0
- package/cypress/docker/prefixed.yml +24 -0
- package/cypress/support/commands.js +12 -6
- package/cypress/support/guillotina.js +1 -0
- package/cypress.config.js +1 -0
- package/locales/af.json +1 -0
- package/locales/ar.json +1 -0
- package/locales/bg.json +1 -0
- package/locales/bn.json +1 -0
- package/locales/ca/LC_MESSAGES/volto.po +96 -17
- package/locales/ca.json +1 -1
- package/locales/cs.json +1 -0
- package/locales/cy.json +1 -0
- package/locales/da.json +1 -0
- package/locales/de/LC_MESSAGES/volto.po +104 -25
- package/locales/de.json +1 -1
- package/locales/el.json +1 -0
- package/locales/en/LC_MESSAGES/volto.po +97 -18
- package/locales/en.json +1 -1
- package/locales/en_AU.json +1 -0
- package/locales/en_GB.json +1 -0
- package/locales/eo.json +1 -0
- package/locales/es/LC_MESSAGES/volto.po +97 -18
- package/locales/es.json +1 -1
- package/locales/et.json +1 -0
- package/locales/eu/LC_MESSAGES/volto.po +96 -17
- package/locales/eu.json +1 -1
- package/locales/fa.json +1 -0
- package/locales/fi/LC_MESSAGES/volto.po +96 -17
- package/locales/fi.json +1 -1
- package/locales/fr/LC_MESSAGES/volto.po +97 -18
- package/locales/fr.json +1 -1
- package/locales/fu.json +1 -0
- package/locales/gl.json +1 -0
- package/locales/he.json +1 -0
- package/locales/hi/LC_MESSAGES/volto.po +100 -21
- package/locales/hi.json +1 -1
- package/locales/hr.json +1 -0
- package/locales/hu.json +1 -0
- package/locales/hy.json +1 -0
- package/locales/id.json +1 -0
- package/locales/it/LC_MESSAGES/volto.po +101 -22
- package/locales/it.json +1 -1
- package/locales/ja/LC_MESSAGES/volto.po +96 -17
- package/locales/ja.json +1 -1
- package/locales/ka.json +1 -0
- package/locales/kn.json +1 -0
- package/locales/ko.json +1 -0
- package/locales/lt.json +1 -0
- package/locales/lv.json +1 -0
- package/locales/mi.json +1 -0
- package/locales/mk.json +1 -0
- package/locales/my.json +1 -0
- package/locales/nb_NO.json +1 -0
- package/locales/nl/LC_MESSAGES/volto.po +100 -21
- package/locales/nl.json +1 -1
- package/locales/nn.json +1 -0
- package/locales/pl.json +1 -0
- package/locales/pt/LC_MESSAGES/volto.po +96 -17
- package/locales/pt.json +1 -1
- package/locales/pt_BR/LC_MESSAGES/volto.po +116 -37
- package/locales/pt_BR.json +1 -1
- package/locales/rm.json +1 -0
- package/locales/ro/LC_MESSAGES/volto.po +100 -21
- package/locales/ro.json +1 -1
- package/locales/ru/LC_MESSAGES/volto.po +100 -21
- package/locales/ru.json +1 -1
- package/locales/sk.json +1 -0
- package/locales/sl.json +1 -0
- package/locales/sm.json +1 -0
- package/locales/sq.json +1 -0
- package/locales/sr.json +1 -0
- package/locales/sr@cyrl.json +1 -0
- package/locales/sr@latn.json +1 -0
- package/locales/sv.json +1 -1
- package/locales/ta.json +1 -0
- package/locales/te.json +1 -0
- package/locales/th.json +1 -0
- package/locales/to.json +1 -0
- package/locales/tr.json +1 -0
- package/locales/uk.json +1 -0
- package/locales/vi.json +1 -0
- package/locales/volto.pot +97 -18
- package/locales/zh_CN/LC_MESSAGES/volto.po +96 -17
- package/locales/zh_CN.json +1 -1
- package/locales/zh_Hant.json +1 -0
- package/locales/zh_Hant_HK.json +1 -0
- package/package.json +36 -27
- package/razzle.config.js +16 -0
- package/src/actions/actions/actions.test.js +3 -3
- package/src/actions/addons/addons.test.js +15 -12
- package/src/actions/aliases/aliases.test.js +1 -1
- package/src/actions/content/content.js +0 -1
- package/src/actions/controlpanels/controlpanels.js +13 -7
- package/src/actions/controlpanels/controlpanels.test.js +11 -5
- package/src/actions/querystring/querystring.test.js +2 -2
- package/src/actions/types/types.test.js +1 -1
- package/src/actions/users/users.js +2 -2
- package/src/components/manage/Actions/Actions.test.jsx +5 -1
- package/src/components/manage/Add/Add.jsx +27 -26
- package/src/components/manage/Add/Add.test.jsx +6 -3
- package/src/components/manage/Aliases/Aliases.test.jsx +7 -7
- package/src/components/manage/Blocks/Block/BlocksForm.jsx +1 -0
- package/src/components/manage/Blocks/Block/BlocksForm.test.jsx +48 -16
- package/src/components/manage/Blocks/Block/Edit.jsx +3 -1
- package/src/components/manage/Blocks/Block/EditBlockWrapper.jsx +9 -4
- package/src/components/manage/Blocks/Block/Settings.test.jsx +5 -1
- package/src/components/manage/Blocks/Block/StyleWrapper.jsx +11 -3
- package/src/components/manage/Blocks/Description/View.test.jsx +1 -1
- package/src/components/manage/Blocks/HTML/Edit.test.jsx +12 -5
- package/src/components/manage/Blocks/HTML/View.test.jsx +1 -1
- package/src/components/manage/Blocks/Image/Edit.jsx +5 -1
- package/src/components/manage/Blocks/Image/ImageSidebar.test.jsx +6 -2
- package/src/components/manage/Blocks/LeadImage/Edit.jsx +2 -2
- package/src/components/manage/Blocks/LeadImage/LeadImageSidebar.jsx +1 -1
- package/src/components/manage/Blocks/LeadImage/LeadImageSidebar.test.jsx +8 -1
- package/src/components/manage/Blocks/Listing/ImageGallery.jsx +6 -4
- package/src/components/manage/Blocks/Listing/View.test.jsx +3 -1
- package/src/components/manage/Blocks/Maps/Edit.jsx +2 -1
- package/src/components/manage/Blocks/Maps/MapsSidebar.test.jsx +5 -1
- package/src/components/manage/Blocks/Search/SearchBlockView.jsx +21 -4
- package/src/components/manage/Blocks/Search/components/DateRangeFacet.test.jsx +13 -7
- package/src/components/manage/Blocks/Search/components/SelectFacet.test.jsx +12 -6
- package/src/components/manage/Blocks/Teaser/Data.jsx +21 -7
- package/src/components/manage/Blocks/Teaser/DefaultBody.jsx +1 -1
- package/src/components/manage/Blocks/Teaser/schema.js +8 -3
- package/src/components/manage/Blocks/Title/Edit.jsx +8 -2
- package/src/components/manage/Blocks/ToC/variations/DefaultTocRenderer.test.jsx +11 -1
- package/src/components/manage/Blocks/Video/Edit.jsx +2 -1
- package/src/components/manage/Blocks/Video/VideoSidebar.test.jsx +5 -1
- package/src/components/manage/ConditionalLink/ConditionalLink.test.tsx +109 -0
- package/src/components/manage/ConditionalLink/ConditionalLink.tsx +36 -0
- package/src/components/manage/Contents/Contents.jsx +23 -2
- package/src/components/manage/Contents/Contents.test.jsx +36 -13
- package/src/components/manage/Contents/ContentsBreadcrumbs.Multilingual.test.jsx +18 -5
- package/src/components/manage/Contents/ContentsBreadcrumbs.jsx +20 -26
- package/src/components/manage/Contents/ContentsBreadcrumbs.test.jsx +14 -0
- package/src/components/manage/Contents/ContentsDeleteModal.jsx +258 -206
- package/src/components/manage/Contents/ContentsDeleteModal.stories.jsx +26 -8
- package/src/components/manage/Contents/ContentsItem.jsx +10 -2
- package/src/components/manage/Contents/ContentsPropertiesModal.test.jsx +5 -1
- package/src/components/manage/Contents/ContentsRenameModal.test.jsx +5 -1
- package/src/components/manage/Contents/ContentsTagsModal.test.jsx +5 -1
- package/src/components/manage/Contents/ContentsUploadModal.test.jsx +13 -22
- package/src/components/manage/Contents/ContentsWorkflowModal.test.jsx +5 -1
- package/src/components/manage/Contents/__mocks__/index.tsx +16 -0
- package/src/components/manage/Contents/__mocks__/index.vitest.tsx +5 -0
- package/src/components/manage/Controlpanels/AddonsControlpanel.test.jsx +28 -3
- package/src/components/manage/Controlpanels/Aliases.test.jsx +35 -3
- package/src/components/manage/Controlpanels/ContentType.jsx +1 -1
- package/src/components/manage/Controlpanels/ContentType.test.jsx +29 -3
- package/src/components/manage/Controlpanels/ContentTypeLayout.test.jsx +4 -2
- package/src/components/manage/Controlpanels/ContentTypes.test.jsx +25 -2
- package/src/components/manage/Controlpanels/Controlpanel.test.jsx +37 -6
- package/src/components/manage/Controlpanels/Controlpanels.test.jsx +47 -3
- package/src/components/manage/Controlpanels/Groups/GroupsControlpanel.jsx +3 -2
- package/src/components/manage/Controlpanels/Groups/GroupsControlpanel.test.jsx +15 -9
- package/src/components/manage/Controlpanels/ModerateComments.test.jsx +31 -5
- package/src/components/manage/Controlpanels/Rules/AddRule.test.jsx +13 -4
- package/src/components/manage/Controlpanels/Rules/ConfigureRule.test.jsx +9 -5
- package/src/components/manage/Controlpanels/Rules/EditRule.test.jsx +12 -4
- package/src/components/manage/Controlpanels/Rules/Rules.test.jsx +7 -3
- package/src/components/manage/Controlpanels/UndoControlpanel.test.jsx +33 -4
- package/src/components/manage/Controlpanels/Users/RenderUsers.jsx +156 -175
- package/src/components/manage/Controlpanels/Users/UserGroupMembershipControlPanel.test.jsx +3 -1
- package/src/components/manage/Controlpanels/Users/UsersControlpanel.jsx +575 -630
- package/src/components/manage/Controlpanels/Users/UsersControlpanel.test.jsx +16 -9
- package/src/components/manage/Delete/Delete.test.jsx +45 -4
- package/src/components/manage/Diff/Diff.test.jsx +15 -6
- package/src/components/manage/Diff/DiffField.test.jsx +12 -6
- package/src/components/manage/Display/Display.test.jsx +17 -6
- package/src/components/manage/Edit/Edit.jsx +2 -3
- package/src/components/manage/Edit/Edit.test.jsx +11 -3
- package/src/components/manage/Form/BlockDataForm.test.jsx +5 -1
- package/src/components/manage/Form/Form.jsx +32 -0
- package/src/components/manage/Form/Form.test.jsx +27 -19
- package/src/components/manage/Form/InlineForm.jsx +2 -2
- package/src/components/manage/Form/InlineForm.test.jsx +5 -1
- package/src/components/manage/Form/ModalForm.test.jsx +5 -1
- package/src/components/manage/Form/__mocks__/index.tsx +17 -0
- package/src/components/manage/Form/__mocks__/index.vitest.tsx +73 -0
- package/src/components/manage/History/History.test.jsx +3 -1
- package/src/components/manage/LinksToItem/LinksToItem.test.jsx +6 -4
- package/src/components/manage/MaybeWrap/MaybeWrap.tsx +15 -0
- package/src/components/manage/Multilingual/CompareLanguages.jsx +2 -5
- package/src/components/manage/Multilingual/CreateTranslation.jsx +8 -8
- package/src/components/manage/Multilingual/ManageTranslations.jsx +4 -2
- package/src/components/manage/Multilingual/ManageTranslations.test.jsx +8 -3
- package/src/components/manage/Multilingual/TranslationObject.jsx +1 -1
- package/src/components/manage/Preferences/ChangePassword.test.jsx +9 -2
- package/src/components/manage/Preferences/PersonalInformation.test.jsx +3 -1
- package/src/components/manage/Preferences/PersonalPreferences.test.jsx +20 -7
- package/src/components/manage/Rules/Rules.test.jsx +6 -3
- package/src/components/manage/Sharing/Sharing.test.jsx +3 -1
- package/src/components/manage/Sidebar/ObjectBrowserNav.jsx +2 -1
- package/src/components/manage/Sidebar/ObjectBrowserNav.test.jsx +3 -3
- package/src/components/manage/Sidebar/SidebarPortal.test.tsx +42 -0
- package/src/components/manage/Sidebar/SidebarPortal.tsx +48 -0
- package/src/components/manage/TemplateChooser/TemplateChooser.jsx +2 -1
- package/src/components/manage/Toolbar/More.jsx +4 -1
- package/src/components/manage/Toolbar/More.test.jsx +9 -7
- package/src/components/manage/Toolbar/PersonalTools.jsx +2 -1
- package/src/components/manage/Toolbar/Toolbar.jsx +3 -4
- package/src/components/manage/Toolbar/Types.jsx +7 -7
- package/src/components/manage/UniversalLink/UniversalLink.test.jsx +196 -14
- package/src/components/manage/UniversalLink/UniversalLink.tsx +215 -0
- package/src/components/manage/Widgets/ArrayWidget.test.jsx +22 -5
- package/src/components/manage/Widgets/CheckboxGroupWidget.test.jsx +12 -5
- package/src/components/manage/Widgets/DatetimeWidget.jsx +5 -0
- package/src/components/manage/Widgets/DatetimeWidget.test.jsx +21 -6
- package/src/components/manage/Widgets/FileWidget.jsx +14 -8
- package/src/components/manage/Widgets/ImageWidget.jsx +176 -40
- package/src/components/manage/Widgets/InternalUrlWidget.jsx +2 -0
- package/src/components/manage/Widgets/NumberWidget.test.jsx +8 -7
- package/src/components/manage/Widgets/ObjectBrowserWidget.jsx +3 -0
- package/src/components/manage/Widgets/ObjectListWidget.jsx +11 -1
- package/src/components/manage/Widgets/ObjectListWidget.test.jsx +18 -8
- package/src/components/manage/Widgets/ObjectWidget.test.jsx +5 -1
- package/src/components/manage/Widgets/RadioGroupWidget.test.jsx +12 -5
- package/src/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.test.jsx +12 -6
- package/src/components/manage/Widgets/RegistryImageWidget.test.jsx +44 -41
- package/src/components/manage/Widgets/SchemaWidget.test.jsx +12 -5
- package/src/components/manage/Widgets/SchemaWidgetFieldset.test.jsx +12 -5
- package/src/components/manage/Widgets/SelectAutoComplete.jsx +29 -12
- package/src/components/manage/Widgets/SelectAutoComplete.test.jsx +12 -6
- package/src/components/manage/Widgets/SelectWidget.jsx +3 -1
- package/src/components/manage/Widgets/SelectWidget.test.jsx +12 -6
- package/src/components/manage/Widgets/TimeWidget.test.jsx +13 -5
- package/src/components/manage/Widgets/TokenWidget.test.jsx +12 -6
- package/src/components/manage/Widgets/UrlWidget.jsx +2 -0
- package/src/components/manage/Widgets/VocabularyTermsWidget.test.jsx +18 -9
- package/src/components/manage/Widgets/__mocks__/index.tsx +16 -0
- package/src/components/manage/Widgets/__mocks__/index.vitest.tsx +41 -0
- package/src/components/manage/Workflow/Workflow.test.jsx +17 -7
- package/src/components/theme/AlternateHrefLangs/AlternateHrefLangs.jsx +1 -3
- package/src/components/theme/AlternateHrefLangs/AlternateHrefLangs.test.jsx +0 -4
- package/src/components/theme/App/App.jsx +3 -1
- package/src/components/theme/App/App.test.jsx +22 -17
- package/src/components/theme/AppExtras/AppExtras.test.jsx +6 -6
- package/src/components/theme/Avatar/Avatar.jsx +2 -1
- package/src/components/theme/Comments/CommentEditModal.test.jsx +5 -1
- package/src/components/theme/Comments/Comments.test.jsx +29 -12
- package/src/components/theme/ContactForm/ContactForm.test.jsx +8 -4
- package/src/components/theme/FormattedDate/FormattedDate.stories.jsx +20 -2
- package/src/components/theme/Header/Header.test.jsx +19 -13
- package/src/components/theme/Image/Image.jsx +11 -8
- package/src/components/theme/LanguageSelector/{LanguageSelector.test.jsx → LanguageSelector.test.tsx} +6 -6
- package/src/components/theme/LanguageSelector/LanguageSelector.tsx +89 -0
- package/src/components/theme/Logo/Logo.Multilingual.test.jsx +0 -5
- package/src/components/theme/Logout/Logout.test.jsx +1 -1
- package/src/components/theme/MultilingualRedirector/MultilingualRedirector.jsx +8 -12
- package/src/components/theme/MultilingualRedirector/MultilingualRedirector.test.jsx +3 -5
- package/src/components/theme/Navigation/NavItem.jsx +1 -5
- package/src/components/theme/Navigation/Navigation.Multilingual.test.jsx +0 -5
- package/src/components/theme/NotFound/NotFound.jsx +5 -2
- package/src/components/theme/NotFound/NotFound.test.jsx +3 -0
- package/src/components/theme/PasswordReset/PasswordReset.test.jsx +10 -1
- package/src/components/theme/PasswordReset/RequestPasswordReset.test.jsx +5 -1
- package/src/components/theme/PreviewImage/PreviewImage.jsx +1 -1
- package/src/components/theme/Register/Register.test.jsx +5 -1
- package/src/components/theme/RequestTimeout/RequestTimeout.jsx +1 -1
- package/src/components/theme/Search/Search.test.jsx +6 -4
- package/src/components/theme/Sitemap/Sitemap.jsx +6 -5
- package/src/components/theme/Sitemap/Sitemap.test.jsx +0 -1
- package/src/components/theme/TsTest/TsTest.test.tsx +0 -1
- package/src/components/theme/View/EventDatesInfo.test.jsx +12 -5
- package/src/components/theme/View/EventView.test.jsx +12 -5
- package/src/components/theme/View/FileView.jsx +9 -1
- package/src/components/theme/View/ListingView.test.jsx +2 -0
- package/src/components/theme/View/SummaryView.test.jsx +10 -0
- package/src/components/theme/View/TabularView.test.jsx +1 -0
- package/src/components/theme/View/View.jsx +1 -1
- package/src/components/theme/View/View.test.jsx +42 -23
- package/src/components/theme/Widgets/ImageWidget.jsx +2 -1
- package/src/config/ControlPanels.js +1 -0
- package/src/config/index.js +18 -25
- package/src/config/server.js +0 -2
- package/src/express-middleware/devproxy.js +20 -5
- package/src/helpers/Api/APIResourceWithAuth.js +8 -3
- package/src/helpers/Api/Api.js +7 -4
- package/src/helpers/Api/Api.plone.rest.test.js +11 -9
- package/src/helpers/Api/Api.test.js +11 -14
- package/src/helpers/AsyncConnect/AsyncConnect.test.jsx +145 -189
- package/src/helpers/AsyncConnect/ssr.js +4 -1
- package/src/helpers/AuthToken/AuthToken.test.js +60 -22
- package/src/helpers/Blocks/Blocks.test.js +1 -1
- package/src/helpers/Content/Content.js +23 -0
- package/src/helpers/Content/Content.test.js +39 -0
- package/src/helpers/Content/withClientSideContent.jsx +35 -0
- package/src/helpers/Extensions/withBlockSchemaEnhancer.jsx +4 -1
- package/src/helpers/Html/Html.jsx +13 -7
- package/src/helpers/Html/Html.test.jsx +32 -28
- package/src/helpers/LanguageMap/LanguageMap.js +115 -8
- package/src/helpers/Loadable/__mocks__/Loadable.jsx +16 -1
- package/src/helpers/Loadable/__mocks__/Loadable.vitest.jsx +39 -0
- package/src/helpers/MessageLabels/MessageLabels.js +5 -0
- package/src/helpers/Sitemap/Sitemap.js +4 -4
- package/src/helpers/Url/Url.js +32 -2
- package/src/helpers/Url/Url.test.js +62 -0
- package/src/helpers/Utils/withSaveAsDraft.jsx +241 -0
- package/src/hooks/user/useUser.js +1 -1
- package/src/middleware/Api.test.js +51 -0
- package/src/middleware/api.js +78 -29
- package/src/middleware/storeProtectLoadUtils.test.js +93 -81
- package/src/reducers/content/content.js +3 -18
- package/src/reducers/diff/diff.js +5 -1
- package/src/reducers/diff/diff.test.js +60 -4
- package/src/routes.js +4 -2
- package/src/server.jsx +45 -14
- package/src/start-client.jsx +9 -6
- package/src/start-server.js +9 -3
- package/test-setup-config.jsx +0 -2
- package/test-setup-globals-vitest.js +46 -0
- package/theme/themes/pastanaga/collections/table.overrides +9 -0
- package/theme/themes/pastanaga/extras/blocks.less +26 -0
- package/theme/themes/pastanaga/extras/contents.less +17 -5
- package/theme/themes/pastanaga/extras/main.less +32 -2
- package/tsconfig.declarations.json +12 -1
- package/tsconfig.json +5 -5
- package/types/components/manage/Blocks/Teaser/schema.d.ts +1 -0
- package/types/components/manage/ConditionalLink/ConditionalLink.d.ts +11 -15
- package/types/components/manage/Contents/__mocks__/index.vitest.d.ts +2 -0
- package/types/components/manage/Controlpanels/Users/RenderUsers.d.ts +18 -2
- package/types/components/manage/Controlpanels/Users/UsersControlpanel.d.ts +6 -2
- package/types/components/manage/Controlpanels/index.d.ts +2 -2
- package/types/components/manage/Form/__mocks__/index.vitest.d.ts +8 -0
- package/types/components/manage/MaybeWrap/MaybeWrap.d.ts +7 -5
- package/types/components/manage/Sidebar/SidebarPortal.d.ts +7 -15
- package/types/components/manage/UniversalLink/UniversalLink.d.ts +54 -20
- package/types/components/manage/Widgets/ImageWidget.d.ts +41 -1
- package/types/components/manage/Widgets/RecurrenceWidget/Utils.d.ts +12 -18
- package/types/components/manage/Widgets/__mocks__/index.vitest.d.ts +33 -0
- package/types/components/theme/FormattedDate/FormattedDate.stories.d.ts +1 -1
- package/types/components/theme/LanguageSelector/LanguageSelector.d.ts +3 -10
- package/types/helpers/Content/Content.d.ts +7 -0
- package/types/helpers/Content/withClientSideContent.d.ts +1 -0
- package/types/helpers/Extensions/withBlockSchemaEnhancer.d.ts +4 -5
- package/types/helpers/Helmet/Helmet.d.ts +1 -1
- package/types/helpers/LanguageMap/LanguageMap.d.ts +428 -4
- package/types/helpers/Loadable/__mocks__/Loadable.vitest.d.ts +3 -0
- package/types/helpers/MessageLabels/MessageLabels.d.ts +68 -62
- package/types/helpers/Url/Url.d.ts +14 -0
- package/types/helpers/Url/bulkFlattenToAppURL.d.ts +5 -0
- package/types/helpers/Utils/withSaveAsDraft.d.ts +1 -0
- package/types/middleware/api.d.ts +6 -9
- package/types/react-router-hash-link.d.ts +12 -0
- package/types/reducers/index.d.ts +1 -0
- package/types/routes.d.ts +4 -0
- package/types/server.d.ts +1 -1
- package/types/start-client.d.ts +0 -1
- package/vite-plugins/svg.mjs +81 -0
- package/vitest.config.mjs +77 -0
- package/package-why.json +0 -34
- package/src/actions/content/content.multilingual.test.js +0 -17
- package/src/components/manage/ConditionalLink/ConditionalLink.jsx +0 -27
- package/src/components/manage/ConditionalLink/ConditionalLink.test.jsx +0 -30
- package/src/components/manage/MaybeWrap/MaybeWrap.jsx +0 -9
- package/src/components/manage/Sidebar/SidebarPortal.jsx +0 -47
- package/src/components/manage/Sidebar/SidebarPortal.test.jsx +0 -26
- package/src/components/manage/UniversalLink/UniversalLink.jsx +0 -154
- package/src/components/manage/Widgets/FileWidget.test.jsx +0 -91
- package/src/components/theme/LanguageSelector/LanguageSelector.jsx +0 -77
- package/theme/themes/pastanaga/extras/utils.less +0 -63
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
import react from '@vitejs/plugin-react';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { svgLoader } from './vite-plugins/svg.mjs';
|
|
5
|
+
import { fileURLToPath } from 'url';
|
|
6
|
+
import { createRequire } from 'module';
|
|
7
|
+
|
|
8
|
+
const require = createRequire(import.meta.url);
|
|
9
|
+
|
|
10
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
11
|
+
const __dirname = path.dirname(__filename);
|
|
12
|
+
|
|
13
|
+
const projectRoot = path.resolve(__dirname);
|
|
14
|
+
|
|
15
|
+
export default defineConfig({
|
|
16
|
+
plugins: [
|
|
17
|
+
react(),
|
|
18
|
+
svgLoader({
|
|
19
|
+
svgoConfig: {
|
|
20
|
+
plugins: [
|
|
21
|
+
{
|
|
22
|
+
name: 'preset-default',
|
|
23
|
+
params: {
|
|
24
|
+
overrides: {
|
|
25
|
+
convertPathData: false,
|
|
26
|
+
removeViewBox: false,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
'removeTitle',
|
|
31
|
+
'removeUselessStrokeAndFill',
|
|
32
|
+
],
|
|
33
|
+
},
|
|
34
|
+
}),
|
|
35
|
+
],
|
|
36
|
+
resolve: {
|
|
37
|
+
alias: {
|
|
38
|
+
'@plone/volto': path.resolve(__dirname, 'src'),
|
|
39
|
+
'@plone/volto-slate': path.resolve(__dirname, '../volto-slate/src'),
|
|
40
|
+
'@root': path.resolve(__dirname, 'src'),
|
|
41
|
+
'promise-file-reader': require.resolve('promise-file-reader'),
|
|
42
|
+
'react-dropzone': require.resolve('react-dropzone'),
|
|
43
|
+
'prop-types': require.resolve('prop-types'),
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
test: {
|
|
47
|
+
isolate: true,
|
|
48
|
+
deps: {
|
|
49
|
+
moduleDirectories: ['node_modules'],
|
|
50
|
+
},
|
|
51
|
+
snapshotFormat: { printBasicPrototype: false },
|
|
52
|
+
globals: true,
|
|
53
|
+
environment: 'jsdom',
|
|
54
|
+
setupFiles: [
|
|
55
|
+
`${projectRoot}/test-setup-globals-vitest.js`,
|
|
56
|
+
`${projectRoot}/test-setup-config.jsx`,
|
|
57
|
+
`${projectRoot}/jest-setup-afterenv.js`,
|
|
58
|
+
`${projectRoot}/jest-addons-loader.js`,
|
|
59
|
+
],
|
|
60
|
+
globalSetup: `${projectRoot}/global-test-setup.js`,
|
|
61
|
+
coverage: {
|
|
62
|
+
provider: 'v8',
|
|
63
|
+
reporter: ['text', 'json', 'html'],
|
|
64
|
+
include: [
|
|
65
|
+
'src/**/*.{test,spec}.{js,ts,jsx,tsx}',
|
|
66
|
+
'__test__/**/*.{test,spec}.{js,ts,jsx,tsx}',
|
|
67
|
+
],
|
|
68
|
+
exclude: [
|
|
69
|
+
'node_modules/**',
|
|
70
|
+
'**/dist/**',
|
|
71
|
+
'**/*.config.{js,ts}',
|
|
72
|
+
'**/jest-*.js',
|
|
73
|
+
],
|
|
74
|
+
},
|
|
75
|
+
css: true,
|
|
76
|
+
},
|
|
77
|
+
});
|
package/package-why.json
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"scripts": {
|
|
3
|
-
"postinstall": "Description for `npm run postinstall` command",
|
|
4
|
-
"analyze": "Description for `npm run analyze` command",
|
|
5
|
-
"start": "Description for `npm run start` command",
|
|
6
|
-
"build": "Description for `npm run build` command",
|
|
7
|
-
"build:clean": "Description for `npm run build:clean` command",
|
|
8
|
-
"dist:clean": "Description for `npm run dist:clean` command",
|
|
9
|
-
"build:dist": "Description for `npm run build:dist` command",
|
|
10
|
-
"test": "Description for `npm run test` command",
|
|
11
|
-
"test:ci": "Description for `npm run test:ci` command",
|
|
12
|
-
"test:husky": "Description for `npm run test:husky` command",
|
|
13
|
-
"test:debug": "Description for `npm run test:debug` command",
|
|
14
|
-
"start:prod": "Description for `npm run start:prod` command",
|
|
15
|
-
"start:dist": "Description for `npm run start:dist` command",
|
|
16
|
-
"prettier": "Description for `npm run prettier` command",
|
|
17
|
-
"prettier:fix": "Description for `npm run prettier:fix` command",
|
|
18
|
-
"stylelint": "Description for `npm run stylelint` command",
|
|
19
|
-
"stylelint:overrides": "Description for `npm run stylelint:overrides` command",
|
|
20
|
-
"stylelint:fix": "Description for `npm run stylelint:fix` command",
|
|
21
|
-
"lint": "Description for `npm run lint` command",
|
|
22
|
-
"lint:fix": "Description for `npm run lint:fix` command",
|
|
23
|
-
"i18n": "Description for `npm run i18n` command",
|
|
24
|
-
"i18n:ci": "Description for `npm run i18n:ci` command",
|
|
25
|
-
"stylelint:patches": "Description for `npm run stylelint:patches` command",
|
|
26
|
-
"patches": "Description for `npm run patches` command",
|
|
27
|
-
"dry-release": "Description for `npm run dry-release` command",
|
|
28
|
-
"release": "Description for `npm run release` command",
|
|
29
|
-
"release-major-alpha": "Description for `npm run release-major-alpha` command",
|
|
30
|
-
"release-alpha": "Description for `npm run release-alpha` command",
|
|
31
|
-
"storybook": "Description for `npm run storybook` command",
|
|
32
|
-
"build-storybook": "Description for `npm run build-storybook` command"
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { getContent } from './content';
|
|
2
|
-
import { GET_CONTENT } from '@plone/volto/constants/ActionTypes';
|
|
3
|
-
import config from '@plone/volto/registry';
|
|
4
|
-
|
|
5
|
-
config.settings.isMultilingual = true;
|
|
6
|
-
config.settings.supportedLanguages = ['de', 'es'];
|
|
7
|
-
|
|
8
|
-
describe('getContent', () => {
|
|
9
|
-
it('[Multilingual] should create an action to get content', () => {
|
|
10
|
-
const url = 'http://localhost';
|
|
11
|
-
const action = getContent(url);
|
|
12
|
-
|
|
13
|
-
expect(action.type).toEqual(GET_CONTENT);
|
|
14
|
-
expect(action.request.op).toEqual('get');
|
|
15
|
-
expect(action.request.path).toEqual(`${url}?expand=translations`);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import UniversalLink from '@plone/volto/components/manage/UniversalLink/UniversalLink';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
|
|
5
|
-
const ConditionalLink = ({ condition, to, item, ...props }) => {
|
|
6
|
-
if (condition) {
|
|
7
|
-
return (
|
|
8
|
-
<UniversalLink href={to} item={item} {...props}>
|
|
9
|
-
{props.children}
|
|
10
|
-
</UniversalLink>
|
|
11
|
-
);
|
|
12
|
-
} else {
|
|
13
|
-
return <>{props.children}</>;
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
ConditionalLink.propTypes = {
|
|
18
|
-
condition: PropTypes.bool,
|
|
19
|
-
to: PropTypes.string,
|
|
20
|
-
item: PropTypes.shape({
|
|
21
|
-
'@id': PropTypes.string,
|
|
22
|
-
remoteUrl: PropTypes.string, //of plone @type 'Link'
|
|
23
|
-
}),
|
|
24
|
-
children: PropTypes.node,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export default ConditionalLink;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import renderer from 'react-test-renderer';
|
|
3
|
-
import { MemoryRouter } from 'react-router-dom';
|
|
4
|
-
|
|
5
|
-
import ConditionalLink from './ConditionalLink';
|
|
6
|
-
|
|
7
|
-
describe('ConditionalLink', () => {
|
|
8
|
-
it('renders a ConditionalLink component not link', () => {
|
|
9
|
-
const component = renderer.create(
|
|
10
|
-
<MemoryRouter>
|
|
11
|
-
<ConditionalLink>
|
|
12
|
-
<h1>Title</h1>
|
|
13
|
-
</ConditionalLink>
|
|
14
|
-
</MemoryRouter>,
|
|
15
|
-
);
|
|
16
|
-
const json = component.toJSON();
|
|
17
|
-
expect(json).toMatchSnapshot();
|
|
18
|
-
});
|
|
19
|
-
it('renders a ConditionalLink component with link', () => {
|
|
20
|
-
const component = renderer.create(
|
|
21
|
-
<MemoryRouter>
|
|
22
|
-
<ConditionalLink isLink>
|
|
23
|
-
<h1>Title</h1>
|
|
24
|
-
</ConditionalLink>
|
|
25
|
-
</MemoryRouter>,
|
|
26
|
-
);
|
|
27
|
-
const json = component.toJSON();
|
|
28
|
-
expect(json).toMatchSnapshot();
|
|
29
|
-
});
|
|
30
|
-
});
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { createPortal } from 'react-dom';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Portal that wraps Sidebar components
|
|
7
|
-
* @param {React.ReactNode} children Sidebar content
|
|
8
|
-
* @param {bool} selected Sidebar needs to know when the related block is selected
|
|
9
|
-
* @param {string} tab Element id where to insert sidebar content, default: sidebar-properties
|
|
10
|
-
* @returns {string} Rendered sidebar
|
|
11
|
-
*/
|
|
12
|
-
const SidebarPortal = ({ children, selected, tab = 'sidebar-properties' }) => {
|
|
13
|
-
const [isClient, setIsClient] = React.useState(null);
|
|
14
|
-
|
|
15
|
-
React.useEffect(() => setIsClient(true), []);
|
|
16
|
-
|
|
17
|
-
return (
|
|
18
|
-
<>
|
|
19
|
-
{isClient &&
|
|
20
|
-
selected &&
|
|
21
|
-
createPortal(
|
|
22
|
-
<div role="form" style={{ height: '100%' }}>
|
|
23
|
-
<div
|
|
24
|
-
style={{ height: '100%' }}
|
|
25
|
-
role="presentation"
|
|
26
|
-
onClick={(e) => {
|
|
27
|
-
e.stopPropagation();
|
|
28
|
-
}}
|
|
29
|
-
onKeyDown={(e) => {
|
|
30
|
-
e.stopPropagation();
|
|
31
|
-
}}
|
|
32
|
-
>
|
|
33
|
-
{children}
|
|
34
|
-
</div>
|
|
35
|
-
</div>,
|
|
36
|
-
document.getElementById(tab),
|
|
37
|
-
)}
|
|
38
|
-
</>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
SidebarPortal.propTypes = {
|
|
43
|
-
children: PropTypes.any,
|
|
44
|
-
selected: PropTypes.bool.isRequired,
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export default SidebarPortal;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import ShallowRenderer from 'react-test-renderer/shallow';
|
|
3
|
-
|
|
4
|
-
import SidebarPortal from './SidebarPortal';
|
|
5
|
-
|
|
6
|
-
test('sidebar portal is rendered when the block is selected', () => {
|
|
7
|
-
const renderer = new ShallowRenderer();
|
|
8
|
-
renderer.render(
|
|
9
|
-
<SidebarPortal selected={true}>
|
|
10
|
-
<p>Tested!</p>
|
|
11
|
-
</SidebarPortal>,
|
|
12
|
-
);
|
|
13
|
-
const component = renderer.getRenderOutput();
|
|
14
|
-
expect(component).toMatchSnapshot();
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test('sidebar portal is not rendered when the block is not selected', () => {
|
|
18
|
-
const renderer = new ShallowRenderer();
|
|
19
|
-
renderer.render(
|
|
20
|
-
<SidebarPortal selected={false}>
|
|
21
|
-
<p>Tested, but you shouldn't see this in the snapshot!</p>
|
|
22
|
-
</SidebarPortal>,
|
|
23
|
-
);
|
|
24
|
-
const component = renderer.getRenderOutput();
|
|
25
|
-
expect(component).toMatchSnapshot();
|
|
26
|
-
});
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* UniversalLink
|
|
3
|
-
* @module components/UniversalLink
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import PropTypes from 'prop-types';
|
|
8
|
-
import { HashLink as Link } from 'react-router-hash-link';
|
|
9
|
-
import { useSelector } from 'react-redux';
|
|
10
|
-
import {
|
|
11
|
-
flattenToAppURL,
|
|
12
|
-
isInternalURL,
|
|
13
|
-
URLUtils,
|
|
14
|
-
} from '@plone/volto/helpers/Url/Url';
|
|
15
|
-
|
|
16
|
-
import config from '@plone/volto/registry';
|
|
17
|
-
import cx from 'classnames';
|
|
18
|
-
|
|
19
|
-
const UniversalLink = ({
|
|
20
|
-
href,
|
|
21
|
-
item = null,
|
|
22
|
-
openLinkInNewTab,
|
|
23
|
-
download = false,
|
|
24
|
-
children,
|
|
25
|
-
className = null,
|
|
26
|
-
title = null,
|
|
27
|
-
...props
|
|
28
|
-
}) => {
|
|
29
|
-
const token = useSelector((state) => state.userSession?.token);
|
|
30
|
-
|
|
31
|
-
let url = href;
|
|
32
|
-
if (!href && item) {
|
|
33
|
-
if (item['@id'] === '') {
|
|
34
|
-
url = config.settings.publicURL;
|
|
35
|
-
} else if (!item['@id']) {
|
|
36
|
-
// eslint-disable-next-line no-console
|
|
37
|
-
console.error(
|
|
38
|
-
'Invalid item passed to UniversalLink',
|
|
39
|
-
item,
|
|
40
|
-
props,
|
|
41
|
-
children,
|
|
42
|
-
);
|
|
43
|
-
url = '#';
|
|
44
|
-
} else {
|
|
45
|
-
//case: generic item
|
|
46
|
-
url = flattenToAppURL(item['@id']);
|
|
47
|
-
|
|
48
|
-
//case: item like a Link
|
|
49
|
-
let remoteUrl = item.remoteUrl || item.getRemoteUrl;
|
|
50
|
-
if (!token && remoteUrl) {
|
|
51
|
-
url = remoteUrl;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
//case: item of type 'File'
|
|
55
|
-
if (
|
|
56
|
-
!token &&
|
|
57
|
-
config.settings.downloadableObjects.includes(item['@type'])
|
|
58
|
-
) {
|
|
59
|
-
url = `${url}/@@download/file`;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
if (
|
|
63
|
-
!token &&
|
|
64
|
-
config.settings.viewableInBrowserObjects.includes(item['@type'])
|
|
65
|
-
) {
|
|
66
|
-
url = `${url}/@@display-file/file`;
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const isExternal = !isInternalURL(url);
|
|
72
|
-
|
|
73
|
-
const isDownload = (!isExternal && url.includes('@@download')) || download;
|
|
74
|
-
const isDisplayFile =
|
|
75
|
-
(!isExternal && url.includes('@@display-file')) || false;
|
|
76
|
-
|
|
77
|
-
const checkedURL = URLUtils.checkAndNormalizeUrl(url);
|
|
78
|
-
|
|
79
|
-
url = checkedURL.url;
|
|
80
|
-
let tag = (
|
|
81
|
-
<Link
|
|
82
|
-
to={flattenToAppURL(url)}
|
|
83
|
-
target={openLinkInNewTab ?? false ? '_blank' : null}
|
|
84
|
-
title={title}
|
|
85
|
-
className={className}
|
|
86
|
-
smooth={config.settings.hashLinkSmoothScroll}
|
|
87
|
-
{...props}
|
|
88
|
-
>
|
|
89
|
-
{children}
|
|
90
|
-
</Link>
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
if (isExternal) {
|
|
94
|
-
const isTelephoneOrMail = checkedURL.isMail || checkedURL.isTelephone;
|
|
95
|
-
tag = (
|
|
96
|
-
<a
|
|
97
|
-
href={url}
|
|
98
|
-
title={title}
|
|
99
|
-
target={
|
|
100
|
-
!isTelephoneOrMail && !(openLinkInNewTab === false) ? '_blank' : null
|
|
101
|
-
}
|
|
102
|
-
rel="noopener noreferrer"
|
|
103
|
-
className={cx({ external: !isTelephoneOrMail }, className)}
|
|
104
|
-
{...props}
|
|
105
|
-
>
|
|
106
|
-
{children}
|
|
107
|
-
</a>
|
|
108
|
-
);
|
|
109
|
-
} else if (isDownload) {
|
|
110
|
-
tag = (
|
|
111
|
-
<a
|
|
112
|
-
href={flattenToAppURL(url)}
|
|
113
|
-
download
|
|
114
|
-
title={title}
|
|
115
|
-
className={className}
|
|
116
|
-
{...props}
|
|
117
|
-
>
|
|
118
|
-
{children}
|
|
119
|
-
</a>
|
|
120
|
-
);
|
|
121
|
-
} else if (isDisplayFile) {
|
|
122
|
-
tag = (
|
|
123
|
-
<a
|
|
124
|
-
href={flattenToAppURL(url)}
|
|
125
|
-
title={title}
|
|
126
|
-
target="_blank"
|
|
127
|
-
rel="noopener noreferrer"
|
|
128
|
-
className={className}
|
|
129
|
-
{...props}
|
|
130
|
-
>
|
|
131
|
-
{children}
|
|
132
|
-
</a>
|
|
133
|
-
);
|
|
134
|
-
}
|
|
135
|
-
return tag;
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
UniversalLink.propTypes = {
|
|
139
|
-
href: PropTypes.string,
|
|
140
|
-
openLinkInNewTab: PropTypes.bool,
|
|
141
|
-
download: PropTypes.bool,
|
|
142
|
-
className: PropTypes.string,
|
|
143
|
-
title: PropTypes.string,
|
|
144
|
-
item: PropTypes.shape({
|
|
145
|
-
'@id': PropTypes.string.isRequired,
|
|
146
|
-
remoteUrl: PropTypes.string, //of plone @type 'Link'
|
|
147
|
-
}),
|
|
148
|
-
children: PropTypes.oneOfType([
|
|
149
|
-
PropTypes.arrayOf(PropTypes.node),
|
|
150
|
-
PropTypes.node,
|
|
151
|
-
]),
|
|
152
|
-
};
|
|
153
|
-
|
|
154
|
-
export default UniversalLink;
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { Provider } from 'react-intl-redux';
|
|
3
|
-
import { render, waitFor } from '@testing-library/react';
|
|
4
|
-
import configureStore from 'redux-mock-store';
|
|
5
|
-
|
|
6
|
-
import FileWidget from './FileWidget';
|
|
7
|
-
|
|
8
|
-
jest.spyOn(global.Date, 'now').mockImplementation(() => '0');
|
|
9
|
-
|
|
10
|
-
const mockStore = configureStore();
|
|
11
|
-
|
|
12
|
-
describe('FileWidget', () => {
|
|
13
|
-
test('renders an empty file widget component', async () => {
|
|
14
|
-
const store = mockStore({
|
|
15
|
-
intl: {
|
|
16
|
-
locale: 'en',
|
|
17
|
-
messages: {},
|
|
18
|
-
},
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
const { container } = render(
|
|
22
|
-
<Provider store={store}>
|
|
23
|
-
<FileWidget
|
|
24
|
-
id="my-field"
|
|
25
|
-
title="My field"
|
|
26
|
-
fieldSet="default"
|
|
27
|
-
onChange={() => {}}
|
|
28
|
-
/>
|
|
29
|
-
</Provider>,
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
await waitFor(() => {});
|
|
33
|
-
expect(container).toMatchSnapshot();
|
|
34
|
-
});
|
|
35
|
-
test('renders a file widget component with value', async () => {
|
|
36
|
-
const store = mockStore({
|
|
37
|
-
intl: {
|
|
38
|
-
locale: 'en',
|
|
39
|
-
messages: {},
|
|
40
|
-
},
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
const { container } = render(
|
|
44
|
-
<Provider store={store}>
|
|
45
|
-
<FileWidget
|
|
46
|
-
id="my-field"
|
|
47
|
-
title="My field"
|
|
48
|
-
fieldSet="default"
|
|
49
|
-
onChange={() => {}}
|
|
50
|
-
value={{
|
|
51
|
-
download: 'http://myfile',
|
|
52
|
-
'content-type': 'image/png',
|
|
53
|
-
filename: 'myfile',
|
|
54
|
-
encoding: '',
|
|
55
|
-
}}
|
|
56
|
-
/>
|
|
57
|
-
</Provider>,
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
await waitFor(() => {});
|
|
61
|
-
expect(container).toMatchSnapshot();
|
|
62
|
-
});
|
|
63
|
-
test('renders a file widget component with value in raw data', async () => {
|
|
64
|
-
const store = mockStore({
|
|
65
|
-
intl: {
|
|
66
|
-
locale: 'en',
|
|
67
|
-
messages: {},
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
const { container } = render(
|
|
72
|
-
<Provider store={store}>
|
|
73
|
-
<FileWidget
|
|
74
|
-
id="my-field"
|
|
75
|
-
title="My field"
|
|
76
|
-
fieldSet="default"
|
|
77
|
-
onChange={() => {}}
|
|
78
|
-
value={{
|
|
79
|
-
data: 'oiweurtksdgfjaslfqw9523563456',
|
|
80
|
-
'content-type': 'image/png',
|
|
81
|
-
filename: 'myfile',
|
|
82
|
-
encoding: 'base64',
|
|
83
|
-
}}
|
|
84
|
-
/>
|
|
85
|
-
</Provider>,
|
|
86
|
-
);
|
|
87
|
-
|
|
88
|
-
await waitFor(() => {});
|
|
89
|
-
expect(container).toMatchSnapshot();
|
|
90
|
-
});
|
|
91
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Language selector component.
|
|
3
|
-
* @module components/LanguageSelector/LanguageSelector
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import PropTypes from 'prop-types';
|
|
8
|
-
import { Link } from 'react-router-dom';
|
|
9
|
-
|
|
10
|
-
import { useSelector } from 'react-redux';
|
|
11
|
-
import cx from 'classnames';
|
|
12
|
-
import find from 'lodash/find';
|
|
13
|
-
import map from 'lodash/map';
|
|
14
|
-
|
|
15
|
-
import Helmet from '@plone/volto/helpers/Helmet/Helmet';
|
|
16
|
-
import langmap from '@plone/volto/helpers/LanguageMap/LanguageMap';
|
|
17
|
-
import { flattenToAppURL } from '@plone/volto/helpers/Url/Url';
|
|
18
|
-
import { toReactIntlLang } from '@plone/volto/helpers/Utils/Utils';
|
|
19
|
-
|
|
20
|
-
import config from '@plone/volto/registry';
|
|
21
|
-
|
|
22
|
-
import { defineMessages, useIntl } from 'react-intl';
|
|
23
|
-
|
|
24
|
-
const messages = defineMessages({
|
|
25
|
-
switchLanguageTo: {
|
|
26
|
-
id: 'Switch to',
|
|
27
|
-
defaultMessage: 'Switch to',
|
|
28
|
-
},
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const LanguageSelector = (props) => {
|
|
32
|
-
const intl = useIntl();
|
|
33
|
-
const currentLang = useSelector((state) => state.intl.locale);
|
|
34
|
-
const translations = useSelector(
|
|
35
|
-
(state) => state.content.data?.['@components']?.translations?.items,
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
const { settings } = config;
|
|
39
|
-
|
|
40
|
-
return settings.isMultilingual ? (
|
|
41
|
-
<div className="language-selector">
|
|
42
|
-
{map(settings.supportedLanguages, (lang) => {
|
|
43
|
-
const translation = find(translations, { language: lang });
|
|
44
|
-
return (
|
|
45
|
-
<Link
|
|
46
|
-
aria-label={`${intl.formatMessage(
|
|
47
|
-
messages.switchLanguageTo,
|
|
48
|
-
)} ${langmap[lang].nativeName.toLowerCase()}`}
|
|
49
|
-
className={cx({ selected: toReactIntlLang(lang) === currentLang })}
|
|
50
|
-
to={translation ? flattenToAppURL(translation['@id']) : `/${lang}`}
|
|
51
|
-
title={langmap[lang].nativeName}
|
|
52
|
-
onClick={() => {
|
|
53
|
-
props.onClickAction();
|
|
54
|
-
}}
|
|
55
|
-
key={`language-selector-${lang}`}
|
|
56
|
-
>
|
|
57
|
-
{langmap[lang].nativeName}
|
|
58
|
-
</Link>
|
|
59
|
-
);
|
|
60
|
-
})}
|
|
61
|
-
</div>
|
|
62
|
-
) : (
|
|
63
|
-
<Helmet>
|
|
64
|
-
<html lang={toReactIntlLang(settings.defaultLanguage)} />
|
|
65
|
-
</Helmet>
|
|
66
|
-
);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
LanguageSelector.propTypes = {
|
|
70
|
-
onClickAction: PropTypes.func,
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
LanguageSelector.defaultProps = {
|
|
74
|
-
onClickAction: () => {},
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export default LanguageSelector;
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
/* Responsive visibility helper classes */
|
|
2
|
-
|
|
3
|
-
body:not(.has-sidebar):not(.has-sidebar-collapsed) {
|
|
4
|
-
/* Mobile */
|
|
5
|
-
@media only screen and (max-width: @largestMobileScreen) {
|
|
6
|
-
[class*='mobile hidden'],
|
|
7
|
-
[class*='tablet only']:not(.mobile),
|
|
8
|
-
[class*='computer only']:not(.mobile),
|
|
9
|
-
[class*='large screen only']:not(.mobile),
|
|
10
|
-
[class*='widescreen only']:not(.mobile),
|
|
11
|
-
[class*='or lower hidden'] {
|
|
12
|
-
display: none !important;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/* Tablet / iPad Portrait */
|
|
17
|
-
@media only screen and (min-width: @tabletBreakpoint) and (max-width: @largestTabletScreen) {
|
|
18
|
-
[class*='mobile only']:not(.tablet),
|
|
19
|
-
[class*='tablet hidden'],
|
|
20
|
-
[class*='computer only']:not(.tablet),
|
|
21
|
-
[class*='large screen only']:not(.tablet),
|
|
22
|
-
[class*='widescreen only']:not(.tablet),
|
|
23
|
-
[class*='or lower hidden']:not(.mobile) {
|
|
24
|
-
display: none !important;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/* Computer / Desktop / iPad Landscape */
|
|
29
|
-
@media only screen and (min-width: @computerBreakpoint) and (max-width: @largestSmallMonitor) {
|
|
30
|
-
[class*='mobile only']:not(.computer),
|
|
31
|
-
[class*='tablet only']:not(.computer),
|
|
32
|
-
[class*='computer hidden'],
|
|
33
|
-
[class*='large screen only']:not(.computer),
|
|
34
|
-
[class*='widescreen only']:not(.computer),
|
|
35
|
-
[class*='or lower hidden']:not(.tablet):not(.mobile) {
|
|
36
|
-
display: none !important;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/* Large Monitor */
|
|
41
|
-
@media only screen and (min-width: @largeMonitorBreakpoint) and (max-width: @largestLargeMonitor) {
|
|
42
|
-
[class*='mobile only']:not([class*='large screen']),
|
|
43
|
-
[class*='tablet only']:not([class*='large screen']),
|
|
44
|
-
[class*='computer only']:not([class*='large screen']),
|
|
45
|
-
[class*='large screen hidden'],
|
|
46
|
-
[class*='widescreen only']:not([class*='large screen']),
|
|
47
|
-
[class*='or lower hidden']:not(.computer):not(.tablet):not(.mobile) {
|
|
48
|
-
display: none !important;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/* Widescreen Monitor */
|
|
53
|
-
@media only screen and (min-width: @widescreenMonitorBreakpoint) {
|
|
54
|
-
[class*='mobile only']:not([class*='widescreen']),
|
|
55
|
-
[class*='tablet only']:not([class*='widescreen']),
|
|
56
|
-
[class*='computer only']:not([class*='widescreen']),
|
|
57
|
-
[class*='large screen only']:not([class*='widescreen']),
|
|
58
|
-
[class*='widescreen hidden'],
|
|
59
|
-
[class*='widescreen or lower hidden'] {
|
|
60
|
-
display: none !important;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|