-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
refactor(ui): improve first time alerting experience #14917
Changes from 12 commits
0526196
8310d03
5bc6f88
d6f553d
2ca9503
a76bea4
095c579
d27a58d
504c567
2dbfcbe
a2692f5
a1fbdf7
0102b9e
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 |
---|---|---|
@@ -1,63 +1,65 @@ | ||
// Libraries | ||
import React, {FC} from 'react' | ||
import React, {FC, ReactChild} from 'react' | ||
|
||
// Components | ||
import { | ||
Button, | ||
ComponentColor, | ||
Panel, | ||
InfluxColors, | ||
DapperScrollbars, | ||
Input, | ||
IconFont, | ||
FlexBox, | ||
FlexDirection, | ||
ComponentSize, | ||
} from '@influxdata/clockface' | ||
import QuestionMarkTooltip from 'src/shared/components/question_mark_tooltip/QuestionMarkTooltip' | ||
|
||
interface Props { | ||
title: string | ||
testID?: string | ||
onCreate: () => void | ||
createButton: JSX.Element | ||
questionMarkTooltipContents: ReactChild | ||
} | ||
|
||
const AlertsColumnHeader: FC<Props> = ({ | ||
children, | ||
onCreate, | ||
title, | ||
testID = '', | ||
}) => { | ||
return ( | ||
<Panel | ||
backgroundColor={InfluxColors.Kevlar} | ||
className="alerting-index--column" | ||
> | ||
<Panel.Header> | ||
<Panel.Title>{title}</Panel.Title> | ||
<Button | ||
text="Create" | ||
icon={IconFont.Plus} | ||
onClick={onCreate} | ||
color={ComponentColor.Primary} | ||
testID={`alert-column--header ${testID}`} | ||
createButton, | ||
questionMarkTooltipContents, | ||
}) => ( | ||
<Panel | ||
backgroundColor={InfluxColors.Kevlar} | ||
className="alerting-index--column" | ||
> | ||
<Panel.Header> | ||
<FlexBox direction={FlexDirection.Row} margin={ComponentSize.Small}> | ||
<Panel.Title style={{fontSize: '17px', width: 'auto'}}> | ||
{title} | ||
</Panel.Title> | ||
<QuestionMarkTooltip | ||
testID={`${title}--question-mark`} | ||
tipContent={questionMarkTooltipContents} | ||
/> | ||
</Panel.Header> | ||
<div className="alerting-index--search"> | ||
<Input | ||
icon={IconFont.Search} | ||
placeholder={`Filter ${title}...`} | ||
value="" | ||
onChange={() => {}} | ||
/> | ||
</div> | ||
<div className="alerting-index--column-body"> | ||
<DapperScrollbars | ||
autoSize={false} | ||
autoHide={true} | ||
style={{width: '100%', height: '100%'}} | ||
> | ||
<div className="alerting-index--list">{children}</div> | ||
</DapperScrollbars> | ||
</div> | ||
</Panel> | ||
) | ||
} | ||
</FlexBox> | ||
{createButton} | ||
</Panel.Header> | ||
<div className="alerting-index--search"> | ||
<Input | ||
icon={IconFont.Search} | ||
placeholder={`Filter ${title}...`} | ||
value="" | ||
onChange={() => {}} | ||
/> | ||
</div> | ||
<div className="alerting-index--column-body"> | ||
<DapperScrollbars | ||
autoSize={false} | ||
autoHide={true} | ||
style={{width: '100%', height: '100%'}} | ||
> | ||
<div className="alerting-index--list">{children}</div> | ||
</DapperScrollbars> | ||
</div> | ||
</Panel> | ||
) | ||
|
||
export default AlertsColumnHeader |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,14 +7,17 @@ import {connect} from 'react-redux' | |
import {viewableLabels} from 'src/labels/selectors' | ||
|
||
// Components | ||
import {Button, IconFont, ComponentColor} from '@influxdata/clockface' | ||
import CheckCards from 'src/alerting/components/CheckCards' | ||
import AlertsColumnHeader from 'src/alerting/components/AlertsColumn' | ||
|
||
// Types | ||
import {Check, AppState} from 'src/types' | ||
import {Check, NotificationRuleDraft, AppState} from 'src/types' | ||
|
||
interface StateProps { | ||
checks: Check[] | ||
rules: NotificationRuleDraft[] | ||
endpoints: AppState['endpoints']['list'] | ||
} | ||
|
||
type Props = StateProps & WithRouterProps | ||
|
@@ -23,13 +26,46 @@ const ChecksColumn: FunctionComponent<Props> = ({ | |
checks, | ||
router, | ||
params: {orgID}, | ||
rules, | ||
endpoints, | ||
}) => { | ||
const handleClick = () => { | ||
router.push(`/orgs/${orgID}/alerting/checks/new`) | ||
} | ||
|
||
const tooltipContents = ( | ||
<> | ||
A <strong>Check</strong> is a periodic query that the system | ||
<br /> | ||
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. Do these 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 manually placed the line breaks in a way that makes it nice to read rather than relying on left/right padding |
||
performs against your time series data | ||
<br /> | ||
that will generate a status | ||
</> | ||
) | ||
|
||
const noAlertingResourcesExist = | ||
!checks.length && !rules.length && !endpoints.length | ||
|
||
const createButton = ( | ||
<Button | ||
color={ComponentColor.Primary} | ||
text="Create" | ||
onClick={handleClick} | ||
testID="create-check" | ||
icon={IconFont.Plus} | ||
/> | ||
) | ||
|
||
return ( | ||
<AlertsColumnHeader title="Checks" onCreate={handleClick}> | ||
<CheckCards checks={checks} /> | ||
<AlertsColumnHeader | ||
title="Checks" | ||
createButton={createButton} | ||
questionMarkTooltipContents={tooltipContents} | ||
> | ||
<CheckCards | ||
checks={checks} | ||
showFirstTimeWidget={noAlertingResourcesExist} | ||
/> | ||
</AlertsColumnHeader> | ||
) | ||
} | ||
|
@@ -38,9 +74,16 @@ const mstp = (state: AppState) => { | |
const { | ||
checks: {list: checks}, | ||
labels: {list: labels}, | ||
rules: {list: rules}, | ||
endpoints, | ||
} = state | ||
|
||
return {checks, labels: viewableLabels(labels)} | ||
return { | ||
checks, | ||
labels: viewableLabels(labels), | ||
rules, | ||
endpoints: endpoints.list, | ||
} | ||
} | ||
|
||
export default connect<StateProps, {}, {}>( | ||
|
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's up with this
LINEBREAK
stuff? Could markdown be passed instead? Or the text passed as multiple props?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.
Glad you asked! The empty state component is overly strict and ends up shooting itself in the foot in the process. I am planning a small change in the next clockface update that should remove all this funk
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.
Ah ok, awesome