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

enables sync button in sync modal #10765

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
<p>
{{ $tr('syncExplanation') }}
</p>
<p>
<p v-if="!isConnected">
{{ $tr('mustBeConnectedToInternet') }}
</p>


<template #actions>
<KButtonGroup>
<KButton
Expand All @@ -26,23 +25,11 @@
<span ref="syncbutton">
<KButton
:text="coreString('syncAction')"
:disabled="submitDisabled"
primary
type="submit"
:disabled="!isConnected"
/>
</span>
<KTooltip
v-if="submitDisabled"
reference="syncbutton"
:refs="$refs"
>
<span v-if="noRegisteredFacilities">
{{ $tr('noFacilitiesTooltip') }}
</span>
<span v-else>
{{ $tr('currentlyOfflineTooltip') }}
</span>
</KTooltip>
</KButtonGroup>
</template>
</KModal>
Expand All @@ -52,7 +39,6 @@

<script>

import some from 'lodash/some';
import { TaskResource } from 'kolibri.resources';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
import { TaskTypes } from 'kolibri.utils.syncTaskUtils';
Expand All @@ -67,21 +53,13 @@
},
},
computed: {
submitDisabled() {
// TODO implement a check for KDP being offline
return this.noRegisteredFacilities;
},
noRegisteredFacilities() {
return !some(this.facilities, fac => fac.dataset.registered);
isConnected() {
return window.navigator.onLine;
},
},
methods: {
handleSubmit() {
// NOTE the button will not be visibly disabled, but does nothing
// when clicked
if (!this.submitDisabled) {
return this.startSyncAllTask();
}
this.startSyncAllTask();
},
startSyncAllTask() {
return TaskResource.startTasks(
Expand Down Expand Up @@ -109,6 +87,7 @@
message: 'You must be connected to the internet.',
context: 'Modal description text',
},
/* eslint-disable kolibri/vue-no-unused-translations */
currentlyOfflineTooltip: {
message: 'You are currently offline',
context:
Expand All @@ -119,6 +98,7 @@
context:
"Floating notification message that appears over the 'Sync' button and indicates why is it not active",
},
/* eslint-enable kolibri/vue-no-unused-translations */
},
};

Expand Down