From da1f968e3f37e1ec47e6db41bd2cd532ccacbe3f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 8 Jan 2026 13:01:31 +0000 Subject: [PATCH] refactor: Use configuration for operators and index types - Replace hardcoded OPERATORS array with getQueryOperators() - Replace hardcoded INDEX_TYPES array with getIndexTypes() - Maintain single source of truth in features.json - Address code review feedback for better maintainability Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com> --- src/components/admin/IndexManagerTab.tsx | 11 ++--------- src/components/admin/QueryBuilderTab.tsx | 17 ++++------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/src/components/admin/IndexManagerTab.tsx b/src/components/admin/IndexManagerTab.tsx index 3e63682..6aae3b6 100644 --- a/src/components/admin/IndexManagerTab.tsx +++ b/src/components/admin/IndexManagerTab.tsx @@ -24,7 +24,7 @@ import { Typography, } from '@mui/material'; import { useState } from 'react'; -import { getFeatureById } from '@/utils/featureConfig'; +import { getFeatureById, getIndexTypes } from '@/utils/featureConfig'; import ConfirmDialog from './ConfirmDialog'; type IndexManagerTabProps = { @@ -32,14 +32,6 @@ type IndexManagerTabProps = { onRefresh: () => void; }; -const INDEX_TYPES = [ - { value: 'BTREE', label: 'B-Tree (Default)', description: 'General purpose, balanced tree index' }, - { value: 'HASH', label: 'Hash', description: 'Fast equality searches' }, - { value: 'GIN', label: 'GIN', description: 'Generalized Inverted Index for full-text search' }, - { value: 'GIST', label: 'GiST', description: 'Generalized Search Tree for geometric data' }, - { value: 'BRIN', label: 'BRIN', description: 'Block Range Index for very large tables' }, -]; - export default function IndexManagerTab({ tables, onRefresh, @@ -62,6 +54,7 @@ export default function IndexManagerTab({ const [deleteIndex, setDeleteIndex] = useState(null); const feature = getFeatureById('index-management'); + const INDEX_TYPES = getIndexTypes(); // Fetch indexes for selected table const fetchIndexes = async (tableName: string) => { diff --git a/src/components/admin/QueryBuilderTab.tsx b/src/components/admin/QueryBuilderTab.tsx index b875675..a2319ce 100644 --- a/src/components/admin/QueryBuilderTab.tsx +++ b/src/components/admin/QueryBuilderTab.tsx @@ -17,6 +17,7 @@ import { Typography, } from '@mui/material'; import { useState } from 'react'; +import { getQueryOperators } from '@/utils/featureConfig'; import DataGrid from './DataGrid'; type QueryBuilderTabProps = { @@ -30,19 +31,6 @@ type WhereCondition = { value: string; }; -const OPERATORS = [ - { value: '=', label: 'Equals' }, - { value: '!=', label: 'Not Equals' }, - { value: '>', label: 'Greater Than' }, - { value: '<', label: 'Less Than' }, - { value: '>=', label: 'Greater or Equal' }, - { value: '<=', label: 'Less or Equal' }, - { value: 'LIKE', label: 'Like (Pattern Match)' }, - { value: 'IN', label: 'In List' }, - { value: 'IS NULL', label: 'Is Null' }, - { value: 'IS NOT NULL', label: 'Is Not Null' }, -]; - export default function QueryBuilderTab({ tables, onExecuteQuery, @@ -60,6 +48,9 @@ export default function QueryBuilderTab({ const [loading, setLoading] = useState(false); const [error, setError] = useState(''); + // Get operators from configuration + const OPERATORS = getQueryOperators(); + // Fetch columns when table is selected const handleTableChange = async (tableName: string) => { setSelectedTable(tableName);