Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegMoshkovich committed Jun 17, 2024
2 parents 63f6fda + 3da473a commit 836dc42
Show file tree
Hide file tree
Showing 17 changed files with 230 additions and 72 deletions.
Binary file removed bldrs-ai-conway-0.1.543.tgz
Binary file not shown.
Binary file added bldrs-ai-conway-0.1.546.tgz
Binary file not shown.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bldrs",
"version": "1.0.1060",
"version": "1.0.1073",
"main": "src/index.jsx",
"license": "AGPL-3.0",
"homepage": "https://github.com/bldrs-ai/Share",
Expand Down Expand Up @@ -57,7 +57,7 @@
"@babel/plugin-syntax-import-assertions": "7.18.6",
"@babel/preset-env": "7.18.10",
"@babel/preset-react": "7.18.6",
"@bldrs-ai/conway": "./bldrs-ai-conway-0.1.543.tgz",
"@bldrs-ai/conway": "./bldrs-ai-conway-0.1.546.tgz",
"@bldrs-ai/ifclib": "5.3.3",
"@emotion/react": "11.10.0",
"@emotion/styled": "11.10.0",
Expand Down
18 changes: 1 addition & 17 deletions src/Components/About/AboutDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import Dialog from '../Dialog'
import {LogoBWithDomain} from '../Logo/Logo'
// TODO(pablo): re-enable after prod freeze bug fixed
// import PrivacyControl from './PrivacyControl'
import LinkedInIcon from '@mui/icons-material/LinkedIn'
import GitHubIcon from '@mui/icons-material/GitHub'
import TwitterIcon from '@mui/icons-material/Twitter'
import DiscordIcon from '../../assets/icons/Discord.svg'


