Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions webview/src/plots/components/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { act } from 'react-dom/test-utils'
import { App } from './App'
import { NewSectionBlock } from './templatePlots/TemplatePlots'
import { SectionDescription } from './PlotsContainer'
import { storeReducers } from '../store'
import { plotsReducers } from '../store'
import { vsCodeApi } from '../../shared/api'
import { createBubbledEvent, dragAndDrop, dragEnter } from '../../test/dragDrop'
import { DragEnterDirection } from '../../shared/components/dragDrop/util'
Expand Down Expand Up @@ -113,7 +113,7 @@ describe('App', () => {
}

const renderAppWithOptionalData = (data?: PlotsData) => {
const store = configureStore({ reducer: storeReducers })
const store = configureStore({ reducer: plotsReducers })
render(
<Provider store={store}>
<App />
Expand Down
6 changes: 3 additions & 3 deletions webview/src/plots/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ import {
updateHasSelectedPlots,
updateSelectedRevisions
} from './webviewSlice'
import { AppDispatch } from '../store'
import { PlotsDispatch } from '../store'
import { useVsCodeMessaging } from '../../shared/hooks/useVsCodeMessaging'

const dispatchCollapsedSections = (
sections: SectionCollapsed,
dispatch: AppDispatch
dispatch: PlotsDispatch
) => {
if (sections) {
dispatch(setCheckpointPlotsCollapsed(sections[Section.CHECKPOINT_PLOTS]))
Expand All @@ -46,7 +46,7 @@ const dispatchCollapsedSections = (

export const feedStore = (
data: MessageToWebview<PlotsData>,
dispatch: AppDispatch
dispatch: PlotsDispatch
// eslint-disable-next-line sonarjs/cognitive-complexity
) => {
if (data.data) {
Expand Down
10 changes: 5 additions & 5 deletions webview/src/plots/components/Plots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { EmptyState } from '../../shared/components/emptyState/EmptyState'
import { Modal } from '../../shared/components/modal/Modal'
import { WebviewWrapper } from '../../shared/components/webviewWrapper/WebviewWrapper'
import { GetStarted } from '../../shared/components/getStarted/GetStarted'
import { RootState } from '../store'
import { PlotsState } from '../store'

// eslint-disable-next-line sonarjs/cognitive-complexity
const PlotsContent = () => {
Expand All @@ -22,15 +22,15 @@ const PlotsContent = () => {
hasSelectedPlots,
selectedRevisions,
zoomedInPlot
} = useSelector((state: RootState) => state.webview)
} = useSelector((state: PlotsState) => state.webview)
const hasCheckpointData = useSelector(
(state: RootState) => state.checkpoint.hasData
(state: PlotsState) => state.checkpoint.hasData
)
const hasComparisonData = useSelector(
(state: RootState) => state.comparison.hasData
(state: PlotsState) => state.comparison.hasData
)
const hasTemplateData = useSelector(
(state: RootState) => state.template.hasData
(state: PlotsState) => state.template.hasData
)

if (!hasData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { ZoomablePlot } from '../ZoomablePlot'
import styles from '../styles.module.scss'
import { withScale } from '../../../util/styles'
import { plotDataStore } from '../plotDataStore'
import { RootState } from '../../store'
import { PlotsState } from '../../store'

interface CheckpointPlotProps {
id: string
Expand All @@ -18,7 +18,7 @@ export const CheckpointPlot: React.FC<CheckpointPlotProps> = ({
colors
}) => {
const plotSnapshot = useSelector(
(state: RootState) => state.checkpoint.plotsSnapshots[id]
(state: PlotsState) => state.checkpoint.plotsSnapshots[id]
)
const [plot, setPlot] = useState(plotDataStore.checkpoint[id])
const spec = useMemo(() => (id && createSpec(id, colors)) || {}, [id, colors])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { DropTarget } from '../DropTarget'
import { VirtualizedGrid } from '../../../shared/components/virtualizedGrid/VirtualizedGrid'
import { shouldUseVirtualizedGrid } from '../util'
import { useNbItemsPerRow } from '../../hooks/useNbItemsPerRow'
import { RootState } from '../../store'
import { PlotsState } from '../../store'

interface CheckpointPlotsProps {
plotsIds: string[]
Expand All @@ -28,7 +28,7 @@ export const CheckpointPlots: React.FC<CheckpointPlotsProps> = ({
colors
}) => {
const [order, setOrder] = useState(plotsIds)
const { size } = useSelector((state: RootState) => state.checkpoint)
const { size } = useSelector((state: PlotsState) => state.checkpoint)
const nbItemsPerRow = useNbItemsPerRow(size)

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import { CheckpointPlots } from './CheckpointPlots'
import { changeSize } from './checkpointPlotsSlice'
import { PlotsContainer } from '../PlotsContainer'
import { sendMessage } from '../../../shared/vscode'
import { RootState } from '../../store'
import { PlotsState } from '../../store'

export const CheckpointPlotsWrapper: React.FC = () => {
const dispatch = useDispatch()
const { plotsIds, size, selectedMetrics, isCollapsed, colors } = useSelector(
(state: RootState) => state.checkpoint
(state: PlotsState) => state.checkpoint
)
const [metrics, setMetrics] = useState<string[]>([])
const [selectedPlots, setSelectedPlots] = useState<string[]>([])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
} from '../../../test/dragDrop'
import { vsCodeApi } from '../../../shared/api'
import { DragEnterDirection } from '../../../shared/components/dragDrop/util'
import { storeReducers } from '../../store'
import { plotsReducers } from '../../store'
import { webviewInitialState } from '../webviewSlice'

const getHeaders = () => screen.getAllByRole('columnheader')
Expand Down Expand Up @@ -70,7 +70,7 @@ describe('ComparisonTable', () => {
zoomedInPlot: undefined
}
},
reducer: storeReducers
reducer: plotsReducers
})}
>
<ComparisonTable />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import {
import plotsStyles from '../styles.module.scss'
import { withScale } from '../../../util/styles'
import { sendMessage } from '../../../shared/vscode'
import { RootState } from '../../store'
import { PlotsState } from '../../store'

export const ComparisonTable: React.FC = () => {
const { plots } = useSelector((state: RootState) => state.comparison)
const { plots } = useSelector((state: PlotsState) => state.comparison)

const { selectedRevisions: revisions } = useSelector(
(state: RootState) => state.webview
(state: PlotsState) => state.webview
)

const pinnedColumn = useRef('')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import styles from './styles.module.scss'
import { DropTarget } from './DropTarget'
import { ComparisonTableHeader } from './ComparisonTableHeader'
import { DragDropContainer } from '../../../shared/components/dragDrop/DragDropContainer'
import { RootState } from '../../store'
import { PlotsState } from '../../store'

export type ComparisonTableColumn = Revision

Expand All @@ -24,7 +24,7 @@ export const ComparisonTableHead: React.FC<ComparisonTableHeadProps> = ({
setPinnedColumn
}) => {
const draggedId = useSelector(
(state: RootState) => state.dragAndDrop.draggedRef?.itemId
(state: PlotsState) => state.dragAndDrop.draggedRef?.itemId
)

const items = columns.map(({ revision, displayColor, group }) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
ComparisonTableRowProps
} from './ComparisonTableRow'
import styles from '../styles.module.scss'
import { storeReducers } from '../../store'
import { plotsReducers } from '../../store'

jest.mock('../../../shared/api')

Expand All @@ -37,7 +37,7 @@ describe('ComparisonTableRow', () => {
render(
<Provider
store={configureStore({
reducer: storeReducers
reducer: plotsReducers
})}
>
<table>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Icon } from '../../../shared/components/Icon'
import { RefreshButton } from '../../../shared/components/button/RefreshButton'
import { sendMessage } from '../../../shared/vscode'
import { ChevronDown, ChevronRight } from '../../../shared/components/icons'
import { RootState } from '../../store'
import { PlotsState } from '../../store'

export interface ComparisonTableRowProps {
path: string
Expand All @@ -24,7 +24,7 @@ export const ComparisonTableRow: React.FC<ComparisonTableRowProps> = ({
pinnedColumn
}) => {
const draggedId = useSelector(
(state: RootState) => state.dragAndDrop.draggedRef?.itemId
(state: PlotsState) => state.dragAndDrop.draggedRef?.itemId
)
const [isShown, setIsShown] = useState(true)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { useSelector, useDispatch } from 'react-redux'
import { ComparisonTable } from './ComparisonTable'
import { changeSize } from './comparisonTableSlice'
import { PlotsContainer } from '../PlotsContainer'
import { RootState } from '../../store'
import { PlotsState } from '../../store'

export const ComparisonTableWrapper: React.FC = () => {
const dispatch = useDispatch()
const { size, isCollapsed } = useSelector(
(state: RootState) => state.comparison
(state: PlotsState) => state.comparison
)
const handleResize = (size: PlotSize) => {
dispatch(changeSize(size))
Expand Down
4 changes: 2 additions & 2 deletions webview/src/plots/components/ribbon/Ribbon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import { RibbonBlock } from './RibbonBlock'
import { sendMessage } from '../../../shared/vscode'
import { IconButton } from '../../../shared/components/button/IconButton'
import { performOrderedUpdate } from '../../../util/objects'
import { RootState } from '../../store'
import { PlotsState } from '../../store'
import { Lines, Refresh } from '../../../shared/components/icons'

const MAX_NB_EXP = 7

export const Ribbon: React.FC = () => {
const revisions = useSelector(
(state: RootState) => state.webview.selectedRevisions
(state: PlotsState) => state.webview.selectedRevisions
)
const [order, setOrder] = useState<string[]>([])
const reorderId = 'id'
Expand Down
4 changes: 2 additions & 2 deletions webview/src/plots/components/templatePlots/AddedSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import cx from 'classnames'
import { TemplatePlotSection } from 'dvc/src/plots/webview/contract'
import styles from '../styles.module.scss'
import { getIDWithoutIndex } from '../../../util/ids'
import { RootState } from '../../store'
import { PlotsState } from '../../store'
import { Icon } from '../../../shared/components/Icon'
import { GraphLine } from '../../../shared/components/icons'

Expand All @@ -25,7 +25,7 @@ export const AddedSection: React.FC<AddedSectionProps> = ({
closestSection,
acceptedGroups
}) => {
const { draggedRef } = useSelector((state: RootState) => state.dragAndDrop)
const { draggedRef } = useSelector((state: PlotsState) => state.dragAndDrop)
const handleDragLeave = () => {
setHoveredSection('')
}
Expand Down
4 changes: 2 additions & 2 deletions webview/src/plots/components/templatePlots/TemplatePlots.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { createIDWithIndex, getIDIndex } from '../../../util/ids'
import styles from '../styles.module.scss'
import { shouldUseVirtualizedGrid } from '../util'
import { useNbItemsPerRow } from '../../hooks/useNbItemsPerRow'
import { RootState } from '../../store'
import { PlotsState } from '../../store'
import { plotDataStore } from '../plotDataStore'

export enum NewSectionBlock {
Expand All @@ -25,7 +25,7 @@ export enum NewSectionBlock {

export const TemplatePlots: React.FC = () => {
const { plotsSnapshot, size } = useSelector(
(state: RootState) => state.template
(state: PlotsState) => state.template
)
const [sections, setSections] = useState<TemplatePlotSection[]>([])
const [hoveredSection, setHoveredSection] = useState('')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { useSelector, useDispatch } from 'react-redux'
import { TemplatePlots } from './TemplatePlots'
import { changeSize } from './templatePlotsSlice'
import { PlotsContainer } from '../PlotsContainer'
import { RootState } from '../../store'
import { PlotsState } from '../../store'

export const TemplatePlotsWrapper: React.FC = () => {
const dispatch = useDispatch()
const { size, isCollapsed } = useSelector(
(state: RootState) => state.template
(state: PlotsState) => state.template
)

const handleResize = (size: PlotSize) => {
Expand Down
4 changes: 2 additions & 2 deletions webview/src/plots/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { Provider } from 'react-redux'
import '../shared/style.scss'
import { App } from './components/App'
import '../util/wdyr'
import { store } from './store'
import { plotsStore } from './store'

const root = ReactDOM.createRoot(document.querySelector('#root') as HTMLElement)
root.render(
<Provider store={store}>
<Provider store={plotsStore}>
<App />
</Provider>
)
10 changes: 5 additions & 5 deletions webview/src/plots/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import templatePlotsReducer from './components/templatePlots/templatePlotsSlice'
import webviewReducer from './components/webviewSlice'
import dragAndDropReducer from '../shared/components/dragDrop/dragDropSlice'

export const storeReducers = {
export const plotsReducers = {
checkpoint: checkpointPlotsReducer,
comparison: comparisonTableReducer,
dragAndDrop: dragAndDropReducer,
template: templatePlotsReducer,
webview: webviewReducer
}

export const store = configureStore({
reducer: storeReducers
export const plotsStore = configureStore({
reducer: plotsReducers
})

export type RootState = ReturnType<typeof store.getState>
export type AppDispatch = typeof store.dispatch
export type PlotsState = ReturnType<typeof plotsStore.getState>
export type PlotsDispatch = typeof plotsStore.dispatch
4 changes: 2 additions & 2 deletions webview/src/shared/components/dragDrop/DragDropContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { changeRef } from './dragDropSlice'
import styles from './styles.module.scss'
import { getIDIndex, getIDWithoutIndex } from '../../../util/ids'
import { Any } from '../../../util/objects'
import { RootState } from '../../../plots/store'
import { PlotsState } from '../../../plots/store'

const orderIdxTune = (direction: DragEnterDirection, isAfter: boolean) => {
if (direction === DragEnterDirection.RIGHT) {
Expand Down Expand Up @@ -86,7 +86,7 @@ export const DragDropContainer: React.FC<DragDropContainerProps> = ({
const [draggedOverId, setDraggedOverId] = useState('')
const [draggedId, setDraggedId] = useState('')
const [direction, setDirection] = useState(DragEnterDirection.LEFT)
const { draggedRef } = useSelector((state: RootState) => state.dragAndDrop)
const { draggedRef } = useSelector((state: PlotsState) => state.dragAndDrop)
const draggedOverIdTimeout = useRef<number>(0)
const dispatch = useDispatch()

Expand Down
4 changes: 2 additions & 2 deletions webview/src/stories/ComparisonTable.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { ComparisonTable } from '../plots/components/comparisonTable/ComparisonT
import { WebviewWrapper } from '../shared/components/webviewWrapper/WebviewWrapper'
import { update } from '../plots/components/comparisonTable/comparisonTableSlice'
import { updateSelectedRevisions } from '../plots/components/webviewSlice'
import { storeReducers } from '../plots/store'
import { plotsReducers } from '../plots/store'

const MockedState: React.FC<{
data: PlotsComparisonData
Expand All @@ -37,7 +37,7 @@ export default {

const Template: Story = ({ plots, revisions }) => {
const store = configureStore({
reducer: storeReducers
reducer: plotsReducers
})
return (
<Provider store={store}>
Expand Down
4 changes: 2 additions & 2 deletions webview/src/stories/Plots.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import './test-vscode-styles.scss'
import '../shared/style.scss'
import '../plots/components/styles.module.scss'
import { feedStore } from '../plots/components/App'
import { storeReducers } from '../plots/store'
import { plotsReducers } from '../plots/store'

const MockedState: React.FC<{ data: PlotsData; children: React.ReactNode }> = ({
children,
Expand Down Expand Up @@ -55,7 +55,7 @@ export default {
const Template: Story<{
data?: PlotsData
}> = ({ data }) => {
const store = configureStore({ reducer: storeReducers })
const store = configureStore({ reducer: plotsReducers })
return (
<Provider store={store}>
<MockedState data={data}>
Expand Down