Skip to content

Commit 31ae348

Browse files
authored
feat(HelpBar): Display support overlays for payg and free accounts (#4382)
* feat: create overlays for contact support page * feat: render overlays depending on user account * chore: clean up * feat: free account overlay * feat: pay g overlay * feat: add mstp to access state
1 parent 541f56c commit 31ae348

File tree

6 files changed

+133
-4
lines changed

6 files changed

+133
-4
lines changed

src/overlays/components/OverlayController.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ import NewRuleOverlay from 'src/notifications/rules/components/NewRuleOverlay'
3939
import CreateSecretOverlay from 'src/secrets/components/CreateSecret/CreateSecretOverlay'
4040
import VariableImportOverlay from 'src/variables/components/VariableImportOverlay'
4141
import ShareOverlay from 'src/flows/components/ShareOverlay'
42+
import PayGSupportOverlay from 'src/support/components/PayGSupportOverlay'
43+
import FreeAccountSupportOverlay from 'src/support/components/FreeAccountSupportOverlay'
4244

4345
// Actions
4446
import {dismissOverlay} from 'src/overlays/actions/overlays'
@@ -147,6 +149,12 @@ export const OverlayController: FunctionComponent = () => {
147149
case 'share-overlay':
148150
activeOverlay.current = <ShareOverlay />
149151
break
152+
case 'payg-support':
153+
activeOverlay.current = <PayGSupportOverlay onClose={onClose} />
154+
break
155+
case 'free-account-support':
156+
activeOverlay.current = <FreeAccountSupportOverlay onClose={onClose} />
157+
break
150158
default:
151159
activeOverlay.current = null
152160
break

src/overlays/components/index.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,3 +139,19 @@ export const ExportVariableOverlay = RouteOverlay(
139139
history.push(`/orgs/${params.orgID}/settings/variables`)
140140
}
141141
)
142+
143+
export const PayGSupportOverlay = RouteOverlay(
144+
OverlayHandler,
145+
'payg-support',
146+
(history, params) => {
147+
history.push(`/orgs/${params.orgID}/support`)
148+
}
149+
)
150+
151+
export const FreeAccountSupportOverlay = RouteOverlay(
152+
OverlayHandler,
153+
'free-account-support',
154+
(history, params) => {
155+
history.push(`/orgs/${params.orgID}/support`)
156+
}
157+
)

src/overlays/reducers/overlays.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ export type OverlayID =
3030
| 'create-rule'
3131
| 'create-secret'
3232
| 'share-overlay'
33+
| 'payg-support'
34+
| 'free-account-support'
3335

3436
export interface OverlayState {
3537
id: OverlayID | null

src/pageLayout/containers/TreeNav.tsx

Lines changed: 38 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import React, {FC, useContext, useEffect} from 'react'
33
import {Link} from 'react-router-dom'
44
import {useSelector} from 'react-redux'
5+
import {connect, ConnectedProps} from 'react-redux'
6+
import {withRouter, RouteComponentProps} from 'react-router-dom'
57

68
// Components
79
import {Icon, IconFont, TreeNav} from '@influxdata/clockface'
@@ -22,12 +24,22 @@ import {SafeBlankLink} from 'src/utils/SafeBlankLink'
2224

2325
// Types
2426
import {NavItem, NavSubItem} from 'src/pageLayout/constants/navigationHierarchy'
27+
import {AppState} from 'src/types'
2528

26-
const TreeSidebar: FC = () => {
27-
const org = useSelector(getOrg)
29+
import {showOverlay, dismissOverlay} from 'src/overlays/actions/overlays'
30+
31+
type ReduxProps = ConnectedProps<typeof connector>
32+
33+
const TreeSidebar: FC<ReduxProps & RouteComponentProps> = ({
34+
showOverlay,
35+
dismissOverlay,
36+
quartzMe,
37+
}) => {
2838
const {presentationMode, navbarMode, setNavbarMode} = useContext(
2939
AppSettingContext
3040
)
41+
const org = useSelector(getOrg)
42+
3143
useEffect(() => {
3244
if (isFlagEnabled('helpBar')) {
3345
const helpBarMenu = document.querySelectorAll<HTMLElement>(
@@ -54,6 +66,17 @@ const TreeSidebar: FC = () => {
5466
}
5567
}
5668

69+
const handleSelect = (): void => {
70+
const accountType = quartzMe?.accountType ?? 'free'
71+
const isPayGCustomer = accountType !== 'free'
72+
73+
if (isPayGCustomer) {
74+
showOverlay('payg-support', null, dismissOverlay)
75+
} else {
76+
showOverlay('free-account-support', null, dismissOverlay)
77+
}
78+
}
79+
5780
return (
5881
<OrgSettings>
5982
<TreeNav
@@ -151,7 +174,7 @@ const TreeSidebar: FC = () => {
151174
id="contactSupport"
152175
label="Contact Support"
153176
testID="nav-subitem-contact-support"
154-
linkElement={className => <Link className={className} to="" />}
177+
onClick={handleSelect}
155178
/>
156179
<TreeNav.SubHeading label="Community" />
157180
<TreeNav.SubItem
@@ -185,4 +208,15 @@ const TreeSidebar: FC = () => {
185208
)
186209
}
187210

188-
export default TreeSidebar
211+
const mstp = (state: AppState) => {
212+
return {quartzMe: state.me.quartzMe}
213+
}
214+
215+
const mdtp = {
216+
showOverlay,
217+
dismissOverlay,
218+
}
219+
220+
const connector = connect(mstp, mdtp)
221+
222+
export default connector(withRouter(TreeSidebar))
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import React, {FC, useContext} from 'react'
2+
3+
// Components
4+
import {Overlay} from '@influxdata/clockface'
5+
6+
// Contexts
7+
import {OverlayContext} from 'src/overlays/components/OverlayController'
8+
9+
// Components
10+
import CloudUpgradeButton from 'src/shared/components/CloudUpgradeButton'
11+
12+
interface OwnProps {
13+
onClose: () => void
14+
}
15+
16+
const FreeAccountSupportOverlay: FC<OwnProps> = () => {
17+
const {onClose} = useContext(OverlayContext)
18+
19+
return (
20+
<Overlay.Container maxWidth={550}>
21+
<Overlay.Header
22+
testID="free-support-overlay-header"
23+
title="Contact Support"
24+
onDismiss={onClose}
25+
/>
26+
27+
<Overlay.Body></Overlay.Body>
28+
<Overlay.Footer>
29+
<CloudUpgradeButton />
30+
</Overlay.Footer>
31+
</Overlay.Container>
32+
)
33+
}
34+
35+
export default FreeAccountSupportOverlay
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React, {FC, useContext} from 'react'
2+
3+
// Components
4+
import {Overlay} from '@influxdata/clockface'
5+
6+
// Contexts
7+
import {OverlayContext} from 'src/overlays/components/OverlayController'
8+
9+
// Types
10+
import ErrorBoundary from 'src/shared/components/ErrorBoundary'
11+
12+
interface OwnProps {
13+
onClose: () => void
14+
}
15+
16+
const PayGSupportOverlay: FC<OwnProps> = () => {
17+
const {onClose} = useContext(OverlayContext)
18+
19+
return (
20+
<Overlay.Container maxWidth={500}>
21+
<Overlay.Header
22+
testID="payg-support-overlay-header"
23+
title="Contact Support"
24+
onDismiss={onClose}
25+
/>
26+
27+
<ErrorBoundary>
28+
<Overlay.Body></Overlay.Body>
29+
</ErrorBoundary>
30+
</Overlay.Container>
31+
)
32+
}
33+
34+
export default PayGSupportOverlay

0 commit comments

Comments
 (0)