Repository navigation
mgr/dashboard: fix error while accessing roles tab when policy attached - #55462
Conversation
|
jenkins test make check |
|
jenkins retest this please |
There was a problem hiding this comment.
it is generally not advised to use the function calls in templates because of the way angular change detection is triggered. You can test this out by putting a console log in the function and see how many times its getting called
Maybe we can move this logic or call this from processMeta function instead and do the processing if its required and update the meta.detail_columns with the newer values and then pass these updated value to the template?
Also this change means that we are passing expandedRow[column] through the json stringify even if it is not meant to be. Can we do this conditionally?
There was a problem hiding this comment.
it is generally not advised to use the function calls in templates because of the way angular change detection is triggered. You can test this out by putting a console log in the function and see how many times its getting called
Maybe we can move this logic or call this from
processMetafunction instead and do the processing if its required and update themeta.detail_columnswith the newer values and then pass these updated value to the template?
I can check that surely.. makes sense if its not efficient.
I liked the idea of moving to processMeta and I can look into that...
Also this change means that we are passing
expandedRow[column]through the json stringify even if it is not meant to be. Can we do this conditionally?
I have changed the JSON.stringify replacer function, If you check the other file, if its a non-string, non-json, it will be returned as is.
The reason for doing this was first I tried json pipe which actually not taking care of escape sequences and was rendering them as it is. In a nutshell, it was non formatted json
I tried conditional way as well, and it was hardcoding certain fields or checking type of objects..
The expandedRow[column] is something coming as array of objects or strings, or objects.
There was a problem hiding this comment.
/**
* Checks strings for JSON value
* If yes, returns the parsed value
* If no, returns the original string
*
* For non-strings, return as it is
**/
customJSONStringify(rowValue: any) {
return JSON.stringify(
rowValue,
(_key: string, value: any) => {
if (typeof value === 'string') {
try {
const parsedValue = JSON.parse(value);
return parsedValue;
} catch (e) {
return value; // returns string but non-json object as it is
}
}
return value; // returns non-string values as it is
},
2
);
}
}
I have added a custom replacer function, so only valid values which are meant to be parsed will go through..
There was a problem hiding this comment.
PS: Just one thing more since we are discussing this here, we can have a custom json pipe for our full dashboard or a generic function that can be used across all since this is a very common use case.
But since this is a very specific it did not amke sense to me to make a very prominent change..
We have json dump required at buckets page as well... and perhaps more in future as its a very common thing that comes from entities.
Thanks for the review!
There was a problem hiding this comment.
yup, i agree. probably a generic pipe could be useful later on for us.
|
Hi @nizamial09 , I have updated the PR , combining all of your comments. PTAL and suggest if there is a better approach, I have come up with this current working now! Summary of changes:
Still, if there is any better approach for formatting deep nested json objects on UI let me know. Thanks! |
|
jenkins retest this please |
nizamial09
left a comment
There was a problem hiding this comment.
Thank you @afreen23. LGTM!
One thing that we need to do later on is to implement the ability to attach policies to a role from the UI. While testing it, I saw that we are missing that feature.
|
and btw, since you are fixing the bug here I think the title of the PR should clearly represent that. and there are some unit-test failures. |
Cool! I will create a tracker for this..so as to not miss this.. |
Fixes https://tracker.ceph.com/issues/64270 Issue: ====== Accessing Object->Users-Roles tab causing 500 internal servor error. This is due to the "PermissionPolicies" which are attached to role and backend was not handling this field for rgw roles. Fix: ==== Added "PermissionPolicies" as the valid field in backend and updated frontend to render the attached policy in formatted JSON Signed-off-by: Afreen <[email protected]>
Done with these...thanks! |
|
jenkins test make check arm64 |
|
jenkins test dashboard cephadm |
|
jenkins test dashboard |
1 similar comment
|
jenkins test dashboard |

Fixes https://tracker.ceph.com/issues/64270
Issue:
Accessing Object->Users-Roles tab causing 500 internal servor error. This is due to the "PermissionPolicies" which are attached to role and backend was not handling this field for rgw roles.

Fix:
Added "PermissionPolicies" as the valid field in backend and updated frontend to render the attached policy in formatted JSON

Checklist
Show available Jenkins commands
jenkins retest this pleasejenkins test classic perfjenkins test crimson perfjenkins test signedjenkins test make checkjenkins test make check arm64jenkins test submodulesjenkins test dashboardjenkins test dashboard cephadmjenkins test apijenkins test docsjenkins render docsjenkins test ceph-volume alljenkins test ceph-volume toxjenkins test windowsjenkins test rook e2e