-
Notifications
You must be signed in to change notification settings - Fork 29
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 webview for when dvc is not available or not initialized #2861
Merged
Merged
Changes from 9 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4c2210b
Add webview for get started
3159c9d
Allow incompatible dvc to show webviews
f0e8a74
Fix tests and lint errors
9a4d68e
Merge branch 'main' into get-started-views
sroy3 07ee526
Make sure webviews load after initialization
8cd5b63
Merge branch 'get-started-views' of https://github.com/iterative/vsco…
eb475ea
Merge branch 'main' into get-started-views
sroy3 bd3b9c8
Change order of sidebar views
1149cb3
Merge branch 'get-started-views' of https://github.com/iterative/vsco…
2e7f2db
Register open get started webview to simplify code paths
64e52fc
Remove useless changes
ca03d49
Merge branch 'main' into get-started-views
sroy3 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import { Memento, ViewColumn } from 'vscode' | ||
import { BaseRepository } from './repository' | ||
import { WebviewData } from './contract' | ||
import { createWebview } from './factory' | ||
import { ViewKey } from './constants' | ||
import { InternalCommands } from '../commands/internal' | ||
import { BaseWorkspace } from '../workspace' | ||
import { ResourceLocator } from '../resourceLocator' | ||
|
||
export abstract class BaseWorkspaceWebviews< | ||
T extends BaseRepository<U>, | ||
|
@@ -12,22 +15,37 @@ export abstract class BaseWorkspaceWebviews< | |
|
||
protected focusedWebviewDvcRoot: string | undefined | ||
|
||
private resourceLocator: ResourceLocator | ||
private getAvailable: () => boolean | ||
|
||
constructor( | ||
internalCommands: InternalCommands, | ||
workspaceState: Memento, | ||
resourceLocator: ResourceLocator, | ||
getAvailable: () => boolean, | ||
repositories?: Record<string, T> | ||
) { | ||
super(internalCommands) | ||
|
||
this.workspaceState = workspaceState | ||
|
||
this.resourceLocator = resourceLocator | ||
|
||
this.getAvailable = getAvailable | ||
|
||
if (repositories) { | ||
this.repositories = repositories | ||
} | ||
} | ||
|
||
public async showWebview(overrideRoot: string, viewColumn?: ViewColumn) { | ||
if (!this.getAvailable() || this.getDvcRoots().length === 0) { | ||
this.showEmptyWebview(viewColumn) | ||
return | ||
} | ||
|
||
const dvcRoot = overrideRoot || (await this.getOnlyOrPickProject()) | ||
|
||
if (!dvcRoot) { | ||
return | ||
} | ||
|
@@ -48,5 +66,15 @@ export abstract class BaseWorkspaceWebviews< | |
return overrideRoot || (await this.getFocusedOrOnlyOrPickProject()) | ||
} | ||
|
||
protected async showEmptyWebview(viewColumn?: ViewColumn) { | ||
await createWebview( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Creating a simple webview for now, but I've already started creating a class for it to add messages. |
||
ViewKey.GET_STARTED, | ||
'', | ||
this.resourceLocator.dvcIcon, | ||
viewColumn, | ||
true | ||
) | ||
} | ||
|
||
abstract getFocusedOrOnlyOrPickProject(): string | Promise<string | undefined> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export const distPath: string | ||
export const experiments: string | ||
export const plots: string | ||
export const getStarted: string | ||
export const react: string |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import React from 'react' | ||
import { EmptyState } from '../../shared/components/emptyState/EmptyState' | ||
|
||
export const App: React.FC = () => { | ||
return ( | ||
<EmptyState> | ||
<div> | ||
<h1>DVC is not available or not initialized</h1> | ||
</div> | ||
</EmptyState> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import React from 'react' | ||
import ReactDOM from 'react-dom/client' | ||
import '../shared/style.scss' | ||
import { App } from './components/App' | ||
|
||
const root = ReactDOM.createRoot(document.querySelector('#root') as HTMLElement) | ||
root.render(<App />) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Q] Would it be easier to show the same view but with different underlying commands under different circumstances? Would that simplify the code elsewhere?
i.e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you're right. I'll try that. Thanks!