-
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
Merged
jloleysens
merged 9 commits into
elastic:master
from
jloleysens:feature/console/ui-progress-bar
Feb 6, 2020
Merged
[Console] Progress bar #56628
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c6da65c
First round of UI updates
jloleysens 799a003
Add notification about in flight request
jloleysens f65381a
Use nbsp; and update the EuiCode to use EuiBadge
jloleysens 191146f
Merge branch 'master' into feature/console/ui-progress-bar
elasticmachine 882693a
Address PR feedback:
jloleysens 24dd028
[NB] Fix for floating tools when request is past bottom of rendered t…
jloleysens 7c9390c
Fix types
jloleysens a3c685e
Update copy
jloleysens ff24cc6
Merge branch 'master' into feature/console/ui-progress-bar
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
|
@@ -89,3 +101,12 @@ | |
.conApp__settingsModal { | ||
min-width: 460px; | ||
} | ||
|
||
.conApp__requestProgressBarContainer { | ||
position: relative; | ||
z-index: $euiZLevel2; | ||
} | ||
|
||
.conApp__tabsExtension { | ||
border-bottom: $euiBorderThin; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/plugins/console/public/application/components/network_request_status_bar/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
133 changes: 133 additions & 0 deletions
133
...e/public/application/components/network_request_status_bar/network_request_status_bar.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import React, { FunctionComponent } from 'react'; | ||
import { EuiFlexGroup, EuiFlexItem, EuiBadge, EuiText, EuiToolTip } from '@elastic/eui'; | ||
|
||
export interface Props { | ||
requestInProgress: boolean; | ||
requestResult?: { | ||
// Status code of the request, e.g., 200 | ||
statusCode: number; | ||
|
||
// Status text of the request, e.g., OK | ||
statusText: string; | ||
|
||
// Method of the request, e.g., GET | ||
method: string; | ||
|
||
// The path of endpoint that was called, e.g., /_search | ||
endpoint: string; | ||
|
||
// The time, in milliseconds, that the last request took | ||
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> = ({ | ||
requestInProgress, | ||
requestResult, | ||
}) => { | ||
let content: React.ReactNode = null; | ||
|
||
if (requestInProgress) { | ||
content = ( | ||
<EuiFlexItem grow={false}> | ||
<EuiBadge color="hollow"> | ||
{i18n.translate('console.requestInProgressBadgeText', { | ||
defaultMessage: 'Request in progress', | ||
})} | ||
</EuiBadge> | ||
</EuiFlexItem> | ||
); | ||
} else if (requestResult) { | ||
const { endpoint, method, statusCode, statusText, timeElapsedMs } = requestResult; | ||
|
||
content = ( | ||
<> | ||
<EuiFlexItem grow={false}> | ||
<EuiToolTip | ||
position="top" | ||
content={ | ||
<EuiText size="s">{`${method} ${ | ||
endpoint.startsWith('/') ? endpoint : '/' + endpoint | ||
}`}</EuiText> | ||
} | ||
> | ||
<EuiBadge color={mapStatusCodeToBadgeColor(statusCode)}> | ||
{/* Use to ensure that no matter the width we don't allow line breaks */} | ||
{statusCode} - {statusText} | ||
</EuiBadge> | ||
</EuiToolTip> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<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> | ||
</> | ||
); | ||
} | ||
|
||
return ( | ||
<EuiFlexGroup | ||
justifyContent="flexEnd" | ||
alignItems="center" | ||
direction="row" | ||
gutterSize="s" | ||
responsive={false} | ||
> | ||
{content} | ||
</EuiFlexGroup> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.