Skip to content

feat: clickhouse warehouse setup UI#8028

Open
Zaimwa9 wants to merge 5 commits into
mainfrom
feat/clickhouse-byo-warehouse-frontend
Open

feat: clickhouse warehouse setup UI#8028
Zaimwa9 wants to merge 5 commits into
mainfrom
feat/clickhouse-byo-warehouse-frontend

Conversation

@Zaimwa9

@Zaimwa9 Zaimwa9 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Thanks for submitting a PR! Please check the boxes below:

  • I have read the Contributing Guide.
  • I have added information to docs/ if required so people know about the feature.
  • I have filled in the "Changes" section below.
  • I have filled in the "How did you test this code" section below.

Changes

Frontend for the clickhouse warehouse connection type, gated behind the clickhouse_warehouse flag (off by default). Builds on the backend in #8020.

  • New ClickHouse config form, visually identical to the Snowflake one: host, name, port, database, username, password and a TLS toggle, with defaults matching the backend. The host is locked when editing; leaving the password blank on edit keeps the stored credentials.
  • The warehouse setup flow offers ClickHouse alongside Flagsmith and Snowflake when the flag is enabled.
  • The connection card wires the Test connection button for ClickHouse and surfaces the new status_detail field: the status tooltip shows the failure reason when the connection is errored, and the test-connection toast reports it instead of a generic message.
  • API layer types updated: write-only credentials, read-only status_detail.

How did you test this code?

Unit tests for the form validation and payload helpers (npm run test:unit -- --testPathPatterns=clickhouseConfig), npm run lint, npm run typecheck (no new errors against the baseline).

Manually: enable the clickhouse_warehouse flag, go to Environment Settings → Warehouse, connect a ClickHouse instance, then edit it and use Test connection to see verification results, including failure reasons.

@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
flagsmith-frontend-preview Ready Ready Preview, Comment Jul 20, 2026 2:51pm
flagsmith-frontend-staging Ready Ready Preview, Comment Jul 20, 2026 2:51pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Ignored Ignored Preview Jul 20, 2026 2:51pm

Request Review

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 55312af4-ff57-4041-a114-41232b0bcf71

📥 Commits

Reviewing files that changed from the base of the PR and between 19b31a1 and aa07e2f.

📒 Files selected for processing (10)
  • frontend/common/types/requests.ts
  • frontend/common/types/responses.ts
  • frontend/web/components/pages/environment-settings/tabs/warehouse-tab/ClickHouseConfigForm.tsx
  • frontend/web/components/pages/environment-settings/tabs/warehouse-tab/ConfigForm.tsx
  • frontend/web/components/pages/environment-settings/tabs/warehouse-tab/WarehouseConnectionCard.tsx
  • frontend/web/components/pages/environment-settings/tabs/warehouse-tab/WarehouseSetup.tsx
  • frontend/web/components/pages/environment-settings/tabs/warehouse-tab/__tests__/clickhouseConfig.test.ts
  • frontend/web/components/pages/environment-settings/tabs/warehouse-tab/clickhouseConfig.ts
  • frontend/web/components/pages/environment-settings/tabs/warehouse-tab/index.tsx
  • frontend/web/components/pages/environment-settings/tabs/warehouse-tab/warehouseFormUtils.ts

📝 Walkthrough

Walkthrough

Adds ClickHouse warehouse request and response types, form validation, payload construction, and tests. Introduces feature-flagged ClickHouse selection, creation, editing, and connection testing in warehouse settings. Updates warehouse cards to display status details, host information, and conditional test actions. Moves shared save-button label logic into a utility and restricts polling to Flagsmith connections.

Estimated code review effort: 3 (Moderate) | ~25 minutes


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.67%. Comparing base (f7a302b) to head (af485e8).
⚠️ Report is 13 commits behind head on feat/clickhouse-byo-warehouse-backend.

Additional details and impacted files
@@                            Coverage Diff                            @@
##           feat/clickhouse-byo-warehouse-backend    #8028      +/-   ##
=========================================================================
+ Coverage                                  98.65%   98.67%   +0.02%     
=========================================================================
  Files                                       1507     1514       +7     
  Lines                                      59866    60930    +1064     
=========================================================================
+ Hits                                       59060    60124    +1064     
  Misses                                       806      806              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Zaimwa9 Zaimwa9 changed the title feat: ClickHouse warehouse setup UI behind clickhouse_warehouse flag feat: clickHouse warehouse setup UI Jul 20, 2026
