From 2ccff703f101adacb9a888e72adf1a248554f795 Mon Sep 17 00:00:00 2001 From: Kiefer Chang Date: Mon, 2 Sep 2019 15:54:53 +0800 Subject: [PATCH] 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 --- .../frontend/src/app/shared/decorators/cd-encode.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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; } -- 2.39.5