Skip to content

Commit

Permalink
Open file dialog (#170)
Browse files Browse the repository at this point in the history
* add open dialog

* update the dialog

* build update

* test file open method

* reduce the scope of the warning dialog

* simplify
  • Loading branch information
OlegMoshkovich committed Apr 8, 2022
1 parent e7a70f6 commit 76cdbf7
Show file tree
Hide file tree
Showing 6 changed files with 307 additions and 213 deletions.
404 changes: 202 additions & 202 deletions docs/index.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bldrs-ai",
"version": "1.0.0-r260",
"version": "1.0.0-r268",
"main": "src/index.jsx",
"homepage": "https://github.com/bldrs-ai/Share",
"bugs": {
Expand Down
9 changes: 2 additions & 7 deletions src/Components/BaseGroup.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react'
import {makeStyles} from '@mui/styles'
import AboutControl from './AboutControl'
import {TooltipToggleButton} from './Buttons'
import OpenIcon from '../assets/2D_Icons/Open.svg'
import OpenModelControl from './OpenModelControl'


/**
Expand All @@ -16,11 +15,7 @@ export default function BaseGroup({installPrefix, fileOpen}) {
const classes = useStyles()
return (
<div className={classes.root}>
<TooltipToggleButton
title='Upload model'
icon={<OpenIcon/>}
onClick={fileOpen}
placement='top'/>
<OpenModelControl installPrefix={installPrefix} fileOpen = {fileOpen}/>
<AboutControl installPrefix={installPrefix}/>
</div>
)
Expand Down
95 changes: 95 additions & 0 deletions src/Components/OpenModelControl.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import React, {useState} from 'react'
import {makeStyles} from '@mui/styles'
import Dialog from './Dialog'
import OpenIcon from '../assets/2D_Icons/Open.svg'
import LocalFileOpen from '../assets/2D_Icons/LocalFileOpen.svg'
import {ControlButton} from './Buttons'


/**
* Displays open warning.
* @return {Object} React component
*/
export default function OpenModelControl({fileOpen}) {
const [isDialogDisplayed, setIsDialogDisplayed] = useState(false)
return (
<ControlButton
title='Shortcut keys'
isDialogDisplayed={isDialogDisplayed}
setIsDialogDisplayed={setIsDialogDisplayed}
icon={<OpenIcon/>}
dialog={
<OpenModelDialog
fileOpen={fileOpen}
isDialogDisplayed={isDialogDisplayed}
setIsDialogDisplayed={setIsDialogDisplayed}/>}/>)
}


/**
* @param {boolean} isDialogDisplayed
* @param {function} setIsDialogDisplayed
* @return {Object} React component
*/
function OpenModelDialog({isDialogDisplayed, setIsDialogDisplayed, fileOpen}) {
const classes = useStyles()
return (
<Dialog
icon={<OpenIcon/>}
headerText='Model Access'
isDialogDisplayed={isDialogDisplayed}
setIsDialogDisplayed={setIsDialogDisplayed}
content={
<div className={classes.content}>
{/* <LocalFileOpen/>
<p className={classes.bullet}>
To take advantage of all features of BLDRS, we recommend using GitHub for model hosting.
<br/>
For more info visit our &nbsp;
<a
className = {classes.link}
target="_blank"
href = 'https://github.com/bldrs-ai/Share/wiki/GitHub-model-hosting'
rel="noreferrer">wiki</a>
<br/>
<b>To access models hosted on GitHub, paste the model link into the search bar.</b>
</p> */}
<LocalFileOpen/>
<p className={classes.bullet}>
<b>Models accessed from local drive cannot be saved or shared.</b>
<br/>
<span
className = {classes.link}
role = 'button'
tabIndex={0}
onKeyPress = {()=>{
fileOpen()
setIsDialogDisplayed(false)
}}
onClick = {()=>{
fileOpen()
setIsDialogDisplayed(false)
}}> open</span>
</p>
</div>
}/>
)
}


const useStyles = makeStyles({
content: {
width: '270px',
},
bullet: {
textAlign: 'left',
},
link: {
color: 'blue',
borderBottom: '1px solid blue',
cursor: 'pointer',
},
openIcon: {
textAlign: 'center',
},
})
4 changes: 4 additions & 0 deletions src/assets/2D_Icons/LocalFileOpen.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 76cdbf7

Please sign in to comment.