Skip to content
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

[DNM][SPIKE] VACMS-14419 next build preview #15166

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ resourceFields:
enhancer:
id: ''
field_administration:
disabled: true
disabled: false
fieldName: field_administration
publicName: field_administration
enhancer:
Expand Down
11 changes: 11 additions & 0 deletions config/sync/next.next_entity_type_config.node.news_story.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
uuid: f003a469-5c52-41c3-b7dd-143482e5b6ff
langcode: en
status: true
dependencies: { }
id: node.news_story
site_resolver: site_selector
configuration:
sites:
local_next_build: local_next_build
revalidator: ''
revalidator_configuration: { }
11 changes: 11 additions & 0 deletions config/sync/next.next_site.local_next_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
uuid: 6792a1c9-192e-465d-9b88-ebf5ef2c503e
langcode: en
status: true
dependencies: { }
id: local_next_build
label: 'Local next build'
base_url: 'http://localhost:3000'
preview_url: 'http://localhost:3000/api/preview'
preview_secret: secret
revalidate_url: ''
revalidate_secret: ''
8 changes: 6 additions & 2 deletions config/sync/next.settings.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
_core:
default_config_hash: xRrZztTZj9Lor1bWUC6p2aB3S29Vg8m94UrOwc5AZps
langcode: en
site_previewer: iframe
site_previewer: link
site_previewer_configuration:
width: 100%
sync_route: false
sync_route: 0
sync_route_skip_routes: ''
preview_url_generator: simple_oauth
preview_url_generator_configuration:
secret_expiration: 300
debug: false
4 changes: 3 additions & 1 deletion config/sync/simple_oauth.settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ _core:
access_token_expiration: 300
authorization_code_expiration: 300
refresh_token_expiration: 1209600
remember_clients: true
token_cron_batch_size: 0
public_key: ../public.key
private_key: ../private.key
remember_clients: true
use_implicit: false
disable_openid_connect: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
uuid: d385dda5-41e0-450b-9a77-9d7729b5e356
langcode: en
status: true
dependencies:
config:
- user.role.next_js_consumer
module:
- user
id: user_add_role_action.next_js_consumer
label: 'Add the Next.js consumer role to the selected user(s)'
type: user
plugin: user_add_role_action
configuration:
rid: next_js_consumer
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
uuid: aa0f54ee-7635-4ada-8fee-2ac7a554c6dc
langcode: en
status: true
dependencies:
config:
- user.role.next_js_consumer
module:
- user
id: user_remove_role_action.next_js_consumer
label: 'Remove the Next.js consumer role from the selected user(s)'
type: user
plugin: user_remove_role_action
configuration:
rid: next_js_consumer
19 changes: 19 additions & 0 deletions config/sync/user.role.next_js_consumer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
uuid: d43dcdb9-8aa5-41fb-a769-154381b4cbf9
langcode: en
status: true
dependencies:
module:
- message_ui
- subrequests
- va_gov_backend
third_party_settings:
va_gov_backend:
vgb_description: 'Used by next-build to generate content preview routes'
id: next_js_consumer
label: 'Next.js consumer'
weight: 7
is_admin: null
permissions:
- 'access user profiles'
- 'bypass message access control'
- 'issue subrequests'
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?php

namespace Drupal\va_gov_api\Plugin\Next\SitePreviewer;

use Drupal\Core\Entity\EntityInterface;
use Drupal\next\Plugin\SitePreviewerBase;

/**
* Provides a link to the preview page.
*
* @SitePreviewer(
* id = "link",
* label = "Link to preview",
* description = "Displays a link to the preview page."
* )
*/
class Link extends SitePreviewerBase {

/**
* {@inheritdoc}
*/
public function render(EntityInterface $entity, array $sites) {
$build = [];

foreach ($sites as $site) {
$build[] = [
'#type' => 'link',
'#title' => $this->t('Preview'),
'#url' => $site->getPreviewUrlForEntity($entity),
'#attributes' => [
'class' => ['button', 'button--primary', 'node-preview-button'],
'target' => '_blank',
],
];
}

return $build;
}

}
29 changes: 29 additions & 0 deletions docroot/modules/custom/va_gov_api/va_gov_api.module
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

/**
* @file
* Contains va_gov_api.module.
*/

