Skip to content

Commit 84fd680

Browse files
Change key/label from preview to draft
1 parent 7f890d7 commit 84fd680

File tree

13 files changed

+40
-40
lines changed

13 files changed

+40
-40
lines changed

modules/next/config/schema/next.schema.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ next.next_entity_type_config.*:
3636
label: 'Site resolver'
3737
configuration:
3838
type: next.site_resolver.configuration.[%parent.site_resolver]
39-
preview_enabled:
39+
draft_enabled:
4040
type: boolean
41-
label: 'Preview mode enabled'
41+
label: 'Draft mode enabled'
4242
revalidator:
4343
type: string
4444
label: 'Revalidator'

modules/next/next.install

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,24 +106,24 @@ function next_update_9106() {
106106
}
107107

108108
/**
109-
* Add the preview_enabled property to the next_entity_type_config.
109+
* Add the draft_enabled property to the next_entity_type_config.
110110
*/
111111
function next_update_9107() {
112112
$entity_definition_update = \Drupal::entityDefinitionUpdateManager();
113113

114114
$storage_definition = BaseFieldDefinition::create('string')
115-
->setLabel(t('Preview mode enabled'));
116-
$entity_definition_update->installFieldStorageDefinition('preview_enabled', 'next_entity_type_config', 'next_entity_type_config', $storage_definition);
115+
->setLabel(t('Draft mode enabled'));
116+
$entity_definition_update->installFieldStorageDefinition('draft_enabled', 'next_entity_type_config', 'next_entity_type_config', $storage_definition);
117117
}
118118

119119
/**
120-
* Enable preview mode on all Next.js entity types.
120+
* Enable draft mode on all Next.js entity types.
121121
*/
122122
function next_update_9108() {
123123
/** @var \Drupal\next\Entity\NextEntityTypeConfigInterface[] $next_entity_type_configs */
124124
$next_entity_type_configs = \Drupal::entityTypeManager()->getStorage('next_entity_type_config')->loadMultiple();
125125
foreach ($next_entity_type_configs as $next_entity_type_config) {
126-
$next_entity_type_config->set('preview_enabled', TRUE);
126+
$next_entity_type_config->set('draft_enabled', TRUE);
127127
$next_entity_type_config->save();
128128
}
129129
}

modules/next/src/Entity/NextEntityTypeConfig.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
* "id",
4545
* "site_resolver",
4646
* "configuration",
47-
* "preview_enabled",
47+
* "draft_enabled",
4848
* "revalidator",
4949
* "revalidator_configuration"
5050
* },
@@ -80,11 +80,11 @@ class NextEntityTypeConfig extends ConfigEntityBase implements NextEntityTypeCon
8080
protected $configuration = [];
8181

8282
/**
83-
* Whether the preview mode is enabled.
83+
* Whether the draft mode is enabled.
8484
*
8585
* @var bool
8686
*/
87-
protected $preview_enabled = FALSE;
87+
protected $draft_enabled = FALSE;
8888

