From bc4c19dfd8f3987c942cacc366914422906ef39d Mon Sep 17 00:00:00 2001 From: Daniel Campbell Date: Thu, 30 Jul 2020 09:14:21 -0700 Subject: [PATCH] feat(ui): Enhance resource creation experience when limits are reached (#19103) * feat(ui): add AssetLimitOverlay * feat(ui): enable create bucket button * feat(ui): enable create dashboard and task buttons * feat(ui): add reusable AssetLimitButton * feat(ui): change alerts limit experience * feat(ui): update changelog * feat(ui): address review comments --- CHANGELOG.md | 6 +- ui/src/alerting/components/AlertsColumn.tsx | 46 ++++-- .../buckets/components/CreateBucketButton.tsx | 37 ++--- ui/src/checks/components/ChecksColumn.tsx | 10 ++ .../checks/components/CreateCheckDropdown.tsx | 32 ++++- ui/src/cloud/actions/limits.ts | 5 + ui/src/cloud/components/AssetLimitButton.tsx | 48 +++++++ ui/src/cloud/components/AssetLimitOverlay.tsx | 71 ++++++++++ ui/src/cloud/utils/limits.ts | 25 ++-- .../dashboard_index/DashboardsIndex.tsx | 15 +- .../overlays/components/OverlayController.tsx | 4 + ui/src/overlays/reducers/overlays.ts | 1 + .../shared/components/AddResourceDropdown.tsx | 43 +++++- .../shared/components/CloudUpgradeButton.tsx | 4 +- ui/src/shared/components/cloud/CloudOnly.scss | 132 ++++++++++++------ ui/src/tasks/components/TasksHeader.tsx | 12 +- ui/src/types/alerting.ts | 7 + 17 files changed, 374 insertions(+), 124 deletions(-) create mode 100644 ui/src/cloud/components/AssetLimitButton.tsx create mode 100644 ui/src/cloud/components/AssetLimitOverlay.tsx diff --git a/CHANGELOG.md b/CHANGELOG.md index 4afa393376d..fc0679eb1fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,20 +3,21 @@ ### Breaking 1. [19066](https://github.com/influxdata/influxdb/pull/19066): Drop deprecated /packages route tree -1. [19116](https://github.com/influxdata/influxdb/pull/19116): Support more types for template envRef default value and require explicit default values +1. [19116](https://github.com/influxdata/influxdb/pull/19116): Support more types for template envRef default value and require explicit default values ### Features 1. [19075](https://github.com/influxdata/influxdb/pull/19075): Add resource links to a stack's resources from public HTTP API list/read calls +1. [19103](https://github.com/influxdata/influxdb/pull/19103): Enhance resource creation experience when limits are reached ### Bug Fixes 1. [19043](https://github.com/influxdata/influxdb/pull/19043): Enforce all influx CLI flag args are valid - ## v2.0.0-beta.15 [2020-07-23] ### Breaking + 1. [19004](https://github.com/influxdata/influxdb/pull/19004): Removed the `migrate` command from the `influxd` binary. 1. [18921](https://github.com/influxdata/influxdb/pull/18921): Restricted UI variable names to not clash with Flux reserved words @@ -41,7 +42,6 @@ 1. [18989](https://github.com/influxdata/influxdb/pull/18989): Stopped fetching tags in the advanced builder 1. [19044](https://github.com/influxdata/influxdb/pull/19044): Graph customization: X and Y axis properly accept values - ## v2.0.0-beta.14 [2020-07-08] ### Features diff --git a/ui/src/alerting/components/AlertsColumn.tsx b/ui/src/alerting/components/AlertsColumn.tsx index a0eaf390b33..a4145ce885f 100644 --- a/ui/src/alerting/components/AlertsColumn.tsx +++ b/ui/src/alerting/components/AlertsColumn.tsx @@ -3,8 +3,8 @@ import React, {FC, ReactChild, useState} from 'react' import {connect} from 'react-redux' // Types -import {AppState, ResourceType} from 'src/types' -import {LimitStatus} from 'src/cloud/actions/limits' +import {AppState, ResourceType, ColumnTypes} from 'src/types' +import {LimitStatus, MonitoringLimits} from 'src/cloud/actions/limits' // Components import { @@ -20,14 +20,17 @@ import { ComponentColor, } from '@influxdata/clockface' import AssetLimitAlert from 'src/cloud/components/AssetLimitAlert' +import AssetLimitButton from 'src/cloud/components/AssetLimitButton' // Utils -import {extractMonitoringLimitStatus} from 'src/cloud/utils/limits' +import { + extractChecksLimits, + extractRulesLimits, + extractEndpointsLimits, +} from 'src/cloud/utils/limits' -type ColumnTypes = - | ResourceType.NotificationRules - | ResourceType.NotificationEndpoints - | ResourceType.Checks +// Constants +import {CLOUD} from 'src/shared/constants' interface OwnProps { type: ColumnTypes @@ -38,7 +41,7 @@ interface OwnProps { } interface StateProps { - limitStatus: LimitStatus + limitStatus: MonitoringLimits } const AlertsColumnHeader: FC = ({ @@ -53,6 +56,20 @@ const AlertsColumnHeader: FC = ({ const formattedTitle = title.toLowerCase().replace(' ', '-') const panelClassName = `alerting-index--column alerting-index--${formattedTitle}` + const resourceName = title.substr(0, title.length - 1) + + const isLimitExceeded = + CLOUD && + limitStatus[type] === LimitStatus.EXCEEDED && + type !== ResourceType.Checks + + const assetLimitButton = ( + + ) return ( = ({ tooltipContents={questionMarkTooltipContents} /> - {createButton} + {isLimitExceeded ? assetLimitButton : createButton}
= ({ >
{children(searchTerm)} - +
@@ -98,7 +118,11 @@ const AlertsColumnHeader: FC = ({ const mstp = ({cloud: {limits}}: AppState) => { return { - limitStatus: extractMonitoringLimitStatus(limits), + limitStatus: { + [ResourceType.Checks]: extractChecksLimits(limits), + [ResourceType.NotificationRules]: extractRulesLimits(limits), + [ResourceType.NotificationEndpoints]: extractEndpointsLimits(limits), + }, } } diff --git a/ui/src/buckets/components/CreateBucketButton.tsx b/ui/src/buckets/components/CreateBucketButton.tsx index 1b29b0491c9..f0a93ebf639 100644 --- a/ui/src/buckets/components/CreateBucketButton.tsx +++ b/ui/src/buckets/components/CreateBucketButton.tsx @@ -3,12 +3,8 @@ 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' +import AssetLimitButton from 'src/cloud/components/AssetLimitButton' // Actions import {checkBucketLimits, LimitStatus} from 'src/cloud/actions/limits' @@ -20,10 +16,12 @@ import {extractBucketLimits} from 'src/cloud/utils/limits' // Types import {AppState} from 'src/types' +// Constants +import {CLOUD} from 'src/shared/constants' + type ReduxProps = ConnectedProps -type Props = ReduxProps -const CreateBucketButton: FC = ({ +const CreateBucketButton: FC = ({ limitStatus, onShowOverlay, onDismissOverlay, @@ -34,33 +32,22 @@ const CreateBucketButton: FC = ({ dispatch(checkBucketLimits()) }, [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 - } - onShowOverlay('create-bucket', null, onDismissOverlay) } + if (CLOUD && limitStatus === LimitStatus.EXCEEDED) { + return + } + return (