Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update MissingResourceAlert to report sync status #11426

2 changes: 2 additions & 0 deletions kolibri/core/assets/src/core-app/apiSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ import * as sync from '../views/sync/syncComponentSet';
import PageRoot from '../views/PageRoot';
import NotificationsRoot from '../views/NotificationsRoot';
import useMinimumKolibriVersion from '../composables/useMinimumKolibriVersion';
import useUserSyncStatus from '../composables/useUserSyncStatus';
import useUser from '../composables/useUser';

// webpack optimization
Expand Down Expand Up @@ -232,6 +233,7 @@ export default {
useKShow,
useMinimumKolibriVersion,
useUser,
useUserSyncStatus,
},
},
resources,
Expand Down
6 changes: 3 additions & 3 deletions kolibri/plugins/learn/assets/src/views/ExamPage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
:answerState="currentAttempt.answer"
@interaction="saveAnswer"
/>
<MissingResourceAlert v-else :multiple="false" />
<ResourceSyncingUiAlert v-else :multiple="false" />
rtibbles marked this conversation as resolved.
Show resolved Hide resolved
</KPageContainer>

<BottomAppBar :dir="bottomBarLayoutDirection" :maxWidth="null">
Expand Down Expand Up @@ -186,7 +186,7 @@
import TimeDuration from 'kolibri.coreVue.components.TimeDuration';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import ImmersivePage from 'kolibri.coreVue.components.ImmersivePage';
import MissingResourceAlert from 'kolibri-common/components/MissingResourceAlert';
import ResourceSyncingUiAlert from '../ResourceSyncingUiAlert';
import useProgressTracking from '../../composables/useProgressTracking';
import { PageNames, ClassesPageNames } from '../../constants';
import { LearnerClassroomResource } from '../../apiResources';
Expand All @@ -208,7 +208,7 @@
TimeDuration,
SuggestedTime,
ImmersivePage,
MissingResourceAlert,
ResourceSyncingUiAlert,
},
mixins: [responsiveWindowMixin, commonCoreStrings],
setup() {
Expand Down
6 changes: 3 additions & 3 deletions kolibri/plugins/learn/assets/src/views/HomePage/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<LearnAppBarPage :appBarTitle="learnString('learnLabel')">
<div v-if="!loading" id="main" role="main">
<MissingResourceAlert v-if="missingResources" />
<ResourceSyncingUiAlert v-if="missingResources" />
<YourClasses
v-if="displayClasses"
class="section"
Expand Down Expand Up @@ -58,8 +58,8 @@
import { get } from '@vueuse/core';
import client from 'kolibri.client';
import urls from 'kolibri.urls';
import MissingResourceAlert from 'kolibri-common/components/MissingResourceAlert';
import useUser from 'kolibri.coreVue.composables.useUser';
import ResourceSyncingUiAlert from '../ResourceSyncingUiAlert';
import useChannels from '../../composables/useChannels';
import useDeviceSettings from '../../composables/useDeviceSettings';
import useLearnerResources, {
Expand Down Expand Up @@ -91,7 +91,7 @@
ContinueLearning,
ExploreChannels,
LearnAppBarPage,
MissingResourceAlert,
ResourceSyncingUiAlert,
},
mixins: [commonLearnStrings],
setup() {
Expand Down
66 changes: 66 additions & 0 deletions kolibri/plugins/learn/assets/src/views/ResourceSyncingUiAlert.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<template>

<MissingResourceAlert
:multiple="multiple"
>
<template v-if="isSyncing && isLearnerOnlyImport" #syncAlert>
{{ syncMessage }}
</template>
</MissingResourceAlert>

</template>


<script>

import MissingResourceAlert from 'kolibri-common/components/MissingResourceAlert.vue';
import useUserSyncStatus from 'kolibri.coreVue.composables.useUserSyncStatus';
import { SyncStatus } from 'kolibri.coreVue.vuex.constants';
import { createTranslator } from 'kolibri.utils.i18n';
import useUser from 'kolibri.coreVue.composables.useUser';

const syncStatusDescriptionStrings = createTranslator('SyncStatusDescription', {
syncingDescription: {
message: 'The device is currently syncing.',
context: 'Description of the device syncing status.',
},
queuedDescription: {
message: 'The device is waiting to sync.',
context: 'Description of the device syncing status',
},
});

export default {
name: 'ResourceSyncingUiAlert',
components: {
MissingResourceAlert,
},
setup() {
const { status } = useUserSyncStatus();
const { isLearnerOnlyImport } = useUser();
return {
status,
isLearnerOnlyImport,
};
},
props: {
multiple: {
type: Boolean,
default: true,
},
},
computed: {
isSyncing() {
return this.status == SyncStatus.QUEUED || this.status == SyncStatus.SYNCING;
},
syncMessage() {
/* eslint-disable kolibri/vue-no-undefined-string-uses */
rtibbles marked this conversation as resolved.
Show resolved Hide resolved
return this.status == SyncStatus.QUEUED
? syncStatusDescriptionStrings.$tr('queuedDescription')
: syncStatusDescriptionStrings.$tr('syncingDescription');
/* eslint-enable */
},
},
};

</script>
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{{ currentLesson.description }}
</p>
</div>
<MissingResourceAlert v-if="lessonResources.length > contentNodes.length" />
<ResourceSyncingUiAlert v-if="lessonResources.length > contentNodes.length" />
</section>

<section v-if="lessonHasResources" class="content-cards">
Expand Down Expand Up @@ -57,7 +57,7 @@
import ProgressIcon from 'kolibri.coreVue.components.ProgressIcon';
import ContentIcon from 'kolibri.coreVue.components.ContentIcon';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import MissingResourceAlert from 'kolibri-common/components/MissingResourceAlert';
import ResourceSyncingUiAlert from '../ResourceSyncingUiAlert';
import useContentLink from '../../composables/useContentLink';
import useContentNodeProgress from '../../composables/useContentNodeProgress';
import { PageNames, ClassesPageNames } from '../../constants';
Expand All @@ -78,7 +78,7 @@
ContentIcon,
ProgressIcon,
LearnAppBarPage,
MissingResourceAlert,
ResourceSyncingUiAlert,
},
mixins: [commonCoreStrings, commonLearnStrings, responsiveWindowMixin],
setup() {
Expand Down
23 changes: 14 additions & 9 deletions packages/kolibri-common/components/MissingResourceAlert.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@
type="warning"
:style="{ marginBottom: 0, marginTop: '8px' }"
>
<span>
rtibbles marked this conversation as resolved.
Show resolved Hide resolved
{{ coreString(
multiple ? 'someResourcesMissingOrNotSupported' :
'resourceNotFoundOnDevice'
) }}
<span v-if="$slots.syncAlert">
<slot name="syncAlert"></slot>
</span>
<span v-else>
<span>
{{ coreString(
multiple ? 'someResourcesMissingOrNotSupported' :
'resourceNotFoundOnDevice'
) }}
&nbsp;
<KButton appearance="basic-link" @click="open = true">
{{ $tr('learnMore') }}
</KButton>
</span>
</span>
&nbsp;
<KButton appearance="basic-link" @click="open = true">
{{ $tr('learnMore') }}
</KButton>
</UiAlert>
<KModal
v-if="open"
Expand Down