-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Harry Pierson <harrypierson@outlook.com>
- Loading branch information
Showing
5 changed files
with
54 additions
and
4 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
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,33 @@ | ||
import * as vscode from 'vscode'; | ||
import { config } from '../extension'; | ||
|
||
export async function setApplicationName() { | ||
|
||
const currentAppName = config.getAppName(); | ||
|
||
const deleteCurrentNameButton = { iconPath: new vscode.ThemeIcon("trash"), tooltip: "Clear app name"}; | ||
|
||
const inputBox = vscode.window.createInputBox(); | ||
inputBox.title = "Set DBOS Cloud app name"; | ||
inputBox.prompt = "Enter custom package name. Leave blank to use name from package.json"; | ||
inputBox.value = currentAppName ?? ""; | ||
inputBox.buttons = currentAppName ? [deleteCurrentNameButton] : []; | ||
inputBox.onDidAccept(async () => { | ||
if (inputBox.validationMessage) { return; } | ||
if (inputBox.value === currentAppName) { return; } | ||
if (inputBox.value === "") { return; } | ||
await config.setAppName(inputBox.value); | ||
inputBox.hide(); | ||
}); | ||
inputBox.onDidTriggerButton(async (btn) => { | ||
if (btn === deleteCurrentNameButton) { | ||
await config.setAppName(undefined); | ||
} | ||
inputBox.hide(); | ||
}); | ||
inputBox.onDidChangeValue(value => { | ||
const regex = /^[a-z0-9-~][a-z0-9-._~]*$/; | ||
inputBox.validationMessage = regex.test(value) ? "" : "Invalid app name"; | ||
}); | ||
inputBox.show(); | ||
} |
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