• 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/HideFields.tsx
1
import { difference, map } from 'lodash';
×
2
import React from 'react';
×
3
import { useViewId, useFields, useView } from '../../hooks';
×
4
import type { GridView, IFieldInstance } from '../../model';
×
5
import { HideFieldsBase } from './HideFieldsBase';
×
6

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

×
15
  const filterFields = (fields: IFieldInstance[], shouldBeHidden?: boolean) =>
×
16
    fields.filter(
×
17
      ({ id }) =>
×
18
        activeViewId && (!shouldBeHidden || view?.columnMeta?.[id]?.hidden === shouldBeHidden)
×
19
    );
×
20

×
21
  const fieldData = filterFields(fields);
×
22
  const hiddenFieldIds = map(filterFields(fields, true), 'id');
×
23
  const hiddenCount = hiddenFieldIds.length;
×
24

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

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

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

×
45
  if (!activeViewId) {
×
46
    return <></>;
×
47
  }
×
48

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