@Zaimwa9 Zaimwa9 changed the title feat: clickHouse warehouse setup UI feat: clickhouse warehouse setup UI Jul 20, 2026
@Zaimwa9
Zaimwa9 marked this pull request as ready for review July 20, 2026 09:09
@Zaimwa9
Zaimwa9 requested review from a team as code owners July 20, 2026 09:09
@Zaimwa9
Zaimwa9 requested review from khvn26 and talissoncosta and removed request for a team July 20, 2026 09:09
@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Jul 20, 2026
@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-8028 Finished ✅ Skipped
ghcr.io/flagsmith/flagsmith-api:pr-8028 Finished ✅ Results
ghcr.io/flagsmith/flagsmith:pr-8028 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-private-cloud:pr-8028 Finished ✅ Results
ghcr.io/flagsmith/flagsmith-frontend:pr-8028 Finished ✅ Results

@Zaimwa9

Zaimwa9 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@themis-blindfold review

@themis-blindfold

Copy link
Copy Markdown

⚖️ Themis judgement: ✅ Ship it

Adds the ClickHouse warehouse connection type to the frontend, gated behind the clickhouse_warehouse feature flag. The implementation mirrors the existing Snowflake setup flow: a config form with host/port/database/username/password/TLS fields, payload builder that separates credentials from config, and proper create/edit/test-connection wiring. The API types are widened to accommodate ClickHouse's numeric port and boolean TLS flag, and the new status_detail field surfaces error reasons in both the connection card tooltip and the test-connection toast.

The form validation logic and payload builder are extracted into a standalone module with thorough unit tests covering port range validation, required-field checks, edit-mode password handling, and credential separation. The polling guard correctly limits automatic test-connection calls to Flagsmith-type connections while ClickHouse uses manual "Test connection" instead.

🎯 Correctness 5/5
🧪 Test coverage 4/5
📐 Code quality 5/5
🚀 Product impact 3/5
📝 Walkthrough
  • API types (requests.ts, responses.ts) — config widened to string | number | boolean for ClickHouse's port and secure fields; credentials write-only field and status_detail read-only field added to the warehouse connection types.
  • ClickHouse config utilities (clickhouseConfig.ts) — defaults, form state type, port validator, form validator, and payload builder with credential separation, all covered by unit tests.
  • ClickHouseConfigForm — React form component mirroring the Snowflake ConfigForm; reuses the same SCSS; host is locked on edit, blank password preserves stored credentials.
  • WarehouseSetup — ClickHouse card added to the type selector, gated behind clickhouse_warehouse flag; shows "Coming Soon" when the flag is off.
  • WarehouseConnectionCard — status tooltip now appends status_detail for errored connections; subtitle shows ClickHouse host; "Test connection" button is now wirable via onTestConnection prop.
  • WarehouseTab orchestrator (index.tsx) — create/update/test handlers for ClickHouse; edit form rendered for ClickHouse type; polling guard limits auto-test to Flagsmith connections only.
🧪 How to verify
  1. Enable the clickhouse_warehouse flag in your local Flagsmith instance; confirm the ClickHouse card appears in Environment Settings > Warehouse alongside Flagsmith (Snowflake/BigQuery/Databricks remain "Coming Soon").
  2. Fill the ClickHouse form with valid details and submit; verify the connection is created and the card shows the host in the subtitle.
  3. Click "Test connection" on the card — confirm a success toast for reachable instances and a status_detail-bearing error toast for unreachable ones.
  4. Edit the connection: confirm host is locked, leaving password blank preserves the stored credential, and saving updates the connection.
  5. Run npm run test:unit -- --testPathPatterns=clickhouseConfig — all validation and payload tests should pass.

Automate: the unit tests already cover the form logic; a Cypress/E2E test for the full create-edit-test-delete flow would close the gap.

Product take: Solid feature addition that puts ClickHouse on equal footing with the Flagsmith warehouse type for BYO-warehouse users. Properly gated behind a flag so it ships dark — low-risk incremental rollout.

🧭 Assumptions & unverified claims
  • The default port 9440 matches the backend's default for ClickHouse native TLS; I could not verify the backend serialiser defaults since they are on the base branch, not in this diff.
  • The test-warehouse-connection endpoint returns status_detail in its response body — the frontend type says so and the code uses it, but the backend endpoint was not part of this diff.

A warehouse that connects on the first try — now that's a feature worth flagging. · reviewed at af485e8

