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

Add get started component to plots webview #1718

Merged
merged 1 commit into from
May 16, 2022
Merged

Conversation

mattseddon
Copy link
Member

@mattseddon mattseddon commented May 16, 2022

Closes #1672

This PR improve the empty state of our plots webview by adding @vscode/webview-ui-toolkit/react buttons to the page whenever the user needs to select either experiments or plots to make something appear.

Demo

Screen.Recording.2022-05-16.at.3.09.37.pm.mov

@mattseddon mattseddon added the product PR that affects product label May 16, 2022
@mattseddon mattseddon self-assigned this May 16, 2022
@@ -0,0 +1,14 @@
/* eslint-disable unicorn/filename-case */
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] I spent around 2 hours trying to get jest to load @microsoft/fast-react-wrapper which is an esm dependency of @vscode/webview-ui-toolkit/react. In the end I had to give up and mock the damn thing.

image

hasSelectedRevisions?: boolean
}

export const GetStarted = ({
Copy link
Member Author

Choose a reason for hiding this comment

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

Please LMK if there is a better pattern to get these buttons and wrappers etc into the React App.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think I should start removing React.FC typings everywhere. I never questioned it and thought it was how things had to be typed, but your pattern of typing the component

export const comp = (props: CompProps) => {
  ...
}

vs

export const comp: React.FC<CompProps> = (props) => {
  ...
}

is actually a better way to type these. (facebook/create-react-app#8177)

Thanks for making me look this up.

Copy link
Contributor

Choose a reason for hiding this comment

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

I was also under the impression React.FC was best practice. Implicit children is removed from the FC type in React 18, so doing so now will help when we get around to that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep this was inspired by me trying (and failing) to upgrade to React 18

@mattseddon mattseddon force-pushed the improve-empty-state branch from d1592d8 to ead0a70 Compare May 16, 2022 05:07
return (
<EmptyState>
<div>
<p>No Plots to Display</p>
Copy link
Member Author

Choose a reason for hiding this comment

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

[Q] What could we replace this with to make it look better?

@mattseddon mattseddon marked this pull request as ready for review May 16, 2022 05:13
@codeclimate
Copy link

codeclimate bot commented May 16, 2022

Code Climate has analyzed commit ead0a70 and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 2

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

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

View more on Code Climate.

@mattseddon mattseddon requested review from shcheklein and a team May 16, 2022 09:44
@shcheklein
Copy link
Member

@mattseddon looks really good, thanks. let's merge it. Next step / question - what if there are no plots setup in the repo at all? can we show some preview and link to the docs?

hasSelectedRevisions?: boolean
}

export const GetStarted = ({
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I should start removing React.FC typings everywhere. I never questioned it and thought it was how things had to be typed, but your pattern of typing the component

export const comp = (props: CompProps) => {
  ...
}

vs

export const comp: React.FC<CompProps> = (props) => {
  ...
}

is actually a better way to type these. (facebook/create-react-app#8177)

Thanks for making me look this up.

onClick: () => void
text: string
isNested?: boolean
children?: React.ReactNode
Copy link
Contributor

Choose a reason for hiding this comment

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

When using React.FC< ButtonProps> children will be implicit and there is no need of adding it in the prop type. But like I mentioned in my previous comment, we probably should remove React.FC types everywhere instead and add children where needed. That way we can specify if it's optional or not and if it's expecting one or more nodes like you did here.

Copy link
Contributor

@rogermparent rogermparent left a comment

Choose a reason for hiding this comment

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

Great stuff! One tiny improvement could be changing the font to the standard sans-serif font over editor/monospace so that this component matches the sidebar welcome views that inspired it.

@mattseddon
Copy link
Member Author

I'll follow up with the comments provided

@mattseddon mattseddon merged commit 16a0c2b into main May 16, 2022
@mattseddon mattseddon deleted the improve-empty-state branch May 16, 2022 19:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product PR that affects product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No plots: improve message when there are no experiments selected
4 participants