
import React from 'react';

import Configuration from '../../Tools/Configuration'

import BaseControl from '../BaseControl.jsx'
import MenuControl from '../Controls/MenuControl.jsx'
import UserControl from '../Controls/UserControl.jsx'
import FileExplorerControl from '../Controls/FileExplorer/FileExplorerControl.jsx'
import ExplorerActionsControl from '../Controls/FileExplorer/ExplorerActionsControl.jsx'
import UploaderControl from '../Controls/FileExplorer/UploaderControl.jsx'
import BootstrapControl from '../Controls/BootstrapControl.jsx'

export default class FileExplorerPage extends BaseControl {

    constructor(props) {
        super(props, "FileExplorerPage");


        let DirectoryID = -1;
        //Получить ID из url
        let url_ID = new URL(window.location.href).
            searchParams.get("ID");

        if (url_ID != null)
            DirectoryID = url_ID;

        this.GlobalState.MainExplorer = {
            //ID папки
            ID: DirectoryID,
            //Отображать или нет SelectColumn
            ShoSelectColumn: true,
            //Названия события изменения содержимого папки
            ChangeEvent: "OnItemsChange_Main"
        };
        //this.EventRegister.EventAction("OnItemsChange");
    }


    render() {
        return (
            <div>              
                <UserControl ref="UserControl"
                    ParentComponent={this}
                />

                <hr />
                <FileExplorerControl ref="FileExplorerControl"
                    ParentComponent={this}
                    //Параметры для того, чтобы можно было содержать 
                    //несколько элементов данного типа с разными дирректориями                   
                    CurrentDirectoryName={"MainExplorer"}            
                />
                <hr />
                {(this.GlobalState.MainExplorer.ID != Configuration.RooDirectoryID)
                    ?
                    <div>
                        <ExplorerActionsControl ref="ExplorerActionsControl"
                            ParentComponent={this}
                        />
                        <hr />
                        <UploaderControl ref="UploaderControl"
                            ParentComponent={this}
                        />
                        <hr />
                    </div>
                    : null
                }
                <hr />
                <BootstrapControl />
                <hr />

            </div>
        );
    }
}

