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

stacklok / codegate-ui / 12828464111

17 Jan 2025 11:48AM CUT coverage: 65.711% (+0.8%) from 64.918%
12828464111

Pull #94

github

web-flow
Merge de9616a3a into d873272ed
Pull Request #94: feat: initial work on codegate version check widget

223 of 416 branches covered (53.61%)

Branch coverage included in aggregate %.

42 of 48 new or added lines in 9 files covered. (87.5%)

442 of 596 relevant lines covered (74.16%)

27.08 hits per line

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

80.0
/src/features/dashboard-codegate-status/components/codegate-status-polling-control.tsx
1
import { Dispatch, SetStateAction } from "react";
2
import {
3
  Label,
4
  Select,
5
  SelectButton,
6
  TDropdownItemOrSection,
7
} from "@stacklok/ui-kit";
8

9
// NOTE: We don't poll more than once per minute, as the server depends on
10
// Github's public API, which is rate limited to 60reqs per hour.
11
export const POLLING_INTERVAl = {
3✔
12
  "1_MIN": { value: 60_000, name: "1 minute" },
13
  "5_MIN": { value: 300_000, name: "5 minutes" },
14
  "10_MIN": { value: 600_000, name: "10 minutes" },
15
} as const;
16

17
export const INTERVAL_SELECT_ITEMS: TDropdownItemOrSection[] = Object.entries(
3✔
18
  POLLING_INTERVAl,
19
).map(([key, { name }]) => {
20
  return { textValue: name, id: key };
9✔
21
});
22

23
export const DEFAULT_INTERVAL: PollingInterval = "5_MIN";
3✔
24

25
export type PollingInterval = keyof typeof POLLING_INTERVAl;
26

27
export function PollIntervalControl({
28
  className,
29
  pollingInterval,
30
  setPollingInterval,
31
}: {
32
  className?: string;
33
  pollingInterval: PollingInterval;
34
  setPollingInterval: Dispatch<SetStateAction<PollingInterval>>;
35
}) {
36
  return (
37
    <Select
38
      className={className}
39
      onSelectionChange={(v) =>
NEW
40
        setPollingInterval(v.toString() as PollingInterval)
×
41
      }
42
      items={INTERVAL_SELECT_ITEMS}
43
      defaultSelectedKey={pollingInterval}
44
    >
45
      <Label className="w-full text-right font-semibold text-secondary -mb-1">
46
        Check for updates
47
      </Label>
48
      <SelectButton
49
        isBorderless
50
        className="h-7 max-w-36 pr-0 [&>span>span]:text-right [&>span>span]:justify-end !gap-0 text-secondary"
51
      />
52
    </Select>
53
  );
54
}
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