-
Notifications
You must be signed in to change notification settings - Fork 15
consolidate responses and errors into console section #733
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
base: feature/editor-refactor
Are you sure you want to change the base?
consolidate responses and errors into console section #733
Conversation
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.
Getting close! Next steps:
- please rebase to resolve the conflicts, from there I will do quick smoke test on my local env
- now that the
Errors
andIngest
components have been refactored intoConsole
, can you remove these from the codebase?
I've checked it out locally, notice few things:
|
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.
Reviewed code up to line 320 in resizable_workspace
, will continue in a bit.
output.txt
Outdated
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.
Please remove this file
@@ -890,11 +887,13 @@ export function LeftNav(props: LeftNavProps) { | |||
)} | |||
</> | |||
</EuiFlexItem> | |||
<EuiFlexItem grow={false} style={{ marginRight: '12px' }}> |
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.
Why is this change needed?
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 not removing this line, the console panel will not expand with error messages. this is because the flex adds additional space with no content, and when error occurs, it confused resizable workspace about how much space to allocate to the console.
<EuiFlexGroup direction="column" gutterSize="none"> | ||
<EuiFlexItem> | ||
<EuiHorizontalRule margin="m" /> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={true}></EuiFlexItem> |
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.
Unnecessary & unused component
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.
removed
const [currentWorkflowId, setCurrentWorkflowId] = useState< | ||
string | undefined | ||
>(props.workflow?.id); | ||
|
||
// Always start with console closed when workflow changes | ||
const [isConsolePanelOpen, setIsConsolePanelOpen] = useState<boolean>(false); | ||
|
||
// Reset console state when workflow changes - ensure it's always closed initially | ||
useEffect(() => { | ||
if (props.workflow?.id !== currentWorkflowId) { | ||
setCurrentWorkflowId(props.workflow?.id); | ||
setIsConsolePanelOpen(false); // Always close on workflow change | ||
} | ||
}, [props.workflow?.id, currentWorkflowId]); |
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.
currentWorkflowId
is not needed, this can be simplified to just having a useEffect listening on props.workflow?.id
. It will then execute whenever it changes. No need to persist a current ID variable.
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.
removed unneeded currentWorkflowId
// Track if this is the initial mount to prevent auto-opening console on page load | ||
const [isInitialMount, setIsInitialMount] = useState<boolean>(true); | ||
|
||
useEffect(() => { | ||
// Mark that initial mount is complete after first render | ||
const timer = setTimeout(() => { | ||
setIsInitialMount(false); | ||
}, 100); | ||
return () => clearTimeout(timer); | ||
}, []); |
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.
isInitialMount
doesn't seem necessary at all. Why not simplify by just having the initial state of the console be closed, and toggle open/closed based on the user clicking the button? This is how all existing code is, and is the general pattern for React component state.
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.
removed isInitialMount
, console is expanded/collapsed by user toggling the panel
if (!isEmpty(ingestPipelineErrors)) { | ||
// Add header message (doesn't count as an error) | ||
errorMessages.push( | ||
'Data not ingested. Errors found with the following ingest processor(s):' | ||
); | ||
// Add actual errors (these count) | ||
const ingestErrors = Object.values(ingestPipelineErrors).map( | ||
(error) => { | ||
// Convert to plain text format instead of JSX | ||
const processorType = error.processorType | ||
? error.processorType.charAt(0).toUpperCase() + | ||
error.processorType.slice(1) | ||
: 'Unknown'; | ||
return `Processor type: ${processorType}\nError: ${ | ||
error.errorMsg || error.toString() | ||
}`; | ||
} | ||
); | ||
errorMessages.push(...ingestErrors); | ||
errorCount += ingestErrors.length; | ||
} | ||
if (!isEmpty(searchPipelineErrors)) { | ||
// Add header message (doesn't count as an error) | ||
errorMessages.push( | ||
'Errors found with the following search processor(s):' | ||
); | ||
// Add actual errors (these count) | ||
const searchErrors = Object.values(searchPipelineErrors).map( | ||
(error) => { | ||
// Convert to plain text format instead of JSX | ||
const processorType = error.processorType | ||
? error.processorType.charAt(0).toUpperCase() + | ||
error.processorType.slice(1) | ||
: 'Unknown'; | ||
return `Processor type: ${processorType}\nError: ${ | ||
error.errorMsg || error.toString() | ||
}`; | ||
} | ||
); | ||
errorMessages.push(...searchErrors); | ||
errorCount += searchErrors.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.
There is a lot of duplicate code here, additionally there is the existing util fn for formatting the error messages. Please leverage this util fn, and/or update accordingly to use here.
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.
refactor the function to the utils file
// Force no page overflow | ||
useEffect(() => { | ||
// Store original styles | ||
const originalBodyOverflow = document.body.style.overflow; | ||
const originalHtmlOverflow = document.documentElement.style.overflow; | ||
|
||
// Force no scrollbars | ||
document.body.style.overflow = 'hidden'; | ||
document.documentElement.style.overflow = 'hidden'; | ||
|
||
// Also fix any EUI containers that might be causing overflow | ||
const euiPage = document.querySelector('.euiPage') as HTMLElement; | ||
const euiPageBody = document.querySelector('.euiPageBody') as HTMLElement; | ||
|
||
let originalEuiPageOverflow = ''; | ||
let originalEuiPageBodyOverflow = ''; | ||
|
||
if (euiPage) { | ||
originalEuiPageOverflow = euiPage.style.overflow; | ||
euiPage.style.overflow = 'hidden'; | ||
euiPage.style.maxHeight = '100vh'; | ||
} | ||
|
||
if (euiPageBody) { | ||
originalEuiPageBodyOverflow = euiPageBody.style.overflow; | ||
euiPageBody.style.overflow = 'hidden'; | ||
euiPageBody.style.maxHeight = '100%'; | ||
} | ||
|
||
return () => { | ||
// Restore original styles on cleanup | ||
document.body.style.overflow = originalBodyOverflow; | ||
document.documentElement.style.overflow = originalHtmlOverflow; | ||
|
||
if (euiPage) { | ||
euiPage.style.overflow = originalEuiPageOverflow; | ||
euiPage.style.maxHeight = ''; | ||
} | ||
|
||
if (euiPageBody) { | ||
euiPageBody.style.overflow = originalEuiPageBodyOverflow; | ||
euiPageBody.style.maxHeight = ''; | ||
} | ||
}; | ||
}, []); |
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 looks like a workaround for an underlying style issue, this shouldn't be necessary. Can you describe why this is here? The existing page does not overflow. The console component should be within that page, and should not have any effect on overflow.
<div | ||
data-test-subj="resizable-workspace" | ||
style={{ | ||
width: '100%', | ||
gap: '4px', | ||
// Keep our component properly sized | ||
height: 'calc(100vh - 10px)', | ||
maxHeight: 'calc(100vh - 10px)', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
overflow: 'hidden', | ||
//avoid console panel scroll bar when first render | ||
overflowX: 'hidden', | ||
overflowY: 'hidden', | ||
}} |
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 concerned why there is all of the styling changes, we should keep things simple. If the console component is nested within this parent container, none of this should be needed. Note how LeftNav
is nested within it, I think we can do the same for the Console component.
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 tried to refactor the code and put Tools
, LeftVal
and Console
under the same parent container. The structure did not fix the styling issues itself, adding scroll bars on the right side of the page, cutting off the bottom padding (issues I have come up with before) I think the left nav works because it is a static container with fixed position and size, and no dynamic behavior is needed, but the console panel can push up and collapse dynamically and requires state driven resizing. These styles are tested out to fix all the style issues mentioned in this PR.
ref={containerRef} | ||
style={{ | ||
flex: 1, | ||
minHeight: 0, | ||
display: 'flex', | ||
flexDirection: 'column', | ||
overflow: 'hidden', | ||
}} |
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.
Same comment as above; this shouldn't be needed.
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.
Same comment as above
}} | ||
> | ||
<EuiResizableContainer | ||
key="debug-static-key" |
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.
what is this key value? can it be removed?
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.
Forget why add this, removed
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 looks like this is not removed
<div | ||
style={{ | ||
height: isConsolePanelOpen ? '30vh' : '35px', | ||
minHeight: isConsolePanelOpen ? '200px' : '35px', | ||
maxHeight: isConsolePanelOpen ? '40vh' : '35px', | ||
flexShrink: 0, | ||
borderTop: '1px solid #D3DAE6', | ||
transition: 'height 0.2s ease', | ||
overflow: 'hidden', | ||
position: 'relative', | ||
width: '100%', | ||
maxWidth: '100%', | ||
marginBottom: '15px', | ||
paddingBottom: '5px', | ||
scrollbarWidth: 'none', | ||
msOverflowStyle: 'none', | ||
}} | ||
> | ||
<EuiPanel | ||
paddingSize="s" | ||
style={{ | ||
height: '100%', | ||
display: 'flex', | ||
flexDirection: 'column', | ||
borderRadius: 0, | ||
borderTop: 'none', | ||
overflowX: 'hidden', | ||
overflowY: | ||
consoleErrorMessages.length > 0 || !isEmpty(ingestResponse) | ||
? 'auto' | ||
: 'hidden', | ||
width: '100%', | ||
maxWidth: '100%', | ||
minWidth: 0, | ||
scrollbarWidth: 'none', | ||
msOverflowStyle: 'none', | ||
}} | ||
className="console-panel-no-scroll" |
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.
same comment as above. This all seems very over-complicated. Using the EUI components with minimal stying changes should be all that's needed.
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.
Same comment above.
const openErrorsFullscreen = () => { | ||
setFullscreenMode('errors'); | ||
const style = document.createElement('style'); | ||
style.id = 'console-fullscreen-hide-header'; | ||
style.textContent = ` | ||
.euiHeader, | ||
[data-test-subj="headerGlobalNav"], | ||
#globalHeaderBars, | ||
.osd-top-nav, | ||
.chrome-nav, | ||
.application-header, | ||
.kibana-header, | ||
.opensearch-header, | ||
header[role="banner"], | ||
.global-header, | ||
.top-nav, | ||
nav[aria-label*="primary"], | ||
nav[aria-label*="global"] { | ||
display: none !important; | ||
visibility: hidden !important; | ||
opacity: 0 !important; | ||
z-index: -1 !important; | ||
height: 0 !important; | ||
overflow: hidden !important; | ||
} | ||
`; | ||
document.head.appendChild(style); | ||
}; |
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.
Few things:
- should not need this long list of styles, please use regular EUI components
- should not need low-level JS here. We should just dynamically render the React components
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.
Tyler I was not able to find any component in the OUI library or EUI library that can do all these things: 1. full screen layout coverage. 2. theme detection 3. delete navigation bar/ header 4. built in X button to close the window 5. built in styling from the framework that I do not need to add any additional style. I also checked the link you shared, at the beginning I though it was a component that I can use, but it seems like a demo (please correct me if I am wrong). I feed the link to AI and ask if there is anything in the EUI or OUI library that at lease I can try out. I tried using EuiModal, it can do theme detection, delete the header, but it has built in constraint that text is only viewable inside some certain area. Also tried EuiFlyout, the header can be removed, but theme detection not working, and no built in styles for the text. The current implementation is not smart (for css injection to delete the header, and theme detection), but I could not find another built in component as solution.
const openResponsesFullscreen = () => { | ||
setFullscreenMode('responses'); | ||
const style = document.createElement('style'); | ||
style.id = 'console-fullscreen-hide-header'; | ||
style.textContent = ` | ||
.euiHeader, | ||
[data-test-subj="headerGlobalNav"], | ||
#globalHeaderBars, | ||
.osd-top-nav, | ||
.chrome-nav, | ||
.application-header, | ||
.kibana-header, | ||
.opensearch-header, | ||
header[role="banner"], | ||
.global-header, | ||
.top-nav, | ||
nav[aria-label*="primary"], | ||
nav[aria-label*="global"] { | ||
display: none !important; | ||
visibility: hidden !important; | ||
opacity: 0 !important; | ||
z-index: -1 !important; | ||
height: 0 !important; | ||
overflow: hidden !important; | ||
} | ||
`; | ||
document.head.appendChild(style); | ||
}; |
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.
same comment as 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.
Same comment as 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.
Strongly suggest to start simple, particularly for the full-screen view. Should be using existing EUI components, and should never need more than 1 or 2 styling tweaks.
Roughly, I would suggest to implement the following way:
- have 3 main "components": the collapsed console, the expanded console, and the full-screen modal, all using the base EUI components.
- maintain 1 or 2 state variables to determine when to show each one
I would suggest to study some of the existing components, and the basic rendering pattern for react components here: https://react.dev/learn
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.
Hello Tyler, I rewrite some test code to figure out if parent/ child structure can guarantee the expected layout, and it looks like all the layout issues I have come across so far: (overflow, scroll bar on the UI page, console bottom padding cut off, overlay issue when console expanded) will still persists. Component structure itself cannot guarantee the expected layout because:
- leftNav is static and will not towards side so that the horizontal width will not be chanllenged and will not disrupt sibling components.
- console can be expanded/collapsed that will affect the layout of other components and potentially reflow all the other components.
- LeftNav uses simple conditional rendering (leftNavOpen ? : undefined) that works seamlessly with the container. Console creates conflicts between our manual isConsolePanelOpen state and EUI's internal resizable panel state (via onToggleCollapsedInternal), causing re-render loops and the component to flash and disappear.
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 left nav expands / collapses. Depending on if opened/closed, we re-generate the width of the other 2 resizable components. See this line.
Why can't we do the same thing for console? It is the same idea, but it is on the bottom, instead of the left.
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.
To re-iterate, adding the console should not be adding anything close to 500 lines of code like it currently is. It will make it impossible to debug resizing issues with a tangle of nested and customized sizing styles set.
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.
Hello Tyler, I tested your example code locally and get the same style issues, most of them have been the same I have been tackling so far. As far as I am aware, react make components communicate with each other and css are used for styling. From my test and from your example code, it looks like putting the console component as a sibling component as the left nav will not automatically resolve the styling issues.
I was also unable to find a 'built-in' component which will automatically solve the styling issues. For example, the full screen UI page.
Tested components in the OUI library or EUI library that can do all these things: 1. full screen layout coverage. 2. theme detection 3. delete navigation bar/ header 4. built in X button to close the window 5. built in styling from the framework that I do not need to add any additional style. I also checked the link you shared, at the beginning I though it was a component that I can use, but it seems like a demo (please correct me if I am wrong). I feed the link to AI and ask if there is anything in the EUI or OUI library that at least I can try out. I tried using EuiModal, it can do theme detection, delete the header, but it has built in constraint that text is only viewable inside some certain area. Also tried EuiFlyout, the header can be removed, but theme detection not working, and no built in styles for the text. The current implementation is not smart (for css injection to delete the header, and theme detection), but I could not find another built in component as solution.
For the comments which I did not reply back, these are the ones I could not figure out a way to simplify, could you help me to simplify these styling 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.
There shouldn't be any changes needed to this component
Signed-off-by: Kama Huang <[email protected]> resove merge conflicts2 Signed-off-by: Kama Huang <[email protected]> fix console expanded issue when mount/unmount Signed-off-by: Kama Huang <[email protected]> fix right scroll bar Signed-off-by: Kama Huang <[email protected]> fix left panel button space Signed-off-by: Kama Huang <[email protected]> fix scroll bar on the console panel Signed-off-by: Kama Huang <[email protected]> fix console bottom cut off issue Signed-off-by: Kama Huang <[email protected]> fix full screen mode for ingest responses Signed-off-by: Kama Huang <[email protected]> clean up code Signed-off-by: Kama Huang <[email protected]> fix console panel cut off Signed-off-by: Kama Huang <[email protected]> fix full screen style Signed-off-by: Kama Huang <[email protected]> fix console state expanded issue Signed-off-by: Kama Huang <[email protected]> fix console panel expanded issue2 Signed-off-by: Kama Huang <[email protected]> scroll bar added but horizontal bar added when error persists Signed-off-by: Kama Huang <[email protected]> fix horizontal bar issue Signed-off-by: Kama Huang <[email protected]> bottom cut off issue fixed but add additional scroll bar in the console even no responses/errors Signed-off-by: Kama Huang <[email protected]> fix console panel scroll bar issue when first rendered Signed-off-by: Kama Huang <[email protected]>
Signed-off-by: Kama Huang <[email protected]>
Signed-off-by: Kama Huang <[email protected]>
Signed-off-by: Kama Huang <[email protected]>
Signed-off-by: Kama Huang <[email protected]>
Signed-off-by: Kama Huang <[email protected]>
Signed-off-by: Kama Huang <[email protected]>
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.
Please refer to https://github.com/ohltyler/dashboards-flow-framework/tree/example as a starting point for simplifying the code. The complexity of all of the manual stylings in ResizableContainer
and Console
is not maintainable or readable, and can lead to very difficult bugs. In general, the mentality you should have is:
- Start with the EUI components, particularly
EuiFlexGroup
/EuiFlexItem
s for building the overall structure and how things should grow as windows expand, etc. This will handle 99% of all of the styling for you, as they have all built-in styling for flex, margin, padding, etc. and keeps the page layouts consistent. - Minor tuning of margins / overflow / etc. if there looks to be small misalignments or weird gaps, wasted space, etc. This also makes it easy to maintain over time.
- Test, test test: Iteratively trying out components and testing it out in browser, seeing how it grows/shrinks, how it functions, is the best place to start.
- Work in a hierarchical pattern: start with implementing the biggest parent components, and work towards the smaller ones. This helps you iteratively test and drill down. If it's implemented all at once, it can be much more difficult to know what component in some nested structure is causing some styling issue, overflow, padding, etc.
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 file still exists, please remove
<EuiFlexItem | ||
grow={false} | ||
style={{ | ||
height: '60px', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
marginBottom: '20px', | ||
}} | ||
> | ||
<EuiFlexGroup | ||
direction="row" | ||
gutterSize="s" | ||
style={{ | ||
padding: '0px', | ||
marginBottom: USE_NEW_HOME_PAGE ? '0px' : '54px', | ||
margin: '0px', | ||
width: '100%', | ||
height: '100%', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', |
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.
These changes should not be necessary, why all of the width/height styling changes? EuiFlexGroup
will already grow to maximize space within their parent container.
Additionally, the USE_NEW_HOME_PAGE flag has been removed; this was required to maximize the space based on OSD using the new home page layout vs. old home page layout. Please add back.
}} | ||
> | ||
<EuiResizableContainer | ||
key="debug-static-key" |
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 looks like this is not removed
Also, make sure to update and point this branch to |
Description
Consolidate ingest responses and errors into console section
Issues Resolved
None
Fixed issues:
Check List
--signoff
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.