-
- {edit && (
-
- See our{' '}
-
- parsing documentation
- {' '}
- for examples, or validate your parsing rules using{' '}
-
- JSONPath.
- {' '}
-
- )}
-
- Timestamp
-
-
-
- !!formContent.jsonTimestamp?.path
- ? handleJsonPathValidation(formContent.jsonTimestamp?.path)
- : null
- }
- placeholder="eg. $.myJSON.myObject[0].timestampKey"
- name="timestamp"
- onChange={e => {
- updateForm({
- ...formContent,
- jsonTimestamp: {
- ...formContent.jsonTimestamp,
- path: e.target.value,
- },
- })
- }}
- onBlur={() =>
- event(
- 'completed form field',
- {formField: 'jsonTimestamp.path'},
- {feature: 'subscriptions'}
- )
- }
- testID="timestamp-json-parsing"
- edit={edit}
- tooltip={JSON_TOOLTIP}
- width="75%"
- />
-
-
- (
-
- {Object.keys(PrecisionTypes).find(
- k => PrecisionTypes[k] === formContent.timestampPrecision
- )}
-
- )}
- menu={onCollapse => (
-
- {Object.keys(PrecisionTypes).map(key => (
- {
- event(
- 'completed form field',
- {
- formField: 'timestampPrecision',
- selected: PrecisionTypes[key],
- },
- {feature: 'subscriptions'}
- )
- formContent.timestampPrecision = PrecisionTypes[key]
- }}
- selected={
- formContent.timestampPrecision === PrecisionTypes[key]
- }
- testID={`json-timestamp-precision-${key}`}
- >
- {key}
-
- ))}
-
- )}
- />
-
-
-
-
-
- Measurement
-
-
- JSON Path
- {
- setUseStaticMeasurement(!useStaticMeasurement)
- updateForm({
- ...formContent,
- jsonMeasurementKey: {
- ...formContent.jsonMeasurementKey,
- name: '',
- path: '',
- },
- })
- }}
- disabled={!edit}
- />
- Name
-
-
- {useStaticMeasurement ? (
- {
- return (
- handleValidation(
- 'Measurement Name',
- formContent.jsonMeasurementKey.name
- ) ??
- handleAvroValidation(
- 'measurement',
- formContent.jsonMeasurementKey.name
- )
- )
- }}
- placeholder="measurement_name"
- name="name"
- onChange={e => {
- updateForm({
- ...formContent,
- jsonMeasurementKey: {
- ...formContent.jsonMeasurementKey,
- name: e.target.value,
- },
- })
- }}
- onBlur={() =>
- event(
- 'completed form field',
- {formField: 'jsonMeasurementKey.name'},
- {feature: 'subscriptions'}
- )
- }
- edit={edit}
- testID="measurement-json-parsing-name"
- tooltip="Provide a static measurement for your messages."
- width="75%"
- />
- ) : (
- {
- const path = formContent.jsonMeasurementKey.path
- return (
- handleValidation('Measurement Path', path) ??
- handleJsonPathValidation(path)
- )
- }}
- placeholder="eg. $.myJSON.myObject[0].myKey"
- name="jsonpath"
- onChange={e => {
- updateForm({
- ...formContent,
- jsonMeasurementKey: {
- ...formContent.jsonMeasurementKey,
- path: e.target.value,
- },
- })
- }}
- onBlur={() =>
- event(
- 'completed form field',
- {formField: 'jsonMeasurementKey.path'},
- {feature: 'subscriptions'}
- )
- }
- edit={edit}
- testID="measurement-json-parsing-path"
- tooltip={JSON_TOOLTIP}
- width="75%"
- />
- )}
-
-
- (
-
- {sanitizeType(formContent.jsonMeasurementKey.type) ??
- dataTypeM}
-
- )}
- menu={onCollapse => (
-
- {dataTypeList.map((d, key) => (
- {
- event(
- 'completed form field',
- {formField: 'jsonMeasurementKey.type', selected: d},
- {feature: 'subscriptions'}
- )
- setDataTypeM(d)
- formContent.jsonMeasurementKey.type = d.toLowerCase()
- }}
- selected={dataTypeM === d}
- testID={`measurement-json-parsing-type-${key}`}
- >
- {d}
-
- ))}
-
- )}
- />
-
-
-
-
-
-
- {formContent.jsonTagKeys.map((_, key) => (
-
- ))}
- {formContent.jsonFieldKeys.map((_, key) => (
-
- ))}
-
- (
-
- Add Rule
-
- )}
- menu={onCollapse => (
-
- {ruleList.map((r, key) => (
- {
- event(
- 'added json parsing rule',
- {ruleType: r},
- {feature: 'subscriptions'}
- )
- setRule(r)
- }}
- selected={rule === r}
- testID={`json-parsing-add-rule-${key}`}
- >
- {r}
-
- ))}
-
- )}
- />
-
- {/* For a later iteration */}
- {/*
- Validate your Parsing Rules
- */}
-
- )
-}
-export default JsonParsingForm
diff --git a/src/writeData/subscriptions/components/JsonPathInput.tsx b/src/writeData/subscriptions/components/JsonPathInput.tsx
deleted file mode 100644
index 8979a059f4..0000000000
--- a/src/writeData/subscriptions/components/JsonPathInput.tsx
+++ /dev/null
@@ -1,273 +0,0 @@
-// Libraries
-import React, {FC, useState} from 'react'
-
-// Components
-import {
- Grid,
- Form,
- Dropdown,
- ButtonShape,
- IconFont,
- ComponentColor,
- ConfirmationButton,
- Heading,
- HeadingElement,
- FontWeight,
- AlignItems,
- ComponentSize,
- FlexDirection,
- FlexBox,
- ComponentStatus,
-} from '@influxdata/clockface'
-
-// Types
-import {Subscription} from 'src/types/subscriptions'
-
-// Utils
-import {
- handleJsonPathValidation,
- handleValidation,
- JSON_TOOLTIP,
- sanitizeType,
- dataTypeList,
- handleAvroValidation,
- handleDuplicateFieldTagName,
-} from 'src/writeData/subscriptions/utils/form'
-import {event} from 'src/cloud/utils/reporting'
-import ValidationInputWithTooltip from 'src/writeData/subscriptions/components/ValidationInputWithTooltip'
-
-interface Props {
- name: string
- updateForm: (any) => void
- formContent: Subscription
- itemNum: number
- edit: boolean
-}
-
-const JsonPathInput: FC