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

stacklok / codegate-ui / 13366154164

17 Feb 2025 08:40AM UTC coverage: 69.732% (+0.5%) from 69.244%
13366154164

push

github

web-flow
feat: add activate workspace button into detail page (#328)

Co-authored-by: Alex McGovern <58784948+alex-mcgovern@users.noreply.github.com>

413 of 650 branches covered (63.54%)

Branch coverage included in aggregate %.

11 of 12 new or added lines in 1 file covered. (91.67%)

1 existing line in 1 file now uncovered.

838 of 1144 relevant lines covered (73.25%)

68.83 hits per line

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

90.91
/src/features/workspace/components/workspace-activate-button.tsx
1
import { useMutationActivateWorkspace } from '@/hooks/use-mutation-activate-workspace'
2
import { useQueryActiveWorkspaceName } from '@/hooks/use-query-active-workspace-name'
3
import {
4
  Button,
5
  Tooltip,
6
  TooltipInfoButton,
7
  TooltipTrigger,
8
} from '@stacklok/ui-kit'
9
import { Check } from '@untitled-ui/icons-react'
10

11
function getTooltipText({
12
  isActivated,
13
  isArchived,
14
}: {
15
  isArchived: boolean
16
  isActivated: boolean
17
}) {
18
  if (isArchived) {
19!
NEW
19
    return 'Cannot activate an archived workspace'
×
20
  }
21

22
  if (isActivated) {
19✔
23
    return 'Workspace already active'
2✔
24
  }
25

26
  return null
17✔
27
}
28

29
function TooltipActivateBtn({
30
  isActivated,
31
  isArchived,
32
}: {
33
  isActivated: boolean
34
  isArchived: boolean
35
}) {
36
  const text = getTooltipText({ isActivated, isArchived })
19✔
37

38
  if (!text) return null
19✔
39
  return (
40
    <TooltipTrigger delay={0}>
41
      <TooltipInfoButton aria-label="Context active button" />
42
      <Tooltip>{text}</Tooltip>
43
    </TooltipTrigger>
44
  )
45
}
46

47
export function WorkspaceActivateButton({
48
  workspaceName,
49
  isArchived,
50
}: {
51
  workspaceName: string
52
  isArchived: boolean | undefined
53
}) {
54
  const { data: activeWorkspaceName, isPending: isPendingWsName } =
55
    useQueryActiveWorkspaceName()
19✔
56
  const { mutateAsync: activateWorkspace, isPending: isPendingMutation } =
57
    useMutationActivateWorkspace()
19✔
58
  const isActivated = activeWorkspaceName === workspaceName
19✔
59
  const isPending = isPendingWsName || isPendingMutation
19✔
60

61
  return (
62
    <div
63
      className="flex items-center justify-end gap-2"
64
      data-testid="workspace-activate"
65
    >
66
      <Button
67
        isDisabled={isActivated || isArchived}
36✔
68
        isPending={isPending}
69
        type="submit"
70
        onPress={() => activateWorkspace({ body: { name: workspaceName } })}
1✔
71
      >
72
        <Check /> Activate
73
      </Button>
74
      <TooltipActivateBtn isActivated={isActivated} isArchived={!!isArchived} />
75
    </div>
76
  )
77
}
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

© 2026 Coveralls, Inc