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

teableio / teable / 10282126814

07 Aug 2024 09:54AM UTC coverage: 17.548% (-0.2%) from 17.734%
10282126814

Pull #793

github

web-flow
Merge a8c46f80b into 4854acca2
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/ExpandRecorder.tsx
1
import type { IRecord } from '@teable/core';
×
2
import { useToast } from '@teable/ui-lib';
×
NEW
3
import type { FC, PropsWithChildren } from 'react';
×
4
import { useLocalStorage } from 'react-use';
×
5
import { LocalStorageKeys } from '../../config/local-storage-keys';
×
6
import { StandaloneViewProvider, ViewProvider } from '../../context';
×
7
import { useTranslation } from '../../context/app/i18n';
×
NEW
8
import { useBaseId, useBasePermission, useTableId } from '../../hooks';
×
9
import { ExpandRecord } from './ExpandRecord';
×
10
import type { ExpandRecordModel } from './type';
×
11

×
12
const Wrap: FC<PropsWithChildren<{ tableId: string }>> = (props) => {
×
13
  const { tableId, children } = props;
×
14
  const currentTableId = useTableId();
×
15
  const baseId = useBaseId();
×
16

×
17
  if (tableId !== currentTableId) {
×
18
    return (
×
19
      <StandaloneViewProvider baseId={baseId} tableId={tableId}>
×
20
        <ViewProvider>{children}</ViewProvider>
×
21
      </StandaloneViewProvider>
×
22
    );
×
23
  }
×
24
  return <>{children}</>;
×
25
};
×
26

×
27
interface IExpandRecorderProps {
×
28
  tableId: string;
×
29
  viewId?: string;
×
30
  recordId?: string;
×
31
  recordIds?: string[];
×
32
  model?: ExpandRecordModel;
×
33
  serverData?: IRecord;
×
34
  onClose?: () => void;
×
35
  onUpdateRecordIdCallback?: (recordId: string) => void;
×
36
}
×
37

×
38
export const ExpandRecorder = (props: IExpandRecorderProps) => {
×
39
  const { model, tableId, recordId, recordIds, serverData, onClose, onUpdateRecordIdCallback } =
×
40
    props;
×
41
  const { toast } = useToast();
×
42
  const { t } = useTranslation();
×
NEW
43
  const basePermission = useBasePermission();
×
NEW
44
  const [recordHistoryVisible, setRecordHistoryVisible] = useLocalStorage<boolean>(
×
NEW
45
    LocalStorageKeys.RecordHistoryVisible,
×
46
    false
×
47
  );
×
48

×
49
  if (!recordId) {
×
50
    return <></>;
×
51
  }
×
52

×
53
  const updateCurrentRecordId = (recordId: string) => {
×
54
    onUpdateRecordIdCallback?.(recordId);
×
55
  };
×
56

×
57
  const onCopyUrl = () => {
×
58
    const url = window.location.href;
×
59
    navigator.clipboard.writeText(url);
×
60
    toast({ description: t('expandRecord.copy') });
×
61
  };
×
62

×
NEW
63
  const onRecordHistoryToggle = () => {
×
NEW
64
    setRecordHistoryVisible(!recordHistoryVisible);
×
65
  };
×
66

×
67
  return (
×
68
    <div id={`${tableId}-${recordId}`}>
×
69
      <Wrap tableId={tableId}>
×
70
        <ExpandRecord
×
71
          visible
×
72
          model={model}
×
73
          recordId={recordId}
×
74
          recordIds={recordIds}
×
75
          serverData={serverData?.id === recordId ? serverData : undefined}
×
NEW
76
          recordHistoryVisible={basePermission?.['record_history|read'] && recordHistoryVisible}
×
77
          onClose={onClose}
×
78
          onPrev={updateCurrentRecordId}
×
79
          onNext={updateCurrentRecordId}
×
80
          onCopyUrl={onCopyUrl}
×
NEW
81
          onRecordHistoryToggle={onRecordHistoryToggle}
×
82
        />
×
83
      </Wrap>
×
84
    </div>
×
85
  );
×
86
};
×
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