Skip to content

Commit c2a40e0

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 6ad14bf commit c2a40e0

18 files changed

Lines changed: 125 additions & 98 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: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ import { OptionsForSignIn, PicturePasswordIconStyle } from 'kolibri-common/const
1010
import { useFacilityConfig } from 'kolibri-common/composables/useFacility';
1111

1212
/**
13-
* @param {string} facilityId The ID of the facility to edit
13+
* Composable providing facility editor state and actions for the facility settings page.
14+
* @param {string} facilityId - The ID of the facility to edit.
15+
* @returns {object} Facility editor state, computed properties, and action methods.
1416
*/
1517
export default function useFacilityEditor(facilityId) {
1618
const { fetchFacilities, getFacility } = useFacilities();
@@ -79,7 +81,8 @@ export default function useFacilityEditor(facilityId) {
7981
}
8082

8183
/**
82-
* Loads the facility and it's config into the composable state
84+
* Fetches the facility configuration and name from the backend.
85+
* @returns {Promise<void>} Resolves when facility data has been loaded.
8386
*/
8487
async function fetchFacility() {
8588
setLoading(true);
@@ -158,9 +161,9 @@ export default function useFacilityEditor(facilityId) {
158161
}
159162

160163
/**
161-
* Updates the facility's name
162-
* @param {string} name
163-
* @return {Promise<*>}
164+
* Saves a new facility name to the backend and refreshes the facilities list.
165+
* @param {string} name - The new facility name to save.
166+
* @returns {Promise<object>} Resolves with the updated facility model.
164167
*/
165168
async function saveFacilityName(name) {
166169
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
@@ -2,8 +2,10 @@ import ClassroomResource from 'kolibri-common/apiResources/ClassroomResource';
22
import { handleApiError } from 'kolibri/utils/appError';
33

44
/**
5-
* Do a POST to create new class
6-
* @param {string} name
5+
* Creates a new class with the given name and adds it to the store.
6+
* @param {object} store - The Vuex store instance.
7+
* @param {string} name - The name for the new class.
8+
* @returns {Promise<void>} Resolves when the class has been created.
79
*/
810
export function createClass(store, name) {
911
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
@@ -4,12 +4,11 @@ import { UserKinds } from 'kolibri/constants';
44
import { updateFacilityLevelRoles } from './utils';
55

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

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