kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Remove isAppContext gates on file upload/download capabilities

Open rtibbles opened this issue 7 months ago • 9 comments

❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.

Overview

Several file upload/download/print UI affordances are gated behind isAppContext, hiding them in our installed apps. This was originally a workaround for the assumption that the app couldn't handle file downloads. The Windows and Mac apps already handle this natively, and the work to add it to the Android WebView layer is tracked in kolibri-installer-android#267 and is trivial. The gates can be removed.

Complexity: Low Target branch: develop

Context

isAppContext is sourced from useUser() (packages/kolibri/composables/useUser.js), which reads sessionState.value.app_context. The value is set server-side in kolibri/core/auth/api.py based on valid_app_key_on_request. None of that needs to change.

The places that gate file upload/download/print UI behind isAppContext:

  1. Content "Save to Device" button — packages/kolibri/components/DownloadButton.vue:74

    return !this.isAppContext && this.downloadableFiles.length;
    
  2. Coach report CSV export — kolibri/plugins/coach/frontend/views/common/ReportsControls.vue:87-89

    exportDisabled() {
      // Always disable in app mode until we add the ability to download files.
      return this.isAppContext || this.disableExport;
    }
    
  3. Facility data CSV import/export + session/summary log downloads — kolibri/plugins/facility/frontend/views/DataPage/index.vue:262-263

    canUploadDownloadFiles() {
      return !this.isAppContext;
    }
    

    This gates the entire ImportInterface block and the session/summary log download buttons via v-if in the template.

  4. "Print all passwords" button — packages/kolibri-common/components/AllPasswordsPage.vue:25

    <KGridItem v-if="!isAppContext" ... class="header-row print-button">
      <KButton :text="printAction$()" :disabled="!hasPicturePasswords" @click="openPrintDialog" />
    </KGridItem>
    

    isAppContext also drives the title row's grid span (lines 17-19), which currently expands to full width when the print button is hidden. This shared component renders on both the coach and facility "All passwords" pages (CoachAllPasswordsPage.vue, FacilityAllPasswordsPage.vue), so removing the gate fixes both.

The Change

Remove the isAppContext checks listed in Context so that file upload, download, and print affordances are visible to users regardless of context.

  • DownloadButton.vue — drop the !this.isAppContext clause from the visibility computation.
  • ReportsControls.vue — drop this.isAppContext from exportDisabled and remove the now-stale comment.
  • DataPage/index.vue — remove the canUploadDownloadFiles computed and its v-if gates on the import interface and log download sections.
  • AllPasswordsPage.vue — drop the v-if="!isAppContext" on the print button and remove the isAppContext ternary from the title row's grid span so it always uses the two-column layout (span 6/4/2).

Out of Scope

  • useUser.js and the backend app_context plumbing
  • The allowOtherBrowsersToConnect checkbox in DeviceSettingsPage (correctly app-only)
  • The BottomAppBar vs inline-save-row layout swaps in DeviceSettingsPage and FacilityConfigPage (layout, not capability — Android needs the inline variant)
  • ShareFileView / FromAppContextPermission (kolibri/core/content/api.py:2043-2063) — the inverse gate (share-out only in-app) is correct
  • Any WebView-layer work in kolibri-installer-android — tracked separately

Acceptance Criteria

General

  • [ ] DownloadButton.vue visibility computation does not reference isAppContext; the "Save to Device" button renders in app context whenever there are downloadable files.
  • [ ] ReportsControls.vue exportDisabled does not reference isAppContext and the obsolete comment is removed; the CSV export control is enabled in app context (subject only to disableExport).
  • [ ] DataPage/index.vue no longer has a canUploadDownloadFiles computed; the import interface and session/summary log download sections render in app context.
  • [ ] AllPasswordsPage.vue print button renders in app context, and the title row uses the two-column layout in both contexts.
  • [ ] Imports, computed properties, and local refs left unused after removal are deleted (e.g. useUser where isAppContext was its only consumer).
  • [ ] Behaviour in non-app context is unchanged: the same affordances render and function as before.

Testing

  • [ ] Existing Jest tests for the affected components continue to pass.
  • [ ] Any tests that specifically assert the isAppContext blocking behaviour are removed.
  • [ ] Manual verification in a regular browser confirms the affordances render and function as before. (Verifying the affordances actually work end-to-end in the Android app is out of scope and depends on kolibri-installer-android#267.)

AI usage

I used Claude to inventory every isAppContext gate in the codebase and to draft this issue iteratively. I verified the cross-repo reference to kolibri-installer-android#267 myself.

rtibbles avatar Apr 28 '26 15:04 rtibbles

Plan: Remove the isAppContext checks that hide file upload/download/print affordances in installed-app contexts, so those affordances render regardless of context.

  • [ ] DownloadButton.vue — "Save to device" button
  • [ ] ReportsControls.vue — coach report CSV export
  • [ ] DataPage/index.vue — facility CSV import/export + log downloads
  • [ ] AllPasswordsPage.vue — "Print all passwords" button + title layout

@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly

How was this generated?
  • Implemented code following the pre-approved plan using test-driven development (red-green-refactor)
  • Ran the project's full test suite and linter before committing
  • For UI changes: captured live screenshots to verify rendering
  • For backend changes: verified with example API/CLI output

rtibblesbot avatar Jul 23 '26 00:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 23 '26 05:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 24 '26 00:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 24 '26 05:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 27 '26 20:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 28 '26 02:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 28 '26 16:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 29 '26 05:07 rtibblesbot

The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.

rtibblesbot avatar Jul 29 '26 10:07 rtibblesbot