When browsing for possible content to pull down across sites, there's no way for users to actually see the content they're pulling down, other than to separately navigate to that site, and then attempt to find that piece of content. Likewise, once a piece of content is pulled down, there's no direct link between the Pull form and the actual piece of content on the site.

To improve this, links to the remote and local copies of the content would be helpful.

Current UI:

Current UI

Proposed UI adding links to remote and local copies:

Proposed UI

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

quicksketch created an issue. See original summary.

quicksketch’s picture

Oops I got the links backward in my screenshot when I mocked that up. The "(view local)" link should appear if you have a local copy of course. It would not display for new entities not yet pulled down.

There is a caveat here in that it's possible to pull down unpublished content or content you don't even access to on the other site. However, even linking to where the content would be is better than no link at all.

Grimreaper’s picture

Hello,

@quicksketch thanks for the suggestion!

Agreed, and no problem for the caveat.

Grimreaper’s picture

I think for the local link it will be easy but for the remote one...

In JsonapiHelper::addOptionFromJson() $data["attributes"]["drupal_internal__nid"] contains the entity id.

So it will be possible to make a link to the remote website:

  1. get the entity id from $data
  2. knowing the entity type, we suppose that the entity type canonical url also exists on the client website and is the same as the server website and so we can construct a link using the route and the entity id.
  3. in the generated link, we replace the domain by the url from the remote website entity url.
Grimreaper’s picture

Assigned: Unassigned » Grimreaper
Grimreaper’s picture

Status: Active » Needs review
FileSize
15.26 KB

And here is a patch.

It also changes some "JSON API" strings into "JSON:API".

I will need to create a dedicated service for the display of the pull form and stop to complexify JsonApiHelper.

  • Grimreaper authored 3cb947b on 8.x-2.x
    Issue #3077810 by quicksketch, Grimreaper: Link to Remote and Local...
Grimreaper’s picture

Assigned: Grimreaper » Unassigned
Status: Needs review » Fixed
quicksketch’s picture

Looking great, thanks @Grimreaper! I'll try this out on our project this week!

quicksketch’s picture

Status: Fixed » Active

Hi @Grimreaper, I tried this out and it works, but it seems there's an extra slash in the remote URL. Here's the markup I'm seeing:

<a href="http://example.com//node/1">Sample News Article</a> <a href="/articles/sample-news-article" hreflang="en">(View local)</a>

Are you seeing this as well?

Grimreaper’s picture

Hi @quicksketch,

Thanks for testing.

I am seeing an extra slash if on the remote website's url there is a trailing slash.

If there is no trailing slash, there is no extra slash.

Is it ok for you or should I change the code a little bit to avoid this case?

quicksketch’s picture

Ah! I see. Maybe in that case we should make a separate issue just to ensure the formatting of the remote URL is consistent? Either throw a validation error or (preferably) just add or remove the trailing slash to the preferred format. For our purposes, I can just fix the value saved in the configuration.

quicksketch’s picture

Status: Active » Fixed
Grimreaper’s picture

Thanks for the follow up issue :)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.