Skip to content

Commit d26289d

Browse files
authored
Enable node selection in node trigger rule form (#6468)
* add constants * add custom form for node trigger rule * use custom form * fix handle submit * 🔧 * update comment * remove log * 🔧 * use new hook * 🔧 * add const * use NodeKind in attributes for core namespace and node_kind attributes * migrate webhook form * remove forms * remove const
1 parent 5bd9599 commit d26289d

File tree

7 files changed

+9
-123
lines changed

7 files changed

+9
-123
lines changed

frontend/app/src/entities/schema/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const ATTRIBUTE_KIND = {
2222
JSON: "JSON",
2323
ANY: "Any",
2424
BOOLEAN: "Boolean",
25+
NODE_KIND: "NodeKind",
2526
} as const;
2627

2728
// Reference: https://docs.infrahub.app/topics/schema > Attribute kinds behavior in the UI

frontend/app/src/entities/schema/ui/providers/schema-provider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ export const SchemaProvider = ({ children }: { children?: React.ReactNode }) =>
6868
...R.fromPairs(schemaKindNameTuples),
6969
SchemaAttribute: "Attribute",
7070
SchemaRelationship: "Relationship",
71-
SchemaNode: "Node",
71+
NodeKind: "Node",
7272
};
7373

7474
const schemaLabels = [
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export const NODE_TRIGGER_ATTRIBUTE = "CoreNodeTriggerAttributeMatch";
2+
export const NODE_TRIGGER_RELATIONSHIP = "CoreNodeTriggerRelationshipMatch";

frontend/app/src/entities/webhook/ui/webhook-form.tsx

Lines changed: 0 additions & 113 deletions
This file was deleted.

frontend/app/src/shared/components/form/dynamic-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ export const DynamicInput = (props: DynamicFieldProps) => {
132132

133133
return <RelationshipField {...props} />;
134134
}
135-
case "kind": {
135+
case ATTRIBUTE_KIND.NODE_KIND: {
136136
return <NodeKindField {...props} />;
137137
}
138138
default: {

frontend/app/src/shared/components/form/object-form.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ import {
22
ACCOUNT_GROUP_OBJECT,
33
ACCOUNT_OBJECT,
44
ACCOUNT_ROLE_OBJECT,
5-
CUSTOM_WEBHOOK_OBJECT,
65
GLOBAL_PERMISSION_OBJECT,
76
NUMBER_POOL_OBJECT,
87
OBJECT_PERMISSION_OBJECT,
98
READONLY_REPOSITORY_KIND,
109
REPOSITORY_KIND,
11-
STANDARD_WEBHOOK_OBJECT,
1210
} from "@/config/constants";
1311

1412
import { AttributeType, RelationshipType } from "@/entities/nodes/getObjectItemDisplayValue";
@@ -24,7 +22,6 @@ import { GlobalPermissionForm } from "@/entities/role-manager/ui/global-permissi
2422
import { ObjectPermissionForm } from "@/entities/role-manager/ui/object-permissions-form";
2523
import { useSchema } from "@/entities/schema/ui/hooks/useSchema";
2624
import { getTemplateRelationshipFromSchema } from "@/entities/schema/utils/get-template-relationship-from-schema";
27-
import { WebhookForm } from "@/entities/webhook/ui/webhook-form";
2825
import NoDataFound from "@/shared/components/errors/no-data-found";
2926
import { DynamicFormProps } from "@/shared/components/form/dynamic-form";
3027
import { GenericObjectForm } from "@/shared/components/form/generic-object-form";
@@ -129,10 +126,6 @@ const ObjectForm = ({ kind, currentProfiles, ...props }: ObjectFormProps) => {
129126
return <NodeWithProfileForm schema={schema} profiles={currentProfiles} {...props} />;
130127
}
131128

132-
if (kind === STANDARD_WEBHOOK_OBJECT || kind === CUSTOM_WEBHOOK_OBJECT) {
133-
return <WebhookForm schema={schema} kind={kind} {...props} />;
134-
}
135-
136129
return <NodeForm schema={schema} profiles={currentProfiles} {...props} />;
137130
};
138131

frontend/app/src/shared/components/form/utils/getFormFieldFromAttribute.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ export const getFormFieldFromAttribute = ({
5757
permissions: { update: attributeData?.permissions?.update_value },
5858
isReadOnly: attributeSchema.read_only,
5959
}),
60-
type: attributeSchema.kind as Exclude<AttributeKind, "Dropdown">,
60+
type:
61+
schema.namespace === "Core" && attributeSchema.name === "node_kind"
62+
? "NodeKind"
63+
: (attributeSchema.kind as Exclude<AttributeKind, "Dropdown">),
6164
rules: {
6265
required: !isFilterForm && !attributeSchema.optional,
6366
validate: {

0 commit comments

Comments
 (0)