Skip to content

Commit

Permalink
Improve source code settings with more context
Browse files Browse the repository at this point in the history
  • Loading branch information
worksofliam committed Aug 11, 2023
1 parent 1349397 commit 520c0bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
13 changes: 10 additions & 3 deletions src/api/CustomUI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -485,7 +486,13 @@ export class Field {
case `checkbox`:
return /* html */`
<vscode-form-group variant="settings-group">
<vscode-checkbox id="${this.id}" name="${this.id}" ${this.default === `checked` ? `checked` : ``}><vscode-label>${this.label}</vscode-label></vscode-checkbox>
<vscode-checkbox
id="${this.id}"
name="${this.id}"
${this.default === `checked` ? `checked` : ``}>
${this.readonly ? `disabled` : ``}
<vscode-label>${this.label}</vscode-label>
</vscode-checkbox>
${this.renderDescription()}
</vscode-form-group>`;

Expand Down Expand Up @@ -532,7 +539,7 @@ export class Field {
case `paragraph`:
return /* html */`
<vscode-form-group variant="settings-group">
<vscode-form-helper>${this.label}</vscode-form-helper>
<span>${this.label}</span>
</vscode-form-group>`;

case `file`:
Expand Down
10 changes: 8 additions & 2 deletions src/webviews/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>*FILE</code> objects that start with <code>O_</code> 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 <code>QSYS2.ASP_INFO</code> 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 <code>*FILE</code> if you have a source file that is 65535 - otherwise use <code>*FILE</code>. 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`,
Expand All @@ -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) {
Expand Down

0 comments on commit 520c0bd

Please sign in to comment.