Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add drag and drop mode to plots #4934

Merged
merged 14 commits into from
Nov 10, 2023
Merged

Add drag and drop mode to plots #4934

merged 14 commits into from
Nov 10, 2023

Conversation

sroy3
Copy link
Contributor

@sroy3 sroy3 commented Oct 31, 2023

1/3 main <- this <- #4942 <- #4960

Part of #4867

Demo

Screen.Recording.2023-10-31.at.3.21.51.PM.mov

I'll iterate on this PR before merging it. This is big enough as is without adding more functionality. To be added in future PRs merging back into this one:

  • Style for the plot while dragging (I think the titles for custom plots aren't the right ones either, to verify)
  • Toggle modes while dragging (seamless with what it used to be) (Seamless drag and drop mode #4942 )

@sroy3 sroy3 added the product PR that affects product label Oct 31, 2023
@sroy3 sroy3 self-assigned this Oct 31, 2023
@@ -151,10 +151,10 @@ const getCustomPlotData = (
const updatedSpec = truncateVegaSpecTitles(spec, nbItemsPerRow, height)

return {
content: updatedSpec,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Making this consistent with template plots


if (addPlotsButton) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There was never a addPlotsButton.


if (menu) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We never passed a menu prop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Was only used by the list filter here

@@ -36,9 +36,6 @@ export const customPlotsSlice = createSlice({
initialState: customPlotsInitialState,
name: 'custom',
reducers: {
changeDisabledDragIds: (state, action: PayloadAction<string[]>) => {
state.disabledDragPlotIds = action.payload
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not necessary anymore as it was used to disable the drag and drop when using the smooth plot slider.

@@ -37,9 +37,6 @@ export const templatePlotsSlice = createSlice({
initialState: templatePlotsInitialState,
name: 'template',
reducers: {
changeDisabledDragIds: (state, action: PayloadAction<string[]>) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sroy3 sroy3 marked this pull request as ready for review November 2, 2023 16:37
parentDraggedOver?: boolean
}

export const Grid: React.FC<GridProps> = ({
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 4 locations. Consider refactoring.

@sroy3 sroy3 marked this pull request as draft November 2, 2023 18:15
Copy link
Contributor

@julieg18 julieg18 left a comment

Choose a reason for hiding this comment

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

Great work so far!

: undefined
}
parentDraggedOver={parentDraggedOver}
disabledDropIds={[]}
Copy link
Contributor

Choose a reason for hiding this comment

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

Since disabledDropIds is optional, why not remove it entirely?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's used by the comparison table

Copy link
Contributor

Choose a reason for hiding this comment

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

Apologies, I meant remove this line like this:

Suggested change
disabledDropIds={[]}

If I'm understanding things correctly, disabledDropIds defaults to an empty array anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, sorry. I'll remove this.

>
<GripIcon className={styles.plotGripIcon} />

<h2>{plot}</h2>
Copy link
Contributor

Choose a reason for hiding this comment

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

The custom plots id looks strange on the drag and drop table, especially if the metrics/params are lengthy:

image

If I'm remembering correctly, the placeholder design isn't finalized but we may want to look into using a formatted title for custom plots like we show in custom plot quick picks:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the first todo in the list (still need to get to it)

@sroy3 sroy3 marked this pull request as ready for review November 6, 2023 16:33
* Make toggling drag and drop mode seamless

* Add tests

* Fix pplot actions

* Fix drag end event

* Add style to plots in drag and drop mode (#4960)

* Add style to drag and drop mode plots

* Format custom plots titles in drag and drop mode

* Self review

* Add tests

* Fix bug and style
sectionKey: PlotsSection
}

export const DragAndDropGrid: React.FC<DragAndDropGridProps> = ({
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 5 locations. Consider refactoring.

parentDraggedOver?: boolean
}

export const Grid: React.FC<GridProps> = ({
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 5 locations. Consider refactoring.

Copy link

codeclimate bot commented Nov 10, 2023

Code Climate has analyzed commit 92d0eca and detected 7 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 1
Duplication 6

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

This pull request will bring the total coverage in the repository to 95.2% (0.1% change).

View more on Code Climate.

@sroy3 sroy3 merged commit 47e4bb9 into main Nov 10, 2023
@sroy3 sroy3 deleted the drag-drop-mode branch November 10, 2023 16:52
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
product PR that affects product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants