diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 422ec0b17491fe44d6ce7abdcbcda36bf1b71b8c..acaa3b0e6ee8928a469e32bb02838da3daa57a9b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -50,7 +50,6 @@ include: # SKIP_ESLINT: '1' variables: - _TARGET_CORE: "9.5.10" SKIP_ESLINT: '1' ################################################################################### diff --git a/composer.json b/composer.json index d774dd25b3f237fceca9f3c87e5c65019a94cae6..58f074ff1e9cab614a1364b3dc6c896246facf80 100644 --- a/composer.json +++ b/composer.json @@ -12,6 +12,6 @@ "drupal/flysystem": "^2.0", "league/flysystem": "^1.0.20", "league/flysystem-aws-s3-v3": "^1.0, !=1.0.12, !=1.0.13", - "drupal/core": "^9.0" + "drupal/core": "^9.2 || ^10" } } diff --git a/flysystem_s3.info.yml b/flysystem_s3.info.yml index 63b4ddf0c67463b94048eebd1b86aa283601a3a0..501002abf123f0564d613a9a8f26abdd75ca12f4 100644 --- a/flysystem_s3.info.yml +++ b/flysystem_s3.info.yml @@ -1,7 +1,7 @@ name: Flysystem Amazon S3 description: "Provides an Amazon S3 plugin for Flysystem." type: module -core_version_requirement: ^9 +core_version_requirement: ^9.2 || ^10.0 version: 8.0-dev package: Flysystem dependencies: diff --git a/flysystem_s3.js b/flysystem_s3.js index ce329ee4b37505c06fdcc7a3230acda184aaebf3..ae9327530d7273b38aa93b0807b69bc8e22702d3 100644 --- a/flysystem_s3.js +++ b/flysystem_s3.js @@ -3,7 +3,7 @@ * Provides JavaScript additions to the S3 CORS upload managed file field type. */ -(function($, Drupal) { +(function($, Drupal, once) { /** * S3 File upload utility functions. * @@ -349,28 +349,20 @@ */ Drupal.behaviors.flySystemS3CorsUpload = { attach(context) { - $(context) - .find( - '.js-form-managed-file input[type="file"][data-flysystem-s3-cors]' - ) + const fileInputSelector = + '.js-form-managed-file input[type="file"][data-flysystem-s3-cors]'; + $(once("auto-cors-upload", fileInputSelector, context)) // Add the CORS upload handler to the file input. - .once("auto-cors-upload") .on("change.autoCorsFileUpload", Drupal.flysystemS3.submitCorsUpload) // Disable the upload button trigger so that the CORS upload handler can run first. .off("change.autoFileUpload", Drupal.file.triggerUploadButton); }, detach(context, setting, trigger) { + const fileInputSelector = '.js-form-managed-file input[type="file"][data-flysystem-s3-cors]'; if (trigger === "unload") { - $(context) - .find( - '.js-form-managed-file input[type="file"][data-flysystem-s3-cors]' - ) - .removeOnce("auto-cors-upload") - .off( - "change.autoCorsFileUpload", - Drupal.flysystemS3.submitCorsUpload - ); + $(once.remove("auto-cors-upload", fileInputSelector, context)) + .off("change.autoCorsFileUpload", Drupal.flysystemS3.submitCorsUpload); } } }; -})(jQuery, Drupal, drupalSettings); +})(jQuery, Drupal, once, drupalSettings); diff --git a/flysystem_s3.libraries.yml b/flysystem_s3.libraries.yml index 679cec89ad4cef63aa603ded2bfb434f309b6d68..11243c9526f341c830fc3d23db05486cfabea079 100644 --- a/flysystem_s3.libraries.yml +++ b/flysystem_s3.libraries.yml @@ -2,5 +2,6 @@ drupal.s3_cors_upload: js: flysystem_s3.js: {} dependencies: - - file/drupal.file - core/drupal.progress + - core/once + - file/drupal.file diff --git a/tests/src/Functional/ModuleInstallUninstallWebTest.php b/tests/src/Functional/ModuleInstallUninstallWebTest.php index b33704d640725ab03fc9e5c34323ffcb607b4d8b..755b9a427a512a3fd52b56b32bda16777501d8a3 100644 --- a/tests/src/Functional/ModuleInstallUninstallWebTest.php +++ b/tests/src/Functional/ModuleInstallUninstallWebTest.php @@ -14,6 +14,6 @@ class ModuleInstallUninstallWebTest extends Base { /** * {@inheritdoc} */ - public static $modules = ['flysystem_s3']; + protected static $modules = ['flysystem_s3']; } diff --git a/tests/src/Unit/Flysystem/S3Test.php b/tests/src/Unit/Flysystem/S3Test.php index ea7587a595fa18360cb45ac9062223ee486bc7ce..6376e8237519e0bf534ceee414b51e428b3c9ece 100644 --- a/tests/src/Unit/Flysystem/S3Test.php +++ b/tests/src/Unit/Flysystem/S3Test.php @@ -12,6 +12,7 @@ use Drupal\Tests\UnitTestCase; use League\Flysystem\AdapterInterface; use League\Flysystem\Config; use Prophecy\Argument; +use Prophecy\PhpUnit\ProphecyTrait; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; @@ -22,6 +23,8 @@ use Symfony\Component\HttpFoundation\RequestStack; */ class S3Test extends UnitTestCase { + use ProphecyTrait; + /** * @covers ::__construct * @covers ::getExternalUrl