Conversation
apps/zui/src/app/lakes/root.tsx
Outdated
| useLayoutEffect(() => { | ||
| if (status) return | ||
| if (lake) dispatch(updateStatus(lake.id)) | ||
| Active.lake.sync() |
There was a problem hiding this comment.
Whenever the current lake id changes, or it's connection status changes, sync what info we have with the lake server.
| switch (status) { | ||
| case "disconnected": | ||
| return <ConnectionError onRetry={() => dispatch(initCurrentTab())} /> | ||
| return <ConnectionError onRetry={() => dispatch(updateStatus(lake.id))} /> |
There was a problem hiding this comment.
initCurrentTab only called this updateStatus function. So I inlined it and removed initCurrentTab.
All of this "lake" status/authentication code needs another look at some point.
| const id = lakeId || defaultLake().id | ||
| // This sets up the lake's tabs | ||
| const lake = Lake.find(id) | ||
| lake.sync() |
There was a problem hiding this comment.
As soon as the app boots up, we sync the lake.
| api.init(store.dispatch, store.getState) | ||
| initDOM() | ||
| initIpcListeners(store) | ||
| initDomainModels({store}) |
There was a problem hiding this comment.
the Domain Models need to be provisioned with the store variable before we call "initLake". So I re-ordered the steps here.
| authData?: AuthData | ||
| features?: { | ||
| describe: boolean | ||
| } |
There was a problem hiding this comment.
I'm going to add a "features" property the the data we cache about the lake. The only feature right now will be "describe".
| static get lake() { | ||
| const id = this.select(Current.getLakeId) | ||
| return Lake.find(id) | ||
| } |
There was a problem hiding this comment.
This is a shortcut to get the Active lake object. Active.lake
apps/zui/src/models/lake.ts
Outdated
|
|
||
| type LakeModelAttrs = LakeAttrs & {status: LakeStatus} | ||
|
|
||
| export class Lake extends DomainModel<LakeModelAttrs> { |
There was a problem hiding this comment.
Here we are adding the methods we need to the Lake model.
I've added:
- find(id)
- client
- features
- sync()
- update
- save
- isRunning()
| @@ -0,0 +1,21 @@ | |||
| import {Lake} from "../lake" | |||
|
|
|||
| export class FeatureDetector { | |||
There was a problem hiding this comment.
This class is responsible for detecting all the features we want.
| const program = this.select(Current.getQueryText) | ||
| const history = this.select(Current.getHistory) | ||
|
|
||
| if (!Active.lake.features.describe) { |
There was a problem hiding this comment.
And finally, if the lake does not have describe, do the minimum required and return early.
| dontRejectError: true, | ||
| }); | ||
| return result.json(); | ||
| if (response.ok || response.status === 400) { |
There was a problem hiding this comment.
Re-arranged the code to allow for an error response from the server. If the describe endpoint returns code 400, there is a problem with the query, but we don't want to throw an error. We want to report the problem to the user. So we parse the JSON as an expected response.
| duplex?: 'half'; | ||
| dontRejectError?: boolean; | ||
| }) { | ||
| protected request(opts: Types.RequestOpts) { |
There was a problem hiding this comment.
I separated the creation of the request into this request method. The existing send method then calls this.
The describeQuery method only uses request and handles errors in a different way than the other methods.
This comment was marked as resolved.
This comment was marked as resolved.
|
I'm currently testing this branch at commit 62a6084. The attached video shows a successful walk-through of the functionality that these changes disable when accessing an older Zed lake service. As prep, I have the ZNG format Zed sample data loaded to both the lake running behind Zui (Zed commit Demo.mp4 |
Fixes #3092
Fixes #3100
The app in this PR does a feature detection step whenever the lake changes or when it boots up for the first time. It will check if the describe endpoint returns a 404. If so, it will disable the following checkboxes above.
Everything seems to be working as intended in this.