11import { Uri , ViewColumn , WebviewPanel , window } from 'vscode'
22import { BaseWebview } from '.'
33import { ViewKey , WebviewDetails } from './constants'
4- import { WebviewState , WebviewData } from './contract'
54import { Resource } from '../resourceLocator'
65import { getWorkspaceRootUris } from '../vscode/workspaceFolders'
76
8- export const isValidDvcRoot = ( dvcRoot ?: string ) : dvcRoot is string => ! ! dvcRoot
7+ export const GLOBAL_WEBVIEW_DVCROOT = 'n/a'
8+
9+ const isValidDvcRoot = ( dvcRoot ?: string ) : dvcRoot is string => ! ! dvcRoot
910
1011const create = (
1112 viewKey : ViewKey ,
1213 webviewPanel : WebviewPanel ,
13- dvcRoot : string ,
14- bypassDvcRoot ?: boolean
14+ dvcRoot : string
1515) => {
16- if ( ! bypassDvcRoot && ! isValidDvcRoot ( dvcRoot ) ) {
16+ if ( ! isValidDvcRoot ( dvcRoot ) ) {
1717 throw new Error ( `trying to set invalid state into ${ viewKey } ` )
1818 }
1919
@@ -26,8 +26,7 @@ export const createWebview = async (
2626 viewKey : ViewKey ,
2727 dvcRoot : string ,
2828 iconPath : Resource ,
29- viewColumn ?: ViewColumn ,
30- bypassDvcRoot ?: boolean
29+ viewColumn ?: ViewColumn
3130) => {
3231 const { title, distPath } = WebviewDetails [ viewKey ]
3332
@@ -44,21 +43,7 @@ export const createWebview = async (
4443
4544 webviewPanel . iconPath = iconPath
4645
47- const view = create ( viewKey , webviewPanel , dvcRoot , bypassDvcRoot )
46+ const view = create ( viewKey , webviewPanel , dvcRoot )
4847 await view . isReady ( )
4948 return view
5049}
51-
52- export const restoreWebview = < T extends WebviewData > (
53- viewKey : ViewKey ,
54- webviewPanel : WebviewPanel ,
55- state : WebviewState
56- ) : Promise < BaseWebview < T > > => {
57- return new Promise ( ( resolve , reject ) => {
58- try {
59- resolve ( create ( viewKey , webviewPanel , state . dvcRoot ) )
60- } catch ( error : unknown ) {
61- reject ( error )
62- }
63- } )
64- }
0 commit comments