8989
/**
9090
* The revalidator.
@@ -140,8 +140,8 @@ public function setSiteResolver(string $plugin_id): NextEntityTypeConfigInterfac
140140
/**
141141
* {@inheritdoc}
142142
*/
143-
public function isPreviewEnabled(): bool {
144-
return $this->preview_enabled;
143+
public function isDraftEnabled(): bool {
144+
return $this->draft_enabled;
145145
}
146146

147147
/**

modules/next/src/Entity/NextEntityTypeConfigInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ public function getSiteResolver(): ?SiteResolverInterface;
3232
public function setSiteResolver(string $plugin_id): self;
3333

3434
/**
35-
* Checks if the preview mode is enabled.
35+
* Checks if the draft mode is enabled.
3636
*
3737
* @return bool
38-
* Return true/false if preview mode is enabled.
38+
* Return true/false if draft mode is enabled.
3939
*/
40-
public function isPreviewEnabled(): bool;
40+
public function isDraftEnabled(): bool;
4141

4242
/**
4343
* Returns the revalidator plugin.

modules/next/src/Form/NextEntityTypeConfigForm.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,13 +156,13 @@ public function form(array $form, FormStateInterface $form_state) {
156156
'#group' => 'settings',
157157
];
158158

159-
$form['draft_mode']['preview_enabled'] = [
159+
$form['draft_mode']['draft_enabled'] = [
160160
'#title' => $this->t('Enabled'),
161161
'#description' => $this->t('Enable draft mode.'),
162162
'#type' => 'checkbox',
163-
'#default_value' => $entity->isPreviewEnabled(),
164-
'#limit_validation_errors' => [['preview_enabled']],
165-
'#submit' => ['::submitPreviewEnabled'],
163+
'#default_value' => $entity->isDraftEnabled(),
164+
'#limit_validation_errors' => [['draft_enabled']],
165+
'#submit' => ['::submitDraftEnabled'],
166166
'#executes_submit_callback' => TRUE,
167167
'#ajax' => [
168168
'callback' => '::ajaxReplaceSettingsForm',
@@ -221,9 +221,9 @@ public function submitId(array $form, FormStateInterface $form_state) {
221221
}
222222

223223
/**
224-
* Handles submit call when preview mode is selected.
224+
* Handles submit call when draft mode is selected.
225225
*/
226-
public function submitPreviewEnabled(array $form, FormStateInterface $form_state) {
226+
public function submitDraftEnabled(array $form, FormStateInterface $form_state) {
227227
$this->entity = $this->buildEntity($form, $form_state);
228228
$form_state->setRebuild();
229229
}

modules/next/src/Render/MainContent/HtmlRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ protected function prepare(array $main_content, Request $request, RouteMatchInte
108108
}
109109

110110
$next_entity_type_config = $this->nextEntityTypeManager->getConfigForEntityType($entity->getEntityTypeId(), $entity->bundle());
111-
if (!$next_entity_type_config || !$next_entity_type_config->isPreviewEnabled()) {
111+
if (!$next_entity_type_config || !$next_entity_type_config->isDraftEnabled()) {
112112
return $build;
113113
}
114114

modules/next/tests/src/Kernel/Entity/NextEntityTypeConfigTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function testSiteResolver() {
5959
/** @var \Drupal\next\Entity\NextEntityTypeConfigInterface $entity_type_config */
6060
$entity_type_config = NextEntityTypeConfig::create([
6161
'id' => 'node.page',
62-
'preview_enabled' => FALSE,
62+
'draft_enabled' => FALSE,
6363
'site_resolver' => 'site_selector',
6464
'configuration' => [
6565
'sites' => [
@@ -124,7 +124,7 @@ public function testRevalidator() {
124124
/** @var \Drupal\next\Entity\NextEntityTypeConfigInterface $entity_type_config */
125125
$entity_type_config = NextEntityTypeConfig::create([
126126
'id' => 'node.page',
127-
'preview_enabled' => FALSE,
127+
'draft_enabled' => FALSE,
128128
'site_resolver' => 'site_selector',
129129
'configuration' => [
130130
'sites' => [
@@ -142,19 +142,19 @@ public function testRevalidator() {
142142
}
143143

144144
/**
145-
* Tests the preview enabled property.
145+
* Tests the draft enabled property.
146146
*
147-
* @covers ::isPreviewEnabled
147+
* @covers ::isDraftEnabled
148148
*/
149-
public function testPreviewEnabled() {
149+
public function testDraftEnabled() {
150150
$blog_site = NextSite::create(['id' => 'blog']);
151151
$blog_site->save();
152152

153153
// Create entity type config.
154154
/** @var \Drupal\next\Entity\NextEntityTypeConfigInterface $entity_type_config */
155155
$entity_type_config = NextEntityTypeConfig::create([
156156
'id' => 'node.page',
157-
'preview_enabled' => TRUE,
157+
'draft_enabled' => TRUE,
158158
'site_resolver' => 'site_selector',
159159
'configuration' => [
160160
'sites' => [
@@ -163,10 +163,10 @@ public function testPreviewEnabled() {
163163
],
164164
]);
165165
$entity_type_config->save();
166-
$this->assertTrue($entity_type_config->isPreviewEnabled());
166+
$this->assertTrue($entity_type_config->isDraftEnabled());
167167

168-
$entity_type_config->set('preview_enabled', FALSE)->save();
169-
$this->assertFalse($entity_type_config->isPreviewEnabled());
168+
$entity_type_config->set('draft_enabled', FALSE)->save();
169+
$this->assertFalse($entity_type_config->isDraftEnabled());
170170
}
171171

172172
}

modules/next/tests/src/Kernel/Event/EntityRevalidatedEventTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ protected function setUp(): void {
4848
// Create entity type config.
4949
$entity_type_config = NextEntityTypeConfig::create([
5050
'id' => 'node.page',
51-
'preview_enabled' => TRUE,
51+
'draft_enabled' => TRUE,
5252
'site_resolver' => 'site_selector',
5353
'configuration' => [
5454
'sites' => [

modules/next/tests/src/Kernel/NextEntityTypeManagerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function testGetSitesForEntity() {
5252

5353
$entity_type_config = NextEntityTypeConfig::create([
5454
'id' => 'node.page',
55-
'preview_enabled' => TRUE,
55+
'draft_enabled' => TRUE,
5656
'site_resolver' => 'site_selector',
5757
'configuration' => [
5858
'sites' => [
@@ -98,7 +98,7 @@ public function testGetSiteResolver() {
9898

9999
$entity_type_config = NextEntityTypeConfig::create([
100100
'id' => 'node.page',
101-
'preview_enabled' => TRUE,
101+
'draft_enabled' => TRUE,
102102
'site_resolver' => 'site_selector',
103103
'configuration' => [
104104
'sites' => [
@@ -122,7 +122,7 @@ public function testGetRevalidator() {
122122

123123
$entity_type_config = NextEntityTypeConfig::create([
124124
'id' => 'node.page',
125-
'preview_enabled' => TRUE,
125+
'draft_enabled' => TRUE,
126126
'site_resolver' => 'site_selector',
127127
'configuration' => [
128128
'sites' => [

modules/next/tests/src/Kernel/Plugin/PathRevalidatorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public function testRevalidate() {
6666
// Create entity type config.
6767
$entity_type_config = NextEntityTypeConfig::create([
6868
'id' => 'node.page',
69-
'preview_enabled' => TRUE,
69+
'draft_enabled' => TRUE,
7070
'site_resolver' => 'site_selector',
7171
'configuration' => [
7272
'sites' => [

0 commit comments

Comments
 (0)