Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions assets/src/js/godam-layers/deprecated.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* GoDAM Layer API: deprecation notices for the add-on hooks it replaces (#2296).
*
* The old hooks keep working until GoDAM 2.10.0; each logs one notice per page
* The old hooks keep working until GoDAM 2.11.0; each logs one notice per page
* the first time it is used.
*/

export const DEPRECATED_SINCE = '2.8.0';
export const REMOVED_IN = '2.10.0';
export const DEPRECATED_SINCE = '2.9.0';
export const REMOVED_IN = '2.11.0';

const shown = new Set();

Expand Down
2 changes: 1 addition & 1 deletion assets/src/js/godam-player/utils/layer-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* `updateProductHotspotPositions()`. Only a manager with
* `createProductHotspots()` runs on images.
*
* Deprecated since GoDAM 2.8.0 (#2296), removed in 2.10.0: new code calls
* Deprecated since GoDAM 2.9.0 (#2296), removed in 2.11.0: new code calls
* `registerLayerRuntime()`. Each call logs a deprecation notice once per page.
*/

Expand Down
2 changes: 1 addition & 1 deletion assets/src/js/godam-player/utils/layer-registry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe( 'Layer API contract: layer registry', () => {
it( 'logs a deprecation notice pointing at registerLayerRuntime()', () => {
const registry = loadRegistry();
registry.registerLayerType( 'acme', { label: 'Acme', validator } );
expect( warn ).toHaveBeenCalledWith( 'GoDAM: window.godamLayerRegistry.registerLayerType() is deprecated since version 2.8.0 and will be removed in version 2.10.0. Use window.godam.layers.registerLayerRuntime() instead.' );
expect( warn ).toHaveBeenCalledWith( 'GoDAM: window.godamLayerRegistry.registerLayerType() is deprecated since version 2.9.0 and will be removed in version 2.11.0. Use window.godam.layers.registerLayerRuntime() instead.' );
} );

it( 'treats the manager as optional', () => {
Expand Down
6 changes: 3 additions & 3 deletions docs/layer-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Build your own layer types for GoDAM videos and images, the way you build blocks

A layer is something that appears on top of a video or image: a call to action, a form, a poll, a hotspot, a product card. GoDAM's own layer types (CTA, Form, Poll, Hotspot and Ad) are registered through this same API, so an add-on's layer type gets the same treatment: an entry in the "Add layer" menu, a settings panel, a timeline marker, saving, and rendering in the player and on `godam/image` blocks.

> **Requires GoDAM 2.8.0.** The older add-on hooks still work until 2.10.0, with deprecation notices. See [Moving from the old hooks](#moving-from-the-old-hooks).
> **Requires GoDAM 2.9.0.** The older add-on hooks still work until 2.11.0, with deprecation notices. See [Moving from the old hooks](#moving-from-the-old-hooks).

## Contents

Expand Down Expand Up @@ -564,9 +564,9 @@ The editor reads and writes this through `/wp/v2/media/{id}` (the `rtgodam_meta`

## Moving from the old hooks

These still work until **GoDAM 2.10.0**. Each logs a deprecation notice when used: in PHP through `_deprecated_hook()` (with `WP_DEBUG`), in JS in the console once per page.
These still work until **GoDAM 2.11.0**. Each logs a deprecation notice when used: in PHP through `_deprecated_hook()` (with `WP_DEBUG`), in JS in the console once per page.

| Deprecated since 2.8.0 | Use instead |
| Deprecated since 2.9.0 | Use instead |
|---|---|
| `godam_video_editor_layer_options` filter | `godam_register_layer_type()`, plus `getAvailability` in the editor |
| `godam_video_editor_layer_components` filter | `godam_register_layer_type()` with an `editorScript` |
Expand Down
6 changes: 3 additions & 3 deletions inc/classes/layers/class-layer-type-registry.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ class Layer_Type_Registry {

/**
* GoDAM version that deprecated the add-on hooks the Layer API replaces (#2296).
* They are removed two minor releases later, in 2.10.0.
* They are removed two minor releases later, in 2.11.0.
*
* @var string
*/
const HOOKS_DEPRECATED_SINCE = '2.8.0';
const HOOKS_DEPRECATED_SINCE = '2.9.0';

/**
* The handle suffix of each asset key a `layer.json` can name, as core names block asset handles.
Expand Down Expand Up @@ -394,7 +394,7 @@ public static function render_with_legacy_action( $layer, $instance_id ) {
/**
* Renders the container of a layer type that has no PHP registration.
*
* @deprecated 2.8.0 Use `godam_register_layer_type()` with a `render_callback` instead.
* @deprecated 2.9.0 Use `godam_register_layer_type()` with a `render_callback` instead.
*
* @param array $layer Layer configuration.
* @param string $instance_id Player instance ID.
Expand Down
2 changes: 1 addition & 1 deletion pages/video-editor/components/SidebarLayers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ describe( 'Layer API contract: SidebarLayers', () => {
color: 'red',
id: 'test-uuid',
} ] );
expect( console ).toHaveWarnedWith( 'GoDAM: window.godamLayerCreators is deprecated since version 2.8.0 and will be removed in version 2.10.0. Use the `create` setting of registerLayerType() instead.' );
expect( console ).toHaveWarnedWith( 'GoDAM: window.godamLayerCreators is deprecated since version 2.9.0 and will be removed in version 2.11.0. Use the `create` setting of registerLayerType() instead.' );
} );

it( 'lets the creator override the name but never the id', () => {
Expand Down
2 changes: 1 addition & 1 deletion pages/video-editor/components/layers/Layer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe( 'Layer API contract: Layer editor dispatch', () => {

expect( editor() ).toBe( 'acme' );
expect( AcmeLayer.mock.calls[ 0 ][ 0 ] ).toEqual( { layerID: 'l2', goBack, duration: 90 } );
expect( console ).toHaveWarnedWith( 'GoDAM: window.godamLayerComponents is deprecated since version 2.8.0 and will be removed in version 2.10.0. Use the `edit` setting of registerLayerType() instead.' );
expect( console ).toHaveWarnedWith( 'GoDAM: window.godamLayerComponents is deprecated since version 2.9.0 and will be removed in version 2.11.0. Use the `edit` setting of registerLayerType() instead.' );
} );

it( 'lets an add-on replace a core editor by listing the same type', () => {
Expand Down
2 changes: 1 addition & 1 deletion pages/video-editor/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe( 'Layer API contract: editor globals for add-ons', () => {

it( 'exposes the real updateLayerField action on window.godamVideoEditorActions, with a deprecation notice', () => {
expect( window.godamVideoEditorActions.updateLayerField ).toBe( require( './redux/slice/videoSlice' ).updateLayerField );
expect( console ).toHaveWarnedWith( 'GoDAM: window.godamVideoEditorActions is deprecated since version 2.8.0 and will be removed in version 2.10.0. Use useLayerAttributes() from window.godam.layerEditor instead.' );
expect( console ).toHaveWarnedWith( 'GoDAM: window.godamVideoEditorActions is deprecated since version 2.9.0 and will be removed in version 2.11.0. Use useLayerAttributes() from window.godam.layerEditor instead.' );
} );

it( 'exposes formatClock and parseClock on window.godamVideoEditorUtils', () => {
Expand Down
4 changes: 2 additions & 2 deletions pages/video-editor/layers/layers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ describe( 'Layer API: bridge from the old add-on hooks', () => {
expect( create( { currentTime: 1 } ) ).toBeUndefined();
window.godamLayerCreators.acme = ( { currentTime } ) => ( { type: 'acme', displayTime: currentTime } );
expect( create( { currentTime: 3 } ) ).toEqual( { type: 'acme', displayTime: 3 } );
expect( console ).toHaveWarnedWith( 'GoDAM: window.godamLayerCreators is deprecated since version 2.8.0 and will be removed in version 2.10.0. Use the `create` setting of registerLayerType() instead.' );
expect( console ).toHaveWarnedWith( 'GoDAM: window.godamLayerCreators is deprecated since version 2.9.0 and will be removed in version 2.11.0. Use the `create` setting of registerLayerType() instead.' );
} );

it( 'looks the settings panel up when it opens', () => {
Expand All @@ -186,7 +186,7 @@ describe( 'Layer API: bridge from the old add-on hooks', () => {
window.godamLayerComponents.WoocommerceLayer = WoocommerceLayer;
expect( getLegacyEditComponent( 'woo' ) ).toBe( WoocommerceLayer );
expect( getLegacyEditComponent( 'acme' ) ).toBeUndefined();
expect( console ).toHaveWarnedWith( 'GoDAM: window.godamLayerComponents is deprecated since version 2.8.0 and will be removed in version 2.10.0. Use the `edit` setting of registerLayerType() instead.' );
expect( console ).toHaveWarnedWith( 'GoDAM: window.godamLayerComponents is deprecated since version 2.9.0 and will be removed in version 2.11.0. Use the `edit` setting of registerLayerType() instead.' );
} );

it( 'does not re-register a type an add-on already registered through the Layer API', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/php/LayerTypeRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ function ( $layer, $instance_id ) {
);

$this->assertSame( '<div data-legacy="video_1:a1"></div>', godam_render_layer( $layer, 'video_1' ) );
$this->assertSame( array( 'godam_player_render_layer@2.8.0' ), $GLOBALS['rtgodam_stub']['deprecated_hooks'] );
$this->assertSame( array( 'godam_player_render_layer@2.9.0' ), $GLOBALS['rtgodam_stub']['deprecated_hooks'] );
$this->assertSame( '', godam_render_layer( $layer, 'img_1', array( 'media' => 'image' ) ) );
}

Expand Down
Loading