-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improves user experience inside Stateful Cloud Playgrounds (#1786)
* Add trusted domains * Auto Open New terminal * Removes TrustedDomains Dialog * Auto open new terminal once * Consolidate UX features into HostedPlayground Merged AutoOpenTerminal and AddTrustedDomains into a single feature flag: HostedPlayground, per code review feedback. * Not a user-setting, make sure it's always default false * Check feature status top and inside feature for clarity --------- Co-authored-by: Sebastian Tiedtke <[email protected]>
- Loading branch information
1 parent
aae987a
commit 61de6c2
Showing
7 changed files
with
110 additions
and
7 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { Uri, workspace } from 'vscode' | ||
import { parse as jsoncParse } from 'jsonc-parser' | ||
|
||
import { FeatureName } from '../../types' | ||
import getLogger from '../logger' | ||
|
||
import { isOnInContextState } from '.' | ||
|
||
const logger = getLogger('AddTrustedDomains') | ||
const trustedDomain = 'https://*.stateful.com' | ||
|
||
export async function addTrustedDomains() { | ||
if (!isOnInContextState(FeatureName.HostedPlayground)) { | ||
return | ||
} | ||
|
||
try { | ||
const uri = Uri.parse('trustedDomains:/Trusted Domains') | ||
const bytes = await workspace.fs.readFile(uri) | ||
const json = jsoncParse(Buffer.from(bytes).toString('utf8')) as string[] | ||
const isTrusted = json.some((entry) => entry === trustedDomain) | ||
|
||
if (!isTrusted) { | ||
json.push(trustedDomain) | ||
await workspace.fs.writeFile(uri, Buffer.from(JSON.stringify(json))) | ||
} | ||
} catch (error) { | ||
let message | ||
if (error instanceof Error) { | ||
message = error.message | ||
} else { | ||
message = JSON.stringify(error) | ||
} | ||
|
||
logger.error(message) | ||
} | ||
} |
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,17 @@ | ||
import { commands } from 'vscode' | ||
|
||
import { FeatureName } from '../../types' | ||
import ContextState from '../contextState' | ||
|
||
import { isOnInContextState } from '.' | ||
|
||
export async function autoOpenTerminal() { | ||
if (!isOnInContextState(FeatureName.HostedPlayground)) { | ||
return | ||
} | ||
|
||
if (!ContextState.getKey<boolean>(`${FeatureName.HostedPlayground}.autoOpenTerminal`)) { | ||
await commands.executeCommand('workbench.action.terminal.new') | ||
await ContextState.addKey(`${FeatureName.HostedPlayground}.autoOpenTerminal`, true) | ||
} | ||
} |
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