Skip to content

Commit

Permalink
feat(multi-org): render RateLimitAlert.tsx in global header when mult…
Browse files Browse the repository at this point in the history
…iOrg flag is on (#5549)
  • Loading branch information
ChitlangeSahas authored Sep 1, 2022
1 parent decf176 commit 0e499bf
Show file tree
Hide file tree
Showing 28 changed files with 107 additions and 43 deletions.
3 changes: 2 additions & 1 deletion src/accounts/AccountHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React, {FC} from 'react'
import {Page} from '@influxdata/clockface'
import RateLimitAlert from 'src/cloud/components/RateLimitAlert'
import LimitChecker from 'src/cloud/components/LimitChecker'
import {isFlagEnabled} from 'src/shared/utils/featureFlag'

type Props = {
testID?: string
Expand All @@ -13,7 +14,7 @@ const AccountHeader: FC<Props> = ({testID = 'member-page--header'}) => (
<Page.Header fullWidth={true} testID={testID}>
<Page.Title title="Account" />
<LimitChecker>
<RateLimitAlert location="account" />
{!isFlagEnabled('multiOrg') && <RateLimitAlert location="account" />}
</LimitChecker>
</Page.Header>
)
Expand Down
3 changes: 2 additions & 1 deletion src/alerting/components/AlertHistoryIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {ResourceIDs} from 'src/checks/reducers'
import {ResourceType, AlertHistoryType, AppState} from 'src/types'
import {RouteComponentProps} from 'react-router-dom'
import TimeZoneDropdown from 'src/shared/components/TimeZoneDropdown'
import {isFlagEnabled} from 'src/shared/utils/featureFlag'

export const ResourceIDsContext = createContext<ResourceIDs>(null)

Expand Down Expand Up @@ -82,7 +83,7 @@ const AlertHistoryIndex: FC<Props> = ({
title="Check Statuses"
testID="alert-history-title"
/>
<RateLimitAlert />
{!isFlagEnabled('multiOrg') && <RateLimitAlert />}
</Page.Header>
<Page.ControlBar fullWidth={true}>
<Page.ControlBarRight>
Expand Down
6 changes: 4 additions & 2 deletions src/alerting/components/AlertingIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
ThresholdCheckOverlay,
DeadmanCheckOverlay as NewDeadmanCheckEO,
} from 'src/overlays/components'
import {FeatureFlag} from 'src/shared/utils/featureFlag'
import {FeatureFlag, isFlagEnabled} from 'src/shared/utils/featureFlag'

// Utils
import {pageTitleSuffixer} from 'src/shared/utils/pageTitles'
Expand Down Expand Up @@ -65,7 +65,9 @@ const AlertingIndex: FunctionComponent = () => {
<Page.Header fullWidth={true} testID="alerts-page--header">
<Page.Title title="Alerts" />
<ErrorBoundary>
<RateLimitAlert location="alerting" />
{!isFlagEnabled('multiOrg') && (
<RateLimitAlert location="alerting" />
)}
</ErrorBoundary>
</Page.Header>
<Page.Contents
Expand Down
5 changes: 4 additions & 1 deletion src/billing/components/BillingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import LimitChecker from 'src/cloud/components/LimitChecker'
// Utils
import {pageTitleSuffixer} from 'src/shared/utils/pageTitles'
import AccountTabContainer from 'src/accounts/AccountTabContainer'
import {isFlagEnabled} from 'src/shared/utils/featureFlag'

const BillingPage: FC = () => {
return (
Expand All @@ -19,7 +20,9 @@ const BillingPage: FC = () => {
<Page.Header fullWidth={true} testID="billing-page--header">
<Page.Title title="Account" />
<LimitChecker>
<RateLimitAlert location="billing" />
{!isFlagEnabled('multiOrg') && (
<RateLimitAlert location="billing" />
)}
</LimitChecker>
</Page.Header>
<AccountTabContainer activeTab="billing">
Expand Down
5 changes: 4 additions & 1 deletion src/checks/components/CheckHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {pageTitleSuffixer} from 'src/shared/utils/pageTitles'

// Types
import {AppState, ResourceType} from 'src/types'
import {isFlagEnabled} from 'src/shared/utils/featureFlag'

const CheckHistory: FC = () => {
const resourceIDs = useSelector((state: AppState) => ({
Expand Down Expand Up @@ -57,7 +58,9 @@ const CheckHistory: FC = () => {
title="Check Statuses"
testID="alert-history-title"
/>
<RateLimitAlert location="check history" />
{!isFlagEnabled('multiOrg') && (
<RateLimitAlert location="check history" />
)}
</Page.Header>
<Page.ControlBar fullWidth={true}>
<Page.ControlBarLeft>
Expand Down
8 changes: 8 additions & 0 deletions src/cloud/components/RateLimitAlert.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,11 @@
display: flex;
align-items: center;
}

.cf-panel--body__xs {
padding: 8px;
}

.cf-banner-panel .cf-panel--body__xs .cf-banner-panel--icon {
margin-right: 0;
}
7 changes: 7 additions & 0 deletions src/cloud/components/RateLimitAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ interface Props {
location?: string
}

const bannerStyle = {border: 'none', borderRadius: '6px'}

const RateLimitAlert: FC<Props> = ({alertOnly, className, location}) => {
const resources = useSelector(extractRateLimitResources)
const status = useSelector(extractRateLimitStatus)
Expand All @@ -68,6 +70,7 @@ const RateLimitAlert: FC<Props> = ({alertOnly, className, location}) => {
dispatch(showOverlay('write-limit', null, () => dispatch(dismissOverlay)))
}

// notification for write limit reached
useEffect(() => {
if (CLOUD && status === 'exceeded' && resources.includes('write')) {
if (showUpgrade) {
Expand Down Expand Up @@ -110,6 +113,7 @@ const RateLimitAlert: FC<Props> = ({alertOnly, className, location}) => {
? IconFont.AlertTriangle
: IconFont.Cloud

// banner panel for cardinality limit exceeded
if (CLOUD && status === 'exceeded' && resources.includes('cardinality')) {
return (
<FlexBox
Expand All @@ -124,13 +128,15 @@ const RateLimitAlert: FC<Props> = ({alertOnly, className, location}) => {
icon={icon}
hideMobileIcon={true}
textColor={InfluxColors.Yeti}
style={bannerStyle}
>
<RateLimitAlertContent />
</BannerPanel>
</FlexBox>
)
}

// upgrade button
if (CLOUD && !alertOnly) {
return (
<CloudUpgradeButton
Expand All @@ -155,6 +161,7 @@ const RateLimitAlert: FC<Props> = ({alertOnly, className, location}) => {
}
)
}}
size={ComponentSize.ExtraSmall}
/>
)
}
Expand Down
4 changes: 3 additions & 1 deletion src/cloud/components/RateLimitAlertContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,9 @@ export const UpgradeContent: FC<UpgradeProps> = ({
return (
<div className={`${className} rate-alert--content__free`}>
<FlexBox
justifyContent={JustifyContent.Center}
justifyContent={JustifyContent.SpaceBetween}
className="rate-alert--button"
stretchToFitWidth={true}
>
<UpgradeMessage
{...{isCredit250ExperienceActive, limitText, link, type}}
Expand Down Expand Up @@ -138,6 +139,7 @@ export const UpgradeContent: FC<UpgradeProps> = ({
}
)
}}
size={ComponentSize.ExtraSmall}
/>
</FlexBox>
</div>
Expand Down
5 changes: 4 additions & 1 deletion src/dashboards/components/DashboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
DASHBOARD_ID,
} from 'src/shared/constants/routes'
import ErrorBoundary from 'src/shared/components/ErrorBoundary'
import {isFlagEnabled} from 'src/shared/utils/featureFlag'

const dashRoute = `/${ORGS}/${ORG_ID}/${DASHBOARDS}/${DASHBOARD_ID}`

Expand All @@ -62,7 +63,9 @@ const SingleDashboardPage: FC<ManualRefreshProps> = ({
return (
<>
<DashboardHeader onManualRefresh={onManualRefresh} />
<RateLimitAlert alertOnly={true} location="dashboard page" />
{!isFlagEnabled('multiOrg') && (
<RateLimitAlert alertOnly={true} location="dashboard page" />
)}
<VariablesControlBar />
<ErrorBoundary>
<DashboardComponent manualRefresh={manualRefresh} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {SortTypes} from 'src/shared/utils/sort'
import {DashboardSortKey} from 'src/shared/components/resource_sort_dropdown/generateSortItems'

import ErrorBoundary from 'src/shared/components/ErrorBoundary'
import {isFlagEnabled} from 'src/shared/utils/featureFlag'

type ReduxProps = ConnectedProps<typeof connector>
type Props = ReduxProps & RouteComponentProps<{orgID: string}>
Expand Down Expand Up @@ -120,7 +121,9 @@ class DashboardIndex extends PureComponent<Props, State> {
>
<Page.Header fullWidth={true}>
<Page.Title title="Dashboards" />
<RateLimitAlert location="dashboards" />
{!isFlagEnabled('multiOrg') && (
<RateLimitAlert location="dashboards" />
)}
</Page.Header>
<Page.ControlBar fullWidth={true}>
<ErrorBoundary>
Expand Down
6 changes: 4 additions & 2 deletions src/dataExplorer/components/DataExplorerPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import RenamablePageTitle from 'src/pageLayout/components/RenamablePageTitle'
// Utils
import {pageTitleSuffixer} from 'src/shared/utils/pageTitles'
import {event, useLoadTimeReporting} from 'src/cloud/utils/reporting'
import {FeatureFlag} from 'src/shared/utils/featureFlag'
import {FeatureFlag, isFlagEnabled} from 'src/shared/utils/featureFlag'

// Types
import {ResourceType} from 'src/types'
Expand Down Expand Up @@ -98,7 +98,9 @@ const DataExplorerPageHeader: FC = () => {
/>
</FlexBox>
</FeatureFlag>
<RateLimitAlert location="data explorer" />
{!isFlagEnabled('multiOrg') && (
<RateLimitAlert location="data explorer" />
)}
</FlexBox>
</Page.Header>
)
Expand Down
2 changes: 1 addition & 1 deletion src/flows/components/FlowsIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ const FlowsIndex = () => {
stretchToFitWidth
>
<Page.Title title={PROJECT_NAME_PLURAL} />
<RateLimitAlert location="flows" />
{!isFlagEnabled('multiOrg') && <RateLimitAlert location="flows" />}
</FlexBox>
)}
{showButtonMode &&
Expand Down
5 changes: 4 additions & 1 deletion src/homepageExperience/containers/ArduinoWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {event} from 'src/cloud/utils/reporting'
import {HOMEPAGE_NAVIGATION_STEPS_ARDUINO} from 'src/homepageExperience/utils'
import {normalizeEventName} from 'src/cloud/utils/reporting'
import RateLimitAlert from 'src/cloud/components/RateLimitAlert'
import {isFlagEnabled} from 'src/shared/utils/featureFlag'

interface State {
currentStep: number
Expand Down Expand Up @@ -173,7 +174,9 @@ export class ArduinoWizard extends PureComponent<{}, State> {
<Page.Header fullWidth={false}>
{/* Need an empty div so the upgrade button aligns to the right. (Because clockface uses space-between to justifyContent)*/}
<div />
<RateLimitAlert location="firstMile.arduinoWizard" />
{!isFlagEnabled('multiOrg') && (
<RateLimitAlert location="firstMile.arduinoWizard" />
)}
</Page.Header>
<Page.Contents scrollable={true}>
<div className="homepage-wizard-container">
Expand Down
5 changes: 4 additions & 1 deletion src/homepageExperience/containers/CliWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {event} from 'src/cloud/utils/reporting'
import {HOMEPAGE_NAVIGATION_STEPS_SHORT} from 'src/homepageExperience/utils'
import {normalizeEventName} from 'src/cloud/utils/reporting'
import RateLimitAlert from 'src/cloud/components/RateLimitAlert'
import {isFlagEnabled} from 'src/shared/utils/featureFlag'

interface State {
currentStep: number
Expand Down Expand Up @@ -169,7 +170,9 @@ export class CliWizard extends PureComponent<{}, State> {
<Page.Header fullWidth={false}>
{/* Need an empty div so the upgrade button aligns to the right. (Because clockface uses space-between to justifyContent)*/}
<div />
<RateLimitAlert location="firstMile.cliWizard" />
{!isFlagEnabled('multiOrg') && (
<RateLimitAlert location="firstMile.cliWizard" />
)}
</Page.Header>
<Page.Contents scrollable={true}>
<div className="homepage-wizard-container">
Expand Down
5 changes: 4 additions & 1 deletion src/homepageExperience/containers/GoWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {HOMEPAGE_NAVIGATION_STEPS} from 'src/homepageExperience/utils'
// Utils
import {event} from 'src/cloud/utils/reporting'
import RateLimitAlert from 'src/cloud/components/RateLimitAlert'
import {isFlagEnabled} from 'src/shared/utils/featureFlag'

interface State {
currentStep: number
Expand Down Expand Up @@ -172,7 +173,9 @@ export class GoWizard extends PureComponent<null, State> {
<Page.Header fullWidth={false}>
{/* Need an empty div so the upgrade button aligns to the right. (Because clockface uses space-between to justifyContent)*/}
<div />
<RateLimitAlert location="firstMile.homepage" />
{!isFlagEnabled('multiOrg') && (
<RateLimitAlert location="firstMile.homepage" />
)}
</Page.Header>
<Page.Contents scrollable={true}>
<div className="homepage-wizard-container">
Expand Down
4 changes: 3 additions & 1 deletion src/homepageExperience/containers/HomepageContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ export const HomepageContainer: FC = () => {
>
Get Started
</Heading>
<RateLimitAlert location="firstMile.homepage" />
{!isFlagEnabled('multiOrg') && (
<RateLimitAlert location="firstMile.homepage" />
)}
</Page.Header>
<Page.Contents scrollable={true} fullWidth={true}>
<Grid>
Expand Down
5 changes: 4 additions & 1 deletion src/homepageExperience/containers/NodejsWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {HOMEPAGE_NAVIGATION_STEPS} from 'src/homepageExperience/utils'
// Utils
import {event} from 'src/cloud/utils/reporting'
import RateLimitAlert from 'src/cloud/components/RateLimitAlert'
import {isFlagEnabled} from 'src/shared/utils/featureFlag'

interface State {
currentStep: number
Expand Down Expand Up @@ -172,7 +173,9 @@ export class NodejsWizard extends PureComponent<null, State> {
<Page.Header fullWidth={false}>
{/* Need an empty div so the upgrade button aligns to the right. (Because clockface uses space-between to justifyContent)*/}
<div />
<RateLimitAlert location="firstMile.homepage" />
{!isFlagEnabled('multiOrg') && (
<RateLimitAlert location="firstMile.homepage" />
)}
</Page.Header>

<Page.Contents scrollable={true}>
Expand Down
5 changes: 4 additions & 1 deletion src/homepageExperience/containers/PythonWizard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import {HOMEPAGE_NAVIGATION_STEPS} from 'src/homepageExperience/utils'
// Utils
import {event} from 'src/cloud/utils/reporting'
import RateLimitAlert from 'src/cloud/components/RateLimitAlert'
import {isFlagEnabled} from 'src/shared/utils/featureFlag'

interface State {
currentStep: number
Expand Down Expand Up @@ -175,7 +176,9 @@ export class PythonWizard extends PureComponent<null, State> {
<Page.Header fullWidth={false}>
{/* Need an empty div so the upgrade button aligns to the right. (Because clockface uses space-between to justifyContent)*/}
<div />
<RateLimitAlert location="firstMile.homepage" />
{!isFlagEnabled('multiOrg') && (
<RateLimitAlert location="firstMile.homepage" />
)}
</Page.Header>
<Page.Contents scrollable={true}>
<div className="homepage-wizard-container">
Expand Down
29 changes: 19 additions & 10 deletions src/identity/components/GlobalHeader/GlobalHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ import {
} from 'src/identity/components/GlobalHeader/DefaultEntities'
import {alphaSortSelectedFirst} from 'src/identity/utils/alphaSortSelectedFirst'
import IdentityUserAvatar from 'src/identity/components/GlobalHeader/IdentityUserAvatar'
import RateLimitAlert from 'src/cloud/components/RateLimitAlert'

const caretStyle = {fontSize: '18px', color: InfluxColors.Grey65}
const rightHandContainerStyle = {width: '700px', marginLeft: 'auto'}

export const GlobalHeader: FC = () => {
const dispatch = useDispatch()
Expand Down Expand Up @@ -89,8 +93,6 @@ export const GlobalHeader: FC = () => {
shouldLoadDropdowns || shouldLoadAvatar
)

const caretStyle = {fontSize: '18px', color: InfluxColors.Grey65}

return shouldLoadGlobalHeader ? (
<FlexBox
className="multiaccountorg--header"
Expand All @@ -110,14 +112,21 @@ export const GlobalHeader: FC = () => {
</FlexBox>
)}

{shouldLoadAvatar && (
<IdentityUserAvatar
email={user.email}
firstName={avatarFirstName}
lastName={avatarLastName}
orgId={org.id}
/>
)}
<FlexBox
margin={ComponentSize.Large}
style={rightHandContainerStyle}
justifyContent={JustifyContent.FlexEnd}
>
<RateLimitAlert location="global header" />
{shouldLoadAvatar && (
<IdentityUserAvatar
email={user.email}
firstName={avatarFirstName}
lastName={avatarLastName}
orgId={org.id}
/>
)}
</FlexBox>
</FlexBox>
) : null
}
Loading

0 comments on commit 0e499bf

Please sign in to comment.