Skip to content

Commit 42b4e71

Browse files
rtibblesclaude
andcommitted
Remediate JSDoc violations in plugins/device
Restores the HACK note in availableChannelsActions explaining the unlisted-channel workaround; restores Node/SelectedNodes/AnnotatedNode typedefs in treeViewUtils; restores the downloadChannelMetadata JSDoc and the "does not interact with Vuex store" caveat in wizard utils. Fills missing block descriptions, @param descriptions, @throws, and @returns declarations. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4184d7e commit 42b4e71

16 files changed

Lines changed: 106 additions & 97 deletions

File tree

kolibri/plugins/device/frontend/modules/deviceInfo/handlers.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ export function getDeviceInfo() {
3737
}
3838

3939
/**
40-
* Action to hydrate device-info page.
41-
*
42-
* @param {Store} store
43-
* @returns Promise<void>
40+
* Fetches device info and commits it to the Vuex store for the device info page.
41+
* @param {object} store - The Vuex store instance.
42+
* @param {object} route - The current Vue Router route object.
43+
* @returns {Promise<void>} Resolves when device info has been loaded into the store.
4444
*/
4545
export function showDeviceInfoPage(store, route) {
4646
const { canManageContent } = useUser();

kolibri/plugins/device/frontend/modules/manageContent/utils.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ import { TaskStatuses } from 'kolibri-common/utils/syncTaskUtils';
33

44
/**
55
* Watches the state.taskList and resolves when the tracked Task is COMPLETED.
6-
*
7-
* @param {string} taskId
8-
* @returns {Promise}
9-
*
6+
* @param {string} taskId - The id of the task to track.
7+
* @param {object} [store] - The Vuex store to watch (defaults to the core store).
8+
* @returns {Promise<{taskId: string, cancelled: boolean}>} Resolves when the task
9+
* completes (or is cancelled, in which case `cancelled` is true). Rejects when the
10+
* task transitions to a failed state.
1011
*/
1112
export function waitForTaskToComplete(taskId, store = coreStore) {
1213
const taskList = state => state.manageContent.taskList;

kolibri/plugins/device/frontend/modules/userPermissions/actions.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import FacilityUserResource from 'kolibri-common/apiResources/FacilityUserResour
33
import { handleApiError } from 'kolibri/utils/appError';
44

55
/**
6-
* Adds or modifies a DevicePermissions model.
7-
*
8-
* @param {boolean} payload.is_superuser
9-
* @param {boolean} payload.can_manage_content
10-
* @returns Promise<DevicePermissions>
6+
* Saves or updates device permissions for a user and commits the updated state to the store.
7+
* @param {object} store - The Vuex store instance.
8+
* @param {object} payload - Permissions payload with userId, is_superuser, and can_manage_content.
9+
* @returns {Promise<object>} Resolves with the updated user model.
1110
*/
1211
export function addOrUpdateUserPermissions(store, payload) {
1312
const permissions = {

kolibri/plugins/device/frontend/modules/userPermissions/handlers.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ import { handleApiError } from 'kolibri/utils/appError';
88
import { pageLoading } from 'kolibri-common/composables/usePageLoading';
99

1010
/**
11-
* Serially fetches Permissions, then FacilityUser. If returned Promise rejects,
12-
* it is from the request for FacilityUser.
13-
*
14-
* @param {string} userId
15-
* @returns Promise<{ permissions, user }, FacilityUserError>
11+
* Serially fetches Permissions, then FacilityUser. If the returned Promise rejects, it
12+
* is from the request for FacilityUser.
13+
* @param {string} userId - The ID of the user to fetch permissions for.
14+
* @returns {Promise<{permissions: object, user: object}>} Resolves with combined
15+
* permissions and user data.
1616
*/
1717
function fetchUserPermissions(userId) {
1818
const permissionsPromise = DevicePermissionsResource.fetchModel({ id: userId, force: true });
@@ -39,11 +39,11 @@ function fetchUserPermissions(userId) {
3939
}
4040

4141
/**
42-
* Action to hydrate user-permissions-page.
43-
*
44-
* @param {Store} store
45-
* @param {string} userId
46-
* @returns Promise<void>
42+
* Load the user permissions page state into the Vuex store.
43+
* @param {object} store - The Vuex store instance.
44+
* @param {string} userId - The ID of the user whose permissions to display.
45+
* @param {object} route - The current Vue Router route object.
46+
* @returns {Promise<void>} Resolves when state has been loaded.
4747
*/
4848
export function showUserPermissionsPage(store, userId, route) {
4949
const { fetchFacilities } = useFacilities();

kolibri/plugins/device/frontend/modules/wizard/actions/availableChannelsActions.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@ import differenceBy from 'lodash/differenceBy';
22
import find from 'lodash/find';
33
import { getRemoteChannelByToken } from '../utils';
44

5+
/**
6+
* @typedef {import('kolibri-common/apiResources/RemoteChannelResource').Channel} Channel
7+
*/
8+
59
/**
610
* HACK: Makes a request to Kolibri Studio to get info on unlisted channels, then appends
7-
* them to the public channels. This hack is to get around the fact that the ChannelMetadata object
8-
* does not indicate the origins of a channel: whether a remote public, remote unlisted, or bespoke
9-
* channel from USB, the ChannelMetadata is identical.
10-
*
11-
* @param {Array<Channel>} publicChannels - the list of publich channels, which will not be queried
12-
* @returns {Promise<Array<Channel>>}
11+
* them to the public channels. This hack is to get around the fact that the ChannelMetadata
12+
* object does not indicate the origins of a channel: whether a remote public, remote unlisted,
13+
* or bespoke channel from USB, the ChannelMetadata is identical.
14+
* @param {object} store - The Vuex store instance.
15+
* @param {Array<Channel>} publicChannels - The list of public channels, which will not be
16+
* queried.
17+
* @returns {Promise<Array<Channel>>} Resolves with the combined channel list.
1318
*/
1419
export function getAllRemoteChannels(store, publicChannels) {
1520
const { channelList } = store.rootState.manageContent;

kolibri/plugins/device/frontend/modules/wizard/actions/contentTreeViewerActions.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,9 @@ function isDescendantOrSelf(testNode, selfNode) {
1212
}
1313

1414
/**
15-
* Queries the server for the current total file size and resource count
16-
* and then sets it to the store.
17-
*
18-
* @returns {Promise}
19-
*
15+
* Fetches and commits the file size and resource count for the current transfer selection.
16+
* @param {object} store - The Vuex store instance with transfer state.
17+
* @returns {Promise<void>} Resolves when the transfer size has been updated in the store.
2018
*/
2119
function setImportExportFileSizeAndResourceCount(store) {
2220
const { transferredChannel, nodesForTransfer } = store.state;
@@ -59,11 +57,10 @@ function setImportExportFileSizeAndResourceCount(store) {
5957
}
6058

6159
/**
62-
* Adds a new node to the transfer list.
63-
*
64-
* @param node {Node} - Node to be added
65-
* @param node.path {Array<String>} - path (via ids) from channel root to the Node
66-
*
60+
* Adds a content node to the transfer include list and updates the transfer size.
61+
* @param {object} store - The Vuex store instance with transfer state.
62+
* @param {object} node - The content node to add to the transfer.
63+
* @returns {Promise<void>} Resolves when the node has been added and transfer size updated.
6764
*/
6865
export function addNodeForTransfer(store, node) {
6966
const { included, omitted } = store.state.nodesForTransfer;
@@ -84,10 +81,10 @@ export function addNodeForTransfer(store, node) {
8481
}
8582

8683
/**
87-
* Removes node from transfer list
88-
*
89-
* @param node {Node} - node to be removed
90-
*
84+
* Removes a content node from the transfer include list and updates the transfer size.
85+
* @param {object} store - The Vuex store instance with transfer state.
86+
* @param {object} node - The content node to remove from the transfer.
87+
* @returns {Promise<void>} Resolves when the node has been removed and transfer size updated.
9188
*/
9289
export function removeNodeForTransfer(store, node) {
9390
const forImport = !store.getters.inExportMode;

kolibri/plugins/device/frontend/modules/wizard/actions/selectContentActions.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import { downloadChannelMetadata } from '../utils';
44
import { getChannelWithContentSizes } from '../apiChannelMetadata';
55

66
/**
7-
* Transitions the import/export wizard to the 'load-channel-metadata' interstitial state
8-
*
7+
* Loads channel metadata for the current transfer, downloading it if needed.
8+
* @param {object} store - The Vuex store instance with wizard state.
9+
* @returns {Promise<void>} Resolves when channel metadata has been loaded into the store.
910
*/
1011
export function loadChannelMetadata(store) {
1112
let dbPromise;
@@ -48,13 +49,9 @@ export function loadChannelMetadata(store) {
4849
}
4950

5051
/**
51-
* Makes a call to freespace API and places result in the store.
52-
* If transfer type is LOCALEXPORT, it gets the selected drive's freespace.
53-
*
54-
* @param {string} path - Path to the Kolibri data folder.
55-
* If empty, defaults to server's KOLIBRI_HOME.
56-
* @returns {Promise}
57-
*
52+
* Gets the available free space on a drive, or on the device's content storage if no drive given.
53+
* @param {object} selectedDrive - Optional drive object with a freespace property.
54+
* @returns {Promise<number>} Resolves with the available free space in bytes, or -1 on error.
5855
*/
5956
export function getAvailableSpaceOnDrive(selectedDrive) {
6057
if (selectedDrive) {

kolibri/plugins/device/frontend/modules/wizard/handlers.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,10 @@ export function showAvailableChannelsPage(store, params, route) {
143143
}
144144

145145
/**
146-
* Handler for going to Select Content Page URL directly
147-
* params are { channel_id: string, drive_id?: string, address_id? },
146+
* Loads the select content page state for a given channel and transfer type.
147+
* @param {object} store - The Vuex store instance.
148+
* @param {object} params - Route params with drive_id, address_id, and channel_id.
149+
* @returns {Promise<void>} Resolves when the select content page state is ready.
148150
*/
149151
export function showSelectContentPage(store, params) {
150152
let selectedDrivePromise = Promise.resolve({});
@@ -255,10 +257,10 @@ export function showSelectContentPage(store, params) {
255257
}
256258

257259
/**
258-
* Updates wizardState.treeView when a new topic is clicked.
259-
*
260-
* @param {Object} topic - { id, title, path }
261-
*
260+
* Fetches granular content node data for a topic and updates the wizard tree view.
261+
* @param {object} store - The Vuex store instance with wizard state.
262+
* @param {object} topic - The topic content node object with id and title.
263+
* @returns {Promise<void>} Resolves when the tree view topic has been updated in the store.
262264
*/
263265
export function updateTreeViewTopic(store, topic) {
264266
const fetchArgs = {};

kolibri/plugins/device/frontend/modules/wizard/utils.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,10 @@ import { waitForTaskToComplete } from '../manageContent/utils';
88
import { getChannelWithContentSizes } from './apiChannelMetadata';
99

1010
/**
11-
* Makes request to RemoteChannel API with a token. Does not actually interact
12-
* with Vuex store.
13-
*
14-
* @param {string} token -
15-
* @returns Promise
11+
* Makes a request to the RemoteChannel API with a token. Does not actually interact with
12+
* the Vuex store.
13+
* @param {string} token - The channel token to look up.
14+
* @returns {Promise<object>} Resolves with the remote channel object.
1615
*/
1716
export function getRemoteChannelByToken(token) {
1817
return RemoteChannelResource.fetchModel({ id: token, force: true });
@@ -23,10 +22,13 @@ export function getRemoteChannelBundleByToken(token) {
2322
}
2423

2524
/**
26-
* Starts Task that downloads a Channel Metadata database.
27-
* NOTE: cannot be normally dispatched as an action, since it uses
28-
* waitForTaskToComplete (which relies on the store singleton with a .watch method)
25+
* Starts a task that downloads a Channel Metadata database.
2926
*
27+
* NOTE: cannot be normally dispatched as an action, since it uses `waitForTaskToComplete`
28+
* (which relies on the store singleton with a `.watch` method).
29+
* @param {object} store - The Vuex store instance; defaults to the core store singleton.
30+
* @returns {Promise<object>} Resolves with the channel content sizes when the task completes.
31+
* @throws {Error} If the wizard is not in an import mode when called.
3032
*/
3133
export function downloadChannelMetadata(store = coreStore) {
3234
if (

kolibri/plugins/device/frontend/views/ManageContentPage/ManageChannelContentsPage/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,8 @@
316316
this.shownModal = null;
317317
},
318318
/**
319+
* Refreshes the page data after a watched content task completes, handling channel deletion.
319320
* @public
320-
* Used by the taskNotificationMixin to handle the completion of the task
321321
*/
322322
onWatchedTaskFinished() {
323323
// clear out the nodeCache

0 commit comments

Comments
 (0)