• 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
/apps/nextjs-app/src/features/app/blocks/table/table-header/AddView.tsx
1
import { ViewType } from '@teable/core';
×
2
import { Plus } from '@teable/icons';
×
3
import { useTablePermission } from '@teable/sdk/hooks';
×
4
import { Button, Popover, PopoverContent, PopoverTrigger, cn } from '@teable/ui-lib/shadcn';
×
5
import { useState } from 'react';
×
6
import { GUIDE_CREATE_VIEW } from '@/components/Guide';
×
7
import { VIEW_ICON_MAP } from '../../view/constant';
×
8
import { useAddView } from '../../view/list/useAddView';
×
9

×
10
const VIEW_INFO_LIST = [
×
11
  {
×
12
    name: 'Grid View',
×
13
    type: ViewType.Grid,
×
14
    Icon: VIEW_ICON_MAP[ViewType.Grid],
×
15
  },
×
16
  {
×
17
    name: 'Form View',
×
18
    type: ViewType.Form,
×
19
    Icon: VIEW_ICON_MAP[ViewType.Form],
×
20
  },
×
NEW
21
  {
×
NEW
22
    name: 'Kanban View',
×
NEW
23
    type: ViewType.Kanban,
×
NEW
24
    Icon: VIEW_ICON_MAP[ViewType.Kanban],
×
NEW
25
  },
×
26
];
×
27

×
28
export const AddView: React.FC = () => {
×
29
  const addView = useAddView();
×
30
  const permission = useTablePermission();
×
31
  const [isOpen, setOpen] = useState(false);
×
32

×
33
  const onClick = (type: ViewType, name: string) => {
×
34
    addView(type, name.split(' ')[0]);
×
35
    setOpen(false);
×
36
  };
×
37

×
38
  if (!permission['view|create']) {
×
39
    return null;
×
40
  }
×
41

×
42
  return (
×
43
    <Popover open={isOpen} onOpenChange={setOpen}>
×
44
      <PopoverTrigger asChild>
×
45
        <Button
×
46
          className={cn(GUIDE_CREATE_VIEW, 'size-7 shrink-0 px-0')}
×
47
          size={'xs'}
×
48
          variant={'outline'}
×
49
        >
×
50
          <Plus className="size-4" />
×
51
        </Button>
×
52
      </PopoverTrigger>
×
53
      <PopoverContent side="bottom" align="start" className="w-40 p-0">
×
54
        {VIEW_INFO_LIST.map((item) => {
×
55
          const { name, type, Icon } = item;
×
56
          return (
×
57
            <Button
×
58
              key={type}
×
59
              variant={'ghost'}
×
60
              size={'xs'}
×
61
              className="w-full justify-start font-normal"
×
62
              onClick={() => onClick(type, name)}
×
63
            >
×
64
              <Icon className="pr-1 text-lg" />
×
65
              {name}
×
66
            </Button>
×
67
          );
×
68
        })}
×
69
      </PopoverContent>
×
70
    </Popover>
×
71
  );
×
72
};
×
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