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

Move Connect to Studio into Setup webview #3452

Merged
merged 6 commits into from
Mar 14, 2023
Merged

Move Connect to Studio into Setup webview #3452

merged 6 commits into from
Mar 14, 2023

Conversation

mattseddon
Copy link
Member

@mattseddon mattseddon commented Mar 13, 2023

2/4 main <- #3448 <- this <- #3462 <- #3463

Related to #3434.

This PR moves the Connect to Studio page inside of the Setup webview.

Demo

Screen.Recording.2023-03-13.at.7.36.18.pm.mov

@mattseddon mattseddon added the product PR that affects product label Mar 13, 2023
@mattseddon mattseddon self-assigned this Mar 13, 2023
@mattseddon mattseddon changed the base branch from main to give-setup-section March 13, 2023 05:21
webview/src/setup/components/App.tsx Outdated Show resolved Hide resolved
@@ -69,12 +69,16 @@ export const SetupExperiments: React.FC<SetupExperimentsProps> = ({
}

if (hasData === undefined) {
return <EmptyState>Loading Project...</EmptyState>
return <EmptyState isFullScreen={false}>Loading Project...</EmptyState>
Copy link

Choose a reason for hiding this comment

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

Avoid too many return statements within this function.

Copy link
Contributor

Choose a reason for hiding this comment

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

Should we move this inside <NoData />? This would probably solve that codeclimate issue.

Copy link
Member Author

Choose a reason for hiding this comment

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

Did something about this in #3463.

}

if (!hasData) {
return <NoData />
}

return <EmptyState>{"You're all setup"}</EmptyState>
return (
Copy link

Choose a reason for hiding this comment

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

Avoid too many return statements within this function.

webview/src/setup/components/App.tsx Outdated Show resolved Hide resolved
@@ -26,7 +26,7 @@ export type SetupExperimentsProps = {
pythonBinPath: string | undefined
}

export const SetupExperiments: React.FC<SetupExperimentsProps> = ({
export const Experiments: React.FC<ExperimentsProps> = ({
Copy link

Choose a reason for hiding this comment

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

Function Experiments has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.

@mattseddon mattseddon changed the base branch from give-setup-section to main March 13, 2023 08:16
}

if (!hasData) {
return <NoData />
Copy link

Choose a reason for hiding this comment

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

Avoid too many return statements within this function.

return <CliIncompatible checkCompatibility={checkCompatibility} />
}

if (cliCompatible === undefined) {
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 2 locations. Consider refactoring.

@@ -399,11 +399,6 @@
"command": "dvc.showCommands",
"category": "DVC"
},
{
"title": "Connect to Studio",
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'll replace these in a follow-up.

Copy link
Member Author

@mattseddon mattseddon Mar 14, 2023

Choose a reason for hiding this comment

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

The current behaviour is back UX but I will fix it in the next PR.

Screen.Recording.2023-03-14.at.12.29.42.pm.mov

The best idea at the moment seems to be to collapse all of the non-relevant sections.

@@ -108,11 +108,11 @@ export const getShareExperimentAsCommitCommand =
}

export const getShareExperimentToStudioCommand =
(internalCommands: InternalCommands, connect: Connect) =>
(internalCommands: InternalCommands, setup: Setup) =>
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] All of the externals of Connect have been moved directly onto Setup to reduce the size of this change. Will work out a smarter split once the dust settles.

hasData: boolean | undefined
}) {
shareLiveToStudio
}: SetupData) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Note to self: Consider using "Step" here instead of sending all of this data (consolidate logic).

@@ -633,5 +636,154 @@ suite('Setup Test Suite', () => {
'should set dvc.cli.incompatible to false if the version is compatible'
).to.be.calledWithExactly('setContext', 'dvc.cli.incompatible', false)
})

