korbit-ai[bot] commented on code in PR #34023:
URL: https://github.com/apache/superset/pull/34023#discussion_r2179486141
##########
superset/initialization/__init__.py:
##########
@@ -286,7 +286,9 @@ def init_views(self) -> None:
label=__("List Roles"),
category="Security",
category_label=__("Security"),
- icon="fa-lock",
+ menu_cond=lambda: bool(
+ appbuilder.app.config["SUPERSET_SECURITY_VIEW_MENU"]
+ ),
Review Comment:
### Duplicated menu visibility condition <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
The menu condition lambda function is repeated three times for different
security views (RolesListView, UsersListView, GroupsListView) with identical
logic.
###### Why this matters
Code duplication makes it harder to maintain consistent behavior across
security views and increases the chance of errors when modifying the condition.
###### Suggested change ∙ *Feature Preview*
Extract the repeated lambda into a named function at module level:
```python
def is_security_view_enabled() -> bool:
return bool(appbuilder.app.config["SUPERSET_SECURITY_VIEW_MENU"])
# Then use it like:
menu_cond=is_security_view_enabled
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/253dd741-a81e-44f6-9210-67c824137b97/upvote)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/253dd741-a81e-44f6-9210-67c824137b97?what_not_true=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/253dd741-a81e-44f6-9210-67c824137b97?what_out_of_scope=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/253dd741-a81e-44f6-9210-67c824137b97?what_not_in_standard=true)
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/253dd741-a81e-44f6-9210-67c824137b97)
</details>
<sub>
💬 Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:7b87136e-f6b0-49ae-a8d8-fab087728293 -->
[](7b87136e-f6b0-49ae-a8d8-fab087728293)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]