Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegMoshkovich committed Mar 16, 2023
1 parent 3aeb5d4 commit 9b10f53
Show file tree
Hide file tree
Showing 19 changed files with 100 additions and 57 deletions.
14 changes: 12 additions & 2 deletions src/Components/About/AboutControl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {getCookieBoolean, setCookieBoolean} from '../../privacy/Privacy'
import useStore from '../../store/useStore'
import Dialog from '../Dialog'
import {ControlButton} from '../Buttons'
import {useIsMobile} from '../Hooks'
import AboutDescription from './AboutDescription'
import PrivacyControl from './PrivacyControl'
import AboutIcon from '../../assets/icons/Information.svg'
Expand All @@ -25,14 +26,23 @@ export default function AboutControl() {
name: 'isFirstTime',
defaultValue: true,
}))
const isMobile = useIsMobile()
const displayTooltip = () => isMobile ? turnOffIsTooltipsOpen() : toggleIsTooltipsOpen()
const toggleIsTooltipsOpen = useStore((state) => state.toggleIsTooltipsOpen)
const turnOffIsTooltipsOpen = useStore((state) => state.turnOffIsTooltipsOpen)
const setIsDialogDisplayedLocal = (value) => {
setIsDialogDisplayed(value)
toggleIsTooltipsOpen()
displayTooltip()
}
const setIsDialogDisplayedForDialog = () => {
setIsDialogDisplayed(false)
setCookieBoolean({component: 'about', name: 'isFirstTime', value: false})
displayTooltip()
}

