-
Notifications
You must be signed in to change notification settings - Fork 713
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
Gives indication of user having permission to join the facility not showing the devices that don't have sign up enabled. #10703
Changes from 10 commits
2883171
8b54332
bf65758
f730e5a
9e388b9
3e1e158
42c1920
7f216d5
0f2e8f5
56e8847
2e4fd9d
0ed7994
52cf5be
eae1aa8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,10 +38,10 @@ | |
:key="idx" | ||
v-model="selectedDeviceId" | ||
class="radio-button" | ||
:value="d.id" | ||
:value="canLearnerSignUp(d.id) ? d.id : false" | ||
:label="d.nickname" | ||
:description="d.base_url" | ||
:disabled="formDisabled || !isDeviceAvailable(d.id)" | ||
:disabled="!canLearnerSignUp(d.id) || formDisabled || !isDeviceAvailable(d.id)" | ||
/> | ||
<KButton | ||
:key="`forget-${idx}`" | ||
|
@@ -65,10 +65,13 @@ | |
:key="d.id" | ||
v-model="selectedDeviceId" | ||
class="radio-button" | ||
:value="d.instance_id" | ||
:value="canLearnerSignUp(d.id) ? d.instance_id : false" | ||
:label="formatNameAndId(d.device_name, d.id)" | ||
:description="formatBaseDevice(d)" | ||
:disabled="formDisabled || fetchFailed || !isDeviceAvailable(d.id)" | ||
:disabled="!canLearnerSignUp(d.id) | ||
|| formDisabled | ||
|| fetchFailed | ||
|| !isDeviceAvailable(d.id)" | ||
/> | ||
</div> | ||
</template> | ||
|
@@ -123,8 +126,8 @@ | |
|
||
<script> | ||
|
||
import { computed } from 'kolibri.lib.vueCompositionApi'; | ||
import { useLocalStorage, get } from '@vueuse/core'; | ||
import { computed, ref } from 'kolibri.lib.vueCompositionApi'; | ||
import { useLocalStorage, get, computedAsync } from '@vueuse/core'; | ||
import find from 'lodash/find'; | ||
import UiAlert from 'kolibri-design-system/lib/keen/UiAlert'; | ||
import commonCoreStrings from 'kolibri.coreVue.mixins.commonCoreStrings'; | ||
|
@@ -137,6 +140,7 @@ | |
useDevicesForLearnOnlyDevice, | ||
} from './useDevices.js'; | ||
import useConnectionChecker from './useConnectionChecker.js'; | ||
import { deviceFacilityCanSignUp } from './api.js'; | ||
|
||
export default { | ||
name: 'SelectDeviceForm', | ||
|
@@ -186,6 +190,24 @@ | |
const discoveredDevices = computed(() => get(devices).filter(d => d.dynamic)); | ||
const savedDevices = computed(() => get(devices).filter(d => !d.dynamic)); | ||
|
||
const isLoading = ref(false); | ||
|
||
const LODDevicesWithSignUpFacility = 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, | ||
|
@@ -205,6 +227,7 @@ | |
discoveredDevices, | ||
savedDevices, | ||
storageDeviceId, | ||
LODDevicesWithSignUpFacility, | ||
}; | ||
}, | ||
props: { | ||
|
@@ -356,6 +379,14 @@ | |
this.$emit('removed_address'); | ||
}); | ||
}, | ||
canLearnerSignUp(id) { | ||
if (this.LODDevicesWithSignUpFacility) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because this is an This is a place where managing tests can get really tough because you'll need to be sure that the async data is available, so I suspect that in the failing test you'll need to be sure that this new method is represented properly. |
||
if (id in this.LODDevicesWithSignUpFacility) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
}, | ||
Wck-iipi marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}, | ||
$trs: { | ||
deletingFailedText: { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Wck-iipi
I'm not seeing anywhere that this ref's value is being read back. This could be used to conditionally put a
<KCircularLoader />
component (which is globally available, no need to import it from anywhere) in place of where either the data or the "no data" message should go?