Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added "enabled" field to SourceControlInputBox for vscode api. #12069

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/plugin-ext/src/common/plugin-api-rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
10 changes: 10 additions & 0 deletions packages/plugin-ext/src/main/browser/scm-main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
11 changes: 11 additions & 0 deletions packages/plugin-ext/src/plugin/scm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions packages/plugin/src/theia.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions packages/scm/src/browser/scm-commit-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
24 changes: 19 additions & 5 deletions packages/scm/src/browser/scm-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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;
Expand Down