You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/01/26 11:49:11 UTC

[GitHub] [superset] ayanginet opened a new issue #12768: Redirect happens whenever user changes language

ayanginet opened a new issue #12768:
URL: https://github.com/apache/superset/issues/12768


   When the user presses on change language a redirect to `/users/list` happens. I think, in terms of UX, it should remain on the same page as before changing the language.
   
   ### Expected results
   
   Remain on the same page, but translated into a different language.
   
   ### Actual results
   
   Redirects to `users/list`.
   
   #### Screenshots
   
   ![gif-gif](https://user-images.githubusercontent.com/39133100/105840998-be580d80-5ff5-11eb-9427-c849a3e55f07.gif)
   
   
   #### How to reproduce the bug
   
   1. Enable languages
   2. Open any page
   3. Change the language
   
   ### Environment
   
   (please complete the following information):
   
   - superset version: `0.999.0dev`
   - python version: `3.7.4`
   - node.js version: `v14.11.0`
   
   ### Checklist
   
   Make sure to follow these steps before submitting your issue - thank you!
   
   - [x] I have checked the superset logs for python stacktraces and included it here as text if there are any.
   - [x] I have reproduced the issue with at least the latest released version of superset.
   - [x] I have checked the issue tracker for the same issue and I haven't found one similar.
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] tianhe1986 commented on issue #12768: Redirect happens whenever user changes language

Posted by GitBox <gi...@apache.org>.
tianhe1986 commented on issue #12768:
URL: https://github.com/apache/superset/issues/12768#issuecomment-902501214


   I encountered the same problem and solved it with a monkey patch. It is effective but not elegant enough. I also submit a PR to [Flask-AppBuilder](https://github.com/dpgaspar/Flask-AppBuilder/pull/1679) as a improvement.
   
   It is because not all pages call `update_redirect` which changing the page history stack, turning out it will jump to other page at the top of the page history stack after switching language.
   
   What I did
   1. Add a monkey patch function in `class SupersetAppInitializer` at `superset/app.py`.
   ```python
       def monkey_patch(self) -> None:
           @expose("/<string:locale>")
           def patch_flask_locale_index(self, locale):
               from flask import abort, redirect, session, request
               from flask_babel import refresh
               from flask_appbuilder.urltools import Stack
               if locale not in self.appbuilder.bm.languages:
                   abort(404, description="Locale not supported.")
   
               if request.referrer is not None:
                   page_history = Stack(session.get("page_history", []))
                   page_history.push(request.referrer)
                   session["page_history"] = page_history.to_json()
               
               session["locale"] = locale
               refresh()
               self.update_redirect()
               return redirect(self.get_redirect())
           
           from flask_appbuilder.babel.views import LocaleView
           LocaleView.index = patch_flask_locale_index
   ```
   
   2. Call the function in `configure_fab` function in `class SupersetAppInitializer` before init appbuilder, that is
   ```python
       def configure_fab(self) -> None:
           if self.config["SILENCE_FAB"]:
               logging.getLogger("flask_appbuilder").setLevel(logging.ERROR)
   
           custom_sm = self.config["CUSTOM_SECURITY_MANAGER"] or SupersetSecurityManager
           if not issubclass(custom_sm, SupersetSecurityManager):
               raise Exception(
                   """Your CUSTOM_SECURITY_MANAGER must now extend SupersetSecurityManager,
                    not FAB's security manager.
                    See [4565] in UPDATING.md"""
               )
   
           self.monkey_patch()
           appbuilder.indexview = SupersetIndexView
           appbuilder.base_template = "superset/base.html"
           appbuilder.security_manager_class = custom_sm
           appbuilder.init_app(self.flask_app, db.session)
   ```
   
   That's it.


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] zuzana-vej commented on issue #12768: Redirect happens whenever user changes language

Posted by GitBox <gi...@apache.org>.
zuzana-vej commented on issue #12768:
URL: https://github.com/apache/superset/issues/12768#issuecomment-1069350577


   Can you please confirm you are still facing this bug / close it not --thanks!


-- 
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: notifications-unsubscribe@superset.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org


[GitHub] [superset] wangweinjcn commented on issue #12768: Redirect happens whenever user changes language

Posted by GitBox <gi...@apache.org>.
wangweinjcn commented on issue #12768:
URL: https://github.com/apache/superset/issues/12768#issuecomment-843894456


   I have same problem, how to fix it?
   thank you!


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org