Skip to content
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): alerting details polish #15056

Merged
merged 9 commits into from
Sep 9, 2019
2 changes: 2 additions & 0 deletions ui/src/alerting/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ export const DEFAULT_DEADMAN_CHECK: Partial<DeadmanCheck> = {
reportZero: DEFAULT_CHECK_REPORT_ZERO,
level: DEFAULT_DEADMAN_LEVEL,
statusMessageTemplate: DEFAULT_STATUS_MESSAGE,
timeSince: '90s',
staleTime: '10m',
}

export const CHECK_QUERY_FIXTURE: DashboardQuery = {
Expand Down
4 changes: 4 additions & 0 deletions ui/src/buckets/components/BucketAddDataButton.scss
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,7 @@
color: $g13-mist;
}
}

.system-bucket {
color: mix($c-honeydew, $g13-mist);
}
31 changes: 23 additions & 8 deletions ui/src/buckets/components/BucketCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import BucketContextMenu from 'src/buckets/components/BucketContextMenu'
import BucketAddDataButton from 'src/buckets/components/BucketAddDataButton'
import {FeatureFlag} from 'src/shared/utils/featureFlag'

// Constants
import {isSystemBucket} from 'src/buckets/constants/index'

// Types
import {Bucket} from 'src/types'
import {DataLoaderType} from 'src/types/dataLoaders'
Expand All @@ -40,7 +43,12 @@ class BucketRow extends PureComponent<Props & WithRouterProps> {
<ResourceCard
testID="bucket--card"
contextMenu={
<BucketContextMenu bucket={bucket} onDeleteBucket={onDeleteBucket} />
!isSystemBucket(bucket) && (
<BucketContextMenu
bucket={bucket}
onDeleteBucket={onDeleteBucket}
/>
)
}
name={
<ResourceCard.Name
Expand All @@ -49,7 +57,12 @@ class BucketRow extends PureComponent<Props & WithRouterProps> {
name={bucket.name}
/>
}
metaData={[<>Retention: {bucket.ruleString}</>]}
metaData={[
isSystemBucket(bucket) && (
<span className="system-bucket">System Bucket</span>
),
<>Retention: {bucket.ruleString}</>,
]}
>
<FlexBox
direction={FlexDirection.Row}
Expand All @@ -61,12 +74,14 @@ class BucketRow extends PureComponent<Props & WithRouterProps> {
onAddLineProtocol={this.handleAddLineProtocol}
onAddScraper={this.handleAddScraper}
/>
<Button
text="Rename"
testID="bucket-rename"
size={ComponentSize.ExtraSmall}
onClick={this.handleRenameBucket}
/>
{!isSystemBucket(bucket) && (
<Button
text="Rename"
testID="bucket-rename"
size={ComponentSize.ExtraSmall}
onClick={this.handleRenameBucket}
/>
)}
<FeatureFlag name="deleteWithPredicate">
<Button
text="Delete Data By Filter"
Expand Down
7 changes: 7 additions & 0 deletions ui/src/buckets/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,8 @@
import {Bucket} from 'src/types'
import {startsWith} from 'lodash'

export const MIN_RETENTION_SECONDS = 3600

export const isSystemBucket = (bucket: Bucket): boolean => {
return startsWith(bucket.name, '_')
}
20 changes: 19 additions & 1 deletion ui/src/shared/components/ThresholdMarkers.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Libraries
import React, {useRef, FunctionComponent} from 'react'
import {Scale} from '@influxdata/giraffe'
import {round} from 'lodash'

// Components
import RangeThresholdMarkers from 'src/shared/components/RangeThresholdMarkers'
Expand All @@ -13,6 +14,9 @@ import {clamp} from 'src/shared/utils/vis'
// Types
import {Threshold} from 'src/types'

// Constants
const DRAGGABLE_THRESHOLD_PRECISION = 2

interface Props {
thresholds: Threshold[]
onSetThresholds: (newThresholds: Threshold[]) => void
Expand Down Expand Up @@ -52,7 +56,21 @@ const ThresholdMarkers: FunctionComponent<Props> = ({
i === index ? nextThreshold : t
)

onSetThresholds(nextThresholds)
const roundedThresholds = nextThresholds.map(nt => {
if (nt.type === 'greater' || nt.type === 'lesser') {
return {...nt, value: round(nt.value, DRAGGABLE_THRESHOLD_PRECISION)}
}

if (nt.type === 'range') {
return {
...nt,
min: round(nt.min, DRAGGABLE_THRESHOLD_PRECISION),
max: round(nt.max, DRAGGABLE_THRESHOLD_PRECISION),
}
}
})

onSetThresholds(roundedThresholds)
}

return (
Expand Down