@Zaimwa9
Zaimwa9 force-pushed the feat/clickhouse-byo-warehouse-frontend branch from af485e8 to 19b31a1 Compare July 20, 2026 09:16
@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  41 seconds
commit  af485e8
info  🔄 Run: #18490 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  46.7 seconds
commit  af485e8
info  🔄 Run: #18490 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  4 passed

Details

stats  4 tests across 4 suites
duration  55.8 seconds
commit  af485e8
info  🔄 Run: #18490 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  11.9 seconds
commit  af485e8
info  🔄 Run: #18490 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  40 seconds
commit  19b31a1
info  🔄 Run: #18491 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  35.8 seconds
commit  19b31a1
info  🔄 Run: #18491 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  5 passed

Details

stats  5 tests across 5 suites
duration  32.4 seconds
commit  19b31a1
info  🔄 Run: #18491 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  6.2 seconds
commit  19b31a1
info  🔄 Run: #18491 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  32.4 seconds
commit  7b7a695
info  🔄 Run: #18494 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  47 seconds
commit  7b7a695
info  🔄 Run: #18494 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  36.3 seconds
commit  7b7a695
info  🔄 Run: #18494 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  32 seconds
commit  7b7a695
info  🔄 Run: #18494 (attempt 1)

@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Visual Regression

19 screenshots compared. See report for details.
View full report

@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Jul 20, 2026
@Zaimwa9

Zaimwa9 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@themis-blindfold review once again but this time focus on the frontend design patterns to make sure the used components follow the snowflake designs. Let's flag whether some scss or classes are duplicated, or could be better implemented.
Can I know why you scored 3/5 in product impact while this is clearly a product-focused new addition?

@Zaimwa9
Zaimwa9 removed the request for review from khvn26 July 20, 2026 09:27

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
frontend/common/types/requests.ts (1)

1031-1046: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Extract the repeated config value union into a named type.

string | number | boolean is duplicated verbatim in both createWarehouseConnection.config and updateWarehouseConnection.config. Extract to a shared type, e.g. type WarehouseConfigValue = string | number | boolean, and reuse it in both places.

As per coding guidelines, "Extract inline union types into named types (for example, use type Status = 'A' | 'B' instead of an inline union)."

♻️ Proposed fix
+type WarehouseConfigValue = string | number | boolean
+
 createWarehouseConnection: {
   environmentId: string
   warehouse_type: string
   name?: string
-  config?: Record<string, string | number | boolean>
+  config?: Record<string, WarehouseConfigValue>
   credentials?: { password: string }
 }
 deleteWarehouseConnection: { environmentId: string; id: number }
 testWarehouseConnection: { environmentId: string; id: number }
 updateWarehouseConnection: {
   environmentId: string
   id: number
   name?: string
-  config?: Record<string, string | number | boolean>
+  config?: Record<string, WarehouseConfigValue>
   credentials?: { password: string }
 }

Source: Coding guidelines

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

92-103: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Duplicated per-type identifier rendering — consider a single lookup.

The account_identifier (Snowflake) and host (ClickHouse) blocks are structurally identical, just keyed on different config fields. As more warehouse types are added (BigQuery/Databricks are already teased in WarehouseSetup), this will keep growing. Consider deriving a single "identifier" value from connection.warehouse_type/connection.config once, and rendering it a single time.

♻️ Illustrative refactor
-{connection.config &&
-  'account_identifier' in connection.config &&
-  connection.config.account_identifier &&
-  `: ${connection.config.account_identifier}`}
-{connection.config &&
-  'host' in connection.config &&
-  connection.config.host &&
-  `: ${connection.config.host}`}
+{getConnectionIdentifier(connection.config) &&
+  `: ${getConnectionIdentifier(connection.config)}`}

147-157: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Permanently-disabled "Test connection" button for non-ClickHouse connections — see consolidated comment.

onTestConnection is undefined for any connection that isn't clickhouse (per index.tsx), yet this button still renders for any !isFlagsmith connection, including Snowflake. The result is a disabled button with no explanation for existing Snowflake connections.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 730e0b0c-7865-4e6d-b738-7dea9f22117f

📥 Commits

Reviewing files that changed from the base of the PR and between f1cd2a5 and 19b31a1.

