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

teableio / teable / 8538004962

03 Apr 2024 11:36AM CUT 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

0.0
/packages/sdk/src/components/hide-fields/VisibleFields.tsx
NEW
1
import { difference } from 'lodash';
×
NEW
2
import React, { useMemo } from 'react';
×
NEW
3
import { useViewId, useFields, useView } from '../../hooks';
×
NEW
4
import type { KanbanView } from '../../model';
×
NEW
5
import { HideFieldsBase } from './HideFieldsBase';
×
NEW
6

×
NEW
7
export const VisibleFields: React.FC<{
×
NEW
8
  footer?: React.ReactNode;
×
NEW
9
  children: (text: string, isActive: boolean) => React.ReactNode;
×
NEW
10
}> = ({ footer, children }) => {
×
NEW
11
  const activeViewId = useViewId();
×
NEW
12
  const totalFields = useFields({ withHidden: true });
×
NEW
13
  const view = useView() as KanbanView | undefined;
×
NEW
14
  const columnMeta = view?.columnMeta;
×
NEW
15

×
NEW
16
  const hiddenFieldIds = useMemo(
×
NEW
17
    () =>
×
NEW
18
      totalFields
×
NEW
19
        .filter(({ id, isPrimary }) => !isPrimary && !columnMeta?.[id]?.visible)
×
NEW
20
        .map(({ id }) => id),
×
NEW
21
    [totalFields, columnMeta]
×
NEW
22
  );
×
NEW
23
  const hiddenCount = hiddenFieldIds.length;
×
NEW
24

×
NEW
25
  const onChange = (hidden: string[]) => {
×
NEW
26
    if (!activeViewId) {
×
NEW
27
      return;
×
NEW
28
    }
×
NEW
29
    const hiddenIds = difference(hidden, hiddenFieldIds);
×
NEW
30
    const showIds = difference(hiddenFieldIds, hidden);
×
NEW
31

×
NEW
32
    if (view) {
×
NEW
33
      hiddenIds.length &&
×
NEW
34
        view.updateColumnMeta(
×
NEW
35
          hiddenIds.map((id) => ({ fieldId: id, columnMeta: { visible: false } }))
×
NEW
36
        );
×
NEW
37

×
NEW
38
      showIds.length &&
×
NEW
39
        view.updateColumnMeta(
×
NEW
40
          showIds.map((id) => ({ fieldId: id, columnMeta: { visible: true } }))
×
NEW
41
        );
×
NEW
42
    }
×
NEW
43
  };
×
NEW
44

×
NEW
45
  if (!activeViewId) {
×
NEW
46
    return null;
×
NEW
47
  }
×
NEW
48

×
NEW
49
  return (
×
NEW
50
    <HideFieldsBase
×
NEW
51
      footer={footer}
×
NEW
52
      fields={totalFields}
×
NEW
53
      hidden={hiddenFieldIds}
×
NEW
54
      onChange={onChange}
×
NEW
55
    >
×
NEW
56
      {children(
×
NEW
57
        hiddenCount ? `${hiddenCount} hidden field(s)` : 'Hide fields',
×
NEW
58
        Boolean(hiddenCount)
×
NEW
59
      )}
×
NEW
60
    </HideFieldsBase>
×
NEW
61
  );
×
NEW
62
};
×
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