]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix cdEncode decorator is not working on class 30064/head
authorKiefer Chang <kiefer.chang@suse.com>
Mon, 2 Sep 2019 07:54:53 +0000 (15:54 +0800)
committerKiefer Chang <kiefer.chang@suse.com>
Tue, 3 Sep 2019 07:36:11 +0000 (15:36 +0800)
Object.keys does not return all methods of a class.

Fixes: https://tracker.ceph.com/issues/41368
Signed-off-by: Kiefer Chang <kiefer.chang@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/shared/decorators/cd-encode.ts

index c77be120f9505d95e48cdd8468683d3a12cb7f15..744cd6a52fc145134697756fb4cd103b9404d861 100644 (file)
@@ -41,11 +41,12 @@ export function cdEncodeNot(target: Object, propertyKey: string, index: number)
 }
 
 function encodeClass(target: Function) {
-  for (const propertyName of Object.keys(target.prototype)) {
+  for (const propertyName of Object.getOwnPropertyNames(target.prototype)) {
     const descriptor = Object.getOwnPropertyDescriptor(target.prototype, propertyName);
 
     const isMethod = descriptor.value instanceof Function;
-    if (!isMethod) {
+    const isConstructor = propertyName === 'constructor';
+    if (!isMethod || isConstructor) {
       continue;
     }