Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An open dialog for directories #154

Open
mahsashadi opened this issue Apr 17, 2021 · 8 comments
Open

An open dialog for directories #154

mahsashadi opened this issue Apr 17, 2021 · 8 comments
Labels
enhancement New feature or request

Comments

@mahsashadi
Copy link
Contributor

In below code, I have a dialog which let user to select and open files:

import React from 'react';
export default function App ({win, proc}) {
  const [basic] = React.useState(() => core.make('osjs/basic-application', proc, win));

    return (
      <Button onClick={() => basic.createOpenDialog()}>Browser Files</Button>
    );
}

How can I make a dialog to only let user select and open among directories?

@andersevenrud
Copy link
Member

andersevenrud commented Apr 17, 2021

There is a filetype property for dialogs, but it doesn't seem like this is available from basic application abstration. I will add this.

@andersevenrud
Copy link
Member

You should now be able to do basic.createOpenDialog({ filetype: 'directory' })

@andersevenrud andersevenrud added the enhancement New feature or request label Apr 17, 2021
@mahsashadi
Copy link
Contributor Author

You should now be able to do basic.createOpenDialog({ filetype: 'directory' })

Thank you, now it is available, But I think the path of selected directory in returned object is not correct.

For example if I select TEST directory in HOME , the path will be "HOME:/" ( it does not contain the very last directory in selected path)

@mahsashadi
Copy link
Contributor Author

mahsashadi commented Apr 26, 2022

Hi there.

But I think the path of selected directory in returned object is not correct.

For example if I select TEST directory in HOME , the path will be "HOME:/" ( it does not contain the very last directory in selected path)

Sorry but I faced this problem again. There must be a problem here when setting path when filetype = 'directory'

@andersevenrud andersevenrud reopened this Apr 26, 2022
@andersevenrud
Copy link
Member

How do I reproduce ?

@mahsashadi
Copy link
Contributor Author

Imagine a simple component like this, which we want to fill the textbox with the selected directory path

import React, {useEffect, useState} from 'react';

export default function Main({core, proc, win}) {

  const basic =  core.make('osjs/basic-application', proc, win);
  const[sourceData, setSourceData] = useState();

  useEffect(() => {
    basic.on('open-file', (selctedData) => {
      setSourceData(selctedData.path);
    });
  }, []);


  const openBasic = () => {
    basic.createOpenDialog({filetype: 'directory', path:'myMonster:/'});
  };

  return (
    <>
      <label>Source</label>
      <input onClick={openBasic} value={sourceData} />
    </>
  );
}

For example, although I selected d directory inside demo directory, the textbox path does not contain d
Screenshot from 2022-04-27 16-14-04

@andersevenrud
Copy link
Member

Does it work when you go inside the directory ?

@mahsashadi
Copy link
Contributor Author

Does it work when you go inside the directory ?

Yes, the selected directory is which the user is inside that.

UX-wise I thought when I click on a directory (highlighted in blue), the OK button should be activated and highlighted one should be the selected one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants