File tree Expand file tree Collapse file tree 4 files changed +27
-6
lines changed
Expand file tree Collapse file tree 4 files changed +27
-6
lines changed Original file line number Diff line number Diff line change 2323 * along with this program. If not, see <http://www.gnu.org/licenses/>.
2424 *
2525 */
26+
2627namespace OCA \Files_Sharing \Listener ;
2728
2829use OCA \Files_Sharing \AppInfo \Application ;
2930use OCA \Files \Event \LoadSidebar ;
3031use OCP \EventDispatcher \Event ;
3132use OCP \EventDispatcher \IEventListener ;
3233use OCP \Util ;
34+ use OCP \AppFramework \Services \IInitialState ;
35+ use OCP \Share \IManager ;
36+
37+ class LoadSidebarListener implements IEventListener
38+ {
39+
40+ public function __construct (private IInitialState $ initialState , private IManager $ shareManager )
41+ {
42+ }
3343
34- class LoadSidebarListener implements IEventListener {
35- public function handle ( Event $ event ): void {
44+ public function handle ( Event $ event ): void
45+ {
3646 if (!($ event instanceof LoadSidebar)) {
3747 return ;
3848 }
3949
4050 Util::addScript (Application::APP_ID , 'files_sharing_tab ' , 'files ' );
51+
52+ $ shareConfig = [
53+ 'allowPublicUploads ' => $ this ->shareManager ->shareApiLinkAllowPublicUpload (),
54+ ];
55+
56+ $ this ->initialState ->provideInitialState ('shareConfig ' , $ shareConfig );
4157 }
4258}
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ export default {
100100 return options
101101 },
102102 supportsFileDrop () {
103- if (this .isFolder ) {
103+ if (this .isFolder && this . config . isPublicUploadEnabled ) {
104104 const shareType = this .share .type ?? this .share .shareType
105105 return [this .SHARE_TYPES .SHARE_TYPE_LINK , this .SHARE_TYPES .SHARE_TYPE_EMAIL ].includes (shareType)
106106 }
Original file line number Diff line number Diff line change 2222 *
2323 */
2424
25+ import { loadState } from '@nextcloud/initial-state'
26+
2527export default class Config {
2628
29+ constructor ( ) {
30+ this . _shareConfig = loadState ( 'files_sharing' , 'shareConfig' , { } )
31+ }
32+
2733 /**
2834 * Is public upload allowed on link shares ?
2935 *
@@ -32,8 +38,7 @@ export default class Config {
3238 * @memberof Config
3339 */
3440 get isPublicUploadEnabled ( ) {
35- return document . getElementsByClassName ( 'files-filestable' ) [ 0 ]
36- && document . getElementsByClassName ( 'files-filestable' ) [ 0 ] . dataset . allowPublicUpload === 'yes'
41+ return this . _shareConfig . allowPublicUploads
3742 }
3843
3944 /**
Original file line number Diff line number Diff line change @@ -453,7 +453,7 @@ export default {
453453 return this .share .id === null || this .share .id === undefined
454454 },
455455 allowsFileDrop () {
456- if (this .isFolder ) {
456+ if (this .isFolder && this . config . isPublicUploadEnabled ) {
457457 if (this .share .type === this .SHARE_TYPES .SHARE_TYPE_LINK || this .share .type === this .SHARE_TYPES .SHARE_TYPE_EMAIL ) {
458458 return true
459459 }
You can’t perform that action at this time.
0 commit comments