Repository: learningequality/kolibri

Issue:
Add deprecation warnings for python 2.7 and IE 11
**Not ready for dev work**

Work with design team to determine where to place deprecation warnings 
- only show to super admins on devices that are running python 2.7 
- super admin if they are running IE11 or if we have a recorded client device version is using IE11 



Discussion:
Could use a non-dismissible warning alert component that appears above the first page container across all pages in the app. For cases where more than one condition is active, all messages should display within the alert, separated by a line break

<img width="1558" alt="Screenshot 2023-04-27 at 3 08 14 PM" src="https://user-images.githubusercontent.com/6668144/235001837-b7f3298c-6e6e-4df3-a1c6-f202c49060e6.png">

Checking the IE11 status will require doing some aggregation over logs in the backend to check for usage of IE11 in those logs as well - so may need an additional API endpoint for doing this check.
@jtamiace should I borrow the structure of what was added [here](https://github.com/learningequality/kolibri/pull/10128) re: the banner styling? I could probably just borrow the component, update the icon to use the "warning" icon, and use the color yellow above?
@rtibbles What logs would we be looking to in this case? I'm thinking about this and I'm at a loss of where to start looking to do this.
Can probably just look for `IE,11` being in the `device_info` property here: https://github.com/learningequality/kolibri/blob/develop/kolibri/core/logger/models.py#L180

(see the method below to see how this info is encoded)

So can probably just do:

```
UserSessionLog.objects.filter(device_info__contains="IE,11").exists()
```

to do the check?
> @jtamiace should I borrow the structure of what was added https://github.com/learningequality/kolibri/pull/10128 re: the banner styling? I could probably just borrow the component, update the icon to use the "warning" icon, and use the color yellow above?

@nucleogenesis yes I think that would work!

Resolving patch:
diff --git a/kolibri/plugins/device/kolibri_plugin.py b/kolibri/plugins/device/kolibri_plugin.py
--- a/kolibri/plugins/device/kolibri_plugin.py
+++ b/kolibri/plugins/device/kolibri_plugin.py
@@ -2,6 +2,8 @@
 from __future__ import print_function
 from __future__ import unicode_literals
 
+import sys
+
 from kolibri.core.auth.constants.user_kinds import SUPERUSER
 from kolibri.core.hooks import NavigationHook
 from kolibri.core.hooks import RoleBasedRedirectHook
@@ -16,15 +18,26 @@ class DeviceManagementPlugin(KolibriPluginBase):
     translated_view_urls = "urls"
 
 
+def any_ie11_users():
+    from kolibri.core.logger.models import UserSessionLog
+
+    return UserSessionLog.objects.filter(device_info__contains="IE,11").count() > 0
+
+
 @register_hook
 class DeviceManagementAsset(WebpackBundleHook):
     bundle_id = "app"
 
     @property
     def plugin_data(self):
+
         return {
             "isRemoteContent": OPTIONS["Deployment"]["REMOTE_CONTENT"],
             "canRestart": bool(OPTIONS["Deployment"]["RESTART_HOOKS"]),
+            "deprecationWarnings": {
+                "py27": sys.version_info.major == 2,
+                "ie11": any_ie11_users(),
+            },
         }
 
 


Test patch:
diff --git a/kolibri/plugins/device/assets/src/views/DeviceSettingsPage/__test__/DeviceSettingsPage.spec.js b/kolibri/plugins/device/assets/src/views/DeviceSettingsPage/__test__/DeviceSettingsPage.spec.js
--- a/kolibri/plugins/device/assets/src/views/DeviceSettingsPage/__test__/DeviceSettingsPage.spec.js
+++ b/kolibri/plugins/device/assets/src/views/DeviceSettingsPage/__test__/DeviceSettingsPage.spec.js
@@ -13,6 +13,15 @@ import { getFreeSpaceOnServer } from '../../AvailableChannelsPage/api';
 jest.mock('../../../composables/usePlugins');
 jest.mock('kolibri.urls');
 
+jest.mock('plugin_data', () => {
+  return {
+    __esModule: true,
+    default: {
+      deprecationWarnings: {},
+    },
+  };
+});
+
 jest.mock('../api.js', () => ({
   getPathPermissions: jest.fn(),
   getPathsPermissions: jest.fn(),