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

stacklok / codegate-ui / 13261729647

11 Feb 2025 11:19AM UTC coverage: 68.226% (-0.5%) from 68.676%
13261729647

Pull #276

github

web-flow
Merge 5f42a30de into 7529f7310
Pull Request #276: feat: implement "Revert" button for workspace name

401 of 671 branches covered (59.76%)

Branch coverage included in aggregate %.

57 of 76 new or added lines in 11 files covered. (75.0%)

868 of 1189 relevant lines covered (73.0%)

73.49 hits per line

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

75.0
/src/forms/rerenders/utils.tsx
1
import type { ControlProps } from "@jsonforms/core";
2
import { Description, FieldError, Label } from "@stacklok/ui-kit";
3

4
export function getRACPropsFromJSONForms(props: ControlProps) {
5
  const { id, errors, required, enabled, handleChange, path, data } = props;
35✔
6

7
  return {
35✔
8
    isRequired: required,
9
    isInvalid: errors.length > 0,
10
    id: id,
11
    isDisabled: !enabled,
12
    onChange: (newValue: unknown) => handleChange(path, newValue),
24✔
13
    value: data,
14
  };
15
}
16

17
/**
18
 * Displays a `jsonforms` validation error if there is one.
19
 * Use when displaying the error in a different place
20
 * than the errors. Otherwise use <JsonFormsDescription />
21
 */
22
export function JsonFormsError({ errors }: ControlProps) {
23
  if (errors.length > 0) {
1!
24
    return <FieldError className="mt-1">{errors}</FieldError>;
25
  }
26

NEW
27
  return null;
×
28
}
29

30
export function JsonFormsDescription(props: ControlProps) {
31
  const { description, errors } = props;
35✔
32

33
  if (errors.length > 0) {
35✔
34
    return <JsonFormsError {...props} />;
35
  }
36

37
  if ((description ?? "").length === 0) {
34!
38
    return null;
34✔
39
  }
40

41
  return (
42
    <Description className="mt-2 text-secondary mb-4 text-base">
43
      {description}
44
    </Description>
45
  );
46
}
47

48
export function LabelWithDescription({
49
  label,
50
  isRequired = false,
×
51
  ...props
52
}: ControlProps & { isRequired?: boolean }) {
53
  return (
54
    <Label className="text-primary text-base mb-4">
55
      <div className="flex items-center mb-2">
56
        {label}{" "}
57
        {isRequired === true ? <span className="text-red-600">*</span> : null}
35!
58
      </div>
59
      <JsonFormsDescription label={label} {...props} />
60
    </Label>
61
  );
62
}
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