Skip to content

feat: centralize all constants in constants.ts#231

Open
ritoban23 wants to merge 18 commits intodatazip-inc:stagingfrom
ritoban23:feat/centralize-constants
Open

feat: centralize all constants in constants.ts#231
ritoban23 wants to merge 18 commits intodatazip-inc:stagingfrom
ritoban23:feat/centralize-constants

Conversation

@ritoban23
Copy link
Copy Markdown

Description

This PR centralizes all scattered constants throughout the codebase into a single constants.ts file. Previously, constants like connector types, status values, tab types, and default values were hardcoded in multiple files, leading to maintenance issues and potential inconsistencies.

Key Changes:

  • Added 5 new constant groups to ui/src/utils/constants.ts:
    • STREAM_FILTERS - Filter options for job streams
    • CONNECTOR_TYPE_MAP - Mapping between lowercase and proper case connector names
    • DEFAULT_CONNECTORS - Default connector values for sources and destinations
    • TAB_TYPE_VALUES - Tab navigation constants with proper TypeScript literal types
    • STATUS_VALUES - Status constants for entities and jobs
  • Updated 10 component files to import and use centralized constants instead of hardcoded strings

Fixes #152

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • Build verification - pnpm run build completes successfully
  • Linting verification - pnpm run lint passes with 0 errors and 0 warnings
  • TypeScript compilation - All type errors resolved, proper literal types enforced
  • Import verification - All components successfully import and use centralized constants
  • Functionality testing - Application starts and navigates correctly with new constants

Test Configuration:

  • Node.js environment with pnpm package manager
  • TypeScript strict mode enabled
  • ESLint with max-warnings set to 0
  • Vite build system

Screenshots or Recordings

No visual changes - this is an internal refactoring that improves code organization and maintainability.

Related PR's (If Any):

deepanshupal09-datazip and others added 10 commits October 1, 2025 16:31
* chore: add comments

* chore: 🚨 lint fix
…atazip-inc#195)

* feat: add error logs i check conenction for source and destination

* fix: parse json message as string

* chore: update response key

* chore: refactor

* chore: remove logEntry struct

* fix: log parsing

* fix: log parsing

* fix: logs parsing logic

* docs: updated api contract
…ogs-in-test-connection

feat: show error logs in test connection
Comment thread ui/src/utils/constants.ts Outdated
Comment thread ui/src/utils/constants.ts Outdated
Comment thread ui/src/utils/constants.ts Outdated
Comment thread ui/src/utils/constants.ts Outdated
Comment thread ui/src/utils/constants.ts Outdated
@ritoban23
Copy link
Copy Markdown
Author

ritoban23 commented Oct 15, 2025

@deepanshupal09-datazip Thanks for the feedback! some quick questions... should I then create a separate enums.ts file or keep them in constants.ts, replace DEFAULT_CONNECTORS.SOURCE with CONNECTOR_TYPES.SOURCE_DEFAULT_CONNECTOR (which alread yexists) or hardcode "MongoDB", also should the eums use singluar or plural names?

* test: ✅ base setup for automation testing using playwright , add test cases fro major flows

* fix: integration workflow changes

* fix: ci changes

* fix: ci changes

* fix: ci changes

* fix: ci changes

* fix: ci changes

* fix: ci changes

* fix: ci changes

* fix: ci changes

* fix: ci changes

* fix: ci changes

* fix: ci changes

* fix: ci changes

* fix: ci changes

* fix: ci changes

* fix: ci changes

* fix: ci changes

* test: add postgres flow

* fix: lint changes

* test: add iceberg specific test

* fix: tests

* fix: stream name

* fix: test fix

* fix: test fix

* fix: test fix

* fix: test fix

* fix: changes

* fix: ci changes

* fix: ci changes

* fix: ci changes

* test: fail test on test connection failure

* fix: ci changes

* fix: changes

* fix: changes

* fix: changes

* fix: changes

* fix: changes

* fix: changes

* fix: test fix

* fix: changes

* fix: changes

* fix: test-data fix

* fix: test-data fix

* fix: changes

* fix: changes

* fix: changes

* fix: host and port changes

* fix: changes

* fix: change

* test: login test updated

* test: refactor create source and destination page

* test: refactor tests

* fix: test fix

* fix: changes

* fix: fix changes

* fix: changes

* fix: changes

* fix: review changes

* refactor: refactor tests to use authenticated state of playwright

* fix: changes

* docs: update tests readme

* test: intercept and log destination spec response

* docs: update readme

* fix: update timeouts for playwright tests

* test: update readme

* fix: add retries in playwright config

* test: fix timeout duration

* fix: update readme

* test: add connector data test-id

* fix: resolve comments

* refactor(test): make and use enums instead of strings

* fix: fix test data builder

* fix: test data job name

* fix: add todo

---------

Co-authored-by: Duke Dhal <duke@datazip.io>
Co-authored-by: deepanshupal09-datazip <deepanshu@datazip.io>
@deepanshupal09-datazip
Copy link
Copy Markdown
Collaborator

@deepanshupal09-datazip Thanks for the feedback! some quick questions... should I then create a separate enums.ts file or keep them in constants.ts, replace DEFAULT_CONNECTORS.SOURCE with CONNECTOR_TYPES.SOURCE_DEFAULT_CONNECTOR (which alread yexists) or hardcode "MongoDB", also should the eums use singluar or plural names?

Hi @ritoban23, sorry for the late reply, been caught up in some work. Answer to your questions:

  1. enums should be singular like CONNECTOR_TYPE
  2. create a folder in ui folder root named enums where all enums would be stored, name the enum file appropriately along with a index.ts for clean exports.
  3. no need to make a separate constant for default connector, just hardcode them directly like SourceConnector.MongoDB

