Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x 1x 1x 1x 1x 1x 1x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x | /* * Copyright 2022 Harness Inc. All rights reserved. * Use of this source code is governed by the PolyForm Shield 1.0.0 license * that can be found in the licenses directory at the root of this repository, also available at * https://polyformproject.org/wp-content/uploads/2020/06/PolyForm-Shield-1.0.0.txt. */ import React from 'react' import moment from 'moment' import { Layout, PageError } from '@wings-software/uicore' import { useStrings } from 'framework/strings' import { useGetUsageAndLimit } from '@common/hooks/useGetUsageAndLimit' import { ModuleName } from 'framework/types/ModuleName' import { ContainerSpinner } from '@common/components/ContainerSpinner/ContainerSpinner' import UsageInfoCard, { ErrorContainer } from './UsageInfoCard' export interface FFUsageInfoProps { subscribedUsers: number activeUsers: number subscribedMonthlyUsers: number activeMonthlyUsers: number month: string featureFlags: number } interface FeatureFlagsUsersCardProps { subscribedUsers: number activeUsers: number leftHeader?: string rightHeader: string tooltip?: string errors: { usageErrorMsg?: string limitErrorMsg?: string } refetches: { refetchUsage?: () => void refetchLimit?: () => void } } const FeatureFlagsUsersCard: React.FC<FeatureFlagsUsersCardProps> = ({ subscribedUsers, activeUsers, leftHeader, tooltip, rightHeader, errors, refetches }) => { const { getString } = useStrings() const defaultLeftHeader = leftHeader || getString('common.subscriptions.usage.monthlyUsers') const defaultTooltip = tooltip || getString('common.subscriptions.usage.ffActiveUserTootip') const hasBar = true const leftFooter = getString('common.subscribed') const rightFooter = getString('common.subscribed') const props = { subscribed: subscribedUsers, usage: activeUsers, leftHeader: defaultLeftHeader, tooltip: defaultTooltip, rightHeader, hasBar, leftFooter, rightFooter } const { usageErrorMsg, limitErrorMsg } = errors const { refetchUsage, refetchLimit } = refetches Iif (usageErrorMsg) { return ( <ErrorContainer> <PageError message={usageErrorMsg} onClick={refetchUsage} /> </ErrorContainer> ) } Iif (limitErrorMsg) { return ( <ErrorContainer> <PageError message={limitErrorMsg} onClick={refetchLimit} /> </ErrorContainer> ) } return <UsageInfoCard {...props} /> } interface FeatureFlagsProps { featureFlags: number refetch?: () => void error?: string } const FeatureFlags: React.FC<FeatureFlagsProps> = ({ featureFlags, error, refetch }) => { const { getString } = useStrings() const leftHeader = getString('common.purpose.cf.continuous') const tooltip = getString('common.subscriptions.usage.ffFFTooltip') const rightHeader = getString('common.current') const hasBar = false const props = { usage: featureFlags, leftHeader, tooltip, rightHeader, hasBar } Iif (error) { return ( <ErrorContainer> <PageError message={error} onClick={refetch} /> </ErrorContainer> ) } return <UsageInfoCard {...props} /> } const FFUsageInfo: React.FC = () => { const { getString } = useStrings() const { limitData, usageData } = useGetUsageAndLimit(ModuleName.CF) const isLoading = limitData.loadingLimit || usageData.loadingUsage Iif (isLoading) { return <ContainerSpinner /> } const { usageErrorMsg, refetchUsage, usage } = usageData const { limitErrorMsg, refetchLimit, limit } = limitData const currentDate = moment(new Date()) const timeStampAsDate = moment(currentDate) return ( <Layout.Horizontal spacing="large"> <FeatureFlagsUsersCard errors={{ usageErrorMsg, limitErrorMsg }} refetches={{ refetchUsage, refetchLimit }} subscribedUsers={limit?.ff?.totalFeatureFlagUnits || 0} activeUsers={usage?.ff?.activeFeatureFlagUsers?.count || 0} leftHeader={getString('common.subscriptions.usage.developers')} tooltip={getString('common.subscriptions.usage.ffDeveloperTooltip')} rightHeader={usage?.ff?.activeFeatureFlagUsers?.displayName || ''} /> <FeatureFlagsUsersCard errors={{ usageErrorMsg, limitErrorMsg }} refetches={{ refetchUsage, refetchLimit }} subscribedUsers={limit?.ff?.totalClientMAUs || 0} activeUsers={usage?.ff?.activeClientMAUs?.count || 0} rightHeader={timeStampAsDate.format('MMMM YYYY')} /> <FeatureFlags featureFlags={limit?.ff?.totalFeatureFlagUnits || 0} error={limitErrorMsg} refetch={refetchLimit} /> </Layout.Horizontal> ) } export default FFUsageInfo |