-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Preview mode: Server-side generated preview URLs #20021
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
Conversation
|
Hi @kjac It looks good from a Backoffice/client perspective. The only thing I thought about was relative vs absolute URLs. In the spirit of SPAs and how we already handle all image URLs, would it then be possible always to return an absolute URL? We want to be able to run the Backoffice on a different server than the backend/preview app, and with absolute URLs, we can avoid the prefixing dance on the client side. |
|
@kjac looks good. I agree with Mads and then I just wanted to ask regarding a minor detail: could |
|
@kjac another thought, what are we supposed to use |
|
Why isExternal I don’t know if these are Kenn’s thoughts too, but the client needs to know when to add query params to the preview URL. All the external URLs in the example come fully fleshed out. We could probably agree on the query params, since we already have some dependency on each other, if we like that better? 🤔 |
|
I would love to generate an absolute URL for the default preview - and we also might be able to do it... but will it work well for the client in a multi-tenant setup with multiple host names for the backoffice? The
External preview URLs should not be tampered with - the client should expect them to be complete (perhaps we'll introduce some templating options later on for inserting culture and/or segment). And of course, the external preview URLs do not require a user state on the Umbraco backoffice server 😉 |
|
Also please note that a preview URL can contain both [
{
"id": "f5b814c7-f435-4dda-93f3-9dd153fefa7f",
"urlInfos": [
{
"message": "This page cannot be previewed because [reason]",
"culture": null,
"url": null,
"isExternal": false
},
{
"message": null,
"culture": null,
"url": "https://preview.somewhere/f5b814c7-f435-4dda-93f3-9dd153fefa7f",
"isExternal": true
},
{
"message": "Preview for brand One",
"culture": null,
"url": "https://preview.brand.one/f5b814c7-f435-4dda-93f3-9dd153fefa7f",
"isExternal": true
},
{
"message": "Preview for brand Two",
"culture": null,
"url": "https://preview.brand.two/f5b814c7-f435-4dda-93f3-9dd153fefa7f",
"isExternal": true
}
]
}
] |
|
I have updated this whole thing; the description reflects the new functionality - don't bother with the comments up until this point 😆 |
from Management API
Fixed TS errors Added temp stub for `getPreviewUrl`
reworked using the "default" `previewOption` kind.
to a more suitable filename. Exported element so can be reused in other packages, e.g. documents, for the new "save and preview" feature.
to work with first action's manifest/API.
Re-engineered to make a "urlProvider" kind for `workspaceActionMenuItem`. This is to simplify the extension point and surrounding logic.
to accept a URL Provider Alias.
to extend `UmbWorkspaceActionElement`. This did mean exposing certain methods/properties to be overridable.
# Conflicts: # src/Umbraco.Web.UI.Client/src/packages/core/backend-api/sdk.gen.ts
AndyButland
left a comment
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.
Code all looks good to me - just one tiny comment. Will do some testing now before approving.
While I'm thinking about it, for the documentation:
- Please can you review what we have documented that needs updating? The 16 docs have been copied over to the 17 folder on the docs repo, so you can create a PR to update those pages.
- Please can you also update this pending PR so we add a section about the breaking changes in this area?
|
As for the docs - I have a separate task for amending docs for 17 for this change. Will update the breaking changes article 👍 |
AndyButland
left a comment
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.
All looks to work as expected when testing out with the default and with a custom URL provider.
iOvergaard
left a comment
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.
I had already approved the FE part on Lee's pull request, so just adding my checkmark here as well for posterity. LGTM.
Prerequisites
Description
This PR is part the effort to create a "new" backoffice replacement of the custom preview URLs concept from the "old" backoffice.
Moving forward, the URL providers will be responsible for generating all preview URLs - both internal and external ones.
To that end:
IUrlProviderinterface has been extended with theGetPreviewUrlAsync()method.IUrlProviderinterface now must provide a uniqueAlias, which couples all URLs (allUrlInforeturn values, including non-preview URLs) to the provider.UrlInfoclass has been revamped to support URLs more gracefully, including the coupling to the provider alias.All of this makes the PR breaking.
How will this all work?
All of this is somewhat work in progress - this is the current proposal.
We will introduce a new backoffice extension for URL providers. At this time, the extension is primarily targeting the preview URLs, but we do envision it could apply elsewhere - for example, for grouping links in the "info" section, or provide dedicated UI for URLs provided by a specific provider, or...
If more than one provider is registered for generating preview URLs, the "Save and preview" button will feature a pop-up with the additional providers for the content editor to choose from (it will likely become possible to determine which provider should be triggered by default "Save and preview" button action).
When the content editor hits "Save and preview" (for any provider, including the default/core URL provider), the backoffice client will:
/document/{id]/preview-urlendpoint.This also means that the client no longer has to "enter" preview by POST'ing to the
/previewendpoint, so this endpoint has been deprecated. Instead, the (server-side) URL provider will be responsible for establishing a valid preview context on the target host - including the default/core URL provider.Testing this PR using the API
Requesting the new
preview-urlendpoint should yield the default preview URL for the passed key.For example:
/document/54161cd8-f36b-4f97-8d43-c51118d20376/preview-url?providerAlias=umbDocumentUrlProvider&culture=en-US&segment=seg-1...should yield:
{ "message": null, "provider": "umbDocumentUrlProvider", "culture": "en-US", "url": "https://localhost:44339/umbraco/preview?id=54161cd8-f36b-4f97-8d43-c51118d20376&culture=en-US&segment=seg-1" }Adding a custom URL provider with a preview URL implementation should enable querying the endpoint for that provider.
For example, with this URL provider:
...the query:
/document/54161cd8-f36b-4f97-8d43-c51118d20376/preview-url?providerAlias=MyUrlProvider&culture=en-US&segment=seg-1...should yield
{ "message": "Preview.me (en-US)", "provider": "MyUrlProvider", "culture": "en-US", "url": "https://preview.me/en-US/seg-1/54161cd8-f36b-4f97-8d43-c51118d20376" }Testing this PR using the client
To utilize the custom URL provider above from the backoffice client, you'll need to add include this client extension:
{ "name": "My UrlProvider", "alias": "My.UrlProvider", "extensions": [ { "type": "workspaceActionMenuItem", "kind": "previewOption", "alias": "My.Custom.PreviewOption", "name": "My Custom Preview Option", "forWorkspaceActions": "Umb.WorkspaceAction.Document.SaveAndPreview", "weight": 101, "meta": { "icon": "icon-umbraco", "label": "Preview.me", "urlProviderAlias": "MyUrlProvider" } } ] }Save that as
umbraco-package.jsonin a folder underApp_Pluginsand restart the client. You'll see the preview option as the default, due to theweightof the extension:The regular "Save and preview" option is found in the pop-up: