Skip to content

Commit

Permalink
feat(scm): add visibility variable in plugin API
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinK-9 authored and xai committed Jul 12, 2022
1 parent d29ac06 commit f1b9175
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 0 deletions.
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 @@ -871,6 +871,7 @@ export interface ScmMain {

$setInputBoxValue(sourceControlHandle: number, value: string): void;
$setInputBoxPlaceholder(sourceControlHandle: number, placeholder: string): void;
$setInputBoxVisible(sourceControlHandle: number, visible: 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 @@ -430,4 +430,14 @@ export class ScmMainImpl implements ScmMain {

repository.input.placeholder = placeholder;
}

$setInputBoxVisible(sourceControlHandle: number, visible: boolean): void {
const repository = this.repositories.get(sourceControlHandle);

if (!repository) {
return;
}

repository.input.visible = visible;
}
}
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 @@ -311,6 +311,17 @@ export class ScmInputBoxImpl implements theia.SourceControlInputBox {
this._placeholder = placeholder;
}

private _visible: boolean = true;

get visible(): boolean {
return this._visible;
}

set visible(visible: boolean) {
this.proxy.$setInputBoxVisible(this.sourceControlHandle, visible);
this._visible = visible;
}

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 @@ -9609,6 +9609,11 @@ export module '@theia/plugin' {
* A string to show as place holder in the input box to guide the user.
*/
placeholder: string;

/**
* Controls whether the input box is visible (default is true).
*/
visible: boolean;
}

interface QuickDiffProvider {
Expand Down
14 changes: 14 additions & 0 deletions packages/scm/src/browser/scm-input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface ScmInputValidator {
export interface ScmInputOptions {
placeholder?: string
validator?: ScmInputValidator
visible?: boolean
}

export interface ScmInputData {
Expand Down Expand Up @@ -94,6 +95,19 @@ export class ScmInput implements Disposable {
this.validate();
}

protected _visible = this.options.visible;
get visible(): boolean {
return this._visible ?? true;
}
set visible(visible: boolean) {
if (this.visible === visible) {
return;
}
this._visible = visible;
this.fireDidChange();
this.validate();
}

protected _issue: ScmInputIssue | undefined;
get issue(): ScmInputIssue | undefined {
return this._issue;
Expand Down

0 comments on commit f1b9175

Please sign in to comment.