-
Notifications
You must be signed in to change notification settings - Fork 720
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11426 from marcellamaki/intermediate-lesson-loadi…
…ng-state Update MissingResourceAlert to report sync status
- Loading branch information
Showing
10 changed files
with
202 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
kolibri/plugins/learn/assets/src/views/ResourceSyncingUiAlert.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<template> | ||
|
||
<MissingResourceAlert | ||
:multiple="multiple" | ||
> | ||
<template v-if="isLearnerOnlyImport && isSyncing" #syncAlert> | ||
{{ syncMessage }} | ||
</template> | ||
</MissingResourceAlert> | ||
|
||
</template> | ||
|
||
|
||
<script> | ||
import { get } from '@vueuse/core'; | ||
import { computed, watch } from 'kolibri.lib.vueCompositionApi'; | ||
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(props, { emit }) { | ||
const { status, syncDownloadsInProgress } = useUserSyncStatus(); | ||
const { isLearnerOnlyImport } = useUser(); | ||
const isSyncing = computed(() => { | ||
return ( | ||
get(status) === SyncStatus.QUEUED || | ||
get(status) === SyncStatus.SYNCING || | ||
get(syncDownloadsInProgress) | ||
); | ||
}); | ||
watch(isSyncing, (newVal, oldVal) => { | ||
if (newVal === false && oldVal === true) { | ||
emit('syncComplete'); | ||
} | ||
}); | ||
return { | ||
status, | ||
syncDownloadsInProgress, | ||
isLearnerOnlyImport, | ||
isSyncing, | ||
}; | ||
}, | ||
props: { | ||
multiple: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
}, | ||
computed: { | ||
syncMessage() { | ||
/* eslint-disable kolibri/vue-no-undefined-string-uses */ | ||
return this.status == SyncStatus.QUEUED | ||
? syncStatusDescriptionStrings.$tr('queuedDescription') | ||
: syncStatusDescriptionStrings.$tr('syncingDescription'); | ||
/* eslint-enable */ | ||
}, | ||
}, | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters