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

feat(ui): Enhance resource creation experience when limits are reached #19103

Merged
merged 7 commits into from
Jul 30, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat(ui): enable create bucket button
  • Loading branch information
mavarius committed Jul 30, 2020
commit cb83821c3e6a098d1e42855875fa6c4d797e0fa6
31 changes: 10 additions & 21 deletions ui/src/buckets/components/CreateBucketButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ import React, {FC, useEffect} from 'react'
import {connect, ConnectedProps, useDispatch} from 'react-redux'

// Components
import {
Button,
IconFont,
ComponentColor,
ComponentStatus,
} from '@influxdata/clockface'
import {Button, IconFont, ComponentColor} from '@influxdata/clockface'

// Actions
import {checkBucketLimits, LimitStatus} from 'src/cloud/actions/limits'
Expand All @@ -20,6 +15,9 @@ import {extractBucketLimits} from 'src/cloud/utils/limits'
// Types
import {AppState} from 'src/types'

// Constants
import {CLOUD} from 'src/shared/constants'

type ReduxProps = ConnectedProps<typeof connector>
type Props = ReduxProps

Expand All @@ -35,32 +33,23 @@ const CreateBucketButton: FC<Props> = ({
}, [dispatch])

const limitExceeded = limitStatus === LimitStatus.EXCEEDED
const text = 'Create Bucket'
let titleText = 'Click to create a bucket'
let buttonStatus = ComponentStatus.Default

if (limitExceeded) {
titleText = 'This account has the maximum number of buckets allowed'
buttonStatus = ComponentStatus.Disabled
}

const handleItemClick = (): void => {
if (limitExceeded) {
return
if (CLOUD && limitExceeded) {
onShowOverlay('asset-limit', {asset: 'Buckets'}, onDismissOverlay)
} else {
onShowOverlay('create-bucket', null, onDismissOverlay)
}

onShowOverlay('create-bucket', null, onDismissOverlay)
}

return (
<Button
icon={IconFont.Plus}
color={ComponentColor.Primary}
text={text}
titleText={titleText}
text="Create Bucket"
titleText="Click to create a bucket"
onClick={handleItemClick}
testID="Create Bucket"
status={buttonStatus}
/>
)
}
Expand Down