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

teableio / teable / 8470050671

28 Mar 2024 03:54PM UTC coverage: 21.785% (-0.05%) from 21.838%
8470050671

Pull #507

github

web-flow
Merge c24fe3a68 into 53432a5aa
Pull Request #507: feat: search api

1396 of 2505 branches covered (55.73%)

23 of 544 new or added lines in 74 files covered. (4.23%)

36 existing lines in 4 files now uncovered.

14551 of 66795 relevant lines covered (21.78%)

2.08 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/table/table-header/TableInfo.tsx
1
import { Table2 } from '@teable/icons';
×
2
import { useConnection, useTable, useTablePermission } from '@teable/sdk/hooks';
×
3
import { Spin } from '@teable/ui-lib/base';
×
NEW
4
import { cn, Input } from '@teable/ui-lib/shadcn';
×
5
import dayjs from 'dayjs';
×
6
import relativeTime from 'dayjs/plugin/relativeTime';
×
7
import { useState } from 'react';
×
8
import { Emoji } from '@/features/app/components/emoji/Emoji';
×
9
import { EmojiPicker } from '@/features/app/components/emoji/EmojiPicker';
×
10
dayjs.extend(relativeTime);
×
11

×
12
export const TableInfo: React.FC<{ className?: string }> = ({ className }) => {
×
13
  const { connected } = useConnection();
×
14
  const permission = useTablePermission();
×
15
  const [isEditing, setIsEditing] = useState(false);
×
16
  const table = useTable();
×
17

×
18
  const icon = table?.icon ? (
×
19
    <Emoji size={'1.25rem'} emoji={table.icon} />
×
20
  ) : (
×
21
    <Table2 className="size-5" />
×
22
  );
×
23
  return (
×
24
    <div
×
NEW
25
      className={cn('flex justify-center items-center relative overflow-hidden gap-2', className)}
×
26
    >
×
27
      {connected ? (
×
28
        <EmojiPicker
×
29
          className="flex size-5 cursor-pointer items-center justify-center hover:bg-muted-foreground/60"
×
30
          onChange={(icon: string) => table?.updateIcon(icon)}
×
31
          disabled={!permission['table|update']}
×
32
        >
×
33
          {icon}
×
34
        </EmojiPicker>
×
35
      ) : (
×
36
        <Spin />
×
37
      )}
×
38
      <div className="relative flex h-7 shrink-0 grow-0 flex-col items-start justify-center">
×
39
        <div
×
40
          className="text-sm leading-none"
×
41
          onDoubleClick={() => {
×
42
            permission['table|update'] && setIsEditing(true);
×
43
          }}
×
44
        >
×
45
          {table?.name}
×
46
        </div>
×
47
        {isEditing && (
×
48
          <Input
×
49
            type="text"
×
50
            defaultValue={table?.name}
×
51
            style={{
×
52
              boxShadow: 'none',
×
53
            }}
×
54
            className="round-none absolute left-0 top-0 size-full cursor-text bg-background px-2 outline-none"
×
55
            // eslint-disable-next-line jsx-a11y/no-autofocus
×
56
            autoFocus
×
57
            onBlur={(e) => {
×
58
              if (e.target.value && e.target.value !== table?.name) {
×
59
                table?.updateName(e.target.value);
×
60
              }
×
61
              setIsEditing(false);
×
62
            }}
×
63
            onKeyDown={(e) => {
×
64
              if (e.key === 'Enter') {
×
65
                if (e.currentTarget.value && e.currentTarget.value !== table?.name) {
×
66
                  table?.updateName(e.currentTarget.value);
×
67
                }
×
68
                setIsEditing(false);
×
69
              }
×
70
            }}
×
71
            onMouseDown={(e) => {
×
72
              e.stopPropagation();
×
73
            }}
×
74
          />
×
75
        )}
×
76
        <div className="hidden text-xs leading-none text-slate-400 sm:block">
×
77
          last modified: {dayjs(table?.lastModifiedTime).fromNow()}
×
78
        </div>
×
79
      </div>
×
80
    </div>
×
81
  );
×
82
};
×
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