/**
* Alter the result of \Drupal\next\Plugin\SitePreviewerInterface::render.
*
* This hook is called after the preview has been assembled.
*
* @param array &$preview
* The preview renderable array from the site_previewer.
* @param array $context
* Context in which the entity is previewed with the following keys:
* - 'plugin': the site_previewer plugin.
* - 'entity': the entity in preview.
* - 'sites': the sites for this entity.
* - 'original_build': the original un-altered build.
*
* @ingroup next_api
*/
function va_gov_api_next_site_preview_alter(array &$preview, array $context) {
// Don't let next overwrite the existing node view page.
$preview['content'] = $context['original_build'][0]['content'];

// See va_gov_backend_preprocess_page() for existing preview button logic.
}
52 changes: 52 additions & 0 deletions private.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
-----BEGIN PRIVATE KEY-----
MIIJQQIBADANBgkqhkiG9w0BAQEFAASCCSswggknAgEAAoICAQDAOtNq0zcahYzX
vQzRFe097v02QEdpaPhZUR303umiW+TngVFo61AcW38FAoQKnKFj6seJ+oGLQ0TH
PEFX+DRrlleog0FwpNQsLWuIzmJUyG2JvIWf0y75aasYrihrTIHrU0zOhkmJ3L0+
hHidlgSgkv9tg2yLuA08OHs8PxqSAkq3ICeH64xoQ6atoltJvbQ01VM0llHVJqi+
fRO/Fx1XkYLnxIMB/uibOX97kguNFhuJEnN3Vvs7dfxN/rG6JPt5KOfl0XnqS2nV
Rbr1uFa59+l3JJwsxnKy+7RXc3clIjO+l15/PB4lallAGNZ/KaUbsv5ZR/WGlt9c
gQgn3HnL6Laa4jStM6lZr+6bN0CYZw6U3Gjetjxh+LU5KGx3nMG0eURrYWXHR9qK
vFqa4/c/PuPPqz78Ylhahyzq3xQYlL+zx9Cj7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ud9StBlcPIHtqMDhrhthbzzNzHN
aO/sqKGCX1SmC8UuZHcf3hscgqU9WUf6aCIM0mc/LY30whfxOw3gUGECUpYDiZ6b
tl5/Wy4Ibh58eyRkgBk18Efv7SwUOjeCLwsvx1WUPTHEuuPsfJnEAjzL21OJ2Ax4
Vf4a2UweP1REvP499qq5w2z6HCp4Rfu/ypimYbE3R1WTxeazT34fBOOHShWXvPa0
NQKCAQBGoX86hYngGzZR+A3waCfQJ063OzO1itLYQDHJc4dYnMVqa0elks86m3rD
TXdcwi2C3X/O0W//VPJvXv90pkS5SgH5zwlfVE90RzXlPhJQE/xoIvaH6bL5aZaj
RhGbdWTLajnr/lYJbXVwLCt3TSqifo+n4h6f1/rPiQDwB/hROVP1EbQjijh+w8sL
FyQOjM/oy1Ch8Y4pAexbX4nOxcQKRqkrBcDecEX6wh9vKpN8Thtei1HLDfx1rrXA
AYSQCqlnNFOyfLPRkY1889cEKRQcyw5I711Qvtp+310pkjAKyQB5e9+N5wAo7lQR
47TMAbEt8V7J4Ip46M55FKGjYDsk
-----END PRIVATE KEY-----
14 changes: 14 additions & 0 deletions public.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-----BEGIN PUBLIC KEY-----
MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAwDrTatM3GoWM170M0RXt
Pe79NkBHaWj4WVEd9N7polvk54FRaOtQHFt/BQKECpyhY+rHifqBi0NExzxBV/g0
a5ZXqINBcKTULC1riM5iVMhtibyFn9Mu+WmrGK4oa0yB61NMzoZJidy9PoR4nZYE
oJL/bYNsi7gNPDh7PD8akgJKtyAnh+uMaEOmraJbSb20NNVTNJZR1Saovn0Tvxcd
V5GC58SDAf7omzl/e5ILjRYbiRJzd1b7O3X8Tf6xuiT7eSjn5dF56ktp1UW69bhW
uffpdyScLMZysvu0V3N3JSIzvpdefzweJWpZQBjWfymlG7L+WUf1hpbfXIEIJ9x5
y+i2muI0rTOpWa/umzdAmGcOlNxo3rY8Yfi1OShsd5zBtHlEa2Flx0fairxamuP3
Pz7jz6s+/GJYWocs6t8UGJS/s8fQo+zf/u780lPW6GIXsgkp7Dndn3MnTCUQ9Ckq
8cvKlZ0Z6XEpkQ4DwXh1lpDN/v0Egj0G3TVG40/mg3aFNRrYiGtmI2mcptlgbyHP
xdC8Bc7PrDtReTXvSw20OsG4N3EOMDlKnwzZIcqnNZ3zR4qS15lrG8c62+A14v8F
Xe65dhksqlSDk1p7E50rkNbDqjpM/Yw4Z6ltktpqEEejAnrVtlpwAIYp7xRkQqbB
9MAGj31PYu7eFlifhO/IB1sCAwEAAQ==
-----END PUBLIC KEY-----