From 910f9bbcdb7db7b67749d77bb19eea66d7ed2a39 Mon Sep 17 00:00:00 2001 From: Richard Tibbles Date: Thu, 19 Dec 2024 09:20:36 -0800 Subject: [PATCH] Remove use of checkCapability function in favour of more explicit checks. --- .../src/views/DeviceSettingsPage/index.vue | 4 +-- kolibri/plugins/device/kolibri_plugin.py | 2 ++ .../MeteredConnectionNotificationModal.vue | 7 +++-- .../assets/src/views/LibraryPage/index.vue | 11 ++++---- kolibri/plugins/learn/kolibri_plugin.py | 2 ++ .../assets/src/machines/wizardMachine.js | 16 +++++++---- .../assets/src/views/SetupWizardIndex.vue | 11 ++++++-- .../onboarding-forms/SettingUpKolibri.vue | 11 ++++++-- .../plugins/setup_wizard/kolibri_plugin.py | 5 +++- .../utils/checkMeteredConnection.js | 12 ++++++++ packages/kolibri/utils/appCapabilities.js | 28 ------------------- 11 files changed, 58 insertions(+), 51 deletions(-) rename {packages/kolibri-common/components => kolibri/plugins/learn/assets/src/views/LibraryPage}/MeteredConnectionNotificationModal.vue (95%) create mode 100644 packages/kolibri-common/utils/checkMeteredConnection.js diff --git a/kolibri/plugins/device/assets/src/views/DeviceSettingsPage/index.vue b/kolibri/plugins/device/assets/src/views/DeviceSettingsPage/index.vue index d0912e9dda2..45a4d549889 100644 --- a/kolibri/plugins/device/assets/src/views/DeviceSettingsPage/index.vue +++ b/kolibri/plugins/device/assets/src/views/DeviceSettingsPage/index.vue @@ -378,12 +378,12 @@ import urls from 'kolibri/urls'; import logger from 'kolibri-logging'; import { ref, watch } from 'vue'; + import pluginData from 'kolibri-plugin-data'; import commonCoreStrings from 'kolibri/uiText/commonCoreStrings'; import UiAlert from 'kolibri-design-system/lib/keen/UiAlert'; import { availableLanguages, currentLanguage, sortLanguages } from 'kolibri/utils/i18n'; import BottomAppBar from 'kolibri/components/BottomAppBar'; import useKResponsiveWindow from 'kolibri-design-system/lib/composables/useKResponsiveWindow'; - import { checkCapability } from 'kolibri/utils/appCapabilities'; import useUser from 'kolibri/composables/useUser'; import useSnackbar from 'kolibri/composables/useSnackbar'; import commonDeviceStrings from '../commonDeviceStrings'; @@ -603,7 +603,7 @@ } }, canCheckMeteredConnection() { - return checkCapability('check_is_metered'); + return pluginData.canCheckMeteredConnection; }, showDisabledAlert() { return this.isRemoteContent || !this.canRestart; diff --git a/kolibri/plugins/device/kolibri_plugin.py b/kolibri/plugins/device/kolibri_plugin.py index 9945202c4d3..af5cda87131 100644 --- a/kolibri/plugins/device/kolibri_plugin.py +++ b/kolibri/plugins/device/kolibri_plugin.py @@ -1,4 +1,5 @@ from kolibri.core.auth.constants.user_kinds import SUPERUSER +from kolibri.core.device.hooks import CheckIsMeteredHook from kolibri.core.hooks import NavigationHook from kolibri.core.hooks import RoleBasedRedirectHook from kolibri.core.webpack.hooks import WebpackBundleHook @@ -28,6 +29,7 @@ def plugin_data(self): return { "isRemoteContent": OPTIONS["Deployment"]["REMOTE_CONTENT"], "canRestart": bool(OPTIONS["Deployment"]["RESTART_HOOKS"]), + "canCheckMeteredConnection": CheckIsMeteredHook.is_registered, "deprecationWarnings": { "ie11": any_ie11_users(), }, diff --git a/packages/kolibri-common/components/MeteredConnectionNotificationModal.vue b/kolibri/plugins/learn/assets/src/views/LibraryPage/MeteredConnectionNotificationModal.vue similarity index 95% rename from packages/kolibri-common/components/MeteredConnectionNotificationModal.vue rename to kolibri/plugins/learn/assets/src/views/LibraryPage/MeteredConnectionNotificationModal.vue index 9e83bdc511b..6b53cc1828e 100644 --- a/packages/kolibri-common/components/MeteredConnectionNotificationModal.vue +++ b/kolibri/plugins/learn/assets/src/views/LibraryPage/MeteredConnectionNotificationModal.vue @@ -35,12 +35,13 @@