it('should handle a message from the webview to open Studio', async () => {
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] These are the Connect test suite tests copied across.

render(<App />)
expect(mockPostMessage).toHaveBeenCalledWith({
type: MessageFromWebviewType.INITIALIZED
describe('Experiments', () => {
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] Indentation change as per the new describe statement.

needsGitInitialized: undefined,
projectInitialized: false,
pythonBinPath: undefined
describe('Studio not connected', () => {
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] Copy pasted from the old Connect App tests.

@mattseddon mattseddon changed the base branch from main to give-setup-section March 14, 2023 01:42
@mattseddon mattseddon marked this pull request as ready for review March 14, 2023 01:45
@mattseddon mattseddon requested a review from shcheklein March 14, 2023 06:26
Copy link
Contributor

@sroy3 sroy3 left a comment

Choose a reason for hiding this comment

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

Screenshot 2023-03-14 at 8 57 42 AM

Not sure why the section is not expanding

]
)
)

const setShareLiveToStudio = (shouldShareLive: boolean) => {
setShareLiveToStudioValue(shouldShareLive)
sendMessage({
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this be inside messages.ts?

@@ -26,7 +26,7 @@ export type SetupExperimentsProps = {
pythonBinPath: string | undefined
}

export const SetupExperiments: React.FC<SetupExperimentsProps> = ({
export const Experiments: React.FC<ExperimentsProps> = ({
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 wondering if a rename to Experiments was a good idea. After looking the experiments table main component is exported as ExperimentsTable (there is a <Experiments /> component, but it isn't exported). Just leaving this here in case anyone else was wondering. I'm fine with the renaming knowing these facts.

@@ -69,12 +69,16 @@ export const SetupExperiments: React.FC<SetupExperimentsProps> = ({
}

if (hasData === undefined) {
return <EmptyState>Loading Project...</EmptyState>
return <EmptyState isFullScreen={false}>Loading Project...</EmptyState>
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we move this inside <NoData />? This would probably solve that codeclimate issue.

@sroy3
Copy link
Contributor

sroy3 commented Mar 14, 2023

Screenshot 2023-03-14 at 8 57 42 AM

Not sure why the section is not expanding

styles.emptySection has height: 33vh; as a styles. Maybe we should have a styles.flexibleHeight variant with height: auto instead or simply use something else than the empty section.

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!

return <EmptyState>{"You're all setup"}</EmptyState>
return (
<EmptyState isFullScreen={false}>
<h1>{"You're all setup"}</h1>
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this needs curly braces:

Suggested change
<h1>{"You're all setup"}</h1>
<h1>You're all setup</h1>

Copy link
Member Author

Choose a reason for hiding this comment

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

Needs to be some variant of You&apos;re all setup without the braces which is why I opted for this. I changed this text in #3463 to Setup Complete. We should agree on what the message should actually be.

{"Configure the extension's connection to "}
<a href="https://studio.iterative.a">Studio</a>.<br />
Studio provides a collaboration platform for Machine Learning and is free
for small teams and individual contributors.
Copy link
Contributor

Choose a reason for hiding this comment

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

Spotted a couple minor things in the text:

  • first line is wrapped in curly braces
  • Should "Machine Learning" be capitalized?
  • link to studio is missing an "i"
      Configure the extension&apos;s connection to{' '}
      <a href="https://studio.iterative.ai">Studio</a>.<br />
      Studio provides a collaboration platform for machine learning and is free
      for small teams and individual contributors.

Copy link
Member Author

Choose a reason for hiding this comment

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

Text is adapted from:

image

link to studio is missing an "i"

That is why we have a const. I'll fix

Copy link
Member Author

Choose a reason for hiding this comment

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

If we care about the consistent use of {"'"} vs &apos; then we need to add a linter rule.

Copy link
Member Author

Choose a reason for hiding this comment

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

Only rule I have been able to find seems to be the opposite of what you're asking for: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Contributor

@julieg18 julieg18 Mar 15, 2023

Choose a reason for hiding this comment

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

If we care about the consistent use of {"'"} vs &apos; then we need to add a linter rule.

I've always gotten error warnings when it comes to apostrophes in the text and I've just corrected them without thinking about it.

Screenshot 2023-03-15 at 7 31 44 AM

But, apparently, you're not seeing them? weird 🤔

Copy link
Contributor

@julieg18 julieg18 Mar 15, 2023

Choose a reason for hiding this comment

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

Only rule I have been able to find seems to be the opposite of what you're asking for: https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-no-literals.md

Can add https://github.com/jsx-eslint/eslint-plugin-react/blob/master/docs/rules/jsx-curly-brace-presence.md though

I've alway's just assumed we don't want extra curly braces that aren't needed in the JSX. Personally, I find it harder to read. No strong preference though!

Copy link
Member Author

Choose a reason for hiding this comment

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

If we care about the consistent use of {"'"} vs &apos; then we need to add a linter rule.

I've always gotten error warnings when it comes to apostrophes in the text and I've just corrected them without thinking about it.

Screenshot 2023-03-15 at 7 31 44 AM

But, apparently, you're not seeing them? weird 🤔

Do you see those errors if there are braces wrapping the text?

@mattseddon
Copy link
Member Author

mattseddon commented Mar 14, 2023

Screenshot 2023-03-14 at 8 57 42 AM Not sure why the section is not expanding

styles.emptySection has height: 33vh; as a styles. Maybe we should have a styles.flexibleHeight variant with height: auto instead or simply use something else than the empty section.

@sroy3 how about:

.emptySection {
  width: 100%;
  min-height: 33vh;
  height: auto;
}

This seems to work:

Screen.Recording.2023-03-15.at.6.29.26.am.mov
Screen.Recording.2023-03-15.at.6.28.32.am.mov

WDYT?

@sroy3
Copy link
Contributor

sroy3 commented Mar 14, 2023

Screenshot 2023-03-14 at 8 57 42 AM Not sure why the section is not expanding

styles.emptySection has height: 33vh; as a styles. Maybe we should have a styles.flexibleHeight variant with height: auto instead or simply use something else than the empty section.

@sroy3 how about:

.emptySection {
  width: 100%;
  min-height: 33vh;
  height: auto;
}

This seems to work:

WDYT?

I think this is the best solution

Base automatically changed from give-setup-section to main March 14, 2023 22:53
@mattseddon mattseddon enabled auto-merge (squash) March 14, 2023 22:55
@codeclimate
Copy link

codeclimate bot commented Mar 14, 2023

Code Climate has analyzed commit 375cdfe and detected 8 issues on this pull request.

Here's the issue category breakdown:

Category Count
Complexity 5
Duplication 3

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

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

View more on Code Climate.

@mattseddon mattseddon merged commit 5302a56 into main Mar 14, 2023
@mattseddon mattseddon deleted the add-connect branch March 14, 2023 23:09
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.

3 participants