[dagit] Copy-to-clipboard fallback for unsupported contexts
Summary:
Resolves #4315.
If a user is serving Dagit from http (non-localhost), the navigator.clipboard value is undefined, so any writeText calls we're making to copy values to the clipboard will error out. (There may be other circumstances where this is the case, so I asked in the GH issue.)
Create a very simple hook to provide callsites with Clipboard | null instead of referencing navigator.clipboard directly. Callers can then decide how to handle the case where the clipboard API is unavailable.
EDIT: The diff now implements a fallback for cases that do not support the Clipboard API.
Test Plan: Load Run page and Schedule page in Dagit with useClipboard returning null. Verify that I'm not given the opportunity to trigger an error.
Reviewers: bengotow
Reviewed By: bengotow
Differential Revision: https://dagster.phacility.com/D8582