New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#4464 temp render slice 1 #4584
Conversation
Codecov Report
@@ Coverage Diff @@
## main #4584 +/- ##
==========================================
+ Coverage 50.87% 50.92% +0.04%
==========================================
Files 916 917 +1
Lines 27183 27307 +124
Branches 5519 5533 +14
==========================================
+ Hits 13830 13905 +75
- Misses 12420 12465 +45
- Partials 933 937 +4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
rootOverride ?? root, | ||
{ | ||
...options, | ||
headless: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the only important difference from the call in runPipeline
above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would comment on this in the code. Helpful for people coming back to it later
@@ -32,6 +32,7 @@ describe("parse compile error", () => { | |||
root: null, | |||
logger: new ConsoleLogger(), | |||
runPipeline: neverPromise, | |||
runRendererPipeline: neverPromise, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -53,6 +53,7 @@ describe("FormData block", () => { | |||
logger: null, | |||
root: null, | |||
runPipeline: neverPromise, | |||
runRendererPipeline: neverPromise, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -49,22 +49,33 @@ export type RendererError = { | |||
* @see PanelEntry | |||
* @see FormEntry | |||
*/ | |||
export type EntryType = "panel" | "form"; | |||
export type EntryType = "panel" | "form" | "temporaryPanel"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
state.temporaryPanels, | ||
(x) => x.extensionId === panel.extensionId | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if it needs to be included in this PR or the next, but we need to call cancel on the other panels from the extension:
See equivalent behavior here for forms:
https://github.com/pixiebrix/pixiebrix-extension/pull/4584/files#diff-f38df102e6740716f2c8515f48e1aa4d043d02404c8b8e2cfbf4e4c0db041c8fR121
@@ -43,6 +44,7 @@ export type SidebarState = SidebarEntries & { | |||
export const emptySidebarState: SidebarState = { | |||
panels: [], | |||
forms: [], | |||
temporaryPanels: [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -113,3 +120,14 @@ export async function showForm(sequence: number, entry: FormEntry) { | |||
export async function hideForm(sequence: number, nonce: UUID) { | |||
runListeners("onHideForm", sequence, { nonce }); | |||
} | |||
|
|||
export async function showTemporaryPanel( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -81,12 +98,15 @@ const ConnectedSidebar: React.VFC = () => { | |||
// Use ignoreApiError to avoid showing error on intermittent network issues or PixieBrix API degradation | |||
ignoreApiError | |||
> | |||
{sidebarState.panels?.length || sidebarState.forms?.length ? ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -56,6 +57,11 @@ export function getSubPipelineFlavor( | |||
return PipelineFlavor.NoEffect; | |||
} | |||
|
|||
if (parentNodeId === DisplayTemporaryInfo.BLOCK_ID) { | |||
// Temporary Info renderer shouldn't have side effects |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
@@ -21,7 +21,7 @@ import "./cryptoNodePolyfill.js"; | |||
import blockRegistry from "@/blocks/registry"; | |||
|
|||
// Maintaining this number is a simple way to ensure bricks don't accidentally get dropped | |||
const EXPECTED_HEADER_COUNT = 104; | |||
const EXPECTED_HEADER_COUNT = 105; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌
if (blockId === DisplayTemporaryInfo.BLOCK_ID) { | ||
return { | ||
title: "Example info", | ||
body: makePipelineExpression([createNewBlock(DocumentRenderer.BLOCK_ID)]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
); | ||
|
||
// Already using errors for control flow, keeping in this way for conciseness | ||
// noinspection ExceptionCaughtLocallyJS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this a WebStorm thing?
Can it be disabled in a config rather than in code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's to suppress an IntelliJ inspection. I can turn off the inspection in project settings instead I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, this is already used in sidebarExtension.ts - line 192
(where this logic is borrowed from), so I don't think it's that big a deal to leave it here as well.
|
||
// Already using errors for control flow, keeping in this way for conciseness | ||
// noinspection ExceptionCaughtLocallyJS | ||
throw new BusinessError("Pipeline does not include a renderer"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little bit confused. Does it throw in case when reducePipelineExpression
successfully completes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, because that means the pipeline does not have a renderer, and this pipeline expects a renderer. It's definitely a little weird to use errors for control flow like this (hence the IDE warning), but it's already how it's done for regular sidebar panels in sidebarExtension.ts
, so I'm using the same logic here.
This reverts commit 1ce4396.
} finally { | ||
controller.abort(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer returning {}
instead of undefined. Not a big deal since neither can be used, so returning a value in the future is not backward incompatible
* Resolve some temporary panels' deferred promises | ||
* @param nonces The nonces of the panels to resolve | ||
*/ | ||
export async function resolveTemporaryPanels(nonces: UUID[]) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIT: I'd prefer this method name to refer to what the method does from a business perspective vs. the code perspective. E.g., what's the impact of resolving the temporary panels?
I think it's something to the effect of "closeTemporaryPanels" or "completeTemporaryPanels"?
"resolve" to me seems to only mean something in the world of promises
I guess this matches what we have for form though. So definitely just a thought/NIT...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I guess I was just trying to follow the way the form one is named. I agree it's not the greatest name though. I can change both names to something better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The form function is named that way to distinguish between resolve and cancel I think, which both "close" the form.
|
||
panels.set(nonce, registration); | ||
|
||
return registration.promise; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
resolveTemporaryPanels: jest.fn(), | ||
})); | ||
|
||
describe("DisplayTemporaryInfo", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment on return value from the brick of undefined vs. {}
Excited to get this merged!
What does this PR do?
Reviewer Tips
runRendererPipeline
field onBlockOptions
incore.ts
reducePipeline.ts
DisplayTemporaryInfo
x
close button in the sidebar tab headerDemo
https://www.loom.com/share/5d663eb547954b26b01d2e4f8eb25b2c
Future Work
Checklist