Problem/Motivation

A frontend can register its preview target over the API, but the target stays on the consumer after the frontend has gone. Local and short-lived environments build up in the Frontend picker, and an editor cannot tell which ones still answer.

A frontend also has to read and replace the whole target list to register, so two frontends on one consumer can overwrite each other.

Proposed resolution

  • Add a PATCH on the targets endpoint that registers one target. It replaces the target with the same label or adds a new one, leaves the other targets alone, and records when it was seen.
  • Move a target that has not been registered for a day to an Inactive group at the bottom of the Frontend picker. It can still be picked, its key does not change, and the next PATCH moves it back.
  • Delete a target on cron after 30 days without a PATCH. Settings can change both limits.
  • Never expire a target added by hand, on the consumer form or in settings.php.
  • When the preview screen opens, ask each frontend's origin for a response from the editor's browser, with a limit of 3 seconds. A frontend that does not answer shows "(not responding)" and can still be picked. Inactive targets and paths on Drupal's own site are not checked.

Remaining tasks

  • Review the merge request.

User interface changes

The Frontend picker gains an Inactive group and a "(not responding)" marker: screenshot.

API changes

  • Adds PATCH /api/consumer-node-preview/targets.
  • Adds the inactive_after and delete_after keys to $settings['consumer_node_preview'].
  • The targets from PreviewTargetsProviderInterface::getAllTargets() gain last_seen and inactive values.

Data model changes

Each item in the preview_targets field gains a last_seen value. There is no update hook, because the module has no release yet.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

deciphered created an issue. See original summary.

deciphered changed the visibility of the branch feature/3634706-target-expiry to hidden.

deciphered changed the visibility of the branch feature/3634706-target-expiry to active.

deciphered’s picture

Status: Active » Fixed

Committed to 1.0.x as 0a629ad. It went in without the merge request, so I've closed MR !2.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.