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

teableio / teable / 8536869866

03 Apr 2024 10:05AM CUT coverage: 21.234% (-0.3%) from 21.535%
8536869866

Pull #514

github

web-flow
Merge 91a25d710 into 45ee7ebb3
Pull Request #514: refactor: user and link selector

1394 of 2532 branches covered (55.06%)

27 of 1620 new or added lines in 60 files covered. (1.67%)

4 existing lines in 2 files now uncovered.

14588 of 68702 relevant lines covered (21.23%)

2.02 hits per line

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

0.0
/packages/sdk/src/components/editor/user/EditorMain.tsx
1
import { useQuery } from '@tanstack/react-query';
×
NEW
2
import type { IUserCellValue } from '@teable/core';
×
NEW
3
import { FieldType } from '@teable/core';
×
4
import { getBaseCollaboratorList } from '@teable/openapi';
×
5
import type { ForwardRefRenderFunction } from 'react';
×
NEW
6
import React, { forwardRef } from 'react';
×
7
import { ReactQueryKeys } from '../../../config';
×
8
import { useBase } from '../../../hooks';
×
NEW
9
import type { ICellEditor, ICellEditorContext } from '../type';
×
NEW
10
import type { IUserEditorRef } from './EditorBase';
×
NEW
11
import { UserEditorBase } from './EditorBase';
×
12

×
13
export interface IUserEditorMainProps extends ICellEditor<IUserCellValue | IUserCellValue[]> {
×
NEW
14
  isMultiple?: boolean;
×
15
  onChange?: (value?: IUserCellValue | IUserCellValue[]) => void;
×
16
  style?: React.CSSProperties;
×
17
  className?: string;
×
18
}
×
19

×
NEW
20
const DefaultDataWrapper = forwardRef<IUserEditorRef, IUserEditorMainProps>((props, ref) => {
×
21
  const { id: baseId } = useBase();
×
22
  const { data: collaborators, isLoading } = useQuery({
×
23
    queryKey: ReactQueryKeys.baseCollaboratorList(baseId),
×
24
    queryFn: ({ queryKey }) => getBaseCollaboratorList(queryKey[1]),
×
25
  });
×
26
  return (
×
NEW
27
    <UserEditorBase
×
NEW
28
      {...props}
×
NEW
29
      collaborators={collaborators?.data}
×
NEW
30
      isLoading={isLoading}
×
NEW
31
      ref={ref}
×
NEW
32
    />
×
33
  );
×
NEW
34
});
×
NEW
35

×
NEW
36
DefaultDataWrapper.displayName = 'UserDefaultDataWrapper';
×
NEW
37

×
NEW
38
const ContextDataWrapper = forwardRef<
×
NEW
39
  IUserEditorRef,
×
NEW
40
  IUserEditorMainProps & {
×
NEW
41
    contextData: ICellEditorContext[FieldType.User];
×
NEW
42
  }
×
NEW
43
>((props, ref) => {
×
NEW
44
  const { isLoading, data } = props.contextData;
×
NEW
45
  return <UserEditorBase {...props} collaborators={data} isLoading={isLoading} ref={ref} />;
×
NEW
46
});
×
NEW
47

×
NEW
48
ContextDataWrapper.displayName = 'UserContextDataWrapper';
×
NEW
49

×
NEW
50
const UserEditorMainBase: ForwardRefRenderFunction<IUserEditorRef, IUserEditorMainProps> = (
×
NEW
51
  props,
×
NEW
52
  ref
×
NEW
53
) => {
×
NEW
54
  const contextData = props.context?.[FieldType.User];
×
NEW
55

×
NEW
56
  if (contextData) {
×
NEW
57
    return <ContextDataWrapper {...props} contextData={contextData} ref={ref} />;
×
NEW
58
  }
×
NEW
59
  return <DefaultDataWrapper {...props} ref={ref} />;
×
60
};
×
61

×
62
export const UserEditorMain = forwardRef(UserEditorMainBase);
×
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