• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

teableio / teable / 10211584623

02 Aug 2024 07:14AM UTC coverage: 17.734% (-64.2%) from 81.98%
10211584623

push

github

web-flow
fix: design page i18n (#787)

* fix: graph page i18n

* fix: crash i18n

* fix: design page i18n

* fix: text

1387 of 2813 branches covered (49.31%)

3 of 32 new or added lines in 6 files covered. (9.38%)

14082 of 79405 relevant lines covered (17.73%)

1.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/apps/nextjs-app/src/features/app/blocks/graph/FieldGraph.tsx
1
import type { IFieldRo } from '@teable/core';
×
2
import { ColorUtils } from '@teable/core';
×
NEW
3
import { useLanDayjs } from '@teable/sdk/hooks';
×
4
import { Badge } from '@teable/ui-lib/shadcn';
×
5
import dayjs from 'dayjs';
×
6
import duration from 'dayjs/plugin/duration';
×
7
import relativeTime from 'dayjs/plugin/relativeTime';
×
8

×
NEW
9
import { useTranslation } from 'next-i18next';
×
10
import { useEffect, useRef, useState } from 'react';
×
11
import { useGraph } from './useGraph';
×
12
import { usePlan } from './usePlan';
×
13

×
14
dayjs.extend(duration);
×
15
dayjs.extend(relativeTime);
×
16

×
17
export const FieldGraph = (params: { tableId: string; fieldId?: string; fieldRo?: IFieldRo }) => {
×
18
  const ref = useRef(null);
×
19
  const planData = usePlan(params);
×
20
  const updateCellCount = planData?.updateCellCount;
×
21
  const estimateTime = planData?.estimateTime || 0;
×
NEW
22
  const { t, i18n } = useTranslation(['table']);
×
NEW
23
  const dayjs = useLanDayjs();
×
24

×
25
  const [tables, setTables] = useState<{ name: string; color: string }[]>([]);
×
26

×
27
  const { updateGraph } = useGraph(ref);
×
28

×
29
  useEffect(() => {
×
30
    const graph = planData?.graph;
×
31

×
32
    if (!graph) {
×
33
      return;
×
34
    }
×
35

×
36
    const { nodes, edges, combos } = graph;
×
37
    const cache: Record<string, string> = {};
×
38
    updateGraph({
×
39
      nodes: nodes?.map((node) => {
×
40
        const comboId = node.comboId || 'default';
×
41
        const color = cache[comboId] ? cache[comboId] : ColorUtils.getRandomColorFromStr(comboId);
×
42
        cache[comboId] = color;
×
43
        const stroke = ColorUtils.getHexForColor(color);
×
44
        return {
×
45
          ...node,
×
46
          label: `${node.label}`,
×
47
          style: {
×
48
            stroke,
×
49
            lineWidth: node.isSelected ? 5 : 1,
×
50
            lineDash: node.isSelected ? [6, 4] : undefined,
×
51
            fill: stroke,
×
52
          },
×
53
        };
×
54
      }),
×
55
      edges,
×
56
    });
×
57
    setTables(
×
58
      combos?.map((combo) => ({
×
59
        name: combo.label,
×
60
        color: ColorUtils.getHexForColor(cache[combo.id]) || '',
×
61
      }))
×
62
    );
×
63
  }, [planData, updateGraph]);
×
64

×
NEW
65
  const formatDuration = dayjs(Date.now() + estimateTime).fromNow();
×
NEW
66

×
67
  return (
×
68
    <div className="flex flex-col gap-2 pb-2">
×
NEW
69
      <div className="flex items-center gap-2 pb-2 text-sm">
×
NEW
70
        {t('table.graph.tableLabel')}
×
71
        {tables.map((table) => {
×
72
          return (
×
73
            <div
×
74
              key={table.color}
×
75
              className="flex items-center justify-center gap-1 rounded border px-1 py-[2px]"
×
76
              style={{
×
77
                borderColor: table.color,
×
78
                backgroundColor: table.color + '80',
×
79
              }}
×
80
            >
×
81
              <span>{table.name}</span>
×
82
            </div>
×
83
          );
×
84
        })}
×
85
      </div>
×
NEW
86
      <div className="flex items-center gap-2 text-xs">
×
NEW
87
        <div>
×
NEW
88
          {t('table.graph.effectCells')}:{' '}
×
NEW
89
          <Badge>{Intl.NumberFormat(i18n.language).format(updateCellCount || 0)}</Badge>
×
NEW
90
        </div>
×
NEW
91
        <div>
×
NEW
92
          {t('table.graph.estimatedTime')}: <b>{formatDuration}</b>
×
NEW
93
        </div>
×
94
      </div>
×
95
      <div className="relative flex h-[calc(100vh-400px)] max-h-[600px] w-full flex-col">
×
96
        <div ref={ref} className="grow rounded border shadow"></div>
×
97
      </div>
×
98
    </div>
×
99
  );
×
100
};
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc