1- import React , { useContext , useEffect } from 'react' ;
2- import { isEmpty } from 'lodash' ;
3- import { PropTypes } from 'prop-types' ;
4- import { FormattedMessage , useIntl } from '@edx/frontend-platform/i18n' ;
51import { getConfig } from '@edx/frontend-platform' ;
6- import {
7- Button ,
8- DataTableContext ,
9- Dropdown ,
10- useToggle ,
11- } from '@openedx/paragon' ;
2+ import { FormattedMessage , useIntl } from '@edx/frontend-platform/i18n' ;
3+ import { Button , DataTableContext , Dropdown , useToggle , } from '@openedx/paragon' ;
124import { Add , Tune } from '@openedx/paragon/icons' ;
5+ import { isEmpty } from 'lodash' ;
6+ import { PropTypes } from 'prop-types' ;
7+ import React , { useContext , useEffect } from 'react' ;
138import messages from '../messages' ;
149import SortAndFilterModal from './sort-and-filter-modal' ;
1510
@@ -26,12 +21,15 @@ const TableActions = ({
2621 const intl = useIntl ( ) ;
2722 const [ isSortOpen , openSort , closeSort ] = useToggle ( false ) ;
2823 const { state, clearSelection } = useContext ( DataTableContext ) ;
24+ const filePickerParams = new URLSearchParams ( window . location . search ) ;
2925
26+ const showFilePicker = Boolean ( filePickerParams . get ( 'filePicker' ) ) && Boolean ( window . opener ) ;
3027 // This useEffect saves DataTable state so it can persist after table re-renders due to data reload.
3128 useEffect ( ( ) => {
3229 setInitialState ( state ) ;
3330 } , [ state ] ) ;
3431
32+
3533 const handleOpenFileSelector = ( ) => {
3634 fileInputControl . click ( ) ;
3735 clearSelection ( ) ;
@@ -80,6 +78,18 @@ const TableActions = ({
8078 < Button iconBefore = { Add } onClick = { handleOpenFileSelector } >
8179 { intl . formatMessage ( messages . addFilesButtonLabel , { fileType } ) }
8280 </ Button >
81+ { showFilePicker && (
82+ < Button
83+ className = "ml-2"
84+ onClick = { async ( ) => {
85+ window . opener . postMessage ( { type : 'org.openedx.assets.selected.v1' , data : selectedFlatRows . map ( ( { original } ) => original ) } , '*' ) ;
86+ window . close ( ) ;
87+ } }
88+ disabled = { selectedFlatRows . length === 0 }
89+ >
90+ Select File(s)
91+ </ Button >
92+ ) }
8393 < SortAndFilterModal { ...{ isSortOpen, closeSort, handleSort } } />
8494 </ >
8595 ) ;
0 commit comments