Skip to content

Commit

Permalink
Merge branch '2.x' into entity_query_support
Browse files Browse the repository at this point in the history
  • Loading branch information
giteshk authored Jul 20, 2023
2 parents 7895d96 + 1d4ac2a commit 4f902ba
Show file tree
Hide file tree
Showing 116 changed files with 1,875 additions and 209 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@ jobs:
id: composercache
run: |
cd drupal
echo "::set-output name=dir::$(composer config cache-files-dir)"
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
- name: Cache composer dependencies
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: ${{ steps.composercache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Checkout apigee_edge module
uses: actions/checkout@v3.0.0
uses: actions/checkout@v3
with:
path: drupal/modules/contrib/apigee_edge

Expand All @@ -86,6 +86,7 @@ jobs:
composer config --no-plugins allow-plugins.wikimedia/composer-merge-plugin true
composer config --no-plugins allow-plugins.composer/package-versions-deprecated true
composer config --no-plugins allow-plugins.cweagans/composer-patches true
composer config --no-plugins allow-plugins.php-http/discovery true
composer require --dev drush/drush
composer config minimum-stability dev
composer require drupal/rules:3.0.0-alpha7
Expand Down
2 changes: 1 addition & 1 deletion apigee_edge.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ dependencies:

configure: apigee_edge.settings

php: "7.1"
php: 8.0
24 changes: 24 additions & 0 deletions apigee_edge.install
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

use Drupal\apigee_edge\OauthTokenFileStorage;
use Drupal\apigee_edge\Plugin\EdgeKeyTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Installer\InstallerKernel;
use Drupal\Core\Url;
use Drupal\user\RoleInterface;
Expand Down Expand Up @@ -349,3 +350,26 @@ function apigee_edge_update_8107() {
$storage->removeTokenFile();
}
}

/**
* Update the field storage defination of Developer App.
*/
function apigee_edge_update_9001() {
$definition_update_manager = \Drupal::entityDefinitionUpdateManager();
/** @var \Drupal\Core\Entity\EntityLastInstalledSchemaRepositoryInterface $last_installed_schema_repository */
$last_installed_schema_repository = \Drupal::service('entity.last_installed_schema.repository');
$entity_type_id = 'developer_app';
$entity_type = $definition_update_manager->getEntityType($entity_type_id);
$field_storage_definitions = $last_installed_schema_repository->getLastInstalledFieldStorageDefinitions($entity_type_id);

$field_storage_definitions['apiProducts'] = BaseFieldDefinition::create('string')
->setName('apiproducts')
->setTargetEntityTypeId($entity_type_id)
->setTargetBundle(NULL)
->setStorageRequired(FALSE)
->setInternal(TRUE)
->setTranslatable(FALSE)
->setRevisionable(FALSE);

$definition_update_manager->updateFieldableEntityType($entity_type, $field_storage_definitions);
}
15 changes: 8 additions & 7 deletions apigee_edge.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ apigee_edge.admin:
js/apigee_edge.admin.js: {}

apigee_edge.analytics:
version: 1.0
version: 1.1
css:
theme:
css/apigee_edge.analytics.css: {}
Expand All @@ -27,7 +27,7 @@ apigee_edge.analytics:
- apigee_edge/charts
- core/drupal
- core/jquery
- core/jquery.once
- core/once
- core/drupalSettings

apigee_edge.components:
Expand All @@ -37,7 +37,7 @@ apigee_edge.components:
css/apigee_edge.components.css: {}

apigee_edge.app_listing:
version: 1.0
version: 1.1
css:
theme:
css/apigee_edge.app_listing.css: {}
Expand All @@ -51,7 +51,7 @@ apigee_edge.status_property:
css/apigee_edge.status_property.css: {}

apigee_edge.secret:
version: 1.1
version: 1.2
css:
theme:
css/apigee_edge.secret.css: {}
Expand All @@ -61,6 +61,7 @@ apigee_edge.secret:
- core/jquery
- core/drupalSettings
- core/drupal
- core/once

apigee_edge.app_view:
version: 1.0
Expand All @@ -69,7 +70,7 @@ apigee_edge.app_view:
css/apigee_edge.app_view.css: {}
dependencies:
- core/jquery
- core/jquery.once
- core/once
- core/drupal
- core/drupalSettings

Expand All @@ -80,12 +81,12 @@ apigee_edge.app_credential:
css/apigee_edge.app_credential.css: {}

apiproduct_access_admin:
version: 1.0
version: 1.1
js:
js/apigee_edge.apiproduct_access_admin.js: {}
dependencies:
- core/jquery
- core/jquery.once
- core/once
- core/drupal
- core/drupalSettings

Expand Down
6 changes: 3 additions & 3 deletions apigee_edge.module
Original file line number Diff line number Diff line change
Expand Up @@ -1186,11 +1186,11 @@ function template_preprocess_app_credential(array &$variables) {
/** @var \DateTimeInterface $value */
if ($value !== -1) {
$time_diff = \Drupal::time()->getRequestTime() - intval($value / 1000);
if ($time_diff > 0) {
if ($time_diff >= 0) {
$value = t('@time ago', ['@time' => $dateFormatter->formatTimeDiffSince(intval($value / 1000))]);
}
else {
$value = t('@time hence', ['@time' => $dateFormatter->formatTimeDiffUntil(intval($value / 1000))]);
$value = t('@time from now', ['@time' => $dateFormatter->formatTimeDiffUntil(intval($value / 1000))]);
}
}
else {
Expand Down Expand Up @@ -1588,7 +1588,7 @@ function apigee_edge_cron() {
// The reason of this is to avoid race conditions.
for ($i = 0; $i < 100; $i++) {
if (($job = $executor->select())) {
$executor->cast($job);
$executor->call($job);
}
else {
break;
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"type": "drupal-module",
"description": "Apigee Edge for Drupal.",
"require": {
"php": "^8.0",
"php": "~8.0.0 || ~8.1.0",
"ext-json": "*",
"apigee/apigee-client-php": "^2.0.16",
"apigee/apigee-client-php": "^2.1.0",
"drupal/core": "^9.4",
"drupal/entity": "^1.0",
"drupal/key": "^1.8",
Expand Down
6 changes: 3 additions & 3 deletions js/apigee_edge.analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
* @see {@link https://developers.google.com/chart|Google Charts}
*/
Drupal.behaviors.apigeeEdgeAnalyticsDraw = {
attach: function attach(context, drupalSettings) {
$(context).find('body').once('load_google_chart').each(function () {
attach: function attach(context, drupalSettings) {
$(once('load_google_chart', 'body', context)).each(function () {
var metric = drupalSettings.analytics.metric;
var timestamps = drupalSettings.analytics.timestamps;
var values = drupalSettings.analytics.values;
Expand Down Expand Up @@ -129,7 +129,7 @@
*/
Drupal.behaviors.apigeeEdgeAnalyticsQuickDatePicker = {
attach: function attach(context, drupalSettings) {
$('#edit-quick-date-picker', context).once().bind('change', function () {
$(once('apigee_analytics_datepicker', '#edit-quick-date-picker', context)).bind('change', function () {
var since = getServerOffsetDate(new Date());
switch (this.selectedOptions['0'].value) {
case '1d':
Expand Down
2 changes: 1 addition & 1 deletion js/apigee_edge.apiproduct_access_admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Drupal.behaviors.apigee_edge_apiproduct_access_admin = {
attach: function attach(context) {
var self = this;
$('table#visibility').once('visibility').each(function () {
$(once('visibility', 'table#visibility')).each(function () {
var $table = $(this);
var $ancestor = void 0;
var method = void 0;
Expand Down
6 changes: 3 additions & 3 deletions js/apigee_edge.app_listing.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* @file
* Javascript functions related to the app listing.
*/
(function ($, Drupal) {
(function ($, Drupal, once) {

'use strict';

Expand All @@ -31,7 +31,7 @@

Drupal.apigeeEdgeAppListing = {
tableToggle: function (context, settings) {
$('.toggle--warning').once('tableToggle').on('click', function (event) {
$(once('tableToggle', '.toggle--warning')).on('click', function (event) {
event.preventDefault();
var targetURL = $(this).attr('href');
var targetID = '#' + targetURL.substr(targetURL.indexOf('#') + 1);
Expand All @@ -50,4 +50,4 @@

}
};
})(jQuery, Drupal);
})(jQuery, Drupal, once);
4 changes: 2 additions & 2 deletions js/apigee_edge.secret.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
$this.addClass(hClass);

// Toggle secret.
$(this).find('.secret__toggle').once().on('click', function (event) {
$(once('apigee_edge_secret', '.secret__toggle', this)).on('click', function (event) {
let index = $(this).closest(appElWrapper).find('.secret__toggle').index(this);
let wrapperIndex = $wrapper.data('app-container-index');
event.preventDefault();
Expand All @@ -57,7 +57,7 @@

// Copy to clipboard.
let $copy = $(this).find('.secret__copy');
$copy.find('button').once().on('click', function (event) {
$(once('copybutton', 'button', this)).on('click', function (event) {
let index = $(this).closest(appElWrapper).find('.secret__copy button').index(this);
let wrapperIndex = $wrapper.closest('fieldset').parent().find('fieldset').index($(this).closest('fieldset'));
callEndpoint($wrapper.data('app-keys-url'), function(data) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@

namespace Drupal\apigee_edge_actions\EventSubscriber;

use Drupal\apigee_edge_actions\Event\EdgeEntityEventEdge;
use Drupal\apigee_edge\Entity\AppInterface;
use Drupal\apigee_edge\Event\AppCredentialAddApiProductEvent;
use Drupal\apigee_edge\Event\AppCredentialDeleteApiProductEvent;
use Drupal\apigee_edge_actions\Event\EdgeEntityEventEdge;
use Drupal\Component\Plugin\Exception\PluginException;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Logger\LoggerChannelInterface;
use Drupal\Core\Session\AccountInterface;
use Symfony\Contracts\EventDispatcher\Event;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Contracts\EventDispatcher\Event;

/**
* Events for an API Product being added to an app already exist.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

namespace Drupal\apigee_edge_actions\Plugin\RulesEvent;

use Drupal\apigee_edge_actions\ApigeeActionsEntityTypeHelperInterface;
use Drupal\apigee_edge\Entity\AppInterface;
use Drupal\apigee_edge\Entity\EdgeEntityTypeInterface;
use Drupal\apigee_edge_actions\ApigeeActionsEntityTypeHelperInterface;
use Drupal\apigee_edge_teams\Entity\TeamAppInterface;
use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\StringTranslation\StringTranslationTrait;
Expand Down
13 changes: 10 additions & 3 deletions modules/apigee_edge_actions/src/TeamMembershipManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

namespace Drupal\apigee_edge_actions;

use Drupal\apigee_edge_actions\Event\EdgeEntityEventEdge;
use Drupal\apigee_edge\Entity\Controller\DeveloperControllerInterface;
use Drupal\apigee_edge\Entity\DeveloperCompaniesCacheInterface;
use Drupal\apigee_edge_actions\Event\EdgeEntityEventEdge;
use Drupal\apigee_edge_teams\CompanyMembersControllerFactoryInterface;
use Drupal\apigee_edge_teams\TeamMembershipManagerInterface;
use Drupal\Core\Cache\CacheTagsInvalidatorInterface;
Expand Down Expand Up @@ -151,8 +151,15 @@ public function removeMembers(string $team, array $developers): void {
/**
* {@inheritdoc}
*/
public function getTeams(string $developer): array {
return $this->inner->getTeams($developer);
public function getTeams(string $developer, string $team = NULL): array {
return $this->inner->getTeams($developer, $team);
}

/**
* {@inheritdoc}
*/
public function syncAppGroupMembers(string $team): array {
return $this->inner->syncAppGroupMembers($team);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ protected function setUp(): void {
parent::setUp();

$this->installEntitySchema('team_member_role');

$this->addOrganizationMatchedResponse();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ protected function setUp(): void {
parent::setUp();

$this->installEntitySchema('team_member_role');

$this->addOrganizationMatchedResponse();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public function testEvent() {
]);
$config_entity->save();

// Add matched organization response so it returns the org whenever called.
$this->addOrganizationMatchedResponse();

// Insert and update entity.
/** @var \Drupal\apigee_edge\Entity\DeveloperAppInterface $entity */
$entity = $this->createDeveloperApp();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
admin:
version: 1.0
version: 1.1
css:
theme:
css/apigee_edge_apiproduct_rbac.admin.css: {}
js:
js/apigee_edge_apiproduct_rbac.admin.js: {}
dependencies:
- core/jquery
- core/jquery.once
- core/once
- core/drupal
- core/drupalSettings
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
Drupal.behaviors.apigee_edge_apiproduct_rbac_admin = {
attach: function attach(context) {
var self = this;
$('table#rbac-settings').once('rbac-settings').each(function () {
$(once('rbac-settings', 'table#rbac-settings')).each(function () {
var $table = $(this);
var $ancestor = void 0;
var method = void 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
use Drupal\apigee_edge_debug\DebugMessageFormatterPluginManager;
use Drupal\apigee_edge_debug\SDKConnector;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Session\AccountInterface;
use GuzzleHttp\RequestOptions;
use GuzzleHttp\TransferStats;
use Psr\Http\Message\RequestInterface;
Expand Down
Loading

0 comments on commit 4f902ba

Please sign in to comment.