Skip to content

Commit

Permalink
Revert "Merge pull request #10703 from Wck-iipi/10313Solution"
Browse files Browse the repository at this point in the history
This reverts commit 9025057, reversing
changes made to 0e2dc3a.
  • Loading branch information
bjester committed Nov 8, 2023
1 parent 6d0bf54 commit 1f1cd87
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@
:key="idx"
v-model="selectedDeviceId"
class="radio-button"
:value="canLearnerSignUp(d.id) ? d.id : false"
:value="d.id"
:label="d.nickname"
:description="d.base_url"
:disabled="!canLearnerSignUp(d.id) || formDisabled || !isDeviceAvailable(d.id)"
:disabled="formDisabled || !isDeviceAvailable(d.id)"
/>
<KButton
:key="`forget-${idx}`"
Expand All @@ -65,13 +65,10 @@
:key="d.id"
v-model="selectedDeviceId"
class="radio-button"
:value="canLearnerSignUp(d.id) ? d.instance_id : false"
:value="d.instance_id"
:label="formatNameAndId(d.device_name, d.id)"
:description="formatBaseDevice(d)"
:disabled="!canLearnerSignUp(d.id)
|| formDisabled
|| fetchFailed
|| !isDeviceAvailable(d.id)"
:disabled="formDisabled || fetchFailed || !isDeviceAvailable(d.id)"
/>
</div>
</template>
Expand Down Expand Up @@ -136,8 +133,8 @@

<script>
import { computed, ref } from 'kolibri.lib.vueCompositionApi';
import { useLocalStorage, get, computedAsync } from '@vueuse/core';
import { computed } from 'kolibri.lib.vueCompositionApi';
import { useLocalStorage, get } from '@vueuse/core';
import find from 'lodash/find';
import UiAlert from 'kolibri-design-system/lib/keen/UiAlert';
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings';
Expand All @@ -150,7 +147,6 @@
useDevicesForLearnOnlyDevice,
} from './useDevices.js';
import useConnectionChecker from './useConnectionChecker.js';
import { deviceFacilityCanSignUp } from './api.js';
export default {
name: 'SelectDeviceForm',
Expand Down Expand Up @@ -200,24 +196,6 @@
const discoveredDevices = computed(() => get(devices).filter(d => d.dynamic));
const savedDevices = computed(() => get(devices).filter(d => !d.dynamic));
const isLoading = ref(false);
const lodsWithSignupFacility = computedAsync(
async () => {
const devicesAvailable = get(devices);
const allDevices = {};
for (const i of devicesAvailable) {
const canSignUp = await deviceFacilityCanSignUp(i.id);
if (canSignUp) {
allDevices[i.id] = true;
}
}
return allDevices;
},
{},
isLoading
);
return {
// useDevices
devices,
Expand All @@ -237,7 +215,6 @@
discoveredDevices,
savedDevices,
storageDeviceId,
lodsWithSignupFacility,
};
},
props: {
Expand Down Expand Up @@ -391,9 +368,6 @@
this.$emit('removed_address');
});
},
canLearnerSignUp(id) {
return this.lodsWithSignupFacility && id in this.lodsWithSignupFacility;
},
},
$trs: {
deletingFailedText: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ jest.mock('../api.js', () => ({
fetchDevices: jest.fn(),
deleteDevice: jest.fn().mockResolvedValue(),
updateConnectionStatus: jest.fn(),
deviceFacilityCanSignUp: jest.fn().mockResolvedValue(true),
}));

const devices = [
Expand Down Expand Up @@ -40,13 +39,7 @@ const staticDevices = devices.map(a => ({ ...a, dynamic: false }));
const dynamicDevices = devices.map(a => ({ ...a, dynamic: true }));

function makeWrapper() {
const deviceIdMap = devices.reduce((acc, device) => {
acc[device.id] = device;
return acc;
}, {});
const wrapper = shallowMount(SelectDeviceForm, {
mocks: { lodsWithSignupFacility: deviceIdMap },
});
const wrapper = shallowMount(SelectDeviceForm);
// prettier-ignore
const els = {
KModal: () => wrapper.findComponent({ name: 'KModal' }),
Expand Down
17 changes: 0 additions & 17 deletions kolibri/core/assets/src/views/sync/SelectDeviceModalGroup/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,3 @@ export function channelIsAvailableAtDevice(channelId, device) {
export function updateConnectionStatus(device) {
return NetworkLocationResource.updateConnectionStatus(device.id);
}

/**
* @param {string} deviceId
* @return {Promise<boolean>}
*/
export function deviceFacilityCanSignUp(deviceId) {
return NetworkLocationResource.fetchFacilities(deviceId).then(({ device_id, facilities }) => {
if (deviceId === device_id) {
for (const facility of facilities) {
if (facility.learner_can_sign_up) {
return true;
}
}
}
return false;
});
}

0 comments on commit 1f1cd87

Please sign in to comment.