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

stacklok / codegate-ui / 13897242479

17 Mar 2025 10:32AM CUT coverage: 66.303% (-0.2%) from 66.498%
13897242479

Pull #379

github

web-flow
Merge b9537e8ba into a46703bce
Pull Request #379: feat: shareable workspaces MVP (frontend)

427 of 707 branches covered (60.4%)

Branch coverage included in aggregate %.

36 of 72 new or added lines in 14 files covered. (50.0%)

3 existing lines in 2 files now uncovered.

911 of 1311 relevant lines covered (69.49%)

40.3 hits per line

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

16.67
/src/features/workspace/components/workspace-upload-button.tsx
1
import { Button } from '@stacklok/ui-kit'
2
import { Upload01 } from '@untitled-ui/icons-react'
3
import { useMutationCreateWorkspace } from '../hooks/use-mutation-create-workspace'
4

5
interface WorkspaceUploadButtonProps {
6
  onSuccess?: () => void
7
}
8

9
export const WorkspaceUploadButton = ({
3✔
10
  onSuccess,
11
}: WorkspaceUploadButtonProps) => {
12
  const { mutateAsync: createWorkspace, isPending } =
13
    useMutationCreateWorkspace()
5✔
14

15
  const handleUpload = async () => {
5✔
NEW
16
    const input = document.createElement('input')
×
NEW
17
    input.type = 'file'
×
NEW
18
    input.accept = 'application/json'
×
19

NEW
20
    input.onchange = async (e) => {
×
NEW
21
      const file = (e.target as HTMLInputElement).files?.[0]
×
NEW
22
      if (!file) return
×
23

NEW
24
      try {
×
NEW
25
        const content = await file.text()
×
NEW
26
        const workspace = JSON.parse(content)
×
27

NEW
28
        createWorkspace(
×
29
          { body: workspace },
30
          {
31
            onSuccess: () => {
NEW
32
              onSuccess?.()
×
33
            },
34
          }
35
        )
36
      } catch (error) {
NEW
37
        console.error('Error parsing JSON file:', error)
×
38
        // You might want to add proper error handling here
39
      }
40
    }
41

NEW
42
    input.click()
×
43
  }
44

45
  return (
46
    <Button
47
      isIcon
48
      variant="secondary"
49
      onPress={handleUpload}
50
      isPending={isPending}
51
    >
52
      <Upload01 />
53
    </Button>
54
  )
55
}
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