Skip to content

Commit f64c95b

Browse files
author
Gene Hynson
authored
feat(sub): certificates coming soon + bug fix (#5052)
1 parent b576f3d commit f64c95b

File tree

13 files changed

+145
-34
lines changed

13 files changed

+145
-34
lines changed

src/dashboards/selectors/index.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ describe('Dashboards.Selector', () => {
113113
theme: 'dark',
114114
versionInfo: {version: '', commit: ''},
115115
flowsCTA: {explorer: true, alerts: true, tasks: true},
116+
subscriptionsCertificateInterest: false,
116117
},
117118
}
118119

@@ -137,6 +138,7 @@ describe('Dashboards.Selector', () => {
137138
theme: 'dark',
138139
versionInfo: {version: '', commit: ''},
139140
flowsCTA: {explorer: true, alerts: true, tasks: true},
141+
subscriptionsCertificateInterest: false,
140142
},
141143
}
142144

@@ -169,6 +171,7 @@ describe('Dashboards.Selector', () => {
169171
theme: 'dark',
170172
versionInfo: {version: '', commit: ''},
171173
flowsCTA: {explorer: true, alerts: true, tasks: true},
174+
subscriptionsCertificateInterest: false,
172175
},
173176
}
174177

@@ -201,6 +204,7 @@ describe('Dashboards.Selector', () => {
201204
theme: 'dark',
202205
versionInfo: {version: '', commit: ''},
203206
flowsCTA: {explorer: true, alerts: true, tasks: true},
207+
subscriptionsCertificateInterest: false,
204208
},
205209
}
206210

@@ -229,6 +233,7 @@ describe('Dashboards.Selector', () => {
229233
theme: 'dark',
230234
versionInfo: {version: '', commit: ''},
231235
flowsCTA: {explorer: true, alerts: true, tasks: true},
236+
subscriptionsCertificateInterest: false,
232237
},
233238
}
234239

src/mockState.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const localState: LocalStorage = {
3535
commit: '',
3636
},
3737
flowsCTA: {alerts: true, explorer: true, tasks: true},
38+
subscriptionsCertificateInterest: false,
3839
},
3940
},
4041
flags: {

src/shared/actions/app.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export enum ActionTypes {
1111
TemplateControlBarVisibilityToggled = 'TemplateControlBarVisibilityToggledAction',
1212
SetFlowsCTA = 'SET_FLOWS_CTA',
1313
Noop = 'NOOP',
14+
SetSubscriptionsCertificateInterest = 'SET_SUB_CERT_INTEREST',
1415
}
1516

1617
export type Action =
@@ -23,6 +24,7 @@ export type Action =
2324
| ReturnType<typeof setTheme>
2425
| ReturnType<typeof setVersionInfo>
2526
| ReturnType<typeof setFlowsCTA>
27+
| ReturnType<typeof setSubscriptionsCertificateInterest>
2628

2729
// ephemeral state action creators
2830

@@ -77,3 +79,8 @@ export const setFlowsCTA = (flowsCTA: FlowsCTA) =>
7779
type: ActionTypes.SetFlowsCTA,
7880
payload: {flowsCTA},
7981
} as const)
82+
83+
export const setSubscriptionsCertificateInterest = () =>
84+
({
85+
type: ActionTypes.SetSubscriptionsCertificateInterest,
86+
} as const)

