From 520c0bda80a4367425161f386c42c9f8f1e73126 Mon Sep 17 00:00:00 2001 From: worksofliam Date: Fri, 11 Aug 2023 12:18:46 -0400 Subject: [PATCH] Improve source code settings with more context --- src/api/CustomUI.ts | 13 ++++++++++--- src/webviews/settings/index.ts | 10 ++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/api/CustomUI.ts b/src/api/CustomUI.ts index c4cce9ebb..d3477818c 100644 --- a/src/api/CustomUI.ts +++ b/src/api/CustomUI.ts @@ -45,9 +45,10 @@ export class Section { return this; } - addCheckbox(id: string, label: string, description?: string, checked?: boolean) { + addCheckbox(id: string, label: string, description?: string, checked?: boolean, readonly?: boolean) { const checkbox = new Field('checkbox', id, label, description); checkbox.default = checked ? 'checked' : ''; + checkbox.readonly = readonly; this.addField(checkbox); return this; } @@ -485,7 +486,13 @@ export class Field { case `checkbox`: return /* html */` - ${this.label} + + ${this.readonly ? `disabled` : ``} + ${this.label} + ${this.renderDescription()} `; @@ -532,7 +539,7 @@ export class Field { case `paragraph`: return /* html */` - ${this.label} + ${this.label} `; case `file`: diff --git a/src/webviews/settings/index.ts b/src/webviews/settings/index.ts index c235a5f0f..5e1a7cbed 100644 --- a/src/webviews/settings/index.ts +++ b/src/webviews/settings/index.ts @@ -64,11 +64,18 @@ export class SettingsUI { .addCheckbox(`autoClearTempData`, `Clear temporary data automatically`, `Automatically clear temporary data in the chosen temporary library when it's done with and on startup. Deletes all *FILE objects that start with O_ in the chosen temporary library.`, config.autoClearTempData) .addCheckbox(`autoSortIFSShortcuts`, `Sort IFS shortcuts automatically`, `Automatically sort the shortcuts in IFS browser when shortcut is added or removed.`, config.autoSortIFSShortcuts); + const sqlIsEnabled = config.enableSQL; + const sourceTab = new Section(); sourceTab + .addCheckbox(`readOnlyMode`, `Read only mode`, `When enabled, saving will be disabled for source members and IFS files.`, config.readOnlyMode) + .addHorizontalRule() + .addParagraph(`${sqlIsEnabled ? `SQL is enabled.` : `SQL is disabled.`} Source ASP and Source file CCSID are only used when SQL disabled and source dates are not enabled.`) .addInput(`sourceASP`, `Source ASP`, `If source files live within a specific ASP, please specify it here. Leave blank otherwise. You can ignore this if you have access to QSYS2.ASP_INFO as Code for IBM i will fetch ASP information automatically.`, { default: config.sourceASP }) .addInput(`sourceFileCCSID`, `Source file CCSID`, `The CCSID of source files on your system. You should only change this setting from *FILE if you have a source file that is 65535 - otherwise use *FILE. Note that this config is used to fetch all members. If you have any source files using 65535, you have bigger problems.`, { default: config.sourceFileCCSID, minlength: 1, maxlength: 5 }) - .addCheckbox(`enableSourceDates`, `Enable Source Dates`, `When enabled, source dates will be retained and updated when editing source members. Requires restart when changed.`, config.enableSourceDates) + .addHorizontalRule() + .addParagraph(`${sqlIsEnabled ? `SQL is enabled.` : `SQL is disabled.`} Source dates are only supported when SQL is enabled.`) + .addCheckbox(`enableSourceDates`, `Enable Source Dates`, `When enabled, source dates will be retained and updated when editing source members. Requires restart when changed.`, config.enableSourceDates, !sqlIsEnabled) .addSelect(`sourceDateMode`, `Source date tracking mode`, [ { selected: config.sourceDateMode === `edit`, @@ -84,7 +91,6 @@ export class SettingsUI { }, ], `Determine which method should be used to track changes while editing source members.`) .addCheckbox(`sourceDateGutter`, `Source Dates in Gutter`, `When enabled, source dates will be displayed in the gutter.`, config.sourceDateGutter) - .addCheckbox(`readOnlyMode`, `Read only mode`, `When enabled, saving will be disabled for source members and IFS files.`, config.readOnlyMode); const terminalsTab = new Section(); if (connection && connection.remoteFeatures.tn5250) {