batches: disable execution until batch spec is ready
Created by: courier-new
Small fix to #27450 so that the "Run batch spec" button on the "Create" page will be disabled if the batch spec that's on the server is stale or the workspaces resolution job hasn't finished yet, as can be seen in parts of this recording:
https://user-images.githubusercontent.com/8942601/141421235-88b34b47-45a1-42af-afa6-3673aaa430c0.mov
The diff looks kinda weird but basically I extracted the polling logic from WorkspacesPreview
for the workspace resolution status into its own hook, useBatchSpecWorkspaceResolution
, so that I can reuse it but call it with fetchPolicy: 'cache-first
from parent "Create" page so it gets all the same status updates as the nested child does without any extra network calls.
That way I can disable "Run batch spec" not only when the batch spec is stale but also when the workspace resolution is still processing or errored out.