Skip to content

Commit 9f3aa7d

Browse files
rtibblesclaude
andcommitted
Remediate JSDoc violations in plugins/setup_wizard and plugins/facility
Restores the importLodUsers TODO comment and merged punctuation in wizardMachine; restores the UseActionWithUndoObject typedef and the unmounted-component warning paragraph on useActionWithUndo; restores the "Needed: id, facility, role" caller hint in userManagement actions. Fills missing block descriptions, @param descriptions, @throws, and @returns declarations. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent ac764ac commit 9f3aa7d

18 files changed

Lines changed: 175 additions & 97 deletions

File tree

kolibri/plugins/facility/frontend/composables/useActionWithUndo.js

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,30 @@ import { bulkUserManagementStrings } from 'kolibri-common/strings/bulkUserManage
22
import useSnackbar from 'kolibri/composables/useSnackbar';
33

44
/**
5-
*
6-
* @param {Object} options
5+
* @typedef {object} UseActionWithUndoObject
6+
* @property {() => Promise<void>} performAction - A method to manually trigger the main action
7+
* with all the undo machinery set up.
8+
*/
9+
10+
/**
11+
* Wraps an action with an undo snackbar, providing a `performAction` function that runs the
12+
* action and shows a snackbar with an undo option when it succeeds.
13+
* @param {object} options - Options object.
714
* @param {() => Promise<boolean>} options.action - Callback that executes the action to perform.
8-
* Should return a boolean promise indicating whether the action was successful. If the action
9-
* succeeds, the snackbar will display a success message and provide an undo option.
10-
*
15+
* Should return a boolean promise indicating whether the action was successful. If the action
16+
* succeeds, the snackbar will display a success message and provide an undo option.
1117
* @param {() => string} options.actionNotice$ - Function that returns the message to display on
12-
* the snackbar when the action is successful.
13-
*
14-
* @param {() => Promise<void>} options.undoAction - Callback that executes the undo action.
15-
* Be careful if this action is happening after the component that triggered the original action has
16-
* been unmounted (e.g. you cannot emit events from an unmounted component). If the undoAction fails
17-
* the function should throw an error, and a snackbar will be shown with a generic error message.
18-
*
19-
* @param {() => string} options.undoActionNotice$ - Function that returns the message to display on
20-
* the snackbar when the undo action is successful.
21-
*
18+
* the snackbar when the action is successful.
19+
* @param {() => Promise<void>} options.undoAction - Callback that executes the undo action. Be
20+
* careful if this action is happening after the component that triggered the original action
21+
* has been unmounted (e.g. you cannot emit events from an unmounted component). If the
22+
* undoAction fails the function should throw an error, and a snackbar will be shown with a
23+
* generic error message.
24+
* @param {() => string} options.undoActionNotice$ - Function that returns the message to display
25+
* on the snackbar when the undo action is successful.
2226
* @param {() => void} [options.onBlur] - Optional callback that executes when the undo button in
23-
* the snackbar loses focus.
24-
*
25-
* @typedef {Object} UseActionWithUndoObject
26-
* @property {() => Promise<void>} performAction - A method to manually trigger the main action
27-
* with all the undo machinery set up.
28-
*
29-
* @returns {UseActionWithUndoObject}
27+
* the snackbar loses focus.
28+
* @returns {UseActionWithUndoObject} Undo-wrapped action helpers.
3029
*/
3130
export default function useActionWithUndo({
3231
action,

kolibri/plugins/facility/frontend/composables/useFacilityEditor.js

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,58 @@ import { OptionsForSignIn, PicturePasswordIconStyle } from 'kolibri-common/const
99
import useFacility from 'kolibri-common/composables/useFacility';
1010

1111
/**
12-
* A composable for editing facility settings and configuration
12+
* @typedef {object} UseFacilityEditorReturn
13+
* @property {import('vue').ComputedRef<string>} facilityId - The id of the facility being edited
14+
* @property {import('vue').Ref<string>} facilityDatasetId - The dataset id used when saving
15+
* config and PIN changes
16+
* @property {import('vue').Ref<string>} facilityName - The editable facility name
17+
* @property {import('vue').Ref<object>} settings - The live facility config being edited
18+
* @property {import('vue').Ref<object>} settingsCopy - A snapshot of settings used to detect
19+
* unsaved changes
20+
* @property {import('vue').Ref<boolean>} isFacilityPinValid - Whether the entered facility PIN is
21+
* valid
22+
* @property {import('vue').Ref<boolean>} facilityDataLoading - Whether facility data is loading
23+
* @property {import('vue').Ref<string|null>} pictureLoginTaskId - The id of the in-progress picture
24+
* login settings task, or null
25+
* @property {import('vue').ComputedRef<object>} facility - The selected facility
26+
* @property {import('vue').ComputedRef<boolean>} settingsHaveChanged - Whether settings differ from
27+
* the saved snapshot
28+
* @property {import('vue').ComputedRef<string|null>} isPinSet - The configured PIN code, or null
29+
* when none is set
30+
* @property {import('vue').ComputedRef<boolean>} isAttendanceFeatureEnabled - Whether the
31+
* attendance feature is enabled
32+
* @property {import('vue').ComputedRef<boolean>} isPictureLoginFeatureEnabled - Whether picture
33+
* login is enabled
34+
* @property {import('vue').WritableComputedRef<string>} signInOption - The selected sign-in option
35+
* @property {import('vue').ComputedRef<string[]>} signInOptions - The available sign-in options
36+
* @property {import('vue').ComputedRef<object|null>} picturePasswordSettings - The picture password
37+
* settings, or null when not enabled
38+
* @property {import('vue').WritableComputedRef<string|undefined>} picturePasswordStyle - The
39+
* picture password icon style
40+
* @property {import('vue').WritableComputedRef<boolean|undefined>} picturePasswordShowIconText -
41+
* Whether picture password icons show their text labels
42+
* @property {() => Promise<void>} fetchFacility - Refetches the facility and its config
43+
* @property {(name: string, value: unknown) => void} modifySetting - Sets a facility config field
44+
* @property {(value: string) => void} modifySignInOption - Applies the chosen sign-in option
45+
* @property {(name: string, value: unknown) => void} modifyPicturePasswordSetting - Sets a picture
46+
* password setting field
47+
* @property {(newExtraFields: object) => void} modifyExtraFields - Replaces the config's
48+
* extra_fields
49+
* @property {() => void} copySettings - Snapshots the current settings into settingsCopy
50+
* @property {() => void} undoSettingsChange - Restores settings from the snapshot
51+
* @property {() => void} resetState - Resets all editor state to initial values
52+
* @property {(name: string) => Promise<object>} saveFacilityName - Saves a new facility name
53+
* @property {() => Promise<void>} saveFacilityConfig - Persists the facility config
54+
* @property {(payload: object) => Promise<void>} setPin - Sets the facility PIN
55+
* @property {() => Promise<void>} unsetPin - Clears the facility PIN
56+
* @property {(loading: boolean) => void} setLoading - Sets the facility data loading flag
57+
* @property {() => Promise<object>} saveFacilityLoginSettings - Persists the login and picture
58+
* password settings
59+
*/
60+
61+
/**
62+
* Composable providing facility editor state and actions for the facility settings page.
63+
* @returns {UseFacilityEditorReturn} Facility editor state, computed properties, and action methods
1364
*/
1465
export default function useFacilityEditor() {
1566
const {
@@ -140,9 +191,9 @@ export default function useFacilityEditor() {
140191
}
141192

142193
/**
143-
* Updates the facility's name
144-
* @param {string} name
145-
* @return {Promise<*>}
194+
* Saves a new facility name to the backend and refreshes the facilities list.
195+
* @param {string} name - The new facility name to save.
196+
* @returns {Promise<object>} Resolves with the updated facility model.
146197
*/
147198
async function saveFacilityName(name) {
148199
const facility = await FacilityResource.saveModel({

kolibri/plugins/facility/frontend/composables/usePagination.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@ import pickBy from 'lodash/pickBy';
44
import clamp from 'lodash/clamp';
55

66
/**
7-
* Composable for managing pagination state and navigation
8-
* Handles page changes, items per page, and URL query synchronization
7+
* Composable providing pagination state and navigation for the users table.
8+
* @param {object} options - Options object.
9+
* @param {object} options.usersCount - A ref or computed with the total number of users.
10+
* @param {object} options.totalPages - A ref or computed with the total number of pages.
11+
* @returns {object} Pagination state and navigation methods.
912
*/
1013
export default function usePagination({ usersCount, totalPages } = {}) {
1114
const route = useRoute();

kolibri/plugins/facility/frontend/composables/useUsersFilters.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,21 @@ import { DateRangeFilters } from '../constants';
1010

1111
/**
1212
* Composable to manage user filters in the user management pages.
13-
*
14-
* @param {object} options
15-
* @param {Array} options.classes - Ref to the list of classes available for filtering.
16-
* @returns
13+
* @param {object} options - Composable options.
14+
* @param {import('vue').Ref<Array<{id: string, name: string}>>} options.classes - Ref to the
15+
* list of classes available for filtering.
16+
* @returns {{
17+
* routeFilters: import('vue').ComputedRef<object>,
18+
* workingFilters: object,
19+
* numAppliedFilters: import('vue').ComputedRef<number>,
20+
* classesOptions: import('vue').ComputedRef<Array<{id: string, label: string}>>,
21+
* userFilterOptions: Array<{id: string, label: string, icon: string}>,
22+
* creationDateOptions: Array<{value: string, label: string, dateSubtraction?: object}>,
23+
* applyFilters: (options?: {nextRouteName?: string}) => void,
24+
* resetFilters: () => void,
25+
* getBackendFilters: () => object,
26+
* resetWorkingFilters: () => void,
27+
* }} The user-filter state, options, and methods.
1728
*/
1829
export default function useUsersFilters({ classes }) {
1930
const router = useRouter();
@@ -134,10 +145,9 @@ export default function useUsersFilters({ classes }) {
134145
* Apply the current filters to the route by updating the query parameters,
135146
* and pushing the new route. This will remove from the query any filters
136147
* that are not longer applied, but will leave any other query parameters intact.
137-
*
138-
* @param {object} options
139-
* @param {string} options.nextRouteName - The name of the route to navigate to
140-
* after applying filters.
148+
* @param {object} [options] - Routing overrides applied alongside the new query.
149+
* @param {string} [options.nextRouteName] - The name of the route to navigate to
150+
* after applying filters; defaults to the current route name.
141151
*/
142152
const applyFilters = ({ nextRouteName } = {}) => {
143153
const nextQuery = { ...route.query };

kolibri/plugins/facility/frontend/composables/useUsersTableSearch.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import pickBy from 'lodash/pickBy';
44
import debounce from 'lodash/debounce';
55

66
/**
7-
* Composable for managing search functionality in the Users table
8-
* Handles search term state and URL query parameter synchronization
7+
* Composable providing search state and methods for the facility users table.
8+
* @returns {object} Search term ref, textbox ref, and methods to focus and clear the search.
99
*/
1010
export default function useUsersTableSearch() {
1111
const route = useRoute();

kolibri/plugins/facility/frontend/modules/classEditManagement/actions.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,12 @@ export function removeClassCoach(store, { classId, userId }) {
4646
}
4747

4848
/**
49-
* Do a PATCH to update the class.
50-
* @param {string} id - class id.
51-
* @param {object} updateData.
49+
* Updates a class with the given data and commits the change to the store.
50+
* @param {object} store - The Vuex store instance.
51+
* @param {object} payload - Payload object.
52+
* @param {string} payload.id - The ID of the class to update.
53+
* @param {object} payload.updateData - The data to update on the class.
54+
* @returns {Promise<void>|void} Resolves when the class has been updated.
5255
*/
5356
export function updateClass(store, { id, updateData }) {
5457
if (!id || Object.keys(updateData).length === 0) {

kolibri/plugins/facility/frontend/modules/classManagement/actions.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@ import { handleApiError } from 'kolibri/utils/appError';
33
import { selectedFacilityId } from 'kolibri-common/composables/useFacility';
44

55
/**
6-
* Do a POST to create new class
7-
* @param {string} name
6+
* Creates a new class with the given name and adds it to the store.
7+
* @param {object} store - The Vuex store instance.
8+
* @param {string} name - The name for the new class.
9+
* @returns {Promise<void>} Resolves when the class has been created.
810
*/
911
export function createClass(store, name) {
1012
return ClassroomResource.saveModel({

kolibri/plugins/facility/frontend/modules/userManagement/actions.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ import { selectedFacilityId } from 'kolibri-common/composables/useFacility';
55
import { updateFacilityLevelRoles } from './utils';
66

77
/**
8-
* Does a POST request to assign a user role (only used in this file)
9-
* @param {Object} user
10-
* @param {string} user.id
11-
* @param {string} user.facility
12-
* @param {string} user.roles
13-
* Needed: id, facility, role
8+
* Does a POST request to assign a user role (only used in this file). Needed fields on `user`:
9+
* `id`, `facility`.
10+
* @param {object} user - The facility user object.
11+
* @param {object} role - The role object; `role.kind` is the role kind to assign.
12+
* @returns {Promise<object>} Resolves with the refreshed user model.
1413
*/
1514
function setUserRole(user, role) {
1615
return updateFacilityLevelRoles(user, role.kind).then(() => {
@@ -20,9 +19,11 @@ function setUserRole(user, role) {
2019
}
2120

2221
/**
23-
* Do a POST to create new user
24-
* @param {object} stateUserData
25-
* Needed: username, full_name, facility, role, password
22+
* Does a POST to create a new facility user. Needed fields on `payload`: `username`, `full_name`,
23+
* `facility`, `role`, `password`.
24+
* @param {object} store - The Vuex store instance.
25+
* @param {object} payload - User creation data: username, password, role, and demographics.
26+
* @returns {Promise<object|void>} Resolves when the user has been created.
2627
*/
2728
export function createFacilityUser(store, payload) {
2829
return FacilityUserResource.saveModel({

kolibri/plugins/facility/frontend/modules/userManagement/utils.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ import RoleResource from 'kolibri-common/apiResources/RoleResource';
55
const FACILITY_ROLES = [UserKinds.ADMIN, UserKinds.ASSIGNABLE_COACH, UserKinds.COACH];
66

77
/**
8-
* Implements business logic for changing a FacilityUser's Role
9-
*
10-
* If Learner/New User -> ASSIGNABLE_COACH/COACH/ADMIN, then create that Role
11-
* If ASSIGNABLE_COACH/COACH/ADMIN -> LEARNER, then delete all Classroom-Level Coach Roles
12-
* IF ASSIGNABLE_COACH/COACH/ADMIN -> ASSIGNABLE_COACH/COACH/ADMIN, then replace only that Role
8+
* Implements business logic for changing a FacilityUser's Role.
139
*
10+
* If Learner/New User -> ASSIGNABLE_COACH/COACH/ADMIN, then create that Role.
11+
* If ASSIGNABLE_COACH/COACH/ADMIN -> LEARNER, then delete all Classroom-Level Coach Roles.
12+
* IF ASSIGNABLE_COACH/COACH/ADMIN -> ASSIGNABLE_COACH/COACH/ADMIN, then replace only that Role.
13+
* @param {object} facilityUser - The user whose facility-level role is being updated.
14+
* @param {string} newRoleKind - The desired UserKinds value for the user's facility role.
15+
* @returns {Promise<unknown>|undefined} Promise resolving once the role updates have
16+
* been persisted, or undefined when no transition is supported by this helper.
1417
*/
1518
export function updateFacilityLevelRoles(facilityUser, newRoleKind) {
1619
const { roles, facility, id } = facilityUser;

kolibri/plugins/setup_wizard/frontend/api.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { Resource } from 'kolibri/apiResource';
55
/**
66
* The <Module>Resource classes here map directly to the <Module>ViewSet of the same
77
* name in the kolibri.plugins.setup_wizard.api module (note how the definitions of)
8-
* the Resource instances below have 'kolibri.plugins.setup_wizard' for their 'namespace'
9-
**/
8+
* the Resource instances below have 'kolibri.plugins.setup_wizard' for their 'namespace'.
9+
*/
1010

1111
export const SetupWizardResource = new Resource({
1212
name: 'setupwizard',

0 commit comments

Comments
 (0)