Skip to content
Snippets Groups Projects
Commit 335c0231 authored by Al Munnings's avatar Al Munnings
Browse files

Issue #3519902: Max length url is too short

parent ef9837e6
No related branches found
No related tags found
1 merge request!5Issue #3519902: Max length url is too short
Pipeline #482873 passed
allowtransparency
createkey
\ No newline at end of file
......@@ -2,7 +2,7 @@ name: "GraphQL Compose: Preview"
description: "Extend preview capabilities for use with GraphQL."
type: module
package: GraphQL Compose (Contrib)
core_version_requirement: ^10.1 || ^11
core_version_requirement: ^10.3 || ^11
php: 8.1
dependencies:
- drupal:node
......
......@@ -16,7 +16,7 @@ class KeyValueDatabaseExpirableTokenFactory extends KeyValueDatabaseExpirableFac
*/
public function get($collection) {
if ($collection === 'tempstore.private.node_preview') {
$this->storages[$collection] ??= new DatabaseStorageExpirableToken($collection, $this->serializer, $this->connection);
$this->storages[$collection] ??= new DatabaseStorageExpirableToken($collection, $this->serializer, $this->connection, $this->time);
}
return parent::get($collection);
......
......@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Drupal\graphql_compose_preview\Plugin\Field\FieldFormatter;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Form\FormStateInterface;
......@@ -82,10 +83,14 @@ class PreviewTokenIframeFormatter extends FormatterBase {
public function settingsSummary() {
$summary = [];
$summary[] = $this->t('Displays as iframe.');
$summary[] = $this->t('URL: @url', ['@url' => $this->getLinkUrl()]);
$summary[] = $this->t('URL: @url', [
'@url' => Unicode::truncate($this->getLinkUrl(), 50, TRUE, TRUE),
]);
if ($this->getSetting('class')) {
$summary[] = $this->t('CSS class: @class', ['@class' => $this->getSetting('class')]);
$summary[] = $this->t('CSS class: @class', [
'@class' => Unicode::truncate($this->getSetting('class'), 50, TRUE, TRUE),
]);
}
return $summary;
......@@ -100,7 +105,6 @@ class PreviewTokenIframeFormatter extends FormatterBase {
'#type' => 'textfield',
'#title' => $this->t('Base URL'),
'#default_value' => $this->getLinkUrl(),
'#required' => TRUE,
'#disabled' => getenv('GRAPHQL_COMPOSE_PREVIEW_URL'),
'#description' => $this->t('
The URL for your iframe. Use the tokens %uuid, %token or %url or environment variable %env.',
......@@ -111,6 +115,7 @@ class PreviewTokenIframeFormatter extends FormatterBase {
'%env' => 'GRAPHQL_COMPOSE_PREVIEW_URL',
],
),
'#maxlength' => 2048,
'#token_types' => ['node'],
],
'token_help' => [
......@@ -122,6 +127,7 @@ class PreviewTokenIframeFormatter extends FormatterBase {
'#title' => $this->t('CSS class'),
'#default_value' => $this->getSetting('class'),
'#description' => $this->t('The CSS class to apply to the iframe.'),
'#maxlength' => 2048,
],
'width' => [
'#type' => 'textfield',
......
......@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Drupal\graphql_compose_preview\Plugin\Field\FieldFormatter;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Form\FormStateInterface;
......@@ -82,11 +83,15 @@ class PreviewTokenLinkFormatter extends FormatterBase {
$summary[] = $this->t('Link title: @title', ['@title' => $this->getSetting('title')]);
if ($this->getLinkUrl()) {
$summary[] = $this->t('Link URL: @url', ['@url' => $this->getLinkUrl()]);
$summary[] = $this->t('Link URL: @url', [
'@url' => Unicode::truncate($this->getLinkUrl(), 50, TRUE, TRUE),
]);
}
if ($this->getSetting('class')) {
$summary[] = $this->t('CSS class: @class', ['@class' => $this->getSetting('class')]);
$summary[] = $this->t('CSS class: @class', [
'@class' => Unicode::truncate($this->getSetting('class'), 50, TRUE, TRUE),
]);
}
return $summary;
......@@ -117,6 +122,7 @@ class PreviewTokenLinkFormatter extends FormatterBase {
'%env' => 'GRAPHQL_COMPOSE_PREVIEW_URL',
],
),
'#maxlength' => 2048,
'#token_types' => ['node'],
],
'token_help' => [
......@@ -128,6 +134,7 @@ class PreviewTokenLinkFormatter extends FormatterBase {
'#title' => $this->t('CSS class'),
'#default_value' => $this->getSetting('class'),
'#description' => $this->t('The CSS class to apply to the link.'),
'#maxlength' => 2048,
],
];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment