-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1181 from DalgoT4D/feature/move-stats-out
Moving data statistics out of UI4t
- Loading branch information
Showing
14 changed files
with
355 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import * as React from 'react'; | ||
const SvgComponent = (props: any) => ( | ||
<svg xmlns="http://www.w3.org/2000/svg" width={24} height={24} fill="none" {...props}> | ||
<mask | ||
id="a" | ||
width={24} | ||
height={24} | ||
x={0} | ||
y={0} | ||
maskUnits="userSpaceOnUse" | ||
style={{ | ||
maskType: 'alpha', | ||
}} | ||
> | ||
<path fill="#D9D9D9" d="M0 0h24v24H0z" /> | ||
</mask> | ||
<g mask="url(#a)"> | ||
<path | ||
fill={props.fill || '#728090'} | ||
d="M2.803 18.82a.776.776 0 0 1-.572-.23.777.777 0 0 1-.231-.573c0-.227.077-.418.23-.571a.776.776 0 0 1 .573-.23h8.859c.227 0 .418.076.571.23.154.154.231.345.231.572a.776.776 0 0 1-.23.572.776.776 0 0 1-.572.23h-8.86Zm0-5.237a.776.776 0 0 1-.572-.23A.777.777 0 0 1 2 12.78c0-.227.077-.418.23-.571a.776.776 0 0 1 .573-.231H6.26c.227 0 .418.077.572.23.153.155.23.345.23.573a.777.777 0 0 1-.23.572.778.778 0 0 1-.572.23H2.803Zm0-5.237a.776.776 0 0 1-.572-.231A.777.777 0 0 1 2 7.543c0-.228.077-.418.23-.572a.776.776 0 0 1 .573-.23H6.26c.227 0 .418.077.572.23.153.155.23.345.23.573a.776.776 0 0 1-.23.572.778.778 0 0 1-.572.23H2.803Zm11.462 7.295c-1.341 0-2.484-.469-3.429-1.405-.945-.938-1.417-2.076-1.417-3.416 0-1.34.472-2.477 1.418-3.414C11.782 6.469 12.926 6 14.267 6c1.342 0 2.484.469 3.428 1.406.944.937 1.416 2.073 1.416 3.41 0 .496-.078.985-.233 1.466-.155.48-.384.921-.687 1.322l3.576 3.545a.731.731 0 0 1 .233.557.776.776 0 0 1-.233.571.748.748 0 0 1-.556.222.794.794 0 0 1-.571-.222l-3.576-3.546a4.707 4.707 0 0 1-1.333.677c-.48.155-.97.233-1.466.233Zm0-1.605c.9 0 1.665-.312 2.296-.937.63-.624.945-1.383.945-2.279 0-.895-.315-1.654-.945-2.279-.63-.624-1.396-.936-2.296-.936-.9 0-1.666.312-2.296.936-.63.625-.945 1.384-.945 2.28 0 .895.315 1.654.945 2.278.63.625 1.395.937 2.296.937Z" | ||
/> | ||
</g> | ||
</svg> | ||
); | ||
export default SvgComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
import { PageHead } from '@/components/PageHead'; | ||
import { WarehouseTable } from '@/components/TransformWorkflow/FlowEditor/Components/Canvas'; | ||
import { StatisticsPane } from '@/components/TransformWorkflow/FlowEditor/Components/LowerSectionTabs/StatisticsPane'; | ||
|
||
import { httpGet } from '@/helpers/http'; | ||
import { Box, Dialog, Divider, Tab, Tabs } from '@mui/material'; | ||
import { useSession } from 'next-auth/react'; | ||
import { useRouter } from 'next/router'; | ||
import { useContext, useEffect, useState } from 'react'; | ||
import { TopNavBar, Transition } from '@/components/DBT/DBTTransformType'; | ||
import { ResizableBox } from 'react-resizable'; | ||
import ProjectTree from '@/components/TransformWorkflow/FlowEditor/Components/ProjectTree'; | ||
import PreviewPane from '@/components/TransformWorkflow/FlowEditor/Components/LowerSectionTabs/PreviewPane'; | ||
import { NodeApi } from 'react-arborist'; | ||
import { usePreviewAction } from '@/contexts/FlowEditorPreviewContext'; | ||
import { successToast } from '../ToastMessage/ToastHelper'; | ||
import { GlobalContext } from '@/contexts/ContextProvider'; | ||
|
||
export const Explore = () => { | ||
const { data: session } = useSession(); | ||
const [selectedTab, setSelectedTab] = useState<'preview' | 'statistics'>('preview'); | ||
const router = useRouter(); | ||
const globalContext = useContext(GlobalContext); | ||
const [loading, setLoading] = useState(false); | ||
|
||
const [dialogueOpen, setDialogueOpen] = useState(true); | ||
const [width, setWidth] = useState(260); | ||
|
||
const [height, setheight] = useState(500); | ||
const [sourceModels, setSourcesModels] = useState<WarehouseTable[]>([]); | ||
|
||
const { setPreviewAction } = usePreviewAction(); | ||
|
||
const fetchSourcesModels = () => { | ||
setLoading(true); | ||
httpGet(session, 'warehouse/sync_tables') | ||
.then((response: WarehouseTable[]) => { | ||
setSourcesModels(response); | ||
successToast('Tables synced with warehouse', [], globalContext); | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}) | ||
.finally(() => { | ||
setLoading(false); | ||
}); | ||
}; | ||
|
||
useEffect(() => { | ||
fetchSourcesModels(); | ||
}, []); | ||
|
||
useEffect(() => { | ||
const dialogBox = document.querySelector('.MuiDialog-container'); | ||
|
||
if (dialogBox) { | ||
const fullHeight = dialogBox?.clientHeight - 100; | ||
setheight(fullHeight); | ||
} | ||
}, [sourceModels]); | ||
|
||
const onResize = (event: any, { size }: any) => { | ||
setWidth(size.width); | ||
}; | ||
|
||
const handleTabChange = (event: React.SyntheticEvent, newValue: 'preview' | 'statistics') => { | ||
setSelectedTab(newValue); | ||
}; | ||
|
||
const handleNodeClick = (nodes: NodeApi<any>[]) => { | ||
if (nodes.length > 0 && nodes[0].isLeaf) { | ||
setPreviewAction({ type: 'preview', data: nodes[0].data }); | ||
} | ||
}; | ||
return ( | ||
<> | ||
<PageHead title="Dalgo | Explore" /> | ||
<Dialog fullScreen open={dialogueOpen} TransitionComponent={Transition}> | ||
<TopNavBar | ||
handleClose={() => { | ||
setDialogueOpen(false); | ||
router.push('/pipeline/ingest'); | ||
}} | ||
/> | ||
|
||
<Box | ||
sx={{ | ||
flexGrow: 1, | ||
display: 'flex', | ||
overflow: 'inherit', | ||
position: 'relative', | ||
}} | ||
> | ||
<ResizableBox | ||
axis="x" | ||
width={width} | ||
onResize={onResize} | ||
minConstraints={[280, Infinity]} | ||
maxConstraints={[550, Infinity]} | ||
resizeHandles={['e']} | ||
> | ||
<ProjectTree | ||
dbtSourceModels={sourceModels} | ||
handleNodeClick={handleNodeClick} | ||
handleSyncClick={fetchSourcesModels} | ||
isSyncing={loading} | ||
/> | ||
</ResizableBox> | ||
<Divider orientation="vertical" sx={{ color: 'black' }} /> | ||
<Box sx={{ width: `calc(100% - ${width}px)` }}> | ||
<Box sx={{ height: 'unset' }}> | ||
<Box | ||
sx={{ | ||
height: '44px', | ||
display: 'flex', | ||
alignItems: 'center', | ||
background: '#F5FAFA', | ||
borderTop: '1px solid #CCCCCC', | ||
borderBottom: '1px solid #CCCCCC', | ||
}} | ||
> | ||
<Tabs | ||
value={selectedTab} | ||
onChange={handleTabChange} | ||
sx={{ | ||
display: 'flex', | ||
alignItems: 'center', | ||
height: '100%', | ||
paddingLeft: '28px', | ||
}} | ||
> | ||
<Tab label="Preview" value="preview" /> | ||
|
||
<Tab label="Data statistics" value="statistics" /> | ||
</Tabs> | ||
</Box> | ||
<Box> | ||
{selectedTab === 'preview' && <PreviewPane height={height} />} | ||
|
||
{selectedTab === 'statistics' && <StatisticsPane height={height} />} | ||
</Box> | ||
</Box> | ||
</Box> | ||
</Box> | ||
</Dialog> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { render, screen, waitFor } from '@testing-library/react'; | ||
import { SessionProvider } from 'next-auth/react'; | ||
import { Session } from 'next-auth'; | ||
import { Explore } from '../Explore'; | ||
import '@testing-library/jest-dom'; | ||
|
||
jest.mock('next/router', () => ({ | ||
useRouter() { | ||
return { | ||
push: jest.fn(), | ||
}; | ||
}, | ||
})); | ||
|
||
window.ResizeObserver = | ||
window.ResizeObserver || | ||
jest.fn().mockImplementation(() => ({ | ||
disconnect: jest.fn(), | ||
observe: jest.fn(), | ||
unobserve: jest.fn(), | ||
})); | ||
|
||
const mockSession: Session = { | ||
expires: 'false', | ||
user: { email: 'a' }, | ||
}; | ||
|
||
const mockedFetch = jest.fn().mockResolvedValueOnce({ | ||
ok: true, | ||
json: jest.fn().mockResolvedValueOnce([]), | ||
}); | ||
(global as any).fetch = mockedFetch; | ||
|
||
it('renders the explore page with preview and data statistics tab', async () => { | ||
render( | ||
<SessionProvider session={mockSession}> | ||
<Explore /> | ||
</SessionProvider> | ||
); | ||
|
||
await waitFor(() => { | ||
expect(screen.getByText('Preview')).toBeInTheDocument(); | ||
expect(screen.getByText('Data statistics')).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.