-
Notifications
You must be signed in to change notification settings - Fork 46
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Render app credential warnings with BigPipe #957
base: 3.x
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,6 +66,9 @@ apigee_edge.common_app_settings: | |
callback_url_placeholder: | ||
type: label | ||
label: 'Placeholder for a Callback URL' | ||
app_credential_warnings_bc_mode: | ||
type: boolean | ||
deprecated: "The 'app_credential_warnings_bc_mode' config schema is deprecated in Apigee Edge 3.0.3 and will be removed from Apigee Edge 4.0.0." | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Todo adjust version number before merge. |
||
|
||
apigee_edge.developer_app_settings: | ||
type: config_object | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
declare(strict_types = 1); | ||
|
||
/** | ||
* Copyright 2023 Google Inc. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* version 2 as published by the Free Software Foundation. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
* MA 02110-1301, USA. | ||
*/ | ||
|
||
namespace Drupal\apigee_edge\LazyBuilder; | ||
|
||
use Drupal\apigee_edge\Entity\AppInterface; | ||
use Drupal\Core\Security\TrustedCallbackInterface; | ||
|
||
/** | ||
* Lazy builder for app credential warnings. | ||
*/ | ||
final class AppWarningsLazyBuilder implements TrustedCallbackInterface { | ||
|
||
/** | ||
* Lazy builds app credentials warnings. | ||
* | ||
* @param string $entity_type_id | ||
* The type of the entity, either "developer_app" or "team_app". | ||
* @param string $id | ||
* The entity id. | ||
* | ||
* @return array | ||
* A render array with warnings. | ||
*/ | ||
public static function lazyBuilder(string $entity_type_id, string $id): array { | ||
if (!in_array($entity_type_id, ['developer_app', 'team_app'], TRUE)) { | ||
throw new \LogicException(sprintf('Unexpected entity type: %s.', $entity_type_id)); | ||
} | ||
|
||
$entity = \Drupal::entityTypeManager()->getStorage($entity_type_id)->load($id); | ||
if ($entity instanceof AppInterface) { | ||
/** @var \Drupal\apigee_edge\Entity\AppWarningsCheckerInterface $app_warnings_checker */ | ||
$app_warnings_checker = \Drupal::service('apigee_edge.entity.app_warnings_checker'); | ||
$warnings = array_filter($app_warnings_checker->getWarnings($entity)); | ||
if (count($warnings) > 0) { | ||
return [ | ||
'#theme' => 'apigee_app_credential_warnings', | ||
'#warnings' => $warnings, | ||
]; | ||
} | ||
} | ||
|
||
return []; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public static function trustedCallbacks(): array { | ||
return ['lazyBuilder']; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Why on earth invokable classes are not supported...???!) |
||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div class="app-credential-warnings"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO add docblocks |
||
<div class="app-credential-warning-placeholder"> | ||
<span>{{ 'Fetching crendential information...'|t }}</span> | ||
</div> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<div class="app-credential-warnings"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO add docblocks |
||
{% for warning in warnings %} | ||
<div class="app-credential-warning">{{ warning }}</div> | ||
{% endfor %} | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should superior flexibility for downstream projects to customize these.