Expand Down Expand Up @@ -61,28 +59,14 @@ function AboutContent() {
justifyContent='center'
alignItems='center'
>
<Stack spacing={2} direction='row'>
<Stack spacing={0} direction='row'>
<TooltipIconButton
title='Discord'
onClick={() => window.open(`https://discord.gg/9SxguBkFfQ`, '_blank')}
icon={<DiscordIcon className='icon-share' style={{width: '50px'}}/>}
placement='bottom'
variant='noBackground'
/>
<TooltipIconButton
title='Twitter'
onClick={() => window.open(`https://twitter.com/bldrs_ai`, '_blank')}
icon={<TwitterIcon className='icon-share'/>}
placement='bottom'
variant='noBackground'
/>
<TooltipIconButton
title='LinkedIn'
onClick={() => window.open(`https://www.linkedin.com/company/bldrs-ai/`, '_blank')}
icon={<LinkedInIcon className='icon-share'/>}
placement='bottom'
variant='noBackground'
/>
<TooltipIconButton
title='GitHub'
onClick={() => window.open(`https://github.com/bldrs-ai/Share`, '_blank')}
Expand Down
110 changes: 99 additions & 11 deletions src/Components/AlertDialog.jsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,122 @@
import React, {ReactElement} from 'react'
import Box from '@mui/material/Box'
import Dialog from '@mui/material/Dialog'
import DialogActions from '@mui/material/DialogActions'
import DialogContent from '@mui/material/DialogContent'
import DialogTitle from '@mui/material/DialogTitle'
import IconButton from '@mui/material/IconButton'
import Link from '@mui/material/Link'
import List from '@mui/material/List'
import ListItem from '@mui/material/ListItem'
import ListItemText from '@mui/material/ListItemText'
import Paper from '@mui/material/Paper'
import Stack from '@mui/material/Stack'
import Typography from '@mui/material/Typography'
import {RectangularButton} from '../Components/Buttons'
import useStore from '../store/useStore'
import CheckIcon from '@mui/icons-material/Check'
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline'
import useTheme from '@mui/styles/useTheme'


/** @return {ReactElement} */
export default function AlertDialog({onClose, children}) {
const alertMessage = useStore((state) => state.alertMessage)
const setAlertMessage = useStore((state) => state.setAlertMessage)
const errorPath = useStore((state) => state.errorPath)
const setErrorPath = useStore((state) => state.setErrorPath)
const theme = useTheme()
const onCloseInner = () => {
setAlertMessage(null)
setErrorPath(null)
onClose()
}
return (
<Dialog
open={alertMessage !== null}
open={errorPath !== null}
onClose={onCloseInner}
aria-labelledby='alert-dialog-title'
aria-describedby='alert-dialog-description'
>
<DialogTitle id='alert-dialog-title'>{'Alert'}</DialogTitle>
<DialogContent>
{alertMessage}
<DialogTitle id='alert-dialog-title'>
<Box
sx={{
display: 'flex',
flexDirection: 'column',
justifyContent: 'center',
alignItems: 'center',
}}
>
<Paper
sx={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
justifyContent: 'center',
width: '2.5em',
height: '2.5em',
borderRadius: '50%',
background: theme.palette.secondary.main,
}}
>
<ErrorOutlineIcon className='icon-share'/>
</Paper>
</Box>
</DialogTitle>
<DialogContent sx={{textAlign: 'left'}}>
<Stack spacing={1} sx={{padding: '0em 1em'}}>
<List>
<ListItem variant='alert'>
<ListItemText
primary={
<Typography
variant='body1'
sx={{fontWeight: 'bold'}}
>
Could not load the model
</Typography>
}
primaryTypographyProps={{variant: 'body1'}}
/>
</ListItem>
<ListItem variant='alert'>
<ListItemText
primary="Log in if repository is private"
primaryTypographyProps={{variant: 'body1'}}
/>
</ListItem>
<ListItem variant='alert'>
<ListItemText
primary={
<Typography
variant='body1'
sx={{
maxWidth: '300px',
wordWrap: 'break-word',
overflowWrap: 'break-word',
whiteSpace: 'normal',
}}
>
Check the file path:
<br/>
{errorPath}
</Typography>
}
/>
</ListItem>
<ListItem variant='alert'>
<ListItemText
primary={
<Typography variant='body1'>
Contact us on our{' '}
<Link href='https://discord.gg/9SxguBkFfQ' target="_blank" rel="noopener noreferrer">
Discord
</Link>{' '}
for help
</Typography>
}
/>
</ListItem>
</List>
</Stack>
</DialogContent>
<DialogActions>
<IconButton onClick={onCloseInner}><CheckIcon/></IconButton>
<DialogActions >
<RectangularButton onClick={onCloseInner} variant='outline' title='Reset'/>
</DialogActions>
</Dialog>
)
Expand Down
6 changes: 2 additions & 4 deletions src/Components/Buttons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,13 @@ export function RectangularButton({
title,
onClick,
icon = null,
border = false,
background = true,
disabled = false,
}) {
assertDefined(title, onClick)
return (
icon ?
<Button onClick={onClick} startIcon={icon} variant='rectangular' color='secondary'>{title}</Button> :
<Button onClick={onClick} variant='rectangular' color='secondary' disabled={disabled}>{title}</Button>
<Button onClick={onClick} startIcon={icon} variant='contained'>{title}</Button> :
<Button onClick={onClick} variant='contained' disabled={disabled}>{title}</Button>
)
}

Expand Down
32 changes: 28 additions & 4 deletions src/Components/Profile/ProfileControl.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, {ReactElement, useEffect, useState} from 'react'
import Avatar from '@mui/material/Avatar'
import Divider from '@mui/material/Divider'
import Menu from '@mui/material/Menu'
import MenuItem from '@mui/material/MenuItem'
import Typography from '@mui/material/Typography'
Expand All @@ -9,6 +10,9 @@ import AccountBoxOutlinedIcon from '@mui/icons-material/AccountBoxOutlined'
import GitHubIcon from '@mui/icons-material/GitHub'
import NightlightOutlinedIcon from '@mui/icons-material/NightlightOutlined'
import WbSunnyOutlinedIcon from '@mui/icons-material/WbSunnyOutlined'
import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined'
import LoginOutlinedIcon from '@mui/icons-material/LoginOutlined'
import LogoutOutlinedIcon from '@mui/icons-material/LogoutOutlined'
import {useAuth0} from '../../Auth0/Auth0Proxy'


Expand All @@ -27,6 +31,7 @@ export default function ProfileControl() {
const [isDay, setIsDay] = useState(theme.palette.mode === 'light')

const onLoginClick = async () => {
onCloseClick()
await loginWithPopup({
appState: {
returnTo: window.location.pathname,
Expand All @@ -35,6 +40,7 @@ export default function ProfileControl() {
}
const onLogoutClick = () => {
logout({returnTo: process.env.OAUTH2_REDIRECT_URI || window.location.origin})
onCloseClick()
}
const onCloseClick = () => setAnchorEl(null)

Expand Down Expand Up @@ -64,17 +70,35 @@ export default function ProfileControl() {
onClose={onCloseClick}
anchorOrigin={{vertical: 'top', horizontal: 'left'}}
transformOrigin={{vertical: 'top', horizontal: 'right'}}
sx={{transform: 'translateX(-1em)'}}

>
<MenuItem onClick={isAuthenticated ? onLogoutClick : onLoginClick} data-testid='login-with-github'>
<GitHubIcon/>

{isAuthenticated ?
<Typography sx={{marginLeft: '10px'}} variant='overline'>Log out</Typography> :
<Typography sx={{marginLeft: '10px'}} variant='overline'>Log in with Github</Typography>}
<>
<LogoutOutlinedIcon/>
<Typography sx={{marginLeft: '10px'}} variant='overline'>Log out</Typography>
</> :
<>
<LoginOutlinedIcon/>
<Typography sx={{marginLeft: '10px'}} variant='overline'>Log in with Github</Typography>
</>
}
</MenuItem>
<MenuItem onClick={() => window.open(`https://github.com/signup`, '_blank')} data-testid='link-join-github'>
<GitHubIcon/>
<Typography sx={{marginLeft: '10px'}} variant='overline'>Join GitHub</Typography>
</MenuItem>
<MenuItem onClick={() => window.open(`https://github.com/bldrs-ai/Share/wiki`, '_blank')} data-testid='link-bldrs-wiki'>
<InfoOutlinedIcon/>
<Typography sx={{marginLeft: '10px'}} variant='overline'>Bldrs Wiki</Typography>
</MenuItem>
<Divider/>
<MenuItem
onClick={() => {
onCloseClick()
theme.toggleColorMode()
onCloseClick()
}}
data-testid={`change-theme-to-${isDay ? 'night' : 'day'}`}
>
Expand Down
6 changes: 5 additions & 1 deletion src/Components/Profile/ProfileControl.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ import LoginMenu from './ProfileControl'


describe('ProfileControl', () => {
it('renders the login button when not logged in', async () => {
it('renders the login button when not logged in, and other links', async () => {
mockedUseAuth0.mockReturnValue(mockedUserLoggedOut)
const {findByTestId, findByText} = render(<LoginMenu/>, {wrapper: ThemeCtx})
const usersMenu = await findByTestId('control-button-profile')
fireEvent.click(usersMenu)

const LoginWithGithub = await findByText('Log in with Github')
const JoinGithub = await findByText('Join GitHub')
const BldrsWiki = await findByText('Bldrs Wiki')
expect(LoginWithGithub).toBeInTheDocument()
expect(JoinGithub).toBeInTheDocument()
expect(BldrsWiki).toBeInTheDocument()
})

it('renders the user avatar when logged in', async () => {
Expand Down
34 changes: 30 additions & 4 deletions src/Components/Search/SearchBar.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import React, {ReactElement, useRef, useEffect, useState} from 'react'
import {useLocation, useNavigate, useSearchParams} from 'react-router-dom'
import Autocomplete from '@mui/material/Autocomplete'
import InputAdornment from '@mui/material/InputAdornment'
import IconButton from '@mui/material/IconButton'
import TextField from '@mui/material/TextField'
import {looksLikeLink, githubUrlOrPathToSharePath} from '../../net/github/utils'
import {handleBeforeUnload} from '../../utils/event'
Expand Down Expand Up @@ -75,15 +77,23 @@ export default function SearchBar() {
searchInputRef.current.blur()
}

const handleKeyDown = (event) => {
if (event.key === 'Enter' && !event.shiftKey) {
event.preventDefault()
onSubmit(event)
}
}


// The container and paper are set to 100% width to fill the
// container SearchBar shares with NavTreePanel. This is an easier
// way to have them share the same width, which is now set in the
// parent container (CadView).
return (
<form onSubmit={onSubmit} style={{width: '100%'}}>
<form onSubmit={onSubmit}>
<Autocomplete
freeSolo
sx={{width: '103%'}}
options={['Dach', 'Decke', 'Fen', 'Wand', 'Leuchte', 'Pos', 'Te']}
value={inputText}
onChange={(_, newValue) => setInputText(newValue || '')}
Expand All @@ -98,10 +108,26 @@ export default function SearchBar() {
error={!!error.length}
placeholder='Search'
variant='outlined'
sx={{
width: '100%',
}}
multiline
onKeyDown={handleKeyDown}
data-testid='textfield-search-query'
InputProps={{
endAdornment: (
<InputAdornment position="end">
<IconButton
aria-label="clear search"
onClick={() => setInputText('')}
sx={{height: '2em', width: '2em'}}
>
<CloseIcon
className="icon-share"
color='primary'
fontSize="small"
/>
</IconButton>
</InputAdornment>
),
}}
/>
)}
/>
Expand Down
1 change: 1 addition & 0 deletions src/Components/Versions/VersionsPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ export default function VersionsPanel({filePath, currentRef}) {
size='small'
/>
}
sx={{m: '0 0 0 10px'}} // equal to SearchBar m:5 + p:5
onCloseClick={() => setIsVersionsVisible(false)}
data-testid='Version Panel'
>
Expand Down
Loading

0 comments on commit 836dc42

Please sign in to comment.