From 7ba65431ba9696a4d36f473ee3c29538de49ddc2 Mon Sep 17 00:00:00 2001 From: Jacob Pierce Date: Thu, 24 Oct 2024 15:24:06 -0700 Subject: [PATCH 1/4] move useChannels to kolibri-common --- kolibri/plugins/learn/assets/src/composables/useDevices.js | 2 +- kolibri/plugins/learn/assets/src/routes/index.js | 2 +- kolibri/plugins/learn/assets/src/views/CardList.vue | 2 +- .../src/views/ChannelRenderer/CustomContentRenderer.vue | 2 +- .../assets/src/views/HomePage/__tests__/HomePage.spec.js | 5 +++-- kolibri/plugins/learn/assets/src/views/HomePage/index.vue | 2 +- .../assets/src/views/HybridLearningContentCard/index.vue | 2 +- kolibri/plugins/learn/assets/src/views/LibraryPage/index.vue | 2 +- kolibri/plugins/learn/assets/src/views/SearchResultsGrid.vue | 2 +- kolibri/plugins/learn/assets/src/views/TopicsContentPage.vue | 2 +- kolibri/plugins/learn/assets/src/views/TopicsPage/index.vue | 2 +- .../assets/src/views/thumbnails/ContentNodeThumbnail.vue | 2 +- .../learn/assets/test/views/explore-libraries-page.spec.js | 2 +- kolibri/plugins/learn/assets/test/views/library-page.spec.js | 4 ++-- .../plugins/learn/assets/test/views/topic-content.spec.js | 5 +++-- kolibri/plugins/learn/assets/test/views/topics-page.spec.js | 5 +++-- .../kolibri-common}/composables/__mocks__/useChannels.js | 0 .../kolibri-common}/composables/useChannels.js | 0 18 files changed, 23 insertions(+), 20 deletions(-) rename {kolibri/plugins/learn/assets/src => packages/kolibri-common}/composables/__mocks__/useChannels.js (100%) rename {kolibri/plugins/learn/assets/src => packages/kolibri-common}/composables/useChannels.js (100%) diff --git a/kolibri/plugins/learn/assets/src/composables/useDevices.js b/kolibri/plugins/learn/assets/src/composables/useDevices.js index f4ac885b17..d50f4a973b 100644 --- a/kolibri/plugins/learn/assets/src/composables/useDevices.js +++ b/kolibri/plugins/learn/assets/src/composables/useDevices.js @@ -15,9 +15,9 @@ import useMinimumKolibriVersion from 'kolibri.coreVue.composables.useMinimumKoli import useUser from 'kolibri.coreVue.composables.useUser'; import { localeCompare } from 'kolibri.utils.i18n'; import plugin_data from 'plugin_data'; +import useChannels from 'kolibri-common/composables/useChannels'; import { KolibriStudioId } from '../constants'; import { learnStrings } from '../views/commonLearnStrings'; -import useChannels from './useChannels'; /** * The ref is defined in the outer scope so it can be used as a shared store diff --git a/kolibri/plugins/learn/assets/src/routes/index.js b/kolibri/plugins/learn/assets/src/routes/index.js index aa832ed02c..808a0bcc3e 100644 --- a/kolibri/plugins/learn/assets/src/routes/index.js +++ b/kolibri/plugins/learn/assets/src/routes/index.js @@ -2,7 +2,7 @@ import { get } from '@vueuse/core'; import store from 'kolibri.coreVue.vuex.store'; import router from 'kolibri.coreVue.router'; import useUser from 'kolibri.coreVue.composables.useUser'; -import useChannels from '../composables/useChannels'; +import useChannels from 'kolibri-common/composables/useChannels'; import { PageNames, ClassesPageNames, KolibriStudioId } from '../constants'; import LibraryPage from '../views/LibraryPage'; import HomePage from '../views/HomePage'; diff --git a/kolibri/plugins/learn/assets/src/views/CardList.vue b/kolibri/plugins/learn/assets/src/views/CardList.vue index 115ac29bc1..36f1e08469 100644 --- a/kolibri/plugins/learn/assets/src/views/CardList.vue +++ b/kolibri/plugins/learn/assets/src/views/CardList.vue @@ -125,7 +125,7 @@ import { ContentLevels, Categories } from 'kolibri.coreVue.vuex.constants'; import camelCase from 'lodash/camelCase'; import useKResponsiveWindow from 'kolibri-design-system/lib/composables/useKResponsiveWindow'; - import useChannels from '../composables/useChannels'; + import useChannels from 'kolibri-common/composables/useChannels'; import LearningActivityLabel from './LearningActivityLabel'; import LearningActivityDuration from './LearningActivityDuration'; import commonLearnStrings from './commonLearnStrings'; diff --git a/kolibri/plugins/learn/assets/src/views/ChannelRenderer/CustomContentRenderer.vue b/kolibri/plugins/learn/assets/src/views/ChannelRenderer/CustomContentRenderer.vue index 4fc893f550..912ede6fe3 100644 --- a/kolibri/plugins/learn/assets/src/views/ChannelRenderer/CustomContentRenderer.vue +++ b/kolibri/plugins/learn/assets/src/views/ChannelRenderer/CustomContentRenderer.vue @@ -36,9 +36,9 @@ import router from 'kolibri.coreVue.router'; import { ContentNodeKinds } from 'kolibri.coreVue.vuex.constants'; import { events, MessageStatuses } from 'hashi/src/hashiBase'; + import useChannels from 'kolibri-common/composables/useChannels'; import { validateChannelTheme } from '../../utils/validateChannelTheme'; import useContentLink from '../../composables/useContentLink'; - import useChannels from '../../composables/useChannels'; import ContentModal from './ContentModal'; const { channelsMap } = useChannels(); diff --git a/kolibri/plugins/learn/assets/src/views/HomePage/__tests__/HomePage.spec.js b/kolibri/plugins/learn/assets/src/views/HomePage/__tests__/HomePage.spec.js index 00eab19cb9..4de42d7a59 100644 --- a/kolibri/plugins/learn/assets/src/views/HomePage/__tests__/HomePage.spec.js +++ b/kolibri/plugins/learn/assets/src/views/HomePage/__tests__/HomePage.spec.js @@ -9,10 +9,11 @@ import useTotalProgress, { useTotalProgressMock, } from 'kolibri.coreVue.composables.useTotalProgress'; import { ref } from 'kolibri.lib.vueCompositionApi'; +// eslint-disable-next-line import/named +import useChannels, { useChannelsMock } from 'kolibri-common/composables/useChannels'; import { ClassesPageNames, PageNames } from '../../../constants'; import HomePage from '../index'; /* eslint-disable import/named */ -import useChannels, { useChannelsMock } from '../../../composables/useChannels'; import useDeviceSettings, { useDeviceSettingsMock } from '../../../composables/useDeviceSettings'; import useLearnerResources, { useLearnerResourcesMock, @@ -21,7 +22,7 @@ import useLearnerResources, { jest.mock('kolibri.client'); jest.mock('kolibri.urls'); jest.mock('kolibri.coreVue.componentSets.sync'); -jest.mock('../../../composables/useChannels'); +jest.mock('kolibri-common/composables/useChannels'); jest.mock('kolibri.coreVue.composables.useUser'); jest.mock('../../../composables/useDeviceSettings'); jest.mock('../../../composables/useLearnerResources'); diff --git a/kolibri/plugins/learn/assets/src/views/HomePage/index.vue b/kolibri/plugins/learn/assets/src/views/HomePage/index.vue index 2eb4cfdec2..a272c4a2fd 100644 --- a/kolibri/plugins/learn/assets/src/views/HomePage/index.vue +++ b/kolibri/plugins/learn/assets/src/views/HomePage/index.vue @@ -67,8 +67,8 @@ import client from 'kolibri.client'; import urls from 'kolibri.urls'; import useUser from 'kolibri.coreVue.composables.useUser'; + import useChannels from 'kolibri-common/composables/useChannels'; import ResourceSyncingUiAlert from '../ResourceSyncingUiAlert'; - import useChannels from '../../composables/useChannels'; import useDeviceSettings from '../../composables/useDeviceSettings'; import useLearnerResources, { setClasses, diff --git a/kolibri/plugins/learn/assets/src/views/HybridLearningContentCard/index.vue b/kolibri/plugins/learn/assets/src/views/HybridLearningContentCard/index.vue index 141184e08d..1170692e87 100644 --- a/kolibri/plugins/learn/assets/src/views/HybridLearningContentCard/index.vue +++ b/kolibri/plugins/learn/assets/src/views/HybridLearningContentCard/index.vue @@ -72,7 +72,7 @@ import { validateLinkObject } from 'kolibri.utils.validators'; import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings'; - import useChannels from '../../composables/useChannels'; + import useChannels from 'kolibri-common/composables/useChannels'; import LearningActivityLabel from '../LearningActivityLabel'; import commonLearnStrings from '../commonLearnStrings'; import CardThumbnail from './CardThumbnail.vue'; diff --git a/kolibri/plugins/learn/assets/src/views/LibraryPage/index.vue b/kolibri/plugins/learn/assets/src/views/LibraryPage/index.vue index d6603aac6c..aa2f81a92f 100644 --- a/kolibri/plugins/learn/assets/src/views/LibraryPage/index.vue +++ b/kolibri/plugins/learn/assets/src/views/LibraryPage/index.vue @@ -176,6 +176,7 @@ import { searchKeys } from 'kolibri-common/composables/useBaseSearch'; import SidePanelModal from 'kolibri-common/components/SidePanelModal'; import SearchFiltersPanel from 'kolibri-common/components/SearchFiltersPanel'; + import useChannels from 'kolibri-common/composables/useChannels'; import { KolibriStudioId, PageNames } from '../../constants'; import useCardViewStyle from '../../composables/useCardViewStyle'; import useContentLink from '../../composables/useContentLink'; @@ -194,7 +195,6 @@ import SearchResultsGrid from '../SearchResultsGrid'; import LearnAppBarPage from '../LearnAppBarPage'; import PostSetupModalGroup from '../../../../../device/assets/src/views/PostSetupModalGroup.vue'; - import useChannels from './../../composables/useChannels'; import ResumableContentGrid from './ResumableContentGrid'; import OtherLibraries from './OtherLibraries'; diff --git a/kolibri/plugins/learn/assets/src/views/SearchResultsGrid.vue b/kolibri/plugins/learn/assets/src/views/SearchResultsGrid.vue index 17323b41f0..f70bfbf2f4 100644 --- a/kolibri/plugins/learn/assets/src/views/SearchResultsGrid.vue +++ b/kolibri/plugins/learn/assets/src/views/SearchResultsGrid.vue @@ -76,8 +76,8 @@ import { ref } from 'kolibri.lib.vueCompositionApi'; import useKResponsiveWindow from 'kolibri-design-system/lib/composables/useKResponsiveWindow'; import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings'; + import SearchChips from 'kolibri-common/components/SearchChips'; import CopiesModal from './CopiesModal'; - import SearchChips from './SearchChips'; import LibraryAndChannelBrowserMainContent from './LibraryAndChannelBrowserMainContent'; export default { diff --git a/kolibri/plugins/learn/assets/src/views/TopicsContentPage.vue b/kolibri/plugins/learn/assets/src/views/TopicsContentPage.vue index 58226678d2..ca02c803a4 100644 --- a/kolibri/plugins/learn/assets/src/views/TopicsContentPage.vue +++ b/kolibri/plugins/learn/assets/src/views/TopicsContentPage.vue @@ -173,9 +173,9 @@ import GlobalSnackbar from 'kolibri-common/components/GlobalSnackbar'; import LearningActivityChip from 'kolibri-common/components/ResourceDisplayAndSearch/LearningActivityChip.vue'; import SidePanelModal from 'kolibri-common/components/SidePanelModal'; + import useChannels from 'kolibri-common/composables/useChannels'; import { PageNames, ClassesPageNames } from '../constants'; import SkipNavigationLink from '../../../../../../kolibri/core/assets/src/views/SkipNavigationLink'; - import useChannels from '../composables/useChannels'; import useContentLink from '../composables/useContentLink'; import useCoreLearn from '../composables/useCoreLearn'; import useContentNodeProgress from '../composables/useContentNodeProgress'; diff --git a/kolibri/plugins/learn/assets/src/views/TopicsPage/index.vue b/kolibri/plugins/learn/assets/src/views/TopicsPage/index.vue index 8d85d3de2a..0ba3a3c6f3 100644 --- a/kolibri/plugins/learn/assets/src/views/TopicsPage/index.vue +++ b/kolibri/plugins/learn/assets/src/views/TopicsPage/index.vue @@ -274,8 +274,8 @@ import LearningActivityChip from 'kolibri-common/components/ResourceDisplayAndSearch/LearningActivityChip.vue'; import SidePanelModal from 'kolibri-common/components/SidePanelModal'; import SearchFiltersPanel from 'kolibri-common/components/SearchFiltersPanel'; + import useChannels from 'kolibri-common/composables/useChannels'; import { PageNames } from '../../constants'; - import useChannels from '../../composables/useChannels'; import useSearch from '../../composables/useSearch'; import useContentLink from '../../composables/useContentLink'; import useContentNodeProgress from '../../composables/useContentNodeProgress'; diff --git a/kolibri/plugins/learn/assets/src/views/thumbnails/ContentNodeThumbnail.vue b/kolibri/plugins/learn/assets/src/views/thumbnails/ContentNodeThumbnail.vue index 6aaa8f3958..fd6007e3d9 100644 --- a/kolibri/plugins/learn/assets/src/views/thumbnails/ContentNodeThumbnail.vue +++ b/kolibri/plugins/learn/assets/src/views/thumbnails/ContentNodeThumbnail.vue @@ -27,7 +27,7 @@