diff --git a/kolibri/plugins/setup_wizard/assets/src/constants.js b/kolibri/plugins/setup_wizard/assets/src/constants.js index ef2b6b1ecfd..b010398ed92 100644 --- a/kolibri/plugins/setup_wizard/assets/src/constants.js +++ b/kolibri/plugins/setup_wizard/assets/src/constants.js @@ -11,7 +11,6 @@ const Presets = Object.freeze({ * enum identifying whether the user has gone to the on my own flow or not */ const UsePresets = Object.freeze({ - ON_MY_OWN: 'on my own', GROUP: 'group', }); diff --git a/kolibri/plugins/setup_wizard/assets/src/machines/wizardMachine.js b/kolibri/plugins/setup_wizard/assets/src/machines/wizardMachine.js index e6b52db6da5..6e76e19e385 100644 --- a/kolibri/plugins/setup_wizard/assets/src/machines/wizardMachine.js +++ b/kolibri/plugins/setup_wizard/assets/src/machines/wizardMachine.js @@ -1,6 +1,12 @@ import uniq from 'lodash/uniq'; import { checkCapability } from 'kolibri.utils.appCapabilities'; -import { DeviceTypePresets, FacilityTypePresets, LodTypePresets, UsePresets } from '../constants'; +import { + DeviceTypePresets, + FacilityTypePresets, + LodTypePresets, + UsePresets, + Presets, +} from '../constants'; /** * __ Setting up the XState Visualizer __ @@ -536,7 +542,7 @@ export const wizardMachine = createMachine( // Functions used to return a true/false value. When the functions are called, they are passed // the current value of the machine's context as the only parameter isOnMyOwnOrGroup: context => { - return context.onMyOwnOrGroup === UsePresets.ON_MY_OWN; + return context.onMyOwnOrGroup === Presets.PERSONAL; }, isGroupSetup: context => { return context.onMyOwnOrGroup === UsePresets.GROUP; diff --git a/kolibri/plugins/setup_wizard/assets/src/views/onboarding-forms/HowAreYouUsingKolibri.vue b/kolibri/plugins/setup_wizard/assets/src/views/onboarding-forms/HowAreYouUsingKolibri.vue index 608a9492be0..30a432d786a 100644 --- a/kolibri/plugins/setup_wizard/assets/src/views/onboarding-forms/HowAreYouUsingKolibri.vue +++ b/kolibri/plugins/setup_wizard/assets/src/views/onboarding-forms/HowAreYouUsingKolibri.vue @@ -9,7 +9,7 @@ @@ -36,29 +36,21 @@ mixins: [commonSyncElements], inject: ['wizardService'], data() { - const selected = this.wizardService.state.context['onMyOwnOrGroup'] || UsePresets.ON_MY_OWN; + const selected = this.wizardService.state.context['onMyOwnOrGroup'] || Presets.PERSONAL; return { selected, }; }, computed: { - isOnMyOwnSetup() { - return this.selected === UsePresets.ON_MY_OWN; - }, UsePresets() { return UsePresets; }, + Presets() { + return Presets; + }, }, methods: { handleContinue() { - if (this.isOnMyOwnSetup) { - // If the user is on their own, set the preset to personal here - // If not then the user will set it using a form later on - this.$store.commit('SET_FACILITY_PRESET', Presets.PERSONAL); - } - this.goToNextStep(); - }, - goToNextStep() { this.wizardService.send({ type: 'CONTINUE', value: this.selected }); }, }, diff --git a/kolibri/plugins/setup_wizard/assets/src/views/onboarding-forms/SettingUpKolibri.vue b/kolibri/plugins/setup_wizard/assets/src/views/onboarding-forms/SettingUpKolibri.vue index 344b96f407c..8dd00728852 100644 --- a/kolibri/plugins/setup_wizard/assets/src/views/onboarding-forms/SettingUpKolibri.vue +++ b/kolibri/plugins/setup_wizard/assets/src/views/onboarding-forms/SettingUpKolibri.vue @@ -44,7 +44,7 @@ import urls from 'kolibri.urls'; import client from 'kolibri.client'; import Lockr from 'lockr'; - import { DeviceTypePresets, UsePresets } from '../../constants'; + import { DeviceTypePresets, Presets } from '../../constants'; export default { name: 'SettingUpKolibri', @@ -143,7 +143,7 @@ ...this.facilityData, superuser, settings: omitBy(settings, v => v === null), - preset: this.wizardContext('formalOrNonformal') || 'nonformal', + preset: this.presetValue, language_id: currentLanguage, device_name: this.wizardContext('deviceName') || @@ -160,7 +160,17 @@ /** Introspecting the machine via it's `state.context` properties */ isOnMyOwnSetup() { - return this.wizardContext('onMyOwnOrGroup') == UsePresets.ON_MY_OWN; + return this.wizardContext('onMyOwnOrGroup') == Presets.PERSONAL; + }, + presetValue() { + // this computed prop was to guard against a strange edge case where a mismatched + // preset was inadvertently being sent to the backend, where the values + // were not valid, including an incorrect fallback, and 'on my own' being sent as a value + if (this.isOnMyOwnSetup) { + return Presets.PERSONAL; + } else { + return this.wizardContext('formalOrNonformal'); + } }, }, created() {