/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import React, { useState } from 'react'; import configMetadata from '../resources/config_metadata.json'; interface ConfigSetting { key: string; title: string; description: string; type: string; category: string; impact: string; requires_restart: boolean; default: any; env_var: string; nested_example: string | null; documentation_url: string | null; } interface ConfigurationTableProps { category?: string; showEnvironmentVariables?: boolean; } const ImpactBadge: React.FC<{ impact: string }> = ({ impact }) => { const colors = { low: '#52c41a', medium: '#faad14', high: '#ff4d4f', }; return ( {impact.toUpperCase()} ); }; const RestartBadge: React.FC<{ requiresRestart: boolean }> = ({ requiresRestart, }) => { if (!requiresRestart) return null; return ( RESTART ); }; const ConfigurationTable: React.FC = ({ category, showEnvironmentVariables = false, }) => { const [selectedCategory, setSelectedCategory] = useState( category || 'all', ); // Get settings based on selected category const getSettings = (): ConfigSetting[] => { if (selectedCategory === 'all') { return configMetadata.all_settings; } return configMetadata.by_category[selectedCategory] || []; }; const settings = getSettings(); const formatDefault = (value: any): string => { if (value === null || value === undefined) return 'None'; if (typeof value === 'object') { return JSON.stringify(value, null, 2); } return String(value); }; const copyToClipboard = (text: string) => { navigator.clipboard.writeText(text); }; return (
{/* Category selector */} {!category && (
Showing {settings.length} configuration settings
)} {/* Table */}
{showEnvironmentVariables && ( )} {settings.map((setting: ConfigSetting) => ( {showEnvironmentVariables && ( )} ))}
Setting Description Type Default Environment Variable Impact
{setting.title}
{setting.key} {setting.documentation_url && ( )}
{setting.description} {setting.type} {formatDefault(setting.default)}
{setting.env_var}
{setting.nested_example && (
{setting.nested_example}
)}
{settings.length === 0 && (
No configuration settings found for the selected category.
)}
); }; export default ConfigurationTable;