Also make separate enums for source and destination connector like SourceConnector and DestinationConnector... you may refer this file

@ritoban23 ritoban23 force-pushed the feat/centralize-constants branch from b962dff to 955c859 Compare October 17, 2025 14:45
Comment thread ui/src/enums/statusValueEnum.ts Outdated
@@ -0,0 +1,10 @@
export enum StatusValue {
Copy link
Copy Markdown
Collaborator

@deepanshupal09-datazip deepanshupal09-datazip Oct 21, 2025

Choose a reason for hiding this comment

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

The name StatusValue is unclear. Since it’s used on the Sources page, please rename it to something more descriptive to improve readability.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also there are only two status in Sources page... Active and Inactive
We don't need these many statuses, please remove useless values

Copy link
Copy Markdown
Collaborator

@deepanshupal09-datazip deepanshupal09-datazip Oct 21, 2025

Choose a reason for hiding this comment

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

Also, please use this enum in Destinations page as well for consistency.

@@ -0,0 +1,6 @@
export enum TabType {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This enum is currently being used in both StreamConfiguration and SourceEdit. Since these components serve different purposes and contexts, sharing the same enum may lead to confusion or unintended coupling in the future. It would be better to define separate enums for each component to maintain clear separation of concerns and improve maintainability.

Also, please ensure that each enum is named appropriately (e.g., StreamTab, SourceTab) so that its purpose and scope are clear.

Comment on lines +128 to +132
const connectorTypeMap: Record<string, string> = {
mongodb: "MongoDB",
postgres: "Postgres",
mysql: "MySQL",
oracle: "Oracle",
[SourceConnector.MONGODB.toLowerCase()]: SourceConnector.MONGODB,
[SourceConnector.POSTGRES.toLowerCase()]: SourceConnector.POSTGRES,
[SourceConnector.MYSQL.toLowerCase()]: SourceConnector.MYSQL,
[SourceConnector.ORACLE.toLowerCase()]: SourceConnector.ORACLE,
Copy link
Copy Markdown
Collaborator

@deepanshupal09-datazip deepanshupal09-datazip Oct 21, 2025

Choose a reason for hiding this comment

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

Suggested change
const connectorTypeMap: Record<string, string> = {
mongodb: "MongoDB",
postgres: "Postgres",
mysql: "MySQL",
oracle: "Oracle",
[SourceConnector.MONGODB.toLowerCase()]: SourceConnector.MONGODB,
[SourceConnector.POSTGRES.toLowerCase()]: SourceConnector.POSTGRES,
[SourceConnector.MYSQL.toLowerCase()]: SourceConnector.MYSQL,
[SourceConnector.ORACLE.toLowerCase()]: SourceConnector.ORACLE,
const SourceConnectorLabel: Record<string, string> = {
[SourceConnector.MONGODB]: "MongoDB",
[SourceConnector.POSTGRES]: "Postgres",
[SourceConnector.MYSQL]: "MySQL",
[SourceConnector.ORACLE]: "Oracle",
}

Also, please move this to the constants file

Copy link
Copy Markdown
Collaborator

@deepanshupal09-datazip deepanshupal09-datazip Oct 21, 2025

Choose a reason for hiding this comment

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

Also, please do the same thing for DestinationEdit as well

Sarthak2845 and others added 2 commits October 24, 2025 16:37
* Added success message on Job History refetch

* Update ui/src/modules/jobs/pages/JobHistory.tsx

Co-authored-by: deepanshupal09-datazip <deepanshu@datazip.io>

---------

Co-authored-by: vikash choudhary <vikash@datazip.io>
Co-authored-by: deepanshupal09-datazip <deepanshu@datazip.io>
…datazip-inc#216)

* fix: replace deprecated Phosphor icons with latest *Icon alternatives

* fix: update Phosphor icons to latest alternatives in DestinationEdit and SourceEdit components and fix Lint issue

* refactor: remove EditSourceModal

* fix: update icon import

---------

Co-authored-by: vikash choudhary <vikash@datazip.io>
@deepanshupal09-datazip deepanshupal09-datazip added the hacktoberfest Issues open for Hacktoberfest contributors label Oct 28, 2025
* feat: add append only mode in ui

* fix: data filter bug

* fix: fix color of append only mode switch

* fix: add custom option in all streams ingestion mode change

* fix: use clsx for conditional styling

* fix: fix icons
…>SourceStatus, centralize connector labels in constants
@ritoban23 ritoban23 force-pushed the feat/centralize-constants branch from cbc6c3a to 142f19f Compare October 29, 2025 13:36
@ritoban23
Copy link
Copy Markdown
Author

@deepanshupal09-datazip I have addressed all the feedbacks . apologies for the late update, thanks!

@deepanshupal09-datazip
Copy link
Copy Markdown
Collaborator

@deepanshupal09-datazip I have addressed all the feedbacks . apologies for the late update, thanks!

No worries... linter is failing... please run pnpm lint:fix in ui folder to fix the errors

@deepanshupal09-datazip
Copy link
Copy Markdown
Collaborator

deepanshupal09-datazip commented Oct 29, 2025

Also, please avoid using force push in the future. When you force pushed, the previous commits (and my comments on them) were removed, which makes it difficult to track changes since the last review. Force pushing disrupts the review process and removes useful context from the commit history. Now I'll have to review from the start, which will take more time.

Please avoid doing that unless it's absolutely necessary.

@ritoban23
Copy link
Copy Markdown
Author

@deepanshupal09-datazip I'll make sure to not do that from next time, I usually force push after rebasing ,didn't realize I shouldn't do it when i was updating after you merged the staging branch

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

Labels

hacktoberfest Issues open for Hacktoberfest contributors

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants