File size: 26,271 Bytes
93dd899
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
/**
 * 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 from 'react';
import {
  Card,
  Collapse,
  Table,
  Tag,
  Typography,
  Alert,
  Space,
  Divider,
  Tabs,
} from 'antd';
import {
  CheckCircleOutlined,
  CloseCircleOutlined,
  WarningOutlined,
  LinkOutlined,
  KeyOutlined,
  SettingOutlined,
  BookOutlined,
  EditOutlined,
  GithubOutlined,
  BugOutlined,
} from '@ant-design/icons';
import type { DatabaseInfo, KnownIncompatibility } from './types';

// Simple code block component for connection strings
const CodeBlock: React.FC<{ children: React.ReactNode }> = ({ children }) => (
  <pre
    style={{
      background: 'var(--ifm-code-background)',
      padding: '12px 16px',
      borderRadius: '4px',
      overflow: 'auto',
      fontSize: '13px',
      fontFamily: 'var(--ifm-font-family-monospace)',
    }}
  >
    <code>{children}</code>
  </pre>
);

const { Title, Paragraph, Text } = Typography;

interface DatabasePageProps {
  database: DatabaseInfo;
  name: string;
}

// Feature badge component
const FeatureBadge: React.FC<{ supported: boolean; label: string }> = ({
  supported,
  label,
}) => (
  <Tag
    icon={supported ? <CheckCircleOutlined /> : <CloseCircleOutlined />}
    color={supported ? 'success' : 'default'}
  >
    {label}
  </Tag>
);

// Time grain badge
const TimeGrainBadge: React.FC<{ supported: boolean; grain: string }> = ({
  supported,
  grain,
}) => (
  <Tag color={supported ? 'blue' : 'default'} style={{ margin: '2px' }}>
    {grain}
  </Tag>
);

const DatabasePage: React.FC<DatabasePageProps> = ({ database, name }) => {
  const { documentation: docs } = database;

  // Helper to render connection string with copy button
  const renderConnectionString = (connStr: string, description?: string) => (
    <div style={{ marginBottom: 16 }}>
      {description && (
        <Text type="secondary" style={{ display: 'block', marginBottom: 4 }}>
          {description}
        </Text>
      )}
      <CodeBlock>{connStr}</CodeBlock>
    </div>
  );

  // Ensure db filename can be obtained regardless of how db doc gets generated
  // by either Flask app (superset.db_engine_specs.postgres) or fallback mode (postgres)
  const databaseModuleFilename = `${database.module?.split('.').pop()}.py`;

  // Render driver information
  const renderDrivers = () => {
    if (!docs?.drivers?.length) return null;

    return (
      <Card title="Drivers" style={{ marginBottom: 16 }}>
        <Tabs
          items={docs.drivers.map((driver, idx) => ({
            key: String(idx),
            label: (
              <span>
                {driver.name}
                {driver.is_recommended && (
                  <Tag color="green" style={{ marginLeft: 8 }}>
                    Recommended
                  </Tag>
                )}
              </span>
            ),
            children: (
              <Space direction="vertical" style={{ width: '100%' }}>
                {driver.pypi_package && (
                  <div>
                    <Text strong>PyPI Package: </Text>
                    <code>{driver.pypi_package}</code>
                  </div>
                )}
                {driver.connection_string &&
                  renderConnectionString(driver.connection_string)}
                {driver.notes && (
                  <Alert message={driver.notes} type="info" showIcon />
                )}
                {driver.docs_url && (
                  <a href={driver.docs_url} target="_blank" rel="noreferrer">
                    <LinkOutlined /> Documentation
                  </a>
                )}
              </Space>
            ),
          }))}
        />
      </Card>
    );
  };

  // Render authentication methods
  const renderAuthMethods = () => {
    if (!docs?.authentication_methods?.length) return null;

    return (
      <Card
        title={
          <>
            <KeyOutlined /> Authentication Methods
          </>
        }
        style={{ marginBottom: 16 }}
      >
        <Collapse
          accordion
          items={docs.authentication_methods.map((auth, idx) => ({
            key: String(idx),
            label: auth.name,
            children: (
              <>
                {auth.description && <Paragraph>{auth.description}</Paragraph>}
                {auth.requirements && (
                  <Alert
                    message="Requirements"
                    description={auth.requirements}
                    type="warning"
                    showIcon
                    style={{ marginBottom: 16 }}
                  />
                )}
                {auth.connection_string &&
                  renderConnectionString(
                    auth.connection_string,
                    'Connection String',
                  )}
                {auth.secure_extra && (
                  <div>
                    <Text strong>Secure Extra Configuration:</Text>
                    <CodeBlock>
                      {JSON.stringify(auth.secure_extra, null, 2)}
                    </CodeBlock>
                  </div>
                )}
                {auth.engine_parameters && (
                  <div>
                    <Text strong>Engine Parameters:</Text>
                    <CodeBlock>
                      {JSON.stringify(auth.engine_parameters, null, 2)}
                    </CodeBlock>
                  </div>
                )}
                {auth.notes && (
                  <Alert message={auth.notes} type="info" showIcon />
                )}
              </>
            ),
          }))}
        />
      </Card>
    );
  };

  // Render engine parameters
  const renderEngineParams = () => {
    if (!docs?.engine_parameters?.length) return null;

    return (
      <Card
        title={
          <>
            <SettingOutlined /> Engine Parameters
          </>
        }
        style={{ marginBottom: 16 }}
      >
        <Collapse
          items={docs.engine_parameters.map((param, idx) => ({
            key: String(idx),
            label: param.name,
            children: (
              <>
                {param.description && (
                  <Paragraph>{param.description}</Paragraph>
                )}
                {param.json && (
                  <CodeBlock>{JSON.stringify(param.json, null, 2)}</CodeBlock>
                )}
                {param.docs_url && (
                  <a href={param.docs_url} target="_blank" rel="noreferrer">
                    <LinkOutlined /> Learn more
                  </a>
                )}
              </>
            ),
          }))}
        />
      </Card>
    );
  };

  // Render known incompatibilities with a Superset dependency (e.g. a driver
  // that doesn't yet support SQLAlchemy 2.0). Shared between the top-level
  // documentation and each compatible-database entry.
  const renderKnownIncompatibilities = (
    incompatibilities?: KnownIncompatibility[],
  ) => {
    if (!incompatibilities?.length) return null;

    return (
      <Space direction="vertical" style={{ width: '100%' }}>
        {incompatibilities.map((incompat, idx) => (
          <Alert
            key={idx}
            type="warning"
            showIcon
            message={incompat.dependency}
            description={
              <>
                {incompat.reason && (
                  <Paragraph style={{ marginBottom: 4 }}>
                    {incompat.reason}
                  </Paragraph>
                )}
                <Space size="middle">
                  {incompat.tracking_url && (
                    <a
                      href={incompat.tracking_url}
                      target="_blank"
                      rel="noreferrer"
                    >
                      <LinkOutlined /> Tracking issue
                    </a>
                  )}
                  {incompat.since && (
                    <Text type="secondary">
                      Last confirmed: {incompat.since}
                    </Text>
                  )}
                </Space>
              </>
            }
          />
        ))}
      </Space>
    );
  };

  // Render compatible databases (for PostgreSQL, etc.)
  const renderCompatibleDatabases = () => {
    if (!docs?.compatible_databases?.length) return null;

    // Create array of all item keys to expand by default
    const allItemKeys = docs.compatible_databases.map((_, idx) => String(idx));

    return (
      <Card title="Compatible Databases" style={{ marginBottom: 16 }}>
        <Paragraph>
          The following databases are compatible with the {name} driver:
        </Paragraph>
        <Collapse
          defaultActiveKey={allItemKeys}
          items={docs.compatible_databases.map((compat, idx) => ({
            key: String(idx),
            label: (
              <div style={{ display: 'flex', alignItems: 'center', gap: 12 }}>
                {compat.logo && (
                  <img
                    src={`/img/databases/${compat.logo}`}
                    alt={compat.name}
                    style={{
                      width: 28,
                      height: 28,
                      objectFit: 'contain',
                    }}
                  />
                )}
                <span>{compat.name}</span>
              </div>
            ),
            children: (
              <>
                {compat.description && (
                  <Paragraph>{compat.description}</Paragraph>
                )}
                {compat.connection_string &&
                  renderConnectionString(compat.connection_string)}
                {compat.parameters && (
                  <div>
                    <Text strong>Parameters:</Text>
                    <Table
                      dataSource={Object.entries(compat.parameters).map(
                        ([key, value]) => ({
                          key,
                          parameter: key,
                          description: value,
                        }),
                      )}
                      columns={[
                        {
                          title: 'Parameter',
                          dataIndex: 'parameter',
                          key: 'p',
                        },
                        {
                          title: 'Description',
                          dataIndex: 'description',
                          key: 'd',
                        },
                      ]}
                      pagination={false}
                      size="small"
                    />
                  </div>
                )}
                {compat.known_incompatibilities?.length > 0 && (
                  <div style={{ marginTop: 16 }}>
                    <Text strong>Known Incompatibilities:</Text>
                    <div style={{ marginTop: 8 }}>
                      {renderKnownIncompatibilities(
                        compat.known_incompatibilities,
                      )}
                    </div>
                  </div>
                )}
                {compat.notes && (
                  <Alert
                    message={compat.notes}
                    type="info"
                    showIcon
                    style={{ marginTop: 16 }}
                  />
                )}
              </>
            ),
          }))}
        />
      </Card>
    );
  };

  // Render feature matrix
  const renderFeatures = () => {
    const features: Array<{ key: keyof DatabaseInfo; label: string }> = [
      { key: 'joins', label: 'JOINs' },
      { key: 'subqueries', label: 'Subqueries' },
      { key: 'supports_dynamic_schema', label: 'Dynamic Schema' },
      { key: 'supports_catalog', label: 'Catalog Support' },
      { key: 'supports_dynamic_catalog', label: 'Dynamic Catalog' },
      { key: 'ssh_tunneling', label: 'SSH Tunneling' },
      { key: 'query_cancelation', label: 'Query Cancellation' },
      { key: 'supports_file_upload', label: 'File Upload' },
      { key: 'user_impersonation', label: 'User Impersonation' },
      { key: 'query_cost_estimation', label: 'Cost Estimation' },
      { key: 'sql_validation', label: 'SQL Validation' },
    ];

    return (
      <Card title="Supported Features" style={{ marginBottom: 16 }}>
        <div style={{ display: 'flex', flexWrap: 'wrap', gap: 8 }}>
          {features.map(({ key, label }) => (
            <FeatureBadge
              key={key}
              supported={Boolean(database[key])}
              label={label}
            />
          ))}
        </div>
        {database.score > 0 && (
          <div style={{ marginTop: 16 }}>
            <Text>
              Feature Score:{' '}
              <Text strong>
                {database.score}/{database.max_score}
              </Text>
            </Text>
          </div>
        )}
      </Card>
    );
  };

  // Render time grains
  const renderTimeGrains = () => {
    if (!database.time_grains) return null;

    const commonGrains = [
      'SECOND',
      'MINUTE',
      'HOUR',
      'DAY',
      'WEEK',
      'MONTH',
      'QUARTER',
      'YEAR',
    ];
    const extendedGrains = Object.keys(database.time_grains).filter(
      g => !commonGrains.includes(g),
    );

    return (
      <Card title="Time Grains" style={{ marginBottom: 16 }}>
        <div style={{ marginBottom: 16 }}>
          <Text strong>Common Time Grains:</Text>
          <div style={{ marginTop: 8 }}>
            {commonGrains.map(grain => (
              <TimeGrainBadge
                key={grain}
                grain={grain}
                supported={Boolean(
                  database.time_grains[
                    grain as keyof typeof database.time_grains
                  ],
                )}
              />
            ))}
          </div>
        </div>
        {extendedGrains.length > 0 && (
          <div>
            <Text strong>Extended Time Grains:</Text>
            <div style={{ marginTop: 8 }}>
              {extendedGrains.map(grain => (
                <TimeGrainBadge
                  key={grain}
                  grain={grain}
                  supported={Boolean(
                    database.time_grains[
                      grain as keyof typeof database.time_grains
                    ],
                  )}
                />
              ))}
            </div>
          </div>
        )}
      </Card>
    );
  };

  // Render troubleshooting / custom errors section
  const renderTroubleshooting = () => {
    if (!docs?.custom_errors?.length) return null;

    // Group errors by category
    const errorsByCategory: Record<string, typeof docs.custom_errors> = {};
    for (const error of docs.custom_errors) {
      const category = error.category || 'General';
      if (!errorsByCategory[category]) {
        errorsByCategory[category] = [];
      }
      errorsByCategory[category].push(error);
    }

    // Define category order for consistent display
    const categoryOrder = [
      'Authentication',
      'Connection',
      'Permissions',
      'Query',
      'Configuration',
      'General',
    ];

    const sortedCategories = Object.keys(errorsByCategory).sort((a, b) => {
      const aIdx = categoryOrder.indexOf(a);
      const bIdx = categoryOrder.indexOf(b);
      if (aIdx === -1 && bIdx === -1) return a.localeCompare(b);
      if (aIdx === -1) return 1;
      if (bIdx === -1) return -1;
      return aIdx - bIdx;
    });

    // Category colors
    const categoryColors: Record<string, string> = {
      Authentication: 'orange',
      Connection: 'red',
      Permissions: 'purple',
      Query: 'blue',
      Configuration: 'cyan',
      General: 'default',
    };

    return (
      <Card
        title={
          <>
            <BugOutlined /> Troubleshooting
          </>
        }
        style={{ marginBottom: 16 }}
      >
        <Paragraph type="secondary">
          Common error messages you may encounter when connecting to or querying{' '}
          {name}, along with their causes and solutions.
        </Paragraph>
        <Collapse
          accordion
          items={sortedCategories.map(category => ({
            key: category,
            label: (
              <span>
                <Tag color={categoryColors[category] || 'default'}>
                  {category}
                </Tag>
                {errorsByCategory[category].length} error
                {errorsByCategory[category].length !== 1 ? 's' : ''}
              </span>
            ),
            children: (
              <>
                {errorsByCategory[category].map((error, idx) => (
                  <div
                    key={idx}
                    style={{
                      marginBottom:
                        idx < errorsByCategory[category].length - 1 ? 16 : 0,
                      paddingBottom:
                        idx < errorsByCategory[category].length - 1 ? 16 : 0,
                      borderBottom:
                        idx < errorsByCategory[category].length - 1
                          ? '1px solid var(--ifm-color-emphasis-200)'
                          : 'none',
                    }}
                  >
                    <div style={{ marginBottom: 8 }}>
                      <Text strong>
                        {error.description || error.error_type}
                      </Text>
                    </div>
                    <Alert
                      message={error.message_template}
                      type="error"
                      style={{ marginBottom: 8 }}
                    />
                    {error.invalid_fields &&
                      error.invalid_fields.length > 0 && (
                        <div style={{ marginBottom: 8 }}>
                          <Text type="secondary">Check these fields: </Text>
                          {error.invalid_fields.map(field => (
                            <Tag key={field} color="warning">
                              {field}
                            </Tag>
                          ))}
                        </div>
                      )}
                    {error.issue_codes && error.issue_codes.length > 0 && (
                      <div>
                        <Text type="secondary">Related issue codes: </Text>
                        {error.issue_codes.map(code => (
                          <Tag key={code}>
                            <a
                              href={`/docs/using-superset/issue-codes#issue-${code}`}
                              style={{ color: 'inherit' }}
                            >
                              Issue {code}
                            </a>
                          </Tag>
                        ))}
                      </div>
                    )}
                  </div>
                ))}
              </>
            ),
          }))}
        />
      </Card>
    );
  };

  return (
    <div className="database-page" id={name.toLowerCase().replace(/\s+/g, '-')}>
      <div style={{ marginBottom: 16 }}>
        {docs?.logo && (
          <img
            src={`/img/databases/${docs.logo}`}
            alt={name}
            style={{
              height: 120,
              objectFit: 'contain',
              marginBottom: 12,
            }}
          />
        )}
        <Title level={1} style={{ margin: 0 }}>
          {name}
        </Title>
        {docs?.homepage_url && (
          <a
            href={docs.homepage_url}
            target="_blank"
            rel="noreferrer"
            style={{ fontSize: 14 }}
          >
            <LinkOutlined /> {docs.homepage_url}
          </a>
        )}
      </div>

      {docs?.description && <Paragraph>{docs.description}</Paragraph>}

      {/* Warnings */}
      {docs?.warnings?.map((warning, idx) => (
        <Alert
          key={idx}
          message={warning}
          type="warning"
          icon={<WarningOutlined />}
          showIcon
          style={{ marginBottom: 16 }}
        />
      ))}

      {/* Known Limitations */}
      {docs?.limitations?.length > 0 && (
        <Card
          title="Known Limitations"
          style={{ marginBottom: 16 }}
          type="inner"
        >
          <ul style={{ margin: 0, paddingLeft: 20 }}>
            {docs.limitations.map((limitation, idx) => (
              <li key={idx}>{limitation}</li>
            ))}
          </ul>
        </Card>
      )}

      {/* Known Incompatibilities */}
      {docs?.known_incompatibilities?.length > 0 && (
        <Card
          title="Known Incompatibilities"
          style={{ marginBottom: 16 }}
          type="inner"
        >
          {renderKnownIncompatibilities(docs.known_incompatibilities)}
        </Card>
      )}

      {/* Installation */}
      {(docs?.pypi_packages?.length || docs?.install_instructions) && (
        <Card title="Installation" style={{ marginBottom: 16 }}>
          {docs.pypi_packages?.length > 0 && (
            <div style={{ marginBottom: 16 }}>
              <Text strong>Required packages: </Text>
              {docs.pypi_packages.map(pkg => (
                <Tag key={pkg} color="blue">
                  {pkg}
                </Tag>
              ))}
            </div>
          )}
          {docs.version_requirements && (
            <Alert
              message={`Version requirement: ${docs.version_requirements}`}
              type="info"
              showIcon
              style={{ marginBottom: 16 }}
            />
          )}
          {docs.install_instructions && (
            <CodeBlock>{docs.install_instructions}</CodeBlock>
          )}
        </Card>
      )}

      {/* Basic Connection */}
      {docs?.connection_string && !docs?.drivers?.length && (
        <Card title="Connection String" style={{ marginBottom: 16 }}>
          {renderConnectionString(docs.connection_string)}
          {docs.parameters && (
            <Table
              dataSource={Object.entries(docs.parameters).map(
                ([key, value]) => ({
                  key,
                  parameter: key,
                  description: value,
                }),
              )}
              columns={[
                { title: 'Parameter', dataIndex: 'parameter', key: 'p' },
                { title: 'Description', dataIndex: 'description', key: 'd' },
              ]}
              pagination={false}
              size="small"
            />
          )}
          {docs.default_port && (
            <Text type="secondary">Default port: {docs.default_port}</Text>
          )}
        </Card>
      )}

      {/* Drivers */}
      {renderDrivers()}

      {/* Connection Examples */}
      {docs?.connection_examples?.length > 0 && (
        <Card title="Connection Examples" style={{ marginBottom: 16 }}>
          {docs.connection_examples.map((example, idx) => (
            <div key={idx}>
              {renderConnectionString(
                example.connection_string,
                example.description,
              )}
            </div>
          ))}
        </Card>
      )}

      {/* Authentication Methods */}
      {renderAuthMethods()}

      {/* Engine Parameters */}
      {renderEngineParams()}

      {/* Features */}
      {renderFeatures()}

      {/* Time Grains */}
      {renderTimeGrains()}

      {/* Troubleshooting / Custom Errors */}
      {renderTroubleshooting()}

      {/* Compatible Databases */}
      {renderCompatibleDatabases()}

      {/* Notes */}
      {docs?.notes && (
        <Alert
          message="Notes"
          description={docs.notes}
          type="info"
          showIcon
          style={{ marginBottom: 16 }}
        />
      )}

      {/* External Links */}
      {(docs?.docs_url || docs?.tutorials?.length) && (
        <Card
          title={
            <>
              <BookOutlined /> Resources
            </>
          }
          style={{ marginBottom: 16 }}
        >
          <Space direction="vertical">
            {docs.docs_url && (
              <a href={docs.docs_url} target="_blank" rel="noreferrer">
                <LinkOutlined /> Official Documentation
              </a>
            )}
            {docs.sqlalchemy_docs_url && (
              <a
                href={docs.sqlalchemy_docs_url}
                target="_blank"
                rel="noreferrer"
              >
                <LinkOutlined /> SQLAlchemy Dialect Documentation
              </a>
            )}
            {docs.tutorials?.map((tutorial, idx) => (
              <a key={idx} href={tutorial} target="_blank" rel="noreferrer">
                <LinkOutlined /> Tutorial {idx + 1}
              </a>
            ))}
          </Space>
        </Card>
      )}

      {/* Edit link */}
      {database.module && (
        <Card
          style={{
            marginBottom: 16,
            background: 'var(--ifm-background-surface-color)',
            borderStyle: 'dashed',
          }}
          size="small"
        >
          <Space>
            <GithubOutlined />
            <Text type="secondary">
              Help improve this documentation by editing the engine spec:
            </Text>
            <a
              href={`https://github.com/apache/superset/edit/master/superset/db_engine_specs/${databaseModuleFilename}`}
              target="_blank"
              rel="noreferrer"
            >
              <EditOutlined /> Edit {databaseModuleFilename}
            </a>
          </Space>
        </Card>
      )}

      <Divider />
    </div>
  );
};

export default DatabasePage;