Skip to content

feat: Asset picker for XBlocks #3130

Open
xitij2000 wants to merge 7 commits into
masterfrom
kshitij/asset-picker
Open

feat: Asset picker for XBlocks #3130
xitij2000 wants to merge 7 commits into
masterfrom
kshitij/asset-picker

Conversation

@xitij2000

@xitij2000 xitij2000 commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Description

This creates a new "file_picker" page in the authoring MFE. This page can be used as an embedded file browser for XBlocks to use for selecting assets. When files are selected it posts a message back to the opener with the selected files so they can be used by the block.

Supporting information

This was discussed on the forums and on related issue.

Testing instructions

Currently testing this requires using an XBlock or other code running in the platform that supports this.

  • Install the Exemplar blocks https://gitlab.com/opencraft/dev/exemplar-blocks
  • Add the cover block, edit it and click on the "Select File" button next to the image url field.
  • Select a file or upload one and select it, then click use selected file.
  • That file's URL will appear in the text box.
  • Save the block and see that the image shows up in the block preview.

Video of above:

Screencast_20260706_191356.webm

Other information

Some of the XBlocks here have been adapted to work with this.

Best Practices Checklist

We're trying to move away from some deprecated patterns in this codebase. Please
check if your PR meets these recommendations before asking for a review:

  • Any new files are using TypeScript (.ts, .tsx).
  • Avoid propTypes and defaultProps in any new or modified code.
  • Tests should use the helpers in src/testUtils.tsx (specifically initializeMocks)
  • Do not add new fields to the Redux state/store. Use React Context to share state among multiple components.
  • Use React Query to load data from REST APIs. See any apiHooks.ts in this repo for examples.
  • All new i18n messages in messages.ts files have a description for translators to use.
  • Avoid using ../ in import paths. To import from parent folders, use @src, e.g. import { initializeMocks } from '@src/testUtils'; instead of from '../../../../testUtils'

@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Jul 6, 2026
@openedx-webhooks

openedx-webhooks commented Jul 6, 2026

Copy link
Copy Markdown

Thanks for the pull request, @xitij2000!

This repository is currently maintained by @bradenmacdonald.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Jul 6, 2026
@xitij2000 xitij2000 changed the title Kshitij/asset picker feat: Asset picket for XBlocks Jul 6, 2026
@xitij2000 xitij2000 changed the title feat: Asset picket for XBlocks feat: Asset picker for XBlocks Jul 6, 2026
@Kelketek

Kelketek commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

@xitij2000 Could you rebase? It looks like this has conflicts.

@mphilbrick211 mphilbrick211 moved this from Needs Triage to Waiting on Author in Contributions Jul 6, 2026

@Kelketek Kelketek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xitij2000 Found some code style issues that can probably be autofixed by the linter.

Had one suggestion for a light refactor.

I'm still getting the detatched footer for this. I'm really curious if it will happen for whoever is upstream, as it's never gone away for me.

Could you please add some tests, and make it to where if uploading a new image, it is auto-selected?

}
}

export const FilePickerColumn = ({ row }:FilePickerColumnProps) => (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export const FilePickerColumn = ({ row }:FilePickerColumnProps) => (
export const FilePickerColumn = ({ row }: FilePickerColumnProps) => (

import PropTypes from 'prop-types';
import {
ActionRow,
Icon,
Card,
Chip,
Truncate,
Truncate, Button,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Truncate, Button,
Truncate,
Button,

interface FilesPageContextInterface {
filePickerMode: boolean,
filePickerOptions?: FilePickerOptions,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

Comment thread src/store.ts Outdated
download: string[];
usageMetrics: string[];
loading:string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

const params = new URLSearchParams(location.search);
const fileTypes = params.get('fileTypes')?.split(',').map(_type => {
const type = _type.trim();
if (['video', 'audio', 'document', 'image', 'code', 'other'].includes(type)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any chance this constant would be valuable elsewhere and could be elevated to the module level (possibly with export?)

export const FILE_TYPES = ['video', 'audio', 'document', 'image', 'code', 'other'] as const

@xitij2000

Copy link
Copy Markdown
Contributor Author

@Kelketek Surprising running lint:fix didn't fix these. I was sure I ran that before committing, but I just ran it again and it did nothing. I'll fix these issues and rebase.

@xitij2000
xitij2000 force-pushed the kshitij/asset-picker branch from b7e0452 to 651a9ca Compare July 9, 2026 12:12
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.75000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 95.77%. Comparing base (5b328de) to head (6f827c5).
⚠️ Report is 10 commits behind head on master.

Files with missing lines Patch % Lines
src/files-and-videos/files-page/FilePickerPage.tsx 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3130      +/-   ##
==========================================
+ Coverage   95.70%   95.77%   +0.06%     
==========================================
  Files        1400     1398       -2     
  Lines       33372    33399      +27     
  Branches     7819     7589     -230     
==========================================
+ Hits        31938    31987      +49     
+ Misses       1387     1368      -19     
+ Partials       47       44       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Kelketek

Copy link
Copy Markdown
Contributor

@xitij2000 Thanks for adding the tests here -- I'm not getting auto-select when uploading a file. Could you look at that?

@xitij2000

Copy link
Copy Markdown
Contributor Author

@Kelketek Sorry I forgot to address this earlier. I had started work on this but it was a lot more complex than I expected. So it might be better to get overall approval for this before working on that since it's a bit complex. I have WIP changes stashed for that.

@Kelketek

Copy link
Copy Markdown
Contributor

@xitij2000 In that case, would you like to focus on the product proposal and circle back to this, then?

@xitij2000

Copy link
Copy Markdown
Contributor Author

@Kelketek Certainly!

@xitij2000
xitij2000 marked this pull request as ready for review July 23, 2026 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Waiting on Author

Development

Successfully merging this pull request may close these issues.

4 participants