-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Console] Progress bar #56628
[Console] Progress bar #56628
Changes from 4 commits
c6da65c
799a003
f65381a
191146f
882693a
24dd028
7c9390c
a3c685e
ff24cc6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,7 @@ | |
button { | ||
line-height: inherit; | ||
} | ||
|
||
position: absolute; | ||
z-index: $euiZLevel1; | ||
top: 0; | ||
|
@@ -75,6 +76,17 @@ | |
z-index: $euiZLevel1; | ||
} | ||
|
||
.conApp__networkRequestContainer { | ||
position: absolute; | ||
min-width: 200px; | ||
width: 100%; | ||
|
||
height: 30px; | ||
top: -30px; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would also remove this empty space. |
||
right: 0; | ||
} | ||
|
||
// SASSTODO: This component seems to not be used anymore? | ||
// Possibly replaced by the Ace version | ||
.conApp__autoComplete { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
@import 'help'; | ||
@import 'history'; | ||
@import 'network_request_status_bar' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
.conApp__outputNetworkRequestStatusBar { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use an EuiFlexGroup to handle layout instead of custom classes? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Originally, I did use an EuiFlexGroup, but found the padding on bottom and top too big. Given your suggested changes below I am happy to change this! |
||
&__item { | ||
padding: 0 10px; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
export { NetworkRequestStatusBar } from './network_request_status_bar'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/* | ||
* Licensed to Elasticsearch B.V. under one or more contributor | ||
* license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright | ||
* ownership. Elasticsearch B.V. licenses this file to you under | ||
* the Apache License, Version 2.0 (the "License"); you may | ||
* not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import React, { FunctionComponent } from 'react'; | ||
import { EuiFlexGroup, EuiFlexItem, EuiBadge, EuiText, EuiToolTip } from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
export interface Props { | ||
statusCode: number; | ||
statusText: string; | ||
method: string; | ||
endpoint: string; | ||
timeElapsedMs: number; | ||
} | ||
|
||
const mapStatusCodeToBadgeColor = (statusCode: number) => { | ||
if (statusCode <= 199) { | ||
return 'default'; | ||
} | ||
|
||
if (statusCode <= 299) { | ||
return 'secondary'; | ||
} | ||
|
||
if (statusCode <= 399) { | ||
return 'primary'; | ||
} | ||
|
||
if (statusCode <= 499) { | ||
return 'warning'; | ||
} | ||
|
||
return 'danger'; | ||
}; | ||
|
||
export const NetworkRequestStatusBar: FunctionComponent<Props> = ({ | ||
endpoint, | ||
statusCode, | ||
statusText, | ||
timeElapsedMs, | ||
method, | ||
}) => ( | ||
<EuiFlexGroup | ||
justifyContent="flexEnd" | ||
alignItems="center" | ||
direction="row" | ||
gutterSize="none" | ||
responsive={false} | ||
> | ||
<EuiFlexItem | ||
grow={false} | ||
className="conApp__outputNetworkRequestStatusBar__item conApp__outputNetworkRequestStatusBar__badge" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. Will clean that up! |
||
> | ||
<EuiToolTip | ||
position="top" | ||
content={ | ||
<EuiText size="s">{`${method} ${ | ||
endpoint.startsWith('/') ? endpoint : '/' + endpoint | ||
}`}</EuiText> | ||
} | ||
> | ||
<EuiBadge color={mapStatusCodeToBadgeColor(statusCode)}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think of hiding the second badge and replacing this one with a hollow one that says "Request in flight" while the request is in flight? I think it improves usability by 1) acting as a placeholder for the request results so you know where to look for them and 2) explaining the purpose of the strobing progress indicator. |
||
{/* Use to ensure that no matter the width we don't allow line breaks */} | ||
{statusCode} - {statusText} | ||
</EuiBadge> | ||
</EuiToolTip> | ||
</EuiFlexItem> | ||
|
||
<EuiFlexItem grow={false} className="conApp__outputNetworkRequestStatusBar__item"> | ||
<EuiToolTip | ||
position="top" | ||
content={ | ||
<EuiText size="s"> | ||
{i18n.translate('console.requestTimeElapasedBadgeTooltipContent', { | ||
defaultMessage: 'Time Elapsed', | ||
})} | ||
</EuiText> | ||
} | ||
> | ||
<EuiText size="s"> | ||
<EuiBadge color="default"> | ||
{timeElapsedMs} {'ms'} | ||
</EuiBadge> | ||
</EuiText> | ||
</EuiToolTip> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,14 +17,15 @@ | |
* under the License. | ||
*/ | ||
|
||
import React, { useCallback } from 'react'; | ||
import React, { useCallback, memo } from 'react'; | ||
import { debounce } from 'lodash'; | ||
import { EuiProgress } from '@elastic/eui'; | ||
|
||
import { EditorContentSpinner } from '../../components'; | ||
import { Panel, PanelsContainer } from '../../../../../kibana_react/public'; | ||
import { Editor as EditorUI, EditorOutput } from './legacy/console_editor'; | ||
import { StorageKeys } from '../../../services'; | ||
import { useEditorReadContext, useServicesContext } from '../../contexts'; | ||
import { useEditorReadContext, useServicesContext, useRequestReadContext } from '../../contexts'; | ||
|
||
const INITIAL_PANEL_WIDTH = 50; | ||
const PANEL_MIN_WIDTH = '100px'; | ||
|
@@ -33,12 +34,13 @@ interface Props { | |
loading: boolean; | ||
} | ||
|
||
export const Editor = ({ loading }: Props) => { | ||
export const Editor = memo(({ loading }: Props) => { | ||
const { | ||
services: { storage }, | ||
} = useServicesContext(); | ||
|
||
const { currentTextObject } = useEditorReadContext(); | ||
const { requestInFlight } = useRequestReadContext(); | ||
|
||
const [firstPanelWidth, secondPanelWidth] = storage.get(StorageKeys.WIDTH, [ | ||
INITIAL_PANEL_WIDTH, | ||
|
@@ -55,23 +57,30 @@ export const Editor = ({ loading }: Props) => { | |
if (!currentTextObject) return null; | ||
|
||
return ( | ||
<PanelsContainer onPanelWidthChange={onPanelWidthChange} resizerClassName="conApp__resizer"> | ||
<Panel | ||
style={{ height: '100%', position: 'relative', minWidth: PANEL_MIN_WIDTH }} | ||
initialWidth={firstPanelWidth} | ||
> | ||
{loading ? ( | ||
<EditorContentSpinner /> | ||
) : ( | ||
<EditorUI initialTextValue={currentTextObject.text} /> | ||
)} | ||
</Panel> | ||
<Panel | ||
style={{ height: '100%', position: 'relative', minWidth: PANEL_MIN_WIDTH }} | ||
initialWidth={secondPanelWidth} | ||
> | ||
{loading ? <EditorContentSpinner /> : <EditorOutput />} | ||
</Panel> | ||
</PanelsContainer> | ||
<> | ||
{requestInFlight ? ( | ||
<div style={{ position: 'relative', zIndex: 2000 }}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use a class name here instead? I'm not sure if our CSP disallows inline styles, but I think we are moving in that direction. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's an interesting point! Do you know whether this is the current CSP There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh cool, didn't know about that file! I'm not sure but it looks like it would be. |
||
<EuiProgress size="xs" color="accent" position="absolute" /> | ||
</div> | ||
) : null} | ||
<PanelsContainer onPanelWidthChange={onPanelWidthChange} resizerClassName="conApp__resizer"> | ||
<Panel | ||
style={{ height: '100%', position: 'relative', minWidth: PANEL_MIN_WIDTH }} | ||
initialWidth={firstPanelWidth} | ||
> | ||
{loading ? ( | ||
<EditorContentSpinner /> | ||
) : ( | ||
<EditorUI initialTextValue={currentTextObject.text} /> | ||
)} | ||
</Panel> | ||
<Panel | ||
style={{ height: '100%', position: 'relative', minWidth: PANEL_MIN_WIDTH }} | ||
initialWidth={secondPanelWidth} | ||
> | ||
{loading ? <EditorContentSpinner /> : <EditorOutput />} | ||
</Panel> | ||
</PanelsContainer> | ||
</> | ||
); | ||
}; | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,8 @@ | |
*/ | ||
|
||
import React, { useEffect, useRef } from 'react'; | ||
|
||
import { NetworkRequestStatusBar } from '../../../../components'; | ||
import { createReadOnlyAceEditor, CustomAceEditor } from '../../../../models/legacy_core_editor'; | ||
import { | ||
useServicesContext, | ||
|
@@ -70,8 +72,8 @@ function EditorOutputUI() { | |
.join('\n') | ||
); | ||
} else if (error) { | ||
editor.session.setMode(modeForContentType(error.contentType)); | ||
editor.update(error.value); | ||
editor.session.setMode(modeForContentType(error.response.contentType)); | ||
editor.update(error.response.value as string); | ||
} else { | ||
editor.update(''); | ||
} | ||
|
@@ -81,17 +83,33 @@ function EditorOutputUI() { | |
applyCurrentSettings(editorInstanceRef.current!, readOnlySettings); | ||
}, [readOnlySettings]); | ||
|
||
const lastDatum = data?.[data.length - 1] ?? error; | ||
|
||
return ( | ||
<div ref={editorRef} className="conApp__output" data-test-subj="response-editor"> | ||
{/* Axe complains about Ace's textarea element missing a label, which interferes with our | ||
<> | ||
{lastDatum ? ( | ||
<div className="conApp__networkRequestContainer"> | ||
<NetworkRequestStatusBar | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like the location of this component causes some rendering problems when you open the "History" dropdown: In terms of component hierarchy, I'd also expect to find it located near the tabs in the code, since it's located near the tabs visually. If we change https://github.com/elastic/kibana/blob/master/src/plugins/console/public/application/containers/main/main.tsx#L70 to this: <EuiFlexItem grow={false}>
<EuiTitle className="euiScreenReaderOnly">
<h1>
{i18n.translate('console.pageHeading', {
defaultMessage: 'Console',
})}
</h1>
</EuiTitle>
<EuiFlexGroup gutterSize="none">
<EuiFlexItem grow={false}>
<TopNavMenu
disabled={!done}
items={getTopNavConfig({
onClickHistory: () => setShowHistory(!showingHistory),
onClickSettings: () => setShowSettings(true),
onClickHelp: () => setShowHelp(!showHelp),
})}
/>
</EuiFlexItem>
<EuiFlexItem className="conApp__tabsExtension">
<NetworkRequestStatusBar
method={'GET'}
endpoint={'/the_last_starfighter'}
statusCode={200}
statusText={':)'}
timeElapsedMs={'411'}
/>
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem> And add this class somewhere: .conApp__tabsExtension {
border-bottom: $euiBorderThin;
} Then the rendered output is correct and the two components will be colocated: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Awesome! Happy with these changes, I was a bit stuck on this one 👍 |
||
method={lastDatum.request.method.toUpperCase()} | ||
endpoint={lastDatum.request.path} | ||
statusCode={lastDatum.response.statusCode} | ||
statusText={lastDatum.response.statusText} | ||
timeElapsedMs={lastDatum.response.timeMs} | ||
/> | ||
</div> | ||
) : null} | ||
|
||
<div ref={editorRef} className="conApp__output" data-test-subj="response-editor"> | ||
{/* Axe complains about Ace's textarea element missing a label, which interferes with our | ||
automated a11y tests per #52136. This wrapper does nothing to address a11y but it does | ||
satisfy Axe. */} | ||
|
||
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */} | ||
<label className="conApp__textAreaLabelHack"> | ||
<div className="conApp__outputContent" id="ConAppOutput" /> | ||
</label> | ||
</div> | ||
{/* eslint-disable-next-line jsx-a11y/label-has-associated-control */} | ||
<label className="conApp__textAreaLabelHack"> | ||
<div className="conApp__outputContent" id="ConAppOutput" /> | ||
</label> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
|
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 just remove this empty space.