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

Replace switch statements that feed the webviews stores #5194

Merged
merged 5 commits into from
Jan 15, 2024
Merged

Conversation

mattseddon
Copy link
Member

@mattseddon mattseddon commented Jan 15, 2024

Closes #5182

}
dispatch(update(!!data.data))

for (const key of Object.keys(data.data)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 2 locations. Consider refactoring.


default:
continue
for (const key of Object.keys(data.data)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Identical blocks of code found in 2 locations. Consider refactoring.

webview/src/experiments/components/App.tsx Show resolved Hide resolved
webview/src/setup/components/App.tsx Show resolved Hide resolved
@@ -1,19 +1,19 @@
import React, { useCallback } from 'react'
import { useDispatch } from 'react-redux'
import { TableData } from 'dvc/src/experiments/webview/contract'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

During the creation of this PR I moved the reducers in and out of this file. Rather than struggle to revert the exact order I resorted to using VS Code's "Organize Imports":

image

Rather than fight the new order I think we should start using this (means I have to think less to make things consistent).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used to do this, but it would clash with some linting we have. There might be a config that was needed.

import type { PlotsActions } from '../plots/components/App'
import type { PlotsDispatch } from '../plots/store'
import type { SetupActions } from '../setup/components/App'
import type { SetupDispatch } from '../setup/store'
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[F] Using type here to try and avoid including unnecessary code in each webview's bundle.

@mattseddon mattseddon marked this pull request as ready for review January 15, 2024 03:37
@mattseddon mattseddon enabled auto-merge (squash) January 15, 2024 17:53
Copy link

codeclimate bot commented Jan 15, 2024

Code Climate has analyzed commit c7dbea1 and detected 0 issues on this pull request.

The test coverage on the diff in this pull request is 96.2% (85% is the threshold).

This pull request will bring the total coverage in the repository to 95.2%.

View more on Code Climate.

@mattseddon mattseddon merged commit b8d62c1 into main Jan 15, 2024
8 checks passed
@mattseddon mattseddon deleted the update-switch branch January 15, 2024 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reduce the number of branches in the switch / case that feed the webviews stores
3 participants