Skip to content

Commit 50b465d

Browse files
author
Gene Hynson
authored
feat(sub): add enable SSL toggle (#6084)
* feat(sub): add enable SSL toggle * fix: flag name * fix: remove Me import
1 parent 8e08f50 commit 50b465d

File tree

8 files changed

+49
-9
lines changed

8 files changed

+49
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"cy": "CYPRESS_dexUrl=https://$INGRESS_HOST:$PORT_HTTPS CYPRESS_baseUrl=http://localhost:9999 cypress open",
5353
"cy:dev": "source ../monitor-ci/.env && CYPRESS_dexUrl=CLOUD CYPRESS_baseUrl=https://$INGRESS_HOST:$PORT_HTTPS cypress open --config testFiles='{cloud,shared}/**/*.*'",
5454
"cy:dev-oss": "source ../monitor-ci/.env && CYPRESS_dexUrl=OSS CYPRESS_baseUrl=https://$INGRESS_HOST:$PORT_HTTPS cypress open --config testFiles='{oss,shared}/**/*.*'",
55-
"generate": "export SHA=97ca3ce15361c5f5b5654fd32a20df4a31c45cd7 && export REMOTE=https://raw.githubusercontent.com/influxdata/openapi/${SHA}/ && yarn generate-meta",
55+
"generate": "export SHA=f495434ca24ea945785919934e330b3138de03a7 && export REMOTE=https://raw.githubusercontent.com/influxdata/openapi/${SHA}/ && yarn generate-meta",
5656
"generate-local": "export REMOTE=../openapi/ && yarn generate-meta",
5757
"generate-local-cloud": "export REMOTE=../openapi/ && yarn generate-meta-cloud",
5858
"generate-meta": "if [ -z \"${CLOUD_URL}\" ]; then yarn generate-meta-oss; else yarn generate-meta-cloud; fi",

src/types/me.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export {MeState} from 'src/me/reducers'
2-
export {AccountType, Me} from 'src/client/unityRoutes'
2+
export {AccountType} from 'src/client/unityRoutes'

src/types/subscriptions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export interface Subscription {
5151
authType: BrokerAuthTypes
5252
brokerCertCreationDate?: string
5353
clientID?: string
54+
useSSL: boolean
5455
}
5556

5657
export interface SubscriptionStatus {

src/writeData/subscriptions/components/BrokerForm.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@
103103
margin: 0 12px;
104104
margin-bottom: 30px;
105105
}
106+
&__ssl-text {
107+
margin-left: $cf-space-s;
108+
}
106109
}
107110
.cf-status-indicator {
108111
top: unset;

src/writeData/subscriptions/components/BrokerFormContent.tsx

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
Toggle,
2424
InputToggleType,
2525
InputLabel,
26+
SlideToggle,
2627
} from '@influxdata/clockface'
2728
import UserInput from 'src/writeData/subscriptions/components/UserInput'
2829
import CertificateInput from 'src/writeData/subscriptions/components/CertificateInput'
@@ -283,17 +284,40 @@ const BrokerFormContent: FC<Props> = ({
283284
)}
284285
</Form.ValidationElement>
285286
</FlexBox>
287+
{isFlagEnabled('subscriptionsSSLSupport') && (
288+
<FlexBox
289+
direction={FlexDirection.Row}
290+
alignItems={AlignItems.Center}
291+
margin={ComponentSize.Medium}
292+
className="static-toggle"
293+
>
294+
<SlideToggle
295+
active={formContent.useSSL}
296+
onChange={() => {
297+
updateForm({
298+
...formContent,
299+
useSSL: !formContent.useSSL,
300+
})
301+
}}
302+
disabled={!edit}
303+
size={ComponentSize.Medium}
304+
/>
305+
<Heading
306+
element={HeadingElement.H4}
307+
weight={FontWeight.Regular}
308+
className={`${className}-broker-form__ssl-text`}
309+
>
310+
Enable SSL
311+
</Heading>
312+
</FlexBox>
313+
)}
286314
{showHostPortExampleText && (
287315
<Heading
288316
element={HeadingElement.H5}
289317
weight={FontWeight.Regular}
290318
className={`${className}-broker-form__example-text`}
291319
>
292-
{getSchemaFromProtocol(
293-
formContent.protocol,
294-
isFlagEnabled('subscriptionsCertificateSupport') &&
295-
formContent.authType === BrokerAuthTypes.Certificate
296-
)}
320+
{getSchemaFromProtocol(formContent.protocol, formContent)}
297321
{`${formContent.brokerHost}:${
298322
!!formContent.brokerPort && !isNaN(formContent.brokerPort)
299323
? formContent.brokerPort
@@ -457,6 +481,7 @@ const BrokerFormContent: FC<Props> = ({
457481
brokerUsername: null,
458482
brokerPassword: null,
459483
authType: BrokerAuthTypes.Certificate,
484+
useSSL: true,
460485
})
461486
}}
462487
value="certificate"

src/writeData/subscriptions/context/subscription.create.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export const DEFAULT_CONTEXT: SubscriptionCreateContextType = {
7676
},
7777
bucket: 'nifi',
7878
timestampPrecision: 'NS',
79+
useSSL: false,
7980
},
8081
updateForm: () => {},
8182
loading: RemoteDataState.NotStarted,

src/writeData/subscriptions/context/subscription.update.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ export const DEFAULT_CONTEXT: SubscriptionUpdateContextType = {
9494
},
9595
bucket: 'nifi',
9696
timestampPrecision: 'NS',
97+
useSSL: false,
9798
},
9899
updateForm: () => {},
99100
loading: RemoteDataState.NotStarted,

src/writeData/subscriptions/utils/form.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import jsonpath from 'jsonpath'
1212
import {IconFont} from '@influxdata/clockface'
1313
import {Bulletin} from '../context/subscription.list'
14+
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
1415

1516
export const DEFAULT_COMPLETED_STEPS = {
1617
[Steps.BrokerForm]: false,
@@ -504,10 +505,18 @@ export const handleAvroValidation = (property: string, value: string) => {
504505
: null
505506
}
506507

507-
export const getSchemaFromProtocol = (protocol: string, isSecure: boolean) => {
508+
export const getSchemaFromProtocol = (
509+
protocol: string,
510+
formContent: Subscription
511+
) => {
512+
const usingCertAuth =
513+
isFlagEnabled('subscriptionsCertificateSupport') &&
514+
formContent.authType === BrokerAuthTypes.Certificate
515+
const usingSSL =
516+
isFlagEnabled('subscriptionsSSLSupport') && formContent.useSSL
508517
switch (protocol.toLowerCase()) {
509518
case 'mqtt': {
510-
return `mqtt${isSecure ? 's' : ''}://`
519+
return `mqtt${usingCertAuth || usingSSL ? 's' : ''}://`
511520
}
512521
default: {
513522
return 'tcp://'

0 commit comments

Comments
 (0)