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

Swap on-my-own const for using the existing Personal const #11514

Merged
Merged
Show file tree
Hide file tree
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
1 change: 0 additions & 1 deletion kolibri/plugins/setup_wizard/assets/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});

Expand Down
Original file line number Diff line number Diff line change
@@ -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 __
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<KRadioButton
v-model="selected"
style="margin-bottom: 1em"
:value="UsePresets.ON_MY_OWN"
:value="Presets.PERSONAL"
:label="$tr('onMyOwnLabel')"
:description="getCommonSyncString('onMyOwn')"
/>
Expand All @@ -36,18 +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;
return this.selected === Presets.PERSONAL;
},
UsePresets() {
return UsePresets;
},
Presets() {
return Presets;
},
},
methods: {
handleContinue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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') ||
Expand All @@ -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() {
Expand Down