src/shared/contexts/app.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
enablePresentationMode,
1010
disablePresentationMode,
1111
setFlowsCTA as setFlowsCTAAction,
12+
setSubscriptionsCertificateInterest as setSubscriptionsCertificateInterestAction,
1213
} from 'src/shared/actions/app'
1314
import {
1415
timeZone as timeZoneFromState,
@@ -17,12 +18,14 @@ import {
1718
fluxQueryBuilder as fluxQueryBuilderFromState,
1819
navbarMode as navbarModeFromState,
1920
getFlowsCTA,
21+
getSubscriptionsCertificateInterest,
2022
} from 'src/shared/selectors/app'
2123
import {notify} from 'src/shared/actions/notifications'
2224
import {PRESENTATION_MODE_ANIMATION_DELAY} from 'src/shared/constants'
2325
import {presentationMode as presentationModeCopy} from 'src/shared/copy/notifications'
2426

2527
import {AppState, TimeZone, Theme, NavBarState, FlowsCTA} from 'src/types'
28+
import {event} from 'src/cloud/utils/reporting'
2629

2730
interface AppSettingContextType {
2831
timeZone: TimeZone
@@ -31,13 +34,15 @@ interface AppSettingContextType {
3134
fluxQueryBuilder: boolean
3235
navbarMode: NavBarState
3336
flowsCTA: FlowsCTA
37+
subscriptionsCertificateInterest: boolean
3438

3539
setTimeZone: (zone: TimeZone) => void
3640
setTheme: (theme: Theme) => void
3741
setPresentationMode: (active: boolean) => void
3842
setFluxQueryBuilder: (active: boolean) => void
3943
setNavbarMode: (mode: NavBarState) => void
4044
setFlowsCTA: (flowsCTA: FlowsCTA) => void
45+
setSubscriptionsCertificateInterest: () => void
4146
}
4247

4348
const DEFAULT_CONTEXT: AppSettingContextType = {
@@ -47,13 +52,15 @@ const DEFAULT_CONTEXT: AppSettingContextType = {
4752
fluxQueryBuilder: false,
4853
navbarMode: 'collapsed' as NavBarState,
4954
flowsCTA: {alerts: true, explorer: true, tasks: true} as FlowsCTA,
55+
subscriptionsCertificateInterest: false,
5056

5157
setTimeZone: (_zone: TimeZone) => {},
5258
setTheme: (_theme: Theme) => {},
5359
setPresentationMode: (_active: boolean) => {},
5460
setFluxQueryBuilder: (_active: boolean) => {},
5561
setNavbarMode: (_mode: NavBarState) => {},
5662
setFlowsCTA: (_flowsCTA: FlowsCTA) => {},
63+
setSubscriptionsCertificateInterest: () => {},
5764
}
5865

5966
export const AppSettingContext = React.createContext<AppSettingContextType>(
@@ -68,13 +75,17 @@ export const AppSettingProvider: FC = ({children}) => {
6875
fluxQueryBuilder,
6976
navbarMode,
7077
flowsCTA,
78+
subscriptionsCertificateInterest,
7179
} = useSelector((state: AppState) => ({
7280
timeZone: timeZoneFromState(state),
7381
theme: themeFromState(state),
7482
presentationMode: presentationModeFromState(state),
7583
fluxQueryBuilder: fluxQueryBuilderFromState(state),
7684
navbarMode: navbarModeFromState(state),
7785
flowsCTA: getFlowsCTA(state),
86+
subscriptionsCertificateInterest: getSubscriptionsCertificateInterest(
87+
state
88+
),
7889
}))
7990
const dispatch = useDispatch()
8091

@@ -121,6 +132,10 @@ export const AppSettingProvider: FC = ({children}) => {
121132
},
122133
[dispatch]
123134
)
135+
const setSubscriptionsCertificateInterest = useCallback(() => {
136+
event('certificate auth interest', {}, {feature: 'subscriptions'})
137+
dispatch(setSubscriptionsCertificateInterestAction())
138+
}, [dispatch])
124139

125140
return (
126141
<AppSettingContext.Provider
@@ -131,13 +146,15 @@ export const AppSettingProvider: FC = ({children}) => {
131146
fluxQueryBuilder,
132147
navbarMode,
133148
flowsCTA,
149+
subscriptionsCertificateInterest,
134150

135151
setTimeZone,
136152
setTheme,
137153
setPresentationMode,
138154
setFluxQueryBuilder,
139155
setNavbarMode,
140156
setFlowsCTA,
157+
setSubscriptionsCertificateInterest,
141158
}}
142159
>
143160
{children}

src/shared/reducers/app.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ describe('Shared.Reducers.appReducer', () => {
2424
theme: 'dark',
2525
versionInfo: {version: '', commit: ''},
2626
flowsCTA: {explorer: true, tasks: true, alerts: true},
27+
subscriptionsCertificateInterest: false,
2728
},
2829
}
2930

src/shared/reducers/app.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface AppState {
1818
theme: Theme
1919
versionInfo: VersionInfo
2020
flowsCTA: FlowsCTA
21+
subscriptionsCertificateInterest: boolean
2122
}
2223
}
2324

@@ -34,6 +35,7 @@ const initialState: AppState = {
3435
fluxQueryBuilder: false,
3536
versionInfo: {version: '', commit: ''},
3637
flowsCTA: {explorer: true, tasks: true, alerts: true},
38+
subscriptionsCertificateInterest: false,
3739
},
3840
}
3941

@@ -117,6 +119,13 @@ const appPersistedReducer = (
117119
}
118120
}
119121

122+
case ActionTypes.SetSubscriptionsCertificateInterest: {
123+
return {
124+
...state,
125+
subscriptionsCertificateInterest: true,
126+
}
127+
}
128+
120129
default:
121130
return state
122131
}

src/shared/selectors/app.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,6 @@ export const getFlowsCTA = (state: AppState): FlowsCTA =>
3232

3333
export const getAllFluxFunctions = (state: AppState): FluxFunction[] =>
3434
state.fluxDocs.fluxDocs
35+
36+
export const getSubscriptionsCertificateInterest = (state: AppState): boolean =>
37+
state.app.persisted.subscriptionsCertificateInterest || false

