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

Timeline load - fixing disappearing future #960

Merged
merged 48 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
eee28da
Theme update (#838)
OlegMoshkovich Nov 8, 2023
7975f14
SideDrawer Details (#839)
OlegMoshkovich Nov 9, 2023
b36ecd4
Move Properties to back to OperationsGroup. Fix multi viewer/three.j…
pablo-mayrgundter Nov 9, 2023
45049f5
add loader test
OlegMoshkovich Nov 9, 2023
2206159
timeline
OlegMoshkovich Nov 9, 2023
bd40ed6
add the hash of a commit to commit data array
OlegMoshkovich Nov 10, 2023
a728d85
add reset button to the version history panel that navigates to main
OlegMoshkovich Nov 11, 2023
86c5214
add reset to the tip of the history in the timeline
OlegMoshkovich Nov 11, 2023
962c543
add no content message to the timeline
OlegMoshkovich Nov 11, 2023
c7639ed
loggin the commits
OlegMoshkovich Nov 14, 2023
a2c3c42
fix debug log problem
OlegMoshkovich Nov 14, 2023
842d897
create mocks
OlegMoshkovich Nov 14, 2023
6c7e0e6
add the mocks for the branches and for commits
OlegMoshkovich Nov 15, 2023
be6178f
trying to resolve the versin history test
OlegMoshkovich Nov 16, 2023
6b777a4
adjust the version history panel tests
OlegMoshkovich Nov 16, 2023
0f48f5c
sort out the test
OlegMoshkovich Nov 16, 2023
676ea15
clean up cad view comment
OlegMoshkovich Nov 16, 2023
441942c
clean up cadview test
OlegMoshkovich Nov 16, 2023
65a8c24
adjst commit
OlegMoshkovich Nov 21, 2023
d9e34ee
add the version history panel test
OlegMoshkovich Nov 21, 2023
b660db8
refactor version container
OlegMoshkovich Nov 21, 2023
08d27a0
refactor version container
OlegMoshkovich Nov 21, 2023
5de984c
fix one of the timeline tests
OlegMoshkovich Nov 27, 2023
d0565d9
adjust the version container test and subrtract branched control from…
OlegMoshkovich Dec 4, 2023
d1a37bb
fix styles in versions conteiner
OlegMoshkovich Dec 4, 2023
b102e99
fix application error font color
OlegMoshkovich Dec 4, 2023
b85abf1
fix timeline fixture
OlegMoshkovich Dec 4, 2023
cea9d28
change the title of versions button
OlegMoshkovich Dec 6, 2023
aa3641a
address comments
OlegMoshkovich Dec 6, 2023
6665ad4
re work versions timeline
OlegMoshkovich Dec 6, 2023
623be47
changed the PII to general
OlegMoshkovich Dec 6, 2023
1fa8765
placement of panels
OlegMoshkovich Dec 6, 2023
6f34b12
subtract sp information
OlegMoshkovich Dec 6, 2023
bda103b
reduce wait time for commit fetch
OlegMoshkovich Dec 6, 2023
9431b58
add the reset action to the panel
OlegMoshkovich Dec 7, 2023
489356a
align panel with share button
OlegMoshkovich Dec 7, 2023
1fd6c17
decrease opacity
OlegMoshkovich Dec 7, 2023
8902c38
eidt descriptions
OlegMoshkovich Dec 10, 2023
cfecdb0
add active version to the store
OlegMoshkovich Dec 11, 2023
40bbc4b
add logging to the versions
OlegMoshkovich Dec 11, 2023
2518d31
add loging to versions timeline
OlegMoshkovich Dec 11, 2023
357b2c8
fix logging
OlegMoshkovich Dec 11, 2023
5e01d7b
fix versions
OlegMoshkovich Dec 11, 2023
efad33f
move state to local
OlegMoshkovich Dec 11, 2023
7f7d861
fix test
OlegMoshkovich Dec 11, 2023
6c4b2a2
Merge and test.
pablo-mayrgundter Feb 2, 2024
57e1d23
Merge and test
pablo-mayrgundter Feb 2, 2024
c677e2a
Fix disappearance of the future.
pablo-mayrgundter Feb 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bldrs",
"version": "1.0.865",
"version": "1.0.916",
"main": "src/index.jsx",
"license": "MIT",
"homepage": "https://github.com/bldrs-ai/Share",
Expand Down
8 changes: 4 additions & 4 deletions src/Components/ApplicationError.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,21 @@ const ApplicationError = () => {
padding: '20px',
}}
>
<Typography variant={'body1'} sx={{fontWeight: 600, pb: 2}}>
<Typography variant={'body1'} sx={{fontWeight: 600, pb: 2}} color='primary'>
Oh no!
</Typography>

<Typography variant={'body1'}>
<Typography variant={'body1'} color='primary'>
We&apos;re not quite sure what went wrong.
</Typography>

<Typography sx={{pb: 2}}>
<Typography sx={{pb: 2}} color='primary'>
Not to worry.<br/>
You can <a href="/">click here to start a new session</a>.
</Typography>

<Box>
<a href="/"><Logo style={{width: '30px'}}/></a>
<a href="/"><Logo style={{width: '24px'}}/></a>
</Box>
</Paper>
)
Expand Down
4 changes: 2 additions & 2 deletions src/Components/BranchesControl.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('BranchControl', () => {
result.current.setModelPath(MOCK_MODEL_PATH_LOCAL)
})
render(<ShareMock><BranchesControl/></ShareMock>)
const branchDropDown = screen.queryByText('Git Branches / Project Versions')
const branchDropDown = screen.queryByText('BRANCHES')
await waitFor(() => {
expect(branchDropDown).toBeNull()
})
Expand All @@ -62,7 +62,7 @@ describe('BranchControl', () => {
)
}),
)
const branchDropDown = screen.queryByText('Git Branches / Project Versions')
const branchDropDown = screen.queryByText('BRANCHES')
await waitFor(() => {
expect(branchDropDown).toBeNull()
})
Expand Down
2 changes: 1 addition & 1 deletion src/Components/ControlsGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function ControlsGroup({navigate, isRepoActive}) {
<SaveModelControl navigate={navigate}/>
{isRepoActive &&
<TooltipIconButton
title='Project History'
title='Versions'
icon={<HistoryIcon className='icon-share' color='secondary'/>}
placement='bottom'
selected={isVersionHistoryVisible}
Expand Down
42 changes: 42 additions & 0 deletions src/Components/OperationsGroup.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react'
import {__getIfcViewerAPIExtendedMockSingleton} from 'web-ifc-viewer'
import {act, render, fireEvent, renderHook} from '@testing-library/react'
import ShareMock from '../ShareMock'
import useStore from '../store/useStore'
import OperationsGroup from './OperationsGroup'


describe('OperationsGroup', () => {
const deselectItems = jest.fn()
let viewer

beforeAll(async () => {
const {result} = renderHook(() => useStore((state) => state))
viewer = __getIfcViewerAPIExtendedMockSingleton()
viewer.isolator = {
toggleIsolationMode: jest.fn(),
hideSelectedElements: jest.fn(),
unHideAllElements: jest.fn(),
}
await act(() => {
result.current.setViewer(viewer)
})
})

it('should render and trigger Properties button when a selected element is present', async () => {
const {result} = renderHook(() => useStore((state) => state))
await act(() => {
result.current.setSelectedElement({id: 123})
})
const {queryByTitle} = render(
<ShareMock
initialEntries={['/v/p/index.ifc#p:x']}
>
<OperationsGroup deselectItems={deselectItems}/>
</ShareMock>,
)
const propertiesButton = queryByTitle('Properties')
fireEvent.click(propertiesButton)
expect(propertiesButton).toBeInTheDocument()
})
})
18 changes: 13 additions & 5 deletions src/Components/Panel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@ import CloseIcon from '@mui/icons-material/Close'
* @param {React.ReactNode} content The content to be displayed in the panel.
* @return {React.ReactElement} A rendered Panel component.
*/
export default function Panel({title, onClose, content, testId = ''}) {
export default function Panel({title, onClose, content, testId = '', action = null}) {
const theme = useTheme()
return (
<Paper
data-testId={testId}
data-testid={testId}
sx={{
'overflowY': 'scroll',
'maxHeight': '490px',
'width': '100%',
'opacity': .9,
'opacity': .96,
'position': 'relative',
'borderRadius': '5px',
'backgroundColor': theme.palette.scene.background,
Expand All @@ -47,11 +47,19 @@ export default function Panel({title, onClose, content, testId = ''}) {
}}
>
<Typography variant='body1' sx={{marginLeft: '.9em', textTransform: 'uppercase'}}>{title}</Typography>
<Box sx={{marginRight: '.3em'}}>
<Stack
direction='row'
justifyContent={'center'}
alignItems={'center'}
sx={{marginRight: '.3em'}}
>
<Box>
{action}
</Box>
<IconButton aria-label="close" size="small" onClick={onClose} sx={{borderRadius: '5px'}}>
<CloseIcon fontSize="small" color='secondary'/>
</IconButton>
</Box>
</Stack>
</Stack>
<Box sx={{padding: '1px 0px'}}>
{content}
Expand Down
47 changes: 0 additions & 47 deletions src/Components/Timeline.test.jsx

This file was deleted.

46 changes: 0 additions & 46 deletions src/Components/VersionHistoryPanel.jsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import {ThemeCtx} from '../theme/Theme.fixture'
import Timeline from './Timeline'
import {ThemeCtx} from '../../theme/Theme.fixture'
import VersionsTimeline from './VersionsTimeline'


const commitData = [
Expand All @@ -22,8 +22,9 @@ const commitData = [
},
]


export default (
<ThemeCtx>
<Timeline commitData={commitData}/>
<VersionsTimeline commitData={commitData}/>
</ThemeCtx>
)
102 changes: 102 additions & 0 deletions src/Components/Versions/VersionsContainer.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
import React, {useState, useEffect} from 'react'
import {useNavigate} from 'react-router-dom'
import IconButton from '@mui/material/IconButton'
import Tooltip from '@mui/material/Tooltip'
import useStore from '../../store/useStore'
import {getCommitsForFile} from '../../utils/GitHub'
import {assertDefined} from '../../utils/assert'
import debug from '../../utils/debug'
import {navigateBaseOnModelPath} from '../../utils/location'
import Panel from '../Panel'
import VersionsTimeline from './VersionsTimeline'
import RestartAltIcon from '@mui/icons-material/RestartAlt'


/**
* VersionsContainer displays a series of versions in a timeline format.
* Each version corresponds to a commit, and this component fetches
* commit data for the provided filepath and displays it.
*
* @param {string} filePath The file for which commits are fetched.
* @param {string} current The current branch or sha, to indicate is active in UI.
* @return {object} A timeline panel of versions.
*/
export default function VersionsContainer({filePath, currentRef}) {
assertDefined(filePath, currentRef)
const [commitData, setCommitData] = useState([])
const accessToken = useStore((state) => state.accessToken)
const repository = useStore((state) => state.repository)
const modelPath = useStore((state) => state.modelPath)
const toggleIsVersionHistoryVisible = useStore((state) => state.toggleIsVersionHistoryVisible)
const navigate = useNavigate()


useEffect(() => {
const fetchCommits = async () => {
try {
const commits = await getCommitsForFile(repository, filePath, accessToken)
if (commits) {
const versionsInfo = commits.map((entry) => {
const extractedData = {
authorName: entry.commit.author.name,
commitMessage: entry.commit.message,
commitDate: entry.commit.author.date,
sha: entry.sha,
}
return extractedData
})
setCommitData(versionsInfo)
}
} catch (error) {
debug().log(error)
}
}
fetchCommits()
}, [repository, filePath, accessToken])

/**
* This callBack navigated to the selected commit
*
* @param {string} index active commit index
*/
const commitNavigate = (index) => {
const sha = commitData[index].sha
if (modelPath) {
const commitPath = navigateBaseOnModelPath(modelPath.org, modelPath.repo, sha, modelPath.filepath)
navigate({
pathname: commitPath,
})
}
}
const navigateToMain = () => {
if (modelPath) {
const mainPath = navigateBaseOnModelPath(modelPath.org, modelPath.repo, 'main', modelPath.filepath)
navigate({
pathname: mainPath,
})
}
}


return (
<Panel
content={
<VersionsTimeline
commitData={commitData}
currentRef={currentRef}
commitNavigateCb={commitNavigate}
/>
}
testId='Version Panel'
title='Versions'
action={
<Tooltip title="Navigate to the tip of version history">
<IconButton aria-label="navigate_to_tip" size="small" onClick={navigateToMain} >
<RestartAltIcon fontSize="inherit"/>
</IconButton>
</Tooltip>
}
onClose={toggleIsVersionHistoryVisible}
/>
)
}
27 changes: 27 additions & 0 deletions src/Components/Versions/VersionsContainer.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react'
import {render, renderHook, act} from '@testing-library/react'
import ShareMock from '../../ShareMock'
import useStore from '../../store/useStore'
import {
MOCK_MODEL_PATH_GIT,
MOCK_REPOSITORY,
} from '../../utils/GitHub'
import VersionsContainer from './VersionsContainer'


describe('VersionsContainer', () => {
it('renders the panel', async () => {
const {result} = renderHook(() => useStore((state) => state))
await act(() => {
result.current.setModelPath(MOCK_MODEL_PATH_GIT)
result.current.setRepository(MOCK_REPOSITORY)
})
const {getByText} = render(
<ShareMock>
<VersionsContainer filePath="/ZGRAGGEN.ifc" currentRef={'main'}/>
</ShareMock>,
)
const dialogTitle = getByText('Versions')
expect(dialogTitle).toBeInTheDocument()
})
})