Skip to content

Commit e9b16b1

Browse files
committed
Update launch wizard to use dropdowns for log levels
Closes apache#1152
1 parent 57df26c commit e9b16b1

File tree

2 files changed

+37
-7
lines changed

2 files changed

+37
-7
lines changed

src/launchWizard/launchWizard.ts

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ export async function activate(ctx: vscode.ExtensionContext) {
4040
)
4141
}
4242

43+
function getAllowedLogLevels(toLower: boolean = false): string[] {
44+
let logLevels: string[] = []
45+
;['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'].forEach((logLevel) => {
46+
logLevels.push(toLower ? logLevel.toLowerCase() : logLevel)
47+
})
48+
return logLevels
49+
}
50+
4351
// Function to get config values
4452
function getConfigValues(data, configIndex) {
4553
if (data && configIndex !== -1) {
@@ -508,7 +516,30 @@ class LaunchWizard {
508516
})
509517

510518
let dfdlDebugger: DFDLDebugger = defaultValues.dfdlDebugger
519+
let debuggerLogLevelSelect = ''
520+
let debuggerLogLevelTypes = getAllowedLogLevels()
521+
let debuggerLogLevel = dfdlDebugger.logging.level
522+
523+
debuggerLogLevelTypes.forEach((type) => {
524+
if (type === debuggerLogLevel) {
525+
debuggerLogLevelSelect += `<option selected value="${type}">${type}</option>`
526+
} else {
527+
debuggerLogLevelSelect += `<option value="${type}">${type}</option>`
528+
}
529+
})
530+
511531
let dataEditor: DataEditorConfig = defaultValues.dataEditor
532+
let dataEditorLogLevelSelect = ''
533+
let dataEditorLogLevelTypes = getAllowedLogLevels(true)
534+
let dataEditorLogLevel = dataEditor.logging.level
535+
536+
dataEditorLogLevelTypes.forEach((type) => {
537+
if (type === dataEditorLogLevel) {
538+
dataEditorLogLevelSelect += `<option selected value="${type}">${type}</option>`
539+
} else {
540+
dataEditorLogLevelSelect += `<option value="${type}">${type}</option>`
541+
}
542+
})
512543

513544
return `
514545
<!DOCTYPE html>
@@ -600,7 +631,9 @@ class LaunchWizard {
600631
<input class="file-input" value="${dfdlDebugger.logging.file}" id="dfdlDebuggerLogFile">
601632
602633
<p id="dfdlDebuggerLogLevelLabel" style="margin-top: 10px;" class="setting-description">Log Level:</p>
603-
<input class="file-input" value="${dfdlDebugger.logging.level}" id="dfdlDebuggerLogLevel">
634+
<select class="file-input" style="width: 200px;" id="dfdlDebuggerLogLevel">
635+
${debuggerLogLevelSelect}
636+
</select>
604637
</div>
605638
606639
<div id="useExistingServerDiv" class="setting-div" onclick="check('useExistingServer')">
@@ -710,7 +743,9 @@ class LaunchWizard {
710743
<input class="file-input" value="${dataEditor.logging.file}" id="dataEditorLogFile">
711744
712745
<p id="dataEditorLogLevelLabel" style="margin-top: 10px;" class="setting-description">Log Level:</p>
713-
<input class="file-input" value="${dataEditor.logging.level}" id="dataEditorLogLevel">
746+
<select class="file-input" style="width: 200px;" id="dataEditorLogLevel">
747+
${dataEditorLogLevelSelect}
748+
</select>
714749
</div>
715750
716751
<br/>

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -782,11 +782,6 @@
782782
resolved "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz"
783783
integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==
784784

785-
acorn-import-assertions@^1.9.0:
786-
version "1.9.0"
787-
resolved "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.9.0.tgz"
788-
integrity sha512-cmMwop9x+8KFhxvKrKfPYmN6/pKTYYHBqLa0DfvVZcKMJWNyWLnaqND7dx/qn66R7ewM1UX5XMaDVP5wlVTaVA==
789-
790785
acorn-walk@^8.1.1:
791786
version "8.2.0"
792787
resolved "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.2.0.tgz"

0 commit comments

Comments
 (0)