src/writeData/subscriptions/components/BrokerForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const BrokerForm: FC<Props> = ({
8282
<div
8383
className="create-broker-form__fixed"
8484
style={{
85-
width: navbarOpen ? 'calc(75% - 235px)' : 'calc(100% - 374px)',
85+
width: navbarOpen ? 'calc(75% - 225px)' : 'calc(75% - 85px)',
8686
}}
8787
>
8888
<FlexBox

src/writeData/subscriptions/components/BrokerFormContent.tsx

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
ComponentStatus,
2222
} from '@influxdata/clockface'
2323
import UserInput from 'src/writeData/subscriptions/components/UserInput'
24+
import CertificateInput from 'src/writeData/subscriptions/components/CertificateInput'
2425

2526
// Utils
2627
import {handleValidation} from 'src/writeData/subscriptions/utils/form'
@@ -191,7 +192,7 @@ const BrokerFormContent: FC<Props> = ({
191192
handleValidation('Broker Host', formContent.brokerHost)
192193
}
193194
helpText={
194-
edit
195+
className !== 'create' && edit
195196
? 'Changing the hostname will require you to provide your password again.'
196197
: ''
197198
}
@@ -323,24 +324,27 @@ const BrokerFormContent: FC<Props> = ({
323324
titleText="User"
324325
disabled={!edit}
325326
>
326-
User
327+
Basic
328+
</SelectGroup.Option>
329+
<SelectGroup.Option
330+
name="certificate"
331+
id="certificate"
332+
testID="certificate--button"
333+
active={security === 'certificate'}
334+
onClick={() => {
335+
event(
336+
'broker security toggle',
337+
{method: 'certificate', step: 'broker'},
338+
{feature: 'subscriptions'}
339+
)
340+
setSecurity('certificate')
341+
}}
342+
value="certificate"
343+
titleText="Certificate"
344+
disabled={!edit}
345+
>
346+
Certificate
327347
</SelectGroup.Option>
328-
{/* For a later iteration */}
329-
{/* <SelectGroup.Option
330-
name="user"
331-
id="user"
332-
testID="user--button"
333-
active={security === 'certificate'}
334-
onClick={() => {
335-
event('broker security toggle', {method: 'certificate'}, {feature: 'subscriptions'})
336-
setSecurity('certificate')
337-
}}
338-
value={'certificate'}
339-
titleText="Certificate"
340-
disabled={false}
341-
>
342-
Certificate
343-
</SelectGroup.Option> */}
344348
</SelectGroup>
345349
{security === 'user' && (
346350
<UserInput
@@ -350,6 +354,7 @@ const BrokerFormContent: FC<Props> = ({
350354
edit={edit}
351355
/>
352356
)}
357+
{security === 'certificate' && <CertificateInput />}
353358
</Grid.Column>
354359
</Grid.Row>
355360
</Grid>
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
// Libraries
2+
import React, {FC, useContext} from 'react'
3+
4+
// Contexts
5+
import {AppSettingContext} from 'src/shared/contexts/app'
6+
7+
// Components
8+
import {
9+
AlignItems,
10+
ComponentSize,
11+
FlexDirection,
12+
FlexBox,
13+
InputLabel,
14+
Button,
15+
Icon,
16+
IconFont,
17+
} from '@influxdata/clockface'
18+
19+
const CertificateInput: FC = () => {
20+
const {
21+
subscriptionsCertificateInterest,
22+
setSubscriptionsCertificateInterest,
23+
} = useContext(AppSettingContext)
24+
return (
25+
<FlexBox
26+
alignItems={AlignItems.Center}
27+
direction={FlexDirection.Column}
28+
margin={ComponentSize.Large}
29+
>
30+
<InputLabel size={ComponentSize.Large} style={{fontWeight: 'bold'}}>
31+
Coming soon!
32+
</InputLabel>
33+
<InputLabel size={ComponentSize.Medium}>
34+
Interested in using certificates to authenticate with your broker? Let
35+
us know so we can notify you when it's available.
36+
</InputLabel>
37+
{!subscriptionsCertificateInterest && (
38+
<Button
39+
text="Notify me"
40+
onClick={() => setSubscriptionsCertificateInterest()}
41+
/>
42+
)}
43+
{subscriptionsCertificateInterest && (
44+
<InputLabel size={ComponentSize.Large}>
45+
<div>
46+
<Icon glyph={IconFont.Checkmark_New} />
47+
{" You're on the list!"}
48+
</div>
49+
</InputLabel>
50+
)}
51+
</FlexBox>
52+
)
53+
}
54+
export default CertificateInput

0 commit comments

Comments
 (0)