Skip to content

Commit aa07e2f

Browse files
committed
fix: address review feedback on warehouse frontend
- Only render Test connection button when the handler is provided (backend only supports ClickHouse, not Snowflake) - Add missing id attributes on ClickHouse form buttons for E2E - Extract shared getButtonLabel helper from both config forms - Extract WarehouseConfigValue named type in requests.ts - Extract WarehouseConfigResponse named type in responses.ts
1 parent 6934367 commit aa07e2f

6 files changed

Lines changed: 26 additions & 16 deletions

File tree

frontend/common/types/requests.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ export interface PipelineStageRequest {
147147
actions: StageActionRequest[]
148148
}
149149

150+
type WarehouseConfigValue = string | number | boolean
151+
150152
export 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<{

frontend/common/types/responses.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff 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+
12931298
export 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

frontend/web/components/pages/environment-settings/tabs/warehouse-tab/ClickHouseConfigForm.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
ClickHouseFormState,
1212
isClickHouseFormValid,
1313
} from './clickhouseConfig'
14+
import { getButtonLabel } from './warehouseFormUtils'
1415
import './ConfigForm.scss'
1516

1617
type 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-
2925
const 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'

frontend/web/components/pages/environment-settings/tabs/warehouse-tab/ConfigForm.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Button from 'components/base/forms/Button'
33
import Input from 'components/base/forms/Input'
44
import ErrorMessage from 'components/ErrorMessage'
55
import { SnowflakeConfig } from 'common/types/responses'
6+
import { getButtonLabel } from './warehouseFormUtils'
67
import './ConfigForm.scss'
78

89
export 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-
2319
const DEFAULTS: SnowflakeConfig = {
2420
account_identifier: '',
2521
database: 'FLAGSMITH',

frontend/web/components/pages/environment-settings/tabs/warehouse-tab/WarehouseConnectionCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
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+
}

0 commit comments

Comments
 (0)