Code Monkey home page Code Monkey logo

react-filemanager's Introduction

ABANDONED!

You can still fork this repository, workout the missing dependencies and extend or/and you can check out the new file manager we are working on.

React based file and media manager developed for Quix Page Builder and open sourced by ThemeXpert team.

Dependency

We've written a PHP library to handle all server side things. You need to include this to your project using composer. More information https://github.com/themexpert/react-filemanager-server

Usage

yarn add @themexpert/react-filemanager

npm -i @themexpert/react-filemanager

Webpack rules

        module: {
            rules: [
                {
                    test: /\.jsx?$/,
                    loader: 'babel?stage=0',
                    include: [].concat(your_project_dirs, [fs.realpathSync(path.resolve(__dirname, './node_modules/@themexpert/react-filemanager/'))])
                }

            ]
        }
import initFM from 'react-filemanager';

const openFileManager = initFM('server_endpoint');
// or
const openFileManager = initFM('server_endpoint', DOMElement);

The returned callback openFileManager accepts a callback as first parameter to show the file manager modal and an object config as second parameter.

In this way, you won't have to instantiate FileManager seperately for different config

const config  = {
                    //add filters, valid filters are [icon,image,video,dir]
                    //currently filters only filters the plugins, not the items
                    filters: "image,icon",

                    //add additional http get/post parameters
                    http_params: {
                        foo: "bar"
                    },

                    //add additional headers
                    headers: {
                        foo: "bar"
                    }
                };

<button onclick="openFileManager(fileSelectCallback, config)">Open File Manager</button> 
function fileSelectCallback(selection) {
    console.log(selection);
    return true; //close the modal
}

It's a good idea to make a wrapper to instantiate the file manager and the using it elsewhere

File: wrapper.js

Content:

import initFM from 'react-filemanager'

export default initFM('server-endpoint');

Use the wrapper in any React component

import React, {Component} from 'react'
import openFileManager from './wrapper' //wherever it is

const config  = {
                    //add filters, valid filters are [icon,image,video,dir]
                    filters: "image,icon",

                    //add additional http get/post parameters
                    http_params: {
                        foo: "bar"
                    },

                    //add additional headers
                    headers: {
                        foo: "bar"
                    }
                };

export default class FilePicker extends Component {
    constructor(props) {
        super(props);
    }
    
    onFileSelect = selection => {
    
        console.log(selection);
        
        return true; //closes the file manager modal
    };
    
    render = () => {
        return (
            <button onClick={openFileManager(this.onFileSelect, config)}>Pick File</button>
        );
    };
}

react-filemanager's People

Contributors

codexpert avatar i-rocky avatar iftekhersunny avatar shamsbd71 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-filemanager's Issues

Shouldn't remember multiple select

When i select multiple image and close the media manager and come by, it showing the selected state. The select state should clean after closing the media manager.

This dependency was not found: components/button

Hello my friend,

I tried to run your code but I had no luck.

I run the commands bellow:

git clone https://github.com/themexpert/react-filemanager.git
cd react-filemanager/
npm init
npm install
npm run prod

But the app stops before the command 'npm run prod' finishes.

This is the output of the command:

@themexpert/[email protected] prod /home/daniel/my-app/react-filemanager
npm run production

@themexpert/[email protected] production /home/daniel/my-app/react-filemanager
cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

21% building modules 94/104 modules 10 active ...dules/antd/lib/button/button-group.js[BABEL] Note: The code generator has deoptimised the styling of "/home/daniel/my-app/react-filemanager/node_modules/@ant-design/icons/lib/dist.js" as it exceeds the max of "500KB".
95% emitting

ERROR Failed to compile with 2 errors 22:47:10

This dependency was not found:

  • components/button in ./src/core/fm/action/index.jsx, ./src/core/fm/content/index.jsx

To install it, you can run: npm install --save components/button
Asset Size Chunks Chunk Names
/dist/build.js 1.66 MB 0 [emitted] [big] /dist/build
dist/style.css 136 kB 0 [emitted] /dist/build
/dist/build.js.map 1.7 MB 0 [emitted] /dist/build
dist/style.css.map 80 bytes 0 [emitted] /dist/build

ERROR in ./src/core/fm/action/index.jsx
Module not found: Error: Can't resolve 'components/button' in '/home/daniel/my-app/react-filemanager/src/core/fm/action'
@ ./src/core/fm/action/index.jsx 23:14-42
@ ./src/core/fm/index.jsx
@ ./src/core/store.js
@ ./src/core/file-manager.jsx
@ ./src/index.js
@ ./build.js
@ multi ./build.js ./src/style.less

ERROR in ./src/core/fm/content/index.jsx
Module not found: Error: Can't resolve 'components/button' in '/home/daniel/my-app/react-filemanager/src/core/fm/content'
@ ./src/core/fm/content/index.jsx 23:14-42
@ ./src/core/fm/index.jsx
@ ./src/core/store.js
@ ./src/core/file-manager.jsx
@ ./src/index.js
@ ./build.js
@ multi ./build.js ./src/style.less
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @themexpert/[email protected] production: cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @themexpert/[email protected] production script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/daniel/.npm/_logs/2020-03-22T01_47_10_417Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @themexpert/[email protected] prod: npm run production
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @themexpert/[email protected] prod script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!

/home/daniel/.npm/_logs/2020-03-22T01_47_10_436Z-debug.log

Looks like there is a problem with "components/button", but I do not know what is the problem.
Am I doing something wrong?

Thank you.

z-index conflict

z-index of fm-modal class hiding the modals from action menu (Upload, New Directory, etc)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.