From acdd040563452f19ccece352a384cedd3bcc5485 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Fern=C3=A1ndez=20de=20Alba?= Date: Thu, 7 Mar 2024 16:32:16 +0100 Subject: [PATCH] Enable `autoPlay` as opt-in. Documentation. (#48) * Enable `autoPlay` as opt-in. Documentation. * Changelog * Fix cypress * Fix test * What about now * Fix again --- .github/workflows/acceptance.yml | 2 +- Makefile | 2 +- README.md | 10 ++++++++++ acceptance/cypress/tests/block.cy.js | 2 ++ news/48.feature | 1 + src/components/schema.js | 14 +++++++++----- src/index.js | 1 + 7 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 news/48.feature diff --git a/.github/workflows/acceptance.yml b/.github/workflows/acceptance.yml index 6d120ae..454337c 100644 --- a/.github/workflows/acceptance.yml +++ b/.github/workflows/acceptance.yml @@ -4,7 +4,7 @@ on: [push] env: ADDON_NAME: "@kitconcept/volto-slider-block" ADDON_PATH: "volto-slider-block" - VOLTO_VERSION: "17.6.0" + VOLTO_VERSION: "17.15.3" jobs: diff --git a/Makefile b/Makefile index a553dce..997ff53 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ RESET=`tput sgr0` YELLOW=`tput setaf 3` PLONE_VERSION=6 -VOLTO_VERSION=17.7.0 +VOLTO_VERSION=17.15.3 ADDON_NAME='@kitconcept/volto-slider-block' ADDON_PATH='volto-slider-block' diff --git a/README.md b/README.md index 15c4c8a..377ac8f 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,16 @@ yarn start Go to http://localhost:3000, login, create a new page. The slider block will show up in the Volto blocks chooser. +## Configuration options + +### `enableAutoPlay` + +This enables the autoplay controls in the block's settings. + +```js +config.blocks.blocksConfig.slider.enableAutoPlay = true; +``` + ## Upgrade Guide ### `volto-slider-block` 6.0.0 diff --git a/acceptance/cypress/tests/block.cy.js b/acceptance/cypress/tests/block.cy.js index dda3fc1..667f13f 100644 --- a/acceptance/cypress/tests/block.cy.js +++ b/acceptance/cypress/tests/block.cy.js @@ -47,6 +47,7 @@ context('Block Acceptance Tests', () => { cy.get( '.objectbrowser-field[aria-labelledby="fieldset-default-field-label-href-0-slides-1"] button[aria-label="Open object browser"]', ).click(); + cy.wait(1000); cy.get('aside .breadcrumbs svg.home-icon').click(); cy.findByLabelText('Select My Page').dblclick(); @@ -87,6 +88,7 @@ context('Block Acceptance Tests', () => { cy.get( '.objectbrowser-field[aria-labelledby="fieldset-default-field-label-href-0-slides-1"] button[aria-label="Open object browser"]', ).click(); + cy.wait(1000); cy.get('aside .breadcrumbs svg.home-icon').click(); cy.findByLabelText('Select My Page').dblclick(); diff --git a/news/48.feature b/news/48.feature new file mode 100644 index 0000000..1d787c7 --- /dev/null +++ b/news/48.feature @@ -0,0 +1 @@ +Enable autoPlay as opt-in. Documentation @sneridagh diff --git a/src/components/schema.js b/src/components/schema.js index 5358c62..1165d36 100644 --- a/src/components/schema.js +++ b/src/components/schema.js @@ -126,11 +126,15 @@ export const SliderSchema = (props) => title: 'Default', fields: ['slides'], }, - { - id: 'autoplay', - title: props.intl.formatMessage(messages.Autoplay), - fields: ['autoplayEnabled', 'autoplayDelay', 'autoplayJump'], - }, + ...(config.blocks.blocksConfig.slider.enableAutoPlay + ? [ + { + id: 'autoplay', + title: props.intl.formatMessage(messages.Autoplay), + fields: ['autoplayEnabled', 'autoplayDelay', 'autoplayJump'], + }, + ] + : []), ], properties: { slides: { diff --git a/src/index.js b/src/index.js index 6f2486b..d897b0d 100644 --- a/src/index.js +++ b/src/index.js @@ -17,6 +17,7 @@ const applyConfig = (config) => { mostUsed: true, sidebarTab: 1, dataAdapter: SliderBlockDataAdapter, + enableAutoPlay: false, }; return config; };