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

teableio / teable / 8538004962

03 Apr 2024 11:36AM UTC coverage: 18.233% (-3.3%) from 21.535%
8538004962

Pull #528

github

web-flow
Merge c1a248a6f into 45ee7ebb3
Pull Request #528: feat: Kanban view

575 of 1136 branches covered (50.62%)

29 of 2908 new or added lines in 83 files covered. (1.0%)

5 existing lines in 5 files now uncovered.

6439 of 35315 relevant lines covered (18.23%)

3.94 hits per line

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

22.58
/packages/sdk/src/hooks/use-fields.ts
1
import { ViewType } from '@teable/core';
1✔
2
import { sortBy } from 'lodash';
1✔
3
import { useContext, useMemo } from 'react';
1✔
4
import { FieldContext } from '../context';
1✔
5
import { useView } from './use-view';
1✔
6

1✔
7
export function useFields(options: { withHidden?: boolean } = {}) {
1✔
8
  const { withHidden } = options;
×
NEW
9
  const { fields: originFields } = useContext(FieldContext);
×
10
  const view = useView();
×
NEW
11
  const { type: viewType, columnMeta } = view ?? {};
×
12

×
13
  return useMemo(() => {
×
NEW
14
    const sortedFields = sortBy(originFields, (field) => columnMeta?.[field.id]?.order ?? Infinity);
×
15

×
NEW
16
    if (withHidden || viewType == null) {
×
NEW
17
      return sortedFields;
×
NEW
18
    }
×
NEW
19
    if (viewType === ViewType.Form) {
×
NEW
20
      return sortedFields.filter(({ id }) => columnMeta?.[id]?.visible);
×
21
    }
×
NEW
22
    if (viewType === ViewType.Kanban) {
×
NEW
23
      return sortedFields.filter(({ id, isPrimary }) => {
×
NEW
24
        return isPrimary || columnMeta?.[id]?.visible;
×
NEW
25
      });
×
NEW
26
    }
×
NEW
27

×
NEW
28
    return sortedFields.filter(({ id }) => !columnMeta?.[id]?.hidden);
×
NEW
29
    // eslint-disable-next-line react-hooks/exhaustive-deps
×
NEW
30
  }, [originFields, withHidden, viewType, JSON.stringify(columnMeta)]);
×
UNCOV
31
}
×
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