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 ( ) ;
@@ -78,6 +76,18 @@ const TableActions = ({
7876 < Button iconBefore = { Add } onClick = { handleOpenFileSelector } >
7977 { intl . formatMessage ( messages . addFilesButtonLabel , { fileType } ) }
8078 </ Button >
79+ { showFilePicker && (
80+ < Button
81+ className = "ml-2"
82+ onClick = { async ( ) => {
83+ window . opener . postMessage ( { type : 'org.openedx.assets.selected.v1' , data : selectedFlatRows . map ( ( { original } ) => original ) } , '*' ) ;
84+ window . close ( ) ;
85+ } }
86+ disabled = { selectedFlatRows . length === 0 }
87+ >
88+ Select File(s)
89+ </ Button >
90+ ) }
8191 < SortAndFilterModal { ...{ isSortOpen, closeSort, handleSort } } />
8292 </ >
8393 ) ;
0 commit comments