diff --git a/packages/plugin-ext/src/common/plugin-api-rpc.ts b/packages/plugin-ext/src/common/plugin-api-rpc.ts index ea99203293ff6..a0af46bf259f5 100644 --- a/packages/plugin-ext/src/common/plugin-api-rpc.ts +++ b/packages/plugin-ext/src/common/plugin-api-rpc.ts @@ -919,6 +919,7 @@ export interface ScmMain { $setInputBoxValue(sourceControlHandle: number, value: string): void; $setInputBoxPlaceholder(sourceControlHandle: number, placeholder: string): void; $setInputBoxVisible(sourceControlHandle: number, visible: boolean): void; + $setInputBoxEnabled(sourceControlHandle: number, enabled: boolean): void; } export interface SourceControlProviderFeatures { diff --git a/packages/plugin-ext/src/main/browser/scm-main.ts b/packages/plugin-ext/src/main/browser/scm-main.ts index 280471cb2d73e..665a3e95bd551 100644 --- a/packages/plugin-ext/src/main/browser/scm-main.ts +++ b/packages/plugin-ext/src/main/browser/scm-main.ts @@ -440,4 +440,14 @@ export class ScmMainImpl implements ScmMain { repository.input.visible = visible; } + + $setInputBoxEnabled(sourceControlHandle: number, enabled: boolean): void { + const repository = this.repositories.get(sourceControlHandle); + + if (!repository) { + return; + } + + repository.input.enabled = enabled; + } } diff --git a/packages/plugin-ext/src/plugin/scm.ts b/packages/plugin-ext/src/plugin/scm.ts index 200326b713716..d13c6ef4e8c21 100644 --- a/packages/plugin-ext/src/plugin/scm.ts +++ b/packages/plugin-ext/src/plugin/scm.ts @@ -322,6 +322,17 @@ export class ScmInputBoxImpl implements theia.SourceControlInputBox { this._visible = visible; } + private _enabled: boolean; + + get enabled(): boolean { + return this._enabled; + } + + set enabled(enabled: boolean) { + this.proxy.$setInputBoxEnabled(this.sourceControlHandle, enabled); + this._enabled = enabled; + } + private _validateInput: ValidateInput | undefined; get validateInput(): ValidateInput | undefined { diff --git a/packages/plugin/src/theia.d.ts b/packages/plugin/src/theia.d.ts index 27f95c00cce24..53744b31e56fa 100644 --- a/packages/plugin/src/theia.d.ts +++ b/packages/plugin/src/theia.d.ts @@ -10802,6 +10802,11 @@ export module '@theia/plugin' { * Controls whether the input box is visible (default is true). */ visible: boolean; + + /** + * Controls whether the input box is enabled (default is `true`). + */ + enabled: boolean; } interface QuickDiffProvider { diff --git a/packages/scm/src/browser/scm-commit-widget.tsx b/packages/scm/src/browser/scm-commit-widget.tsx index 21e8613dbac93..917c2870e4d8c 100644 --- a/packages/scm/src/browser/scm-commit-widget.tsx +++ b/packages/scm/src/browser/scm-commit-widget.tsx @@ -138,6 +138,7 @@ export class ScmCommitWidget extends ReactWidget implements StatefulWidget { spellCheck={false} autoFocus={true} value={input.value} + disabled={!input.enabled} onChange={this.setInputValue} ref={this.inputRef} rows={1} diff --git a/packages/scm/src/browser/scm-input.ts b/packages/scm/src/browser/scm-input.ts index 42f291d9c7918..9ca807ff54a68 100644 --- a/packages/scm/src/browser/scm-input.ts +++ b/packages/scm/src/browser/scm-input.ts @@ -36,14 +36,15 @@ export interface ScmInputValidator { } export interface ScmInputOptions { - placeholder?: string - validator?: ScmInputValidator - visible?: boolean + placeholder?: string; + validator?: ScmInputValidator; + visible?: boolean; + enabled?: boolean; } export interface ScmInputData { - value?: string - issue?: ScmInputIssue + value?: string; + issue?: ScmInputIssue; } export class ScmInput implements Disposable { @@ -108,6 +109,19 @@ export class ScmInput implements Disposable { this.validate(); } + protected _enabled = this.options.enabled ?? true; + get enabled(): boolean { + return this._enabled; + } + set enabled(enabled: boolean) { + if (this._enabled === enabled) { + return; + } + this._enabled = enabled; + this.fireDidChange(); + this.validate(); + } + protected _issue: ScmInputIssue | undefined; get issue(): ScmInputIssue | undefined { return this._issue;