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_afteranddelete_afterkeys to$settings['consumer_node_preview']. - The targets from
PreviewTargetsProviderInterface::getAllTargets()gainlast_seenandinactivevalues.
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.
Issue fork consumer_node_preview-3634706
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:
- feature/3634706-target-expiry
changes, plain diff MR !2
Comments
Comment #5
decipheredCommitted to 1.0.x as 0a629ad. It went in without the merge request, so I've closed MR !2.