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>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-08 13:01:31 +00:00
parent 9eb8feb1d2
commit da1f968e3f
2 changed files with 6 additions and 22 deletions

View File

@@ -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<string | null>(null);
const feature = getFeatureById('index-management');
const INDEX_TYPES = getIndexTypes();
// Fetch indexes for selected table
const fetchIndexes = async (tableName: string) => {

View File

@@ -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);