From: Kiefer Chang Date: Mon, 2 Sep 2019 07:54:53 +0000 (+0800) Subject: mgr/dashboard: fix cdEncode decorator is not working on class X-Git-Tag: v15.1.0~1666^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=2ccff703f101adacb9a888e72adf1a248554f795;p=ceph-ci.git mgr/dashboard: fix cdEncode decorator is not working on class Object.keys does not return all methods of a class. Fixes: https://tracker.ceph.com/issues/41368 Signed-off-by: Kiefer Chang --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/decorators/cd-encode.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/decorators/cd-encode.ts index c77be120f95..744cd6a52fc 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/decorators/cd-encode.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/decorators/cd-encode.ts @@ -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; }