return (
<ControlButton
title='About bldrs'
title='About'
isDialogDisplayed={isDialogDisplayed}
setIsDialogDisplayed={setIsDialogDisplayedLocal}
icon={
Expand Down
6 changes: 3 additions & 3 deletions src/Components/About/AboutControl.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import AboutControl from './AboutControl'
describe('About control tests', () => {
test('renders the AboutControl button', () => {
const {getByTitle} = render(<MockComponent><AboutControl/></MockComponent>)
const aboutControl = getByTitle('About bldrs')
const aboutControl = getByTitle('About')
expect(aboutControl).toBeInTheDocument()
})

test('renders AbotDialog when control is pressed', () => {
test('renders AboutDialog when control is pressed', () => {
const {getByTitle, getByText} = render(<MockComponent><AboutControl/></MockComponent>)
const aboutControl = getByTitle('About bldrs')
const aboutControl = getByTitle('About')
fireEvent.click(aboutControl)
const dialogTitle = getByText('build every thing together')
expect(dialogTitle).toBeInTheDocument()
Expand Down
20 changes: 10 additions & 10 deletions src/Components/About/AboutDescription.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ export default function AboutDescription({setIsDialogDisplayed}) {
height: '160px',
fontSize: '.9em',
fontWeight: 'bold',
borderRadius: '10px',
borderRadius: '3px',
margin: '2em 0',
padding: '.3em 1em .5em .5em',
color: theme.palette.primary.contrastText,
backgroundColor: theme.palette.scene.background,
border: `1px solid ${theme.palette.primary.main}`,
textAlign: 'left',
}}
>
Expand All @@ -40,10 +40,10 @@ export default function AboutDescription({setIsDialogDisplayed}) {
}}
>
<Typography variant={'h5'}>
Cross-functional online collaboration unlocks team flow,
productivity and creativity.
Open workspaces, open standards and open source code is the most powerful way to work.
Cooperation is the unfair advantage.
Cross-functional online collaboration unlocks team flow,
productivity and creativity.
Open workspaces, open standards and open source code is the most powerful way to work.
Cooperation is the unfair advantage.
</Typography>
<Box
sx={{
Expand All @@ -56,21 +56,21 @@ export default function AboutDescription({setIsDialogDisplayed}) {
}}
>
<a
// eslint-disable-next-line max-len
href='https://bldrs.ai/share/v/p/index.ifc#c:-119.076,0.202,83.165,-44.967,19.4,-4.972::i:1506392033'
href='https://bldrs.ai/share/v/p/index.ifc#c:-113.444,0.464,81.43,-23.595,24.522,10.88::i:1493510953'
onClick={onClickLink}
>
<div style={{textDecoration: 'underline', marginLeft: '10px'}}>Guide</div>
<Typography sx={{textDecoration: 'underline', marginLeft: '10px'}}>Guide</Typography>
</a>
<a
// eslint-disable-next-line max-len
href='https://bldrs.ai/share/v/gh/OlegMoshkovich/Logo/main/IFC_STUDY.ifc#c:40.821,-10.247,39.647,5.918,-13.326,-13.866::i:1605443723'
onClick={onClickLink}
>
<div style={{textDecoration: 'underline', marginLeft: '10px'}}>Team</div>
<Typography sx={{textDecoration: 'underline', marginLeft: '10px'}}>Team</Typography>
</a>
</Box>
</Box>
</Box>
)
}

2 changes: 1 addition & 1 deletion src/Components/BranchesControl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default function Branches() {
}}
onChange={(e) => handleSelect(e)}
variant='outlined'
label='Git Branches / Project Versions'
label='Project Iterations'
value={selected}
select
role="button"
Expand Down
41 changes: 17 additions & 24 deletions src/Components/Buttons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import ToggleButton from '@mui/material/ToggleButton'
import Tooltip from '@mui/material/Tooltip'
import {assertDefined} from '../utils/assert'
import useStore from '../store/useStore'
import {useIsMobile} from './Hooks'
import CloseIcon from '../assets/icons/Close.svg'


Expand All @@ -16,7 +15,6 @@ import CloseIcon from '../assets/icons/Close.svg'
* @property {boolean} [selected] Selected state. Default: false
* @property {string} [size] Size enum: 'small', 'medium' or 'large'. Default: 'medium'
* @property {string} dataTestId Internal attribute for component testing. Default: ''
* @property {boolean} noInfo
* @return {React.Component} React component
*/
export function TooltipIconButton({
Expand All @@ -27,13 +25,12 @@ export function TooltipIconButton({
selected = false,
size = 'medium',
dataTestId = '',
noInfo = false,
aboutInfo = true,
}) {
assertDefined(title, onClick, icon)
const isMobile = useIsMobile()
const [openLocal, setOpenLocal] = React.useState(false)
const isTooltipsOpen = useStore((state) => state.isTooltipsOpen)
const open = !noInfo ? isTooltipsOpen : false
const open = aboutInfo ? isTooltipsOpen : false
const handleClose = () => {
setOpenLocal(false)
}
Expand All @@ -42,24 +39,20 @@ export function TooltipIconButton({
}
return (
<>
{isMobile ?
<ToggleButton selected={selected} onClick={onClick} value={''} size={size}>
{icon}
</ToggleButton> :
<Tooltip
open={openLocal || open}
onClose={handleClose}
onOpen={handleOpen}
title={title}
describeChild
placement={placement}
data-testid={dataTestId}
>
<ToggleButton selected={selected} onClick={onClick} value={''} size={size}>
{icon}
</ToggleButton>
</Tooltip>
}
<Tooltip
open={openLocal || open}
onClose={handleClose}
onOpen={handleOpen}
title={title}
describeChild
placement={placement}
data-testid={dataTestId}
PopperProps={{style: {zIndex: 0}}}
>
<ToggleButton selected={selected} onClick={onClick} value={''} size={size}>
{icon}
</ToggleButton>
</Tooltip>
</>
)
}
Expand Down Expand Up @@ -109,7 +102,7 @@ export function CloseButton({onClick}) {
placement='bottom'
icon={<CloseIcon style={{width: '15px', height: '15px'}}/>}
size='medium'
noInfo={true}
aboutInfo={false}
/>
)
}
Expand Down
19 changes: 18 additions & 1 deletion src/Components/Buttons.test.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react'
import {fireEvent, render} from '@testing-library/react'
import {fireEvent, render, renderHook, act} from '@testing-library/react'
import {MockComponent} from '../__mocks__/MockComponent'
import {TooltipIconButton} from './Buttons'
import useStore from '../store/useStore'
import QuestionIcon from '../assets/icons/Question.svg'


Expand All @@ -25,4 +26,20 @@ describe('<TooltipIconButton />', () => {
const tooltip = await rendered.findByRole('tooltip')
expect(tooltip).toBeInTheDocument()
})
test('show tooltip when the help is activated', async () => {
const {result} = renderHook(() => useStore((state) => state))
await act(() => {
result.current.toggleIsTooltipsOpen()
})
const {getByText} = render(
<MockComponent>
<TooltipIconButton
title={'TestTooltip'}
// eslint-disable-next-line no-empty-function
onClick={() => {}}
icon={<QuestionIcon/>}
/>
</MockComponent>)
expect(await getByText('TestTooltip')).toBeVisible()
})
})
1 change: 1 addition & 0 deletions src/Components/Dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default function Dialog({
onClose={close}
sx={{
textAlign: 'center',
zIndex: 1000,
}}
PaperProps={{variant: 'control'}}
>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Logo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function Logo({onClick}) {
placement="right"
icon={<LogoIcon/>}
onClick={onClick}
noInfo={true}
aboutInfo={false}
/>
</Box>
)
Expand Down
1 change: 1 addition & 0 deletions src/Components/Notes/NoteCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ const CardFooter = ({
placement='bottom'
onClick={onClickCamera}
icon={<CameraIcon/>}
aboutInfo={false}
/>}
{selected &&
<TooltipIconButton
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Notes/Notes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function Notes() {
const fetchedNotes = []
const issuesData = await getIssues(repository, accessToken)
let issueIndex = 0
issuesData.data.slice(0).map((issue, index) => {
issuesData.data.slice(0).reverse().map((issue, index) => {
if (issue.body === null) {
debug().warn(`issue ${index} has no body: `, issue)
return null
Expand Down
5 changes: 2 additions & 3 deletions src/Components/OpenModelControl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,9 @@ export default function OpenModelControl({fileOpen}) {
title={'Open IFC'}
onClick={() => setIsDialogDisplayed(true)}
icon={<OpenIcon/>}
placement={'top'}
placement={'right'}
selected={isDialogDisplayed}
dataTestId='open-ifc'
noInfo={true}
dataTestId='open-ifc'ß
/>
</Paper>
{isDialogDisplayed &&
Expand Down
27 changes: 25 additions & 2 deletions src/Components/OperationsGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import useTheme from '@mui/styles/useTheme'
import useStore from '../store/useStore'
import {assertDefined} from '../utils/assert'
import {hexToRgba} from '../utils/color'
import {useIsMobile} from './Hooks'
import AboutControl from './About/AboutControl'
import CameraControl from './CameraControl'
import CutPlaneMenu from './CutPlaneMenu'
Expand All @@ -16,6 +17,7 @@ import ListIcon from '../assets/icons/List.svg'
import MoonIcon from '../assets/icons/Moon.svg'
import NotesIcon from '../assets/icons/Notes.svg'
import SunIcon from '../assets/icons/Sun.svg'
import QuestionIcon from '../assets/icons/Question.svg'


/**
Expand All @@ -38,6 +40,13 @@ export default function OperationsGroup({deselectItems}) {
const isCollaborationGroupVisible = useStore((state) => state.isCollaborationGroupVisible)
const isModelInteractionGroupVisible = useStore((state) => state.isModelInteractionGroupVisible)
const isSettingsVisible = useStore((state) => state.isSettingsVisible)
const toggleIsTooltipsOpen = useStore((state) => state.toggleIsTooltipsOpen)
const isTooltipsOpen = useStore((state) => state.isTooltipsOpen)
const turnOffIsTooltipsOpen = useStore((state) => state.turnOffIsTooltipsOpen)
const isMobile = useIsMobile()
const turnOffTooltips = () => {
return isMobile ? turnOffIsTooltipsOpen() : null
}

const isSelected = () => {
const ifSelected = (
Expand Down Expand Up @@ -104,11 +113,18 @@ export default function OperationsGroup({deselectItems}) {
title='Notes'
icon={<NotesIcon/>}
selected={isNotesOn}
onClick={() => toggle('Notes')}
onClick={() => {
turnOffTooltips()
toggle('Notes')
}
}
/>
<TooltipIconButton
title='Properties'
onClick={() => toggle('Properties')}
onClick={() => {
turnOffTooltips()
toggle('Properties')
}}
selected={isPropertiesOn}
icon={<ListIcon/>}
/>
Expand All @@ -120,6 +136,7 @@ export default function OperationsGroup({deselectItems}) {
selected={isSelected()}
icon={<ClearIcon/>}
/>

</ButtonGroup>
}

Expand All @@ -130,6 +147,12 @@ export default function OperationsGroup({deselectItems}) {
onClick={() => theme.toggleColorMode()}
icon={theme.palette.mode === 'light' ? <MoonIcon/> : <SunIcon/>}
/>
<TooltipIconButton
title='Help'
onClick={() => toggleIsTooltipsOpen()}
selected={isTooltipsOpen}
icon={<QuestionIcon/>}
/>
<AboutControl/>
</ButtonGroup>
}
Expand Down
6 changes: 3 additions & 3 deletions src/Components/SearchBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ export default function SearchBar({fileOpen}) {
value={inputText}
onChange={onInputChange}
error={true}
placeholder={'Search / Insert GitHub link'}
placeholder={'Search'}
sx={{
...theme.typography.tree,
'marginTop': '4px',
'marginLeft': '8px',
'marginLeft': '14px',
'& input::placeholder': {
opacity: .3,
opacity: .2,
},
}}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/Components/SearchBar.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ describe( 'SearchBar', () => {
it('SeachBar', () => {
// eslint-disable-next-line no-empty-function
render(<ShareMock><SearchBar onClickMenuCb={() => {}} isOpen={true}/></ShareMock>)
expect(screen.getByPlaceholderText('Search / Insert GitHub link')).toBeInTheDocument()
expect(screen.getByPlaceholderText('Search')).toBeInTheDocument()
})
})
2 changes: 1 addition & 1 deletion src/Containers/CadView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ function OperationsGroupAndDrawer({deselectItems}) {
<Box
sx={{
position: 'absolute',
top: 0,
top: 3,
right: 0,
}}
>
Expand Down
1 change: 0 additions & 1 deletion src/__mocks__/api-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ export const handlers = [

rest.patch('https://api.github.com/repos/:org/:repo/issues/:issueNumber', (req, res, ctx) => {
const {org, repo} = req.params
console.log('in the patch mock')
if (org !== 'pablo-mayrgundter' || repo !== 'Share' ) {
console.log('in the if')
return res(
Expand Down
4 changes: 2 additions & 2 deletions src/assets/icons/Question.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 9b10f53

Please sign in to comment.