@checkstack/ui 1.1.5 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# @checkstack/ui
|
|
2
2
|
|
|
3
|
+
## 1.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 23c80bc: ### Jira Data Center Support
|
|
8
|
+
|
|
9
|
+
Added support for on-premise Jira Data Center installations alongside existing Jira Cloud support:
|
|
10
|
+
|
|
11
|
+
- **Authentication mode switching**: New `authMode` field (`cloud` | `datacenter`) on connection configuration. Cloud uses Basic Auth (email + API token), Data Center uses Bearer Auth (Personal Access Token).
|
|
12
|
+
- **API version routing**: Automatically selects REST API v3 for Cloud and v2 for Data Center.
|
|
13
|
+
- **Description format**: Cloud uses Atlassian Document Format (ADF), Data Center uses plain text.
|
|
14
|
+
- **Connection schema v2**: Backward-compatible — defaults to `cloud` mode for existing connections.
|
|
15
|
+
|
|
16
|
+
### DynamicForm `x-hidden-when` Conditional Visibility
|
|
17
|
+
|
|
18
|
+
New generic platform feature for conditionally hiding form fields based on sibling field values:
|
|
19
|
+
|
|
20
|
+
- Added `x-hidden-when` metadata extension to `ConfigMeta` and `JsonSchemaProperty`.
|
|
21
|
+
- DynamicForm automatically hides fields and skips their validation when conditions match.
|
|
22
|
+
- Used by Jira integration to hide the email field when `authMode` is `datacenter`.
|
|
23
|
+
|
|
3
24
|
## 1.1.5
|
|
4
25
|
|
|
5
26
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import React from "react";
|
|
|
3
3
|
import { EmptyState } from "../../index";
|
|
4
4
|
|
|
5
5
|
import type { DynamicFormProps } from "./types";
|
|
6
|
-
import { extractDefaults, isValueEmpty } from "./utils";
|
|
6
|
+
import { extractDefaults, isValueEmpty, isFieldHiddenByCondition } from "./utils";
|
|
7
7
|
import { FormField } from "./FormField";
|
|
8
8
|
|
|
9
9
|
/**
|
|
@@ -50,6 +50,13 @@ export const DynamicForm: React.FC<DynamicFormProps> = ({
|
|
|
50
50
|
// Skip hidden fields - they are auto-populated
|
|
51
51
|
if (propSchema["x-hidden"]) continue;
|
|
52
52
|
|
|
53
|
+
// Skip conditionally hidden fields - they are not visible
|
|
54
|
+
if (
|
|
55
|
+
propSchema["x-hidden-when"] &&
|
|
56
|
+
isFieldHiddenByCondition(propSchema["x-hidden-when"], value)
|
|
57
|
+
)
|
|
58
|
+
continue;
|
|
59
|
+
|
|
53
60
|
if (isValueEmpty(value[key], propSchema)) {
|
|
54
61
|
isValid = false;
|
|
55
62
|
break;
|
|
@@ -79,7 +86,15 @@ export const DynamicForm: React.FC<DynamicFormProps> = ({
|
|
|
79
86
|
return (
|
|
80
87
|
<div className="space-y-6">
|
|
81
88
|
{Object.entries(schema.properties)
|
|
82
|
-
.filter(([, propSchema]) =>
|
|
89
|
+
.filter(([, propSchema]) => {
|
|
90
|
+
if (propSchema["x-hidden"]) return false;
|
|
91
|
+
if (
|
|
92
|
+
propSchema["x-hidden-when"] &&
|
|
93
|
+
isFieldHiddenByCondition(propSchema["x-hidden-when"], value)
|
|
94
|
+
)
|
|
95
|
+
return false;
|
|
96
|
+
return true;
|
|
97
|
+
})
|
|
83
98
|
.map(([key, propSchema]) => {
|
|
84
99
|
const isRequired = schema.required?.includes(key);
|
|
85
100
|
const label = key.charAt(0).toUpperCase() + key.slice(1);
|
|
@@ -21,6 +21,7 @@ export interface JsonSchemaProperty extends JsonSchemaPropertyCore<JsonSchemaPro
|
|
|
21
21
|
"x-hidden"?: boolean; // Field should be hidden in form (auto-populated)
|
|
22
22
|
"x-searchable"?: boolean; // Shows search input for filtering dropdown options
|
|
23
23
|
"x-editor-types"?: EditorType[]; // Available editor types for multi-type input
|
|
24
|
+
"x-hidden-when"?: Record<string, string[]>; // Conditionally hide based on sibling field values
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
/** Option returned by an options resolver */
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
extractDefaults,
|
|
6
6
|
getCleanDescription,
|
|
7
7
|
isValueEmpty,
|
|
8
|
+
isFieldHiddenByCondition,
|
|
8
9
|
NONE_SENTINEL,
|
|
9
10
|
parseSelectValue,
|
|
10
11
|
serializeFormData,
|
|
@@ -398,3 +399,71 @@ describe("detectEditorType", () => {
|
|
|
398
399
|
});
|
|
399
400
|
});
|
|
400
401
|
});
|
|
402
|
+
|
|
403
|
+
// =============================================================================
|
|
404
|
+
// Conditional Visibility Tests
|
|
405
|
+
// =============================================================================
|
|
406
|
+
|
|
407
|
+
describe("isFieldHiddenByCondition", () => {
|
|
408
|
+
it("returns true when sibling value matches a value in the array", () => {
|
|
409
|
+
const conditions = { authMode: ["datacenter"] };
|
|
410
|
+
const formValues = { authMode: "datacenter" };
|
|
411
|
+
expect(isFieldHiddenByCondition(conditions, formValues)).toBe(true);
|
|
412
|
+
});
|
|
413
|
+
|
|
414
|
+
it("returns true when sibling value matches any value in the array", () => {
|
|
415
|
+
const conditions = { authMode: ["datacenter", "server"] };
|
|
416
|
+
const formValues = { authMode: "server" };
|
|
417
|
+
expect(isFieldHiddenByCondition(conditions, formValues)).toBe(true);
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
it("returns false when sibling value does not match", () => {
|
|
421
|
+
const conditions = { authMode: ["datacenter"] };
|
|
422
|
+
const formValues = { authMode: "cloud" };
|
|
423
|
+
expect(isFieldHiddenByCondition(conditions, formValues)).toBe(false);
|
|
424
|
+
});
|
|
425
|
+
|
|
426
|
+
it("returns false when sibling field is missing (coerces to empty string)", () => {
|
|
427
|
+
const conditions = { authMode: ["datacenter"] };
|
|
428
|
+
const formValues = {};
|
|
429
|
+
expect(isFieldHiddenByCondition(conditions, formValues)).toBe(false);
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
it("returns true when sibling field is missing and empty string is in the value list", () => {
|
|
433
|
+
const conditions = { authMode: [""] };
|
|
434
|
+
const formValues = {};
|
|
435
|
+
expect(isFieldHiddenByCondition(conditions, formValues)).toBe(true);
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
it("handles multiple conditions with OR semantics (any match hides)", () => {
|
|
439
|
+
const conditions = {
|
|
440
|
+
authMode: ["datacenter"],
|
|
441
|
+
environment: ["staging"],
|
|
442
|
+
};
|
|
443
|
+
// Only authMode matches
|
|
444
|
+
expect(
|
|
445
|
+
isFieldHiddenByCondition(conditions, {
|
|
446
|
+
authMode: "datacenter",
|
|
447
|
+
environment: "production",
|
|
448
|
+
}),
|
|
449
|
+
).toBe(true);
|
|
450
|
+
// Only environment matches
|
|
451
|
+
expect(
|
|
452
|
+
isFieldHiddenByCondition(conditions, {
|
|
453
|
+
authMode: "cloud",
|
|
454
|
+
environment: "staging",
|
|
455
|
+
}),
|
|
456
|
+
).toBe(true);
|
|
457
|
+
// Neither matches
|
|
458
|
+
expect(
|
|
459
|
+
isFieldHiddenByCondition(conditions, {
|
|
460
|
+
authMode: "cloud",
|
|
461
|
+
environment: "production",
|
|
462
|
+
}),
|
|
463
|
+
).toBe(false);
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
it("returns false for empty conditions object", () => {
|
|
467
|
+
expect(isFieldHiddenByCondition({}, { authMode: "cloud" })).toBe(false);
|
|
468
|
+
});
|
|
469
|
+
});
|
|
@@ -72,6 +72,22 @@ export function isValueEmpty(
|
|
|
72
72
|
/** Sentinel value used to represent "None" selection in Select components */
|
|
73
73
|
export const NONE_SENTINEL = "__none__";
|
|
74
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Evaluate x-hidden-when conditions against current form values.
|
|
77
|
+
* Returns true if the field should be hidden.
|
|
78
|
+
*
|
|
79
|
+
* Each condition maps a sibling field name to values that trigger hiding.
|
|
80
|
+
* The field is hidden if ANY condition matches (OR semantics).
|
|
81
|
+
*/
|
|
82
|
+
export function isFieldHiddenByCondition(
|
|
83
|
+
conditions: Record<string, string[]>,
|
|
84
|
+
formValues: Record<string, unknown>,
|
|
85
|
+
): boolean {
|
|
86
|
+
return Object.entries(conditions).some(([field, values]) =>
|
|
87
|
+
values.includes(String(formValues[field] ?? "")),
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
75
91
|
/**
|
|
76
92
|
* Converts a select value to the actual form value.
|
|
77
93
|
* Handles the "None" sentinel value by returning undefined.
|