Skip to content

Commit 11e108a

Browse files
committed
feat(next): update Next.js settings to add draft mode
Issue #502
1 parent e0fc4bd commit 11e108a

File tree

8 files changed

+25
-25
lines changed

8 files changed

+25
-25
lines changed

modules/next/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "drupal/next",
3-
"description": "Next.js + Drupal for Incremental Static Regeneration and Preview mode.",
3+
"description": "Next.js + Drupal for Incremental Static Regeneration and Draft mode.",
44
"type": "drupal-module",
55
"homepage": "http://drupal.org/project/next",
66
"license": "GPL-2.0-or-later",

modules/next/modules/next_jwt/src/Plugin/Next/PreviewUrlGenerator/Jwt.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ public function defaultConfiguration() {
103103
*/
104104
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
105105
$form['secret_expiration'] = [
106-
'#title' => $this->t('Preview secret expiration time'),
107-
'#description' => $this->t('The value, in seconds, to be used as expiration time for the preview secret. <strong>It is recommended to use short-lived secrets for increased security.</strong>'),
106+
'#title' => $this->t('Secret expiration time'),
107+
'#description' => $this->t('The value, in seconds, to be used as expiration time for the validation secret. <strong>It is recommended to use short-lived secrets for increased security.</strong>'),
108108
'#type' => 'number',
109109
'#required' => TRUE,
110110
'#default_value' => $this->configuration['secret_expiration'],

modules/next/next.info.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: Next.js
2-
description: Next.js + Drupal for Incremental Static Regeneration and Preview mode.
2+
description: Next.js + Drupal for Incremental Static Regeneration and Draft mode.
33
type: module
44
core_version_requirement: ^9 || ^10
55
package: Web services

modules/next/src/Controller/NextSiteEntityController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function environmentVariables(NextSiteInterface $next_site) {
6464

6565
if ($secret = $next_site->getPreviewSecret()) {
6666
$variables += [
67-
'preview_variables' => '# Required for Preview Mode',
67+
'preview_variables' => '# Required for Draft Mode',
6868
'DRUPAL_PREVIEW_SECRET' => $secret,
6969
];
7070
}

modules/next/src/Form/NextEntityTypeConfigForm.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,16 @@ public function form(array $form, FormStateInterface $form_state) {
119119
'#title' => $this->t('Settings'),
120120
];
121121

122-
$form['preview_mode'] = [
123-
'#title' => $this->t('Preview Mode'),
124-
'#description' => $this->t('Configure preview mode the entity type.'),
122+
$form['draft_mode'] = [
123+
'#title' => $this->t('Draft Mode'),
124+
'#description' => $this->t('Configure draft mode for this entity type.'),
125125
'#type' => 'details',
126126
'#group' => 'settings',
127127
];
128128

129-
$form['preview_mode']['site_resolver'] = [
129+
$form['draft_mode']['site_resolver'] = [
130130
'#title' => $this->t('Plugin'),
131-
'#description' => $this->t('Select a plugin to use for resolving the preview site for this entity type.'),
131+
'#description' => $this->t('Select a plugin to use when validating the draft url for this entity type.'),
132132
'#type' => 'select',
133133
'#options' => array_merge(['' => $this->t('None')], array_column($this->siteResolverManager->getDefinitions(), 'label', 'id')),
134134
'#default_value' => $entity->getSiteResolver() ? $entity->getSiteResolver()->getId() : NULL,
@@ -142,7 +142,7 @@ public function form(array $form, FormStateInterface $form_state) {
142142
],
143143
];
144144

145-
$form['preview_mode']['site_resolver_settings_container'] = [
145+
$form['draft_mode']['site_resolver_settings_container'] = [
146146
'#type' => 'container',
147147
'#prefix' => '<div id="site-resolver-settings">',
148148
'#suffix' => '</div>',
@@ -152,7 +152,7 @@ public function form(array $form, FormStateInterface $form_state) {
152152
if ($site_resolver instanceof ConfigurableSiteResolverInterface) {
153153
$form['configuration'] = [];
154154
$subform_state = SubformState::createForSubform($form['configuration'], $form, $form_state);
155-
$form['preview_mode']['site_resolver_settings_container']['configuration'] = $site_resolver->buildConfigurationForm($form['configuration'], $subform_state);
155+
$form['draft_mode']['site_resolver_settings_container']['configuration'] = $site_resolver->buildConfigurationForm($form['configuration'], $subform_state);
156156
}
157157

158158
$form['revalidation'] = [
@@ -223,7 +223,7 @@ public function submitSiteResolver(array $form, FormStateInterface $form_state)
223223
* Handles switching the site resolver selector.
224224
*/
225225
public function ajaxReplaceSiteResolverSettingsForm($form, FormStateInterface $form_state) {
226-
return $form['preview_mode']['site_resolver_settings_container'];
226+
return $form['draft_mode']['site_resolver_settings_container'];
227227
}
228228

229229
/**

modules/next/src/Form/NextSettingsForm.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,14 +87,14 @@ public function buildForm(array $form, FormStateInterface $form_state) {
8787
];
8888

8989
$form['preview_url_generator_container'] = [
90-
'#title' => $this->t('Preview URL'),
90+
'#title' => $this->t('Draft Mode'),
9191
'#type' => 'details',
9292
'#group' => 'settings',
9393
];
9494

9595
$form['preview_url_generator_container']['preview_url_generator'] = [
9696
'#title' => $this->t('Plugin'),
97-
'#description' => $this->t('Select a plugin to use for the preview URL generator.'),
97+
'#description' => $this->t('Select a plugin to use for the draft validation generator.'),
9898
'#type' => 'select',
9999
'#options' => array_column($this->previewUrlGeneratorManager->getDefinitions(), 'label', 'id'),
100100
'#default_value' => $config->get('preview_url_generator'),

modules/next/src/Form/NextSiteForm.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,32 +51,32 @@ public function form(array $form, FormStateInterface $form_state) {
5151
];
5252

5353
$form['preview'] = [
54-
'#title' => $this->t('Preview Mode'),
55-
'#description' => $this->t('Preview mode allows editors to preview content on the site. You can read more on the <a href=":uri" target="_blank">Next.js documentation</a>.', [
56-
':uri' => 'https://nextjs.org/docs/advanced-features/preview-mode',
54+
'#title' => $this->t('Draft Mode'),
55+
'#description' => $this->t('Draft mode (or the deprecated Preview mode) allows editors to preview content on the site. You can read more on the <a href=":uri" target="_blank">Next.js documentation</a>.', [
56+
':uri' => 'https://nextjs.org/docs/app/building-your-application/configuring/draft-mode',
5757
]),
5858
'#type' => 'details',
5959
'#group' => 'settings',
6060
];
6161

6262
$form['preview']['preview_url'] = [
6363
'#type' => 'url',
64-
'#title' => $this->t('Preview URL'),
65-
'#description' => $this->t('Enter the preview URL. Example: <em>https://example.com/api/preview</em>.'),
64+
'#title' => $this->t('Draft URL (or Preview URL)'),
65+
'#description' => $this->t('Enter the draft URL or preview URL. Example: <em>https://example.com/api/draft</em> or <em>https://example.com/api/preview</em>.'),
6666
'#default_value' => $entity->getPreviewUrl(),
6767
];
6868

6969
$form['preview']['preview_secret'] = [
7070
'#type' => 'textfield',
71-
'#title' => $this->t('Preview secret'),
72-
'#description' => $this->t('Enter a secret for the site preview. This is the same value used for <em>DRUPAL_PREVIEW_SECRET</em>.'),
71+
'#title' => $this->t('Secret key'),
72+
'#description' => $this->t('Enter a secret for the site draft/preview. This must be unique for each Next.js site'),
7373
'#default_value' => $entity->getPreviewSecret(),
7474
];
7575

7676
$form['revalidation'] = [
7777
'#title' => $this->t('On-demand Revalidation'),
7878
'#description' => $this->t('On-demand revalidation updates your pages when content is updated on your Drupal site. You can read more on the <a href=":uri" target="_blank">Next.js documentation</a>.', [
79-
':uri' => 'https://nextjs.org/docs/advanced-features/preview-mode',
79+
':uri' => 'https://nextjs.org/docs/app/building-your-application/data-fetching/fetching-caching-and-revalidating#revalidating-data',
8080
]),
8181
'#type' => 'details',
8282
'#group' => 'settings',

modules/next/src/Plugin/Next/PreviewUrlGenerator/SimpleOauth.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ public function defaultConfiguration() {
8383
*/
8484
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
8585
$form['secret_expiration'] = [
86-
'#title' => $this->t('Preview secret expiration time'),
87-
'#description' => $this->t('The value, in seconds, to be used as expiration time for the preview secret. <strong>It is recommended to use short-lived secrets for increased security.</strong>'),
86+
'#title' => $this->t('Secret expiration time'),
87+
'#description' => $this->t('The value, in seconds, to be used as expiration time for the validation secret. <strong>It is recommended to use short-lived secrets for increased security.</strong>'),
8888
'#type' => 'number',
8989
'#required' => TRUE,
9090
'#default_value' => $this->configuration['secret_expiration'],

0 commit comments

Comments
 (0)