📒 Files selected for processing (8)
  • frontend/common/types/requests.ts
  • frontend/common/types/responses.ts
  • frontend/web/components/pages/environment-settings/tabs/warehouse-tab/ClickHouseConfigForm.tsx
  • frontend/web/components/pages/environment-settings/tabs/warehouse-tab/WarehouseConnectionCard.tsx
  • frontend/web/components/pages/environment-settings/tabs/warehouse-tab/WarehouseSetup.tsx
  • frontend/web/components/pages/environment-settings/tabs/warehouse-tab/__tests__/clickhouseConfig.test.ts
  • frontend/web/components/pages/environment-settings/tabs/warehouse-tab/clickhouseConfig.ts
  • frontend/web/components/pages/environment-settings/tabs/warehouse-tab/index.tsx

Comment thread frontend/common/types/responses.ts Outdated
Comment on lines +1 to +14
import React, { FC, useState } from 'react'
import Button from 'components/base/forms/Button'
import Input from 'components/base/forms/Input'
import Switch from 'components/Switch'
import ErrorMessage from 'components/ErrorMessage'
import { ClickHouseConfig } from 'common/types/responses'
import {
buildClickHousePayload,
CLICKHOUSE_DEFAULTS,
ClickHouseFormData,
ClickHouseFormState,
isClickHouseFormValid,
} from './clickhouseConfig'
import './ConfigForm.scss'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Move into its own component folder and stop importing ConfigForm.scss directly.

This new component lives directly under warehouse-tab/ and imports ./ConfigForm.scss (Snowflake's stylesheet) rather than having its own co-located stylesheet. That silently couples ClickHouse styling to the Snowflake form file.

As per path instructions, "Each new component must live in its own folder with a barrel index.ts, a ComponentName/ComponentName.tsx file, co-located ComponentName.scss, any subcomponents, and imports should use the component folder path rather than the inner file."

♻️ Proposed structure
ClickHouseConfigForm/
  index.ts               // export { default } from './ClickHouseConfigForm'
  ClickHouseConfigForm.tsx
  ClickHouseConfigForm.scss   // own styles, or explicitly import the shared partial

Source: Path instructions

@themis-blindfold

Copy link
Copy Markdown

Review failed after 2 attempt(s) (OutputError). Check the worker logs.

@Zaimwa9 Zaimwa9 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 🧹 Ship it, nits inside — no correctness issues, two nits filed inline:

  1. getButtonLabel duplication — identical helper copied from the Snowflake form; should be shared to avoid a third copy when the next warehouse type arrives.
  2. Missing id attributes on form buttons — the Snowflake form has them for E2E selectors; the ClickHouse form omits them.

The PR is well-structured overall: clean type separation for credentials vs config, solid unit tests on the pure logic, correct polling scoping, and consistent use of the shared SCSS and BEM conventions.

Recovered Themis review, posted manually (bot post failed on an output-format validation error).

@github-actions github-actions Bot added feature New feature or request and removed feature New feature or request labels Jul 20, 2026
@Zaimwa9
Zaimwa9 force-pushed the feat/clickhouse-byo-warehouse-backend branch from c9cb041 to 4b54dc7 Compare July 20, 2026 12:18
@Zaimwa9
Zaimwa9 requested review from a team as code owners July 20, 2026 12:18
@Zaimwa9
Zaimwa9 requested review from Holmus and removed request for a team July 20, 2026 12:18
Base automatically changed from feat/clickhouse-byo-warehouse-backend to main July 20, 2026 13:45
Zaimwa9 added 5 commits July 20, 2026 16:50
- 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
@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor
✅ private-cloud · depot-ubuntu-latest-16 — run #18534 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  52.4 seconds
commit  aa07e2f
info  🔄 Run: #18534 (attempt 1)

🗂️ Previous results
✅ private-cloud · depot-ubuntu-latest-arm-16 — run #18534 (attempt 1)

Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)

passed  3 passed

Details

stats  3 tests across 3 suites
duration  36.5 seconds
commit  aa07e2f
info  🔄 Run: #18534 (attempt 1)

✅ oss · depot-ubuntu-latest-arm-16 — run #18534 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-arm-16)

passed  2 passed

Details

stats  2 tests across 2 suites
duration  48 seconds
commit  aa07e2f
info  🔄 Run: #18534 (attempt 1)

✅ oss · depot-ubuntu-latest-16 — run #18534 (attempt 1)

Playwright Test Results (oss - depot-ubuntu-latest-16)

passed  1 passed

Details

stats  1 test across 1 suite
duration  36.6 seconds
commit  aa07e2f
info  🔄 Run: #18534 (attempt 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API feature New feature or request front-end Issue related to the React Front End Dashboard

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant