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

teableio / teable / 10281066376

07 Aug 2024 08:42AM UTC coverage: 17.548% (-0.2%) from 17.734%
10281066376

Pull #793

github

web-flow
Merge 425f5ab0e into 6131ee284
Pull Request #793: feat: record history

1387 of 2823 branches covered (49.13%)

6 of 1033 new or added lines in 43 files covered. (0.58%)

34 existing lines in 5 files now uncovered.

14088 of 80281 relevant lines covered (17.55%)

1.74 hits per line

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

0.0
/packages/sdk/src/components/expand-record/ExpandRecordHeader.tsx
NEW
1
import { ChevronDown, ChevronUp, History, Link, X } from '@teable/icons';
×
2
import { Button, Separator, cn } from '@teable/ui-lib';
×
3
import { useMeasure } from 'react-use';
×
4
import { useTranslation } from '../../context/app/i18n';
×
NEW
5
import { useBasePermission } from '../../hooks';
×
6
import { TooltipWrap } from './TooltipWrap';
×
7

×
8
interface IExpandRecordHeader {
×
9
  title?: string;
×
NEW
10
  recordHistoryVisible?: boolean;
×
11
  disabledPrev?: boolean;
×
12
  disabledNext?: boolean;
×
13
  onClose?: () => void;
×
14
  onPrev?: () => void;
×
15
  onNext?: () => void;
×
16
  onCopyUrl?: () => void;
×
NEW
17
  onRecordHistoryToggle?: () => void;
×
18
}
×
19

×
20
// eslint-disable-next-line @typescript-eslint/naming-convention
×
21
const MIN_TITLE_WIDTH = 300;
×
22
// eslint-disable-next-line @typescript-eslint/naming-convention
×
23
const MIN_OPERATOR_WIDTH = 200;
×
24

×
25
export const ExpandRecordHeader = (props: IExpandRecordHeader) => {
×
26
  const {
×
27
    title,
×
NEW
28
    recordHistoryVisible,
×
29
    disabledPrev,
×
30
    disabledNext,
×
31
    onPrev,
×
32
    onNext,
×
33
    onClose,
×
34
    onCopyUrl,
×
NEW
35
    onRecordHistoryToggle,
×
36
  } = props;
×
37

×
NEW
38
  const basePermission = useBasePermission();
×
39
  const [ref, { width }] = useMeasure<HTMLDivElement>();
×
40
  const { t } = useTranslation();
×
41
  const showTitle = width > MIN_TITLE_WIDTH;
×
42
  const showOperator = width > MIN_OPERATOR_WIDTH;
×
43

×
44
  return (
×
45
    <div
×
46
      ref={ref}
×
47
      className={cn(
×
48
        'w-full h-12 flex items-center gap-4 px-4 border-b border-solid border-border',
×
49
        'justify-between' && !showTitle
×
50
      )}
×
51
    >
×
52
      <div>
×
53
        <TooltipWrap description="Previous record" disabled={disabledPrev}>
×
54
          <Button
×
55
            variant={'ghost'}
×
56
            tabIndex={-1}
×
57
            size={'xs'}
×
58
            onClick={onPrev}
×
59
            disabled={disabledPrev}
×
60
          >
×
61
            <ChevronUp />
×
62
          </Button>
×
63
        </TooltipWrap>
×
64
        <TooltipWrap description="Next record" disabled={disabledNext}>
×
65
          <Button
×
66
            variant={'ghost'}
×
67
            size={'xs'}
×
68
            tabIndex={-1}
×
69
            onClick={onNext}
×
70
            disabled={disabledNext}
×
71
          >
×
72
            <ChevronDown />
×
73
          </Button>
×
74
        </TooltipWrap>
×
75
      </div>
×
76
      {showTitle && (
×
77
        <h4
×
78
          title={title}
×
79
          className="flex-1 scroll-m-20 truncate text-xl font-semibold tracking-tight"
×
80
        >
×
81
          {title || t('common.unnamedRecord')}
×
82
        </h4>
×
83
      )}
×
84
      {showOperator && (
×
85
        <div>
×
NEW
86
          <TooltipWrap description={t('expandRecord.copyRecordUrl')}>
×
87
            <Button variant={'ghost'} size={'xs'} onClick={onCopyUrl}>
×
88
              <Link />
×
89
            </Button>
×
90
          </TooltipWrap>
×
NEW
91
          {basePermission?.['record_history|read'] && (
×
NEW
92
            <TooltipWrap
×
NEW
93
              description={
×
NEW
94
                recordHistoryVisible
×
NEW
95
                  ? t('expandRecord.recordHistory.hiddenRecordHistory')
×
NEW
96
                  : t('expandRecord.recordHistory.showRecordHistory')
×
NEW
97
              }
×
98
            >
×
NEW
99
              <Button
×
NEW
100
                variant={recordHistoryVisible ? 'secondary' : 'ghost'}
×
NEW
101
                size={'xs'}
×
NEW
102
                onClick={onRecordHistoryToggle}
×
NEW
103
              >
×
NEW
104
                <History />
×
NEW
105
              </Button>
×
NEW
106
            </TooltipWrap>
×
NEW
107
          )}
×
108
        </div>
×
109
      )}
×
110
      <Separator className="h-6" orientation="vertical" />
×
111
      <Button variant={'ghost'} size={'xs'} onClick={onClose}>
×
112
        <X />
×
113
      </Button>
×
114
    </div>
×
115
  );
×
116
};
×
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