diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml index b7d30624..cdfd4655 100644 --- a/.github/workflows/php.yml +++ b/.github/workflows/php.yml @@ -32,7 +32,6 @@ jobs: fail-fast: false matrix: php-version: - - "7.4" - "8.0" - "8.1" drupal-core: @@ -42,9 +41,19 @@ jobs: instance-type: - "Edge" - "X" - #include: - # - php-version: "8.1" - # drupal-core: "10.0.x" + include: + - php-version: "8.1" + drupal-core: "10.0.x" + instance-type: "Edge" + - php-version: "8.1" + drupal-core: "10.0.x" + instance-type: "X" + - php-version: "8.1" + drupal-core: "10.1.x" + instance-type: "Edge" + - php-version: "8.1" + drupal-core: "10.1.x" + instance-type: "X" steps: @@ -99,8 +108,6 @@ jobs: composer config --no-plugins allow-plugins.php-http/discovery true composer config preferred-install."drupal/apigee_edge" source composer config preferred-install."apigee/apigee-client-php" source - composer require drupal/rules:3.0.0-alpha7 - composer require --dev drush/drush composer config minimum-stability dev composer require drupal/commerce:^2.16 composer require drupal/token:~1.0 diff --git a/apigee_m10n.info.yml b/apigee_m10n.info.yml index 93e00277..8b7aca40 100644 --- a/apigee_m10n.info.yml +++ b/apigee_m10n.info.yml @@ -3,11 +3,11 @@ description: Apigee Edge Monetization Drupal integration package: Apigee type: module -core_version_requirement: ^8.7.7 || ^9 +core_version_requirement: ^9 || ^10 dependencies: - apigee_edge:apigee_edge - drupal:link - requirement:requirement -php: "7.1" +php: 8.0 diff --git a/composer.json b/composer.json index cee6fedb..e7cdd1f7 100644 --- a/composer.json +++ b/composer.json @@ -4,21 +4,21 @@ "type": "drupal-module", "description": "Apigee Edge Monetization for Drupal", "require": { - "php": "^7.4 || ^8.0", + "php": "~8.0 || ~8.1", "ext-bcmath": "*", "cweagans/composer-patches": "~1.6", - "commerceguys/intl": "~1.0", - "drupal/apigee_edge": "^2.0.2", - "drupal/core": "^9.4", - "drupal/requirement": "~1.0", - "apigee/apigee-client-php": "^2.0.16" + "commerceguys/intl": "~1.0 || ^2.0", + "drupal/apigee_edge": "^2.0.2 || ^3.0.0", + "drupal/core": "^9.4 || ^10.0", + "drupal/requirement": "^1.2", + "drupal/jquery_ui_dialog": "^2.0", + "apigee/apigee-client-php": "^2.0.16 || ^3.0.0" }, "require-dev": { "apigee/apigee-mock-client-php": "^1.1.1", - "behat/mink-extension": "^2.0", - "bex/behat-screenshot": "^1.2", - "drupal/core-dev": "^9.4", - "drush/drush": "^9.0 || ^10.0", + "drupal/drupal-extension": "^4.2.1 || ~5", + "drupal/core-dev": "^9.4 || ^10.0", + "drush/drush": "^11.5", "mglaman/drupal-check": "^1.3", "phpmd/phpmd": "^2.8.2", "phpmetrics/phpmetrics": "^2.5", diff --git a/config/install/core.entity_view_display.purchased_plan.purchased_plan.default.yml b/config/install/core.entity_view_display.purchased_plan.purchased_plan.default.yml index 947cfd7e..3aff4c9e 100644 --- a/config/install/core.entity_view_display.purchased_plan.purchased_plan.default.yml +++ b/config/install/core.entity_view_display.purchased_plan.purchased_plan.default.yml @@ -24,6 +24,15 @@ content: date_format: medium custom_date_format: '' timezone: '' + tooltip: + date_format: long + custom_date_format: '' + time_diff: + enabled: false + future_format: '@interval hence' + past_format: '@interval ago' + granularity: 2 + refresh: 60 third_party_settings: { } ratePlan: type: entity_reference_label @@ -42,6 +51,15 @@ content: date_format: medium custom_date_format: '' timezone: '' + tooltip: + date_format: long + custom_date_format: '' + time_diff: + enabled: false + future_format: '@interval hence' + past_format: '@interval ago' + granularity: 2 + refresh: 60 third_party_settings: { } hidden: created: true diff --git a/config/install/core.entity_view_display.rate_plan.rate_plan.default.yml b/config/install/core.entity_view_display.rate_plan.rate_plan.default.yml index c6aa2d62..1f5db841 100644 --- a/config/install/core.entity_view_display.rate_plan.rate_plan.default.yml +++ b/config/install/core.entity_view_display.rate_plan.rate_plan.default.yml @@ -39,6 +39,15 @@ content: date_format: custom custom_date_format: m/d/Y timezone: '' + tooltip: + date_format: long + custom_date_format: '' + time_diff: + enabled: false + future_format: '@interval hence' + past_format: '@interval ago' + granularity: 2 + refresh: 60 text: 'This plan has a new version effective @date. Toggle below to see the future rate plan.' third_party_settings: { } products: diff --git a/config/schema/apigee_m10n.schema.yml b/config/schema/apigee_m10n.schema.yml index 60181188..ea0ba872 100755 --- a/config/schema/apigee_m10n.schema.yml +++ b/config/schema/apigee_m10n.schema.yml @@ -90,6 +90,35 @@ field.formatter.settings.apigee_datestamp: timezone: type: string label: 'Timezone' + tooltip: + type: mapping + label: Tooltip + mapping: + date_format: + type: string + label: 'Tooltip date format' + custom_date_format: + type: string + label: 'Tooltip custom date format' + time_diff: + type: mapping + label: 'Time difference' + mapping: + enabled: + type: boolean + label: 'Show as time difference' + future_format: + type: string + label: 'Future format' + past_format: + type: string + label: 'Past format' + granularity: + type: integer + label: 'Time units' + refresh: + type: integer + label: 'Refresh interval in seconds' field.formatter.settings.apigee_tnc_default: type: mapping @@ -112,6 +141,35 @@ field.formatter.settings.apigee_date_and_text_formatter: timezone: type: string label: 'Timezone' + tooltip: + type: mapping + label: Tooltip + mapping: + date_format: + type: string + label: 'Tooltip date format' + custom_date_format: + type: string + label: 'Tooltip custom date format' + time_diff: + type: mapping + label: 'Time difference' + mapping: + enabled: + type: boolean + label: 'Show as time difference' + future_format: + type: string + label: 'Future format' + past_format: + type: string + label: 'Past format' + granularity: + type: integer + label: 'Time units' + refresh: + type: integer + label: 'Refresh interval in seconds' text: type: string label: 'Text' diff --git a/modules/apigee_m10n_add_credit/apigee_m10n_add_credit.info.yml b/modules/apigee_m10n_add_credit/apigee_m10n_add_credit.info.yml index 3356a5e3..5d279604 100644 --- a/modules/apigee_m10n_add_credit/apigee_m10n_add_credit.info.yml +++ b/modules/apigee_m10n_add_credit/apigee_m10n_add_credit.info.yml @@ -3,7 +3,7 @@ description: Provides the ability to create a Drupal Commerce "Add Credit" produ package: Apigee type: module -core_version_requirement: ^8.7.7 || ^9 +core_version_requirement: ^9 || ^10 dependencies: - apigee_m10n:apigee_m10n @@ -14,5 +14,6 @@ dependencies: - commerce:commerce_order - commerce:commerce_cart - commerce:commerce_checkout + - jquery_ui_dialog:jquery_ui_dialog -php: "7.1" +php: 8.0 diff --git a/modules/apigee_m10n_add_credit/apigee_m10n_add_credit.install b/modules/apigee_m10n_add_credit/apigee_m10n_add_credit.install index 0850b29b..da0c4fde 100644 --- a/modules/apigee_m10n_add_credit/apigee_m10n_add_credit.install +++ b/modules/apigee_m10n_add_credit/apigee_m10n_add_credit.install @@ -64,3 +64,19 @@ function apigee_m10n_add_credit_install() { user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, AddCreditServiceInterface::DEFAULT_AUTHENTICATED_PERMISSIONS); } } + +/** + * Install jquery_ui_dialog module if apigee_m10n_add_credit module is installed. + */ +function apigee_m10n_add_credit_update_9000(&$sandbox) { + // When upgrading, jquery_ui_dialog module is not enabled. + // Check if apigee_m10n_add_credit module is enabled. + if (Drupal::moduleHandler()->moduleExists('apigee_m10n_add_credit')) { + $installer = \Drupal::service('module_installer'); + // Install jquery_ui_dialog module. + $installer->install(['jquery_ui_dialog']); + } + + // Clear all caches. + drupal_flush_all_caches(); +} diff --git a/modules/apigee_m10n_add_credit/js/apigee_m10n_add_credit.add_credit.js b/modules/apigee_m10n_add_credit/js/apigee_m10n_add_credit.add_credit.js index bf77956f..cd8a86f8 100644 --- a/modules/apigee_m10n_add_credit/js/apigee_m10n_add_credit.add_credit.js +++ b/modules/apigee_m10n_add_credit/js/apigee_m10n_add_credit.add_credit.js @@ -28,8 +28,9 @@ attach: function attach(context) { var self = this; $(".two_decimal_price div input").keyup(function(){ - var number = ($(this).val().split('.')); - if (number[1].length > 2) + var number = ($(this).val().split('.')); + // Check if there is value after decimal. + if (number[1] && number[1].length > 2) { var price = parseFloat($(this).val()); $(this).val(price.toFixed(2)); diff --git a/modules/apigee_m10n_add_credit/src/AddCreditService.php b/modules/apigee_m10n_add_credit/src/AddCreditService.php index 4e586b2e..e455fd5e 100755 --- a/modules/apigee_m10n_add_credit/src/AddCreditService.php +++ b/modules/apigee_m10n_add_credit/src/AddCreditService.php @@ -471,7 +471,7 @@ public function apigeeM10nPrepaidBalanceListAlter(array &$build, EntityInterface $build['table']['#attached'] = [ 'library' => [ 'core/drupal.dialog.ajax', - 'core/jquery.ui.dialog', + 'jquery_ui_dialog/dialog', ], ]; } diff --git a/modules/apigee_m10n_add_credit/tests/src/Functional/AddCreditFunctionalTestBase.php b/modules/apigee_m10n_add_credit/tests/src/Functional/AddCreditFunctionalTestBase.php index 05e91567..2f33f89e 100644 --- a/modules/apigee_m10n_add_credit/tests/src/Functional/AddCreditFunctionalTestBase.php +++ b/modules/apigee_m10n_add_credit/tests/src/Functional/AddCreditFunctionalTestBase.php @@ -57,6 +57,7 @@ class AddCreditFunctionalTestBase extends MonetizationFunctionalTestBase { 'commerce', 'user', 'field_ui', + 'jquery_ui_dialog' ]; /** diff --git a/modules/apigee_m10n_add_credit/tests/src/Functional/ApigeeX/AddCreditFunctionalTestBase.php b/modules/apigee_m10n_add_credit/tests/src/Functional/ApigeeX/AddCreditFunctionalTestBase.php index ed944b70..439dce9e 100644 --- a/modules/apigee_m10n_add_credit/tests/src/Functional/ApigeeX/AddCreditFunctionalTestBase.php +++ b/modules/apigee_m10n_add_credit/tests/src/Functional/ApigeeX/AddCreditFunctionalTestBase.php @@ -57,6 +57,7 @@ class AddCreditFunctionalTestBase extends MonetizationFunctionalTestBase { 'commerce', 'user', 'field_ui', + 'jquery_ui_dialog' ]; /** diff --git a/modules/apigee_m10n_add_credit/tests/src/FunctionalJavascript/ApigeeX/AddCreditCustomAmountTest.php b/modules/apigee_m10n_add_credit/tests/src/FunctionalJavascript/ApigeeX/AddCreditCustomAmountTest.php index ca6fb3fc..d3fdcf79 100755 --- a/modules/apigee_m10n_add_credit/tests/src/FunctionalJavascript/ApigeeX/AddCreditCustomAmountTest.php +++ b/modules/apigee_m10n_add_credit/tests/src/FunctionalJavascript/ApigeeX/AddCreditCustomAmountTest.php @@ -43,6 +43,11 @@ class AddCreditCustomAmountTest extends AddCreditFunctionalJavascriptTestBase { */ protected $developer; + /** + * {@inheritdoc} + */ + protected $defaultTheme = 'claro'; + /** * {@inheritdoc} * diff --git a/modules/apigee_m10n_teams/apigee_m10n_teams.info.yml b/modules/apigee_m10n_teams/apigee_m10n_teams.info.yml index e8e7681d..fda0137c 100644 --- a/modules/apigee_m10n_teams/apigee_m10n_teams.info.yml +++ b/modules/apigee_m10n_teams/apigee_m10n_teams.info.yml @@ -3,10 +3,10 @@ description: Adds monetization support for Apigee Edge Teams. package: Apigee (Experimental) type: module -core_version_requirement: ^8.7.7 || ^9 +core_version_requirement: ^9 || ^10 dependencies: - apigee_m10n:apigee_m10n - apigee_edge:apigee_edge_teams -php: "7.1" +php: 8.0 diff --git a/modules/apigee_m10n_teams/tests/src/Kernel/Entity/PurchasedRatePlanEntityKernelTest.php b/modules/apigee_m10n_teams/tests/src/Kernel/Entity/PurchasedRatePlanEntityKernelTest.php index 6073f015..285490fb 100644 --- a/modules/apigee_m10n_teams/tests/src/Kernel/Entity/PurchasedRatePlanEntityKernelTest.php +++ b/modules/apigee_m10n_teams/tests/src/Kernel/Entity/PurchasedRatePlanEntityKernelTest.php @@ -209,11 +209,14 @@ protected function memberViewPurchasedRatePlans() { $this->setRawContent($response->getContent()); static::assertSame(Response::HTTP_OK, $response->getStatusCode()); - // Checking "Active and Future Purchased Plans" table columns. + // As div generated for startdate is different for Drupal 10.1 + // hence need to check Drupal version and select the div. + $div_to_use = floatval(\Drupal::VERSION) <= 10.0 ? '.purchased-plan-row:nth-child(1) td.purchased-plan-start-date div' : '.purchased-plan-row:nth-child(1) td.purchased-plan-start-date div time'; + $this->assertCssElementText('.purchased-plan-row:nth-child(1) td.purchased-plan-status span', 'Active'); $this->assertCssElementText('.purchased-plan-row:nth-child(1) td.purchased-plan-rate-plan a', $this->rate_plan->getDisplayName()); - $this->assertCssElementText('.purchased-plan-row:nth-child(1) td.purchased-plan-start-date div', $this->purchased_plan->getStartDate()->format('m/d/Y')); + $this->assertCssElementText($div_to_use, $this->purchased_plan->getStartDate()->format('m/d/Y')); $this->assertCssElementText('.purchased-plan-row:nth-child(1) td.purchased-plan-end-date', ''); } diff --git a/src/Plugin/Field/FieldFormatter/DateAndTextFormatter.php b/src/Plugin/Field/FieldFormatter/DateAndTextFormatter.php index f9ed093e..249a76cd 100644 --- a/src/Plugin/Field/FieldFormatter/DateAndTextFormatter.php +++ b/src/Plugin/Field/FieldFormatter/DateAndTextFormatter.php @@ -72,9 +72,10 @@ public function viewElements(FieldItemListInterface $items, $langcode) { foreach ($items as $delta => $item) { // Grab the formatted date from the TimestampFormatter and add it to the // text. + // For Drupal 10.1, date is available in '#text'. $elements[$delta] = [ '#markup' => t($text, [ - '@date' => $elements[$delta]['#markup'], + '@date' => $elements[$delta]['#markup'] ?? $elements[$delta]['#text'], ]), ]; } diff --git a/src/Routing/MonetizationRouteSubscriber.php b/src/Routing/MonetizationRouteSubscriber.php index 19007046..7d6f8775 100755 --- a/src/Routing/MonetizationRouteSubscriber.php +++ b/src/Routing/MonetizationRouteSubscriber.php @@ -89,7 +89,7 @@ protected function alterRoutes(RouteCollection $collection) { /** * {@inheritdoc} */ - public static function getSubscribedEvents() { + public static function getSubscribedEvents(): array { $events = parent::getSubscribedEvents(); $events[RoutingEvents::ALTER] = ['onAlterRoutes', -101]; return $events; diff --git a/tests/modules/apigee_m10n_test/apigee_m10n_test.info.yml b/tests/modules/apigee_m10n_test/apigee_m10n_test.info.yml index e1030381..87684c3d 100644 --- a/tests/modules/apigee_m10n_test/apigee_m10n_test.info.yml +++ b/tests/modules/apigee_m10n_test/apigee_m10n_test.info.yml @@ -1,7 +1,7 @@ name: 'Apigee Monetization: Testing' type: module description: 'Support module for the Apigee Monetization tests.' -core_version_requirement: ^8.7.7 || ^9 +core_version_requirement: ^9 || ^10 package: Testing dependencies: diff --git a/tests/src/Kernel/Plugin/Field/FieldFormatter/DatestampFormatterKernelTest.php b/tests/src/Kernel/Plugin/Field/FieldFormatter/DatestampFormatterKernelTest.php index 5e082242..869f6dfb 100644 --- a/tests/src/Kernel/Plugin/Field/FieldFormatter/DatestampFormatterKernelTest.php +++ b/tests/src/Kernel/Plugin/Field/FieldFormatter/DatestampFormatterKernelTest.php @@ -110,6 +110,17 @@ public function testView() { 'date_format' => $date_format, 'custom_date_format' => $custom_date_format, 'timezone' => '', + 'tooltip' => [ + 'date_format' => $date_format, + 'custom_date_format' => 'm/d/Y' + ], + 'time_diff' => [ + 'enabled' => FALSE, + 'future_format' => '@interval hence', + 'past_format' => '@interval ago', + 'granularity' => 2, + 'refresh' => 60, + ] ], 'label' => TRUE, 'view_mode' => 'default', @@ -127,7 +138,8 @@ public function testView() { static::assertSame('Start Date', (string) $build['#title']); static::assertTrue($build['#label_display']); - static::assertSame($expected, (string) $build[0]['#markup']); + // For Drupal 10.1, date is available in '#text'. + static::assertSame($expected, (string) ($build[0]['#markup'] ?? $build[0]['#text'])); } }