Skip to content

Commit 7624ea2

Browse files
authored
fix matter binding detele error (#1232)
1 parent cb500a3 commit 7624ea2

File tree

3 files changed

+16
-33
lines changed

3 files changed

+16
-33
lines changed

dashboard/src/components/dialogs/acl/model.ts

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11

2+
export type AccessControlTargetStruct = {
3+
cluster: number | undefined;
4+
endpoint: number | undefined;
5+
deviceType: number | undefined;
6+
};
7+
28
export type AccessControlEntryRawInput = {
39
"1": number;
410
"2": number;
511
"3": number[];
6-
"4": null;
12+
"4": AccessControlTargetStruct[] | undefined;
713
"254": number;
814
};
915

10-
export type AccessControlTargetStruct = {
11-
cluster: number | undefined;
12-
endpoint: number | undefined;
13-
deviceType: number | undefined;
14-
};
15-
1616
export type AccessControlEntryStruct = {
1717
privilege: number;
1818
authMode: number;
@@ -95,15 +95,6 @@ export class AccessControlEntryDataTransformer {
9595
}
9696
}
9797

98-
if (
99-
result.privilege === undefined ||
100-
result.authMode === undefined ||
101-
result.subjects === undefined ||
102-
result.fabricIndex === undefined
103-
) {
104-
throw new Error("Missing required fields in AccessControlEntryStruct");
105-
}
106-
10798
return result as AccessControlEntryStruct;
10899
}
109100
}

dashboard/src/components/dialogs/binding/model.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,6 @@ export class BindingEntryDataTransformer {
4747
}
4848
}
4949

50-
// Validate required fields
51-
if (
52-
result.node === undefined ||
53-
result.endpoint === undefined ||
54-
result.fabricIndex === undefined
55-
) {
56-
throw new Error("Missing required fields in BindingEntryStruct");
57-
}
58-
5950
return result as BindingEntryStruct;
6051
}
6152
}

dashboard/src/components/dialogs/binding/node-binding-dialog.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ export class NodeBindingDialog extends LitElement {
5757
private fetchACLEntry(targetNodeId: number): AccessControlEntryStruct[] {
5858
const acl_cluster_raw: [InputType] =
5959
this.client.nodes[targetNodeId].attributes["0/31/0"];
60-
6160
return Object.values(acl_cluster_raw).map((value: InputType) =>
6261
AccessControlEntryDataTransformer.transform(value),
6362
);
@@ -67,9 +66,10 @@ export class NodeBindingDialog extends LitElement {
6766
const rawBindings = this.fetchBindingEntry();
6867
try {
6968
const targetNodeId = rawBindings[index].node;
69+
const endpoint = rawBindings[index].endpoint;
7070
await this.removeNodeAtACLEntry(
7171
this.node!.node_id,
72-
this.endpoint,
72+
endpoint,
7373
targetNodeId,
7474
);
7575
const updatedBindings = this.removeBindingAtIndex(rawBindings, index);
@@ -92,23 +92,21 @@ export class NodeBindingDialog extends LitElement {
9292
)
9393
.filter((entry): entry is Exclude<typeof entry, null> => entry !== null);
9494

95-
console.log(updatedACLEntries);
9695
await this.client.setACLEntry(targetNodeId, updatedACLEntries);
9796
}
9897

9998
private removeEntryAtACL(
10099
nodeId: number,
101100
sourceEndpoint: number,
102101
entry: AccessControlEntryStruct,
103-
): AccessControlEntryStruct | null {
102+
): AccessControlEntryStruct | undefined {
104103
const hasSubject = entry.subjects!.includes(nodeId);
105-
106104
if (!hasSubject) return entry;
107105

108106
const hasTarget = entry.targets!.filter(
109107
(item) => item.endpoint === sourceEndpoint,
110108
);
111-
return hasTarget.length > 0 ? null : entry;
109+
return hasTarget.length > 0 ? undefined : entry;
112110
}
113111

114112
private removeBindingAtIndex(
@@ -216,7 +214,7 @@ export class NodeBindingDialog extends LitElement {
216214
return;
217215
}
218216
if (isNaN(targetCluster) || targetCluster < 0) {
219-
alert("Please enter a valid target endpoint");
217+
alert("Please enter a valid target cluster");
220218
return;
221219
}
222220

@@ -234,7 +232,10 @@ export class NodeBindingDialog extends LitElement {
234232
fabricIndex: this.client.connection.serverInfo!.fabric_id,
235233
};
236234
const result_acl = await this.add_target_acl(targetNodeId, acl_entry);
237-
if (!result_acl) return;
235+
if (!result_acl) {
236+
alert("add target acl error!");
237+
return;
238+
}
238239

239240
const endpoint = this.endpoint;
240241
const bindingEntry: BindingEntryStruct = {

0 commit comments

Comments
 (0)