File tree Expand file tree Collapse file tree
web/components/pages/environment-settings/tabs/warehouse-tab Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -147,6 +147,8 @@ export interface PipelineStageRequest {
147147 actions : StageActionRequest [ ]
148148}
149149
150+ type WarehouseConfigValue = string | number | boolean
151+
150152export type Req = {
151153 getFeatureCodeReferences : {
152154 projectId : number
@@ -1032,7 +1034,7 @@ export type Req = {
10321034 environmentId : string
10331035 warehouse_type : string
10341036 name ?: string
1035- config ?: Record < string , string | number | boolean >
1037+ config ?: Record < string , WarehouseConfigValue >
10361038 credentials ?: { password : string }
10371039 }
10381040 deleteWarehouseConnection : { environmentId : string ; id : number }
@@ -1041,7 +1043,7 @@ export type Req = {
10411043 environmentId : string
10421044 id : number
10431045 name ?: string
1044- config ?: Record < string , string | number | boolean >
1046+ config ?: Record < string , WarehouseConfigValue >
10451047 credentials ?: { password : string }
10461048 }
10471049 getExperiments : PagedRequest < {
Original file line number Diff line number Diff line change @@ -1290,13 +1290,18 @@ export type ClickHouseConfig = {
12901290 secure : boolean
12911291}
12921292
1293+ export type WarehouseConfigResponse =
1294+ | SnowflakeConfig
1295+ | ClickHouseConfig
1296+ | Record < string , never >
1297+
12931298export type WarehouseConnection = {
12941299 id : number
12951300 warehouse_type : WarehouseType
12961301 status : WarehouseConnectionStatus
12971302 status_detail : string | null
12981303 name : string
1299- config : SnowflakeConfig | ClickHouseConfig | Record < string , never >
1304+ config : WarehouseConfigResponse
13001305 created_at : string
13011306 total_events_received : number | null
13021307 unique_events_count : number | null
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
1111 ClickHouseFormState ,
1212 isClickHouseFormValid ,
1313} from './clickhouseConfig'
14+ import { getButtonLabel } from './warehouseFormUtils'
1415import './ConfigForm.scss'
1516
1617type ClickHouseConfigFormProps = {
@@ -21,11 +22,6 @@ type ClickHouseConfigFormProps = {
2122 initialName ?: string
2223}
2324
24- const getButtonLabel = ( isEdit : boolean , isSaving : boolean ) : string => {
25- if ( isSaving ) return isEdit ? 'Saving...' : 'Creating...'
26- return isEdit ? 'Save changes' : 'Save and continue'
27- }
28-
2925const ClickHouseConfigForm : FC < ClickHouseConfigFormProps > = ( {
3026 initialConfig,
3127 initialName = '' ,
@@ -169,10 +165,17 @@ const ClickHouseConfigForm: FC<ClickHouseConfigFormProps> = ({
169165 ) }
170166
171167 < div className = 'wh-config-form__actions' >
172- < Button theme = 'outline' size = 'small' onClick = { onCancel } type = 'button' >
168+ < Button
169+ id = 'warehouse-config-cancel'
170+ theme = 'outline'
171+ size = 'small'
172+ onClick = { onCancel }
173+ type = 'button'
174+ >
173175 Cancel
174176 </ Button >
175177 < Button
178+ id = 'warehouse-config-save'
176179 theme = 'primary'
177180 size = 'small'
178181 type = 'submit'
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import Button from 'components/base/forms/Button'
33import Input from 'components/base/forms/Input'
44import ErrorMessage from 'components/ErrorMessage'
55import { SnowflakeConfig } from 'common/types/responses'
6+ import { getButtonLabel } from './warehouseFormUtils'
67import './ConfigForm.scss'
78
89export type ConfigFormData = SnowflakeConfig & { name : string }
@@ -15,11 +16,6 @@ type ConfigFormProps = {
1516 initialName ?: string
1617}
1718
18- const getButtonLabel = ( isEdit : boolean , isSaving : boolean ) : string => {
19- if ( isSaving ) return isEdit ? 'Saving...' : 'Creating...'
20- return isEdit ? 'Save changes' : 'Save and continue'
21- }
22-
2319const DEFAULTS : SnowflakeConfig = {
2420 account_identifier : '' ,
2521 database : 'FLAGSMITH' ,
Original file line number Diff line number Diff line change @@ -144,13 +144,13 @@ const WarehouseConnectionCard: FC<WarehouseConnectionCardProps> = ({
144144 ) }
145145 < WarehouseEventCodeHelp />
146146 < div className = 'd-flex justify-content-end mt-3' >
147- { ! isFlagsmith && (
147+ { onTestConnection && (
148148 < Button
149149 id = 'warehouse-connection-test'
150150 theme = 'outline'
151151 size = 'small'
152152 onClick = { onTestConnection }
153- disabled = { ! onTestConnection || isSendingTestEvent }
153+ disabled = { isSendingTestEvent }
154154 >
155155 { isSendingTestEvent ? 'Testing...' : 'Test connection' }
156156 </ Button >
Original file line number Diff line number Diff line change 1+ export const getButtonLabel = ( isEdit : boolean , isSaving : boolean ) : string => {
2+ if ( isSaving ) return isEdit ? 'Saving...' : 'Creating...'
3+ return isEdit ? 'Save changes' : 'Save and continue'
4+ }
You can’t perform that action at this time.
0 commit comments