Skip to content

Commit

Permalink
feat(scm): add visibility variable in plugin API
Browse files Browse the repository at this point in the history
Co-authored-by: Olaf Lessenich <olessenich@eclipsesource.com>

Contributed on behalf of STMicroelectronics

Signed-off-by: Olaf Lessenich <olessenich@eclipsesource.com>
  • Loading branch information
KevinK-9 authored and xai committed Jul 12, 2022
1 parent d29ac06 commit 1e3fad0
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

- [Previous Changelogs](https://github.com/eclipse-theia/theia/tree/master/doc/changelogs/)

## v1.28.0 - Unreleased
- [plugin] added support for property `SourceControlInputBox#visible` [#11412](https://github.com/eclipse-theia/theia/pull/11412) - Contributed on behalf of STMicroelectronics

## v1.27.0 - 6/30/2022

- [core] added better styling for active sidepanel borders [#11330](https://github.com/eclipse-theia/theia/pull/11330)
Expand Down
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
6 changes: 4 additions & 2 deletions packages/scm/src/browser/scm-commit-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export class ScmCommitWidget extends ReactWidget implements StatefulWidget {

const keybinding = this.keybindings.acceleratorFor(this.keybindings.getKeybindingsForCommand('scm.acceptInput')[0]).join('+');
const message = format(input.placeholder || '', keybinding);
return <div className={ScmCommitWidget.Styles.INPUT_MESSAGE_CONTAINER}>
const textArea = input.visible ?
<TextareaAutosize
className={`${ScmCommitWidget.Styles.INPUT_MESSAGE} theia-input theia-scm-input-message-${validationStatus}`}
id={ScmCommitWidget.Styles.INPUT_MESSAGE}
Expand All @@ -142,7 +142,9 @@ export class ScmCommitWidget extends ReactWidget implements StatefulWidget {
ref={this.inputRef}
rows={1}
maxRows={6} /* from VS Code */>
</TextareaAutosize>
</TextareaAutosize> : '';
return <div className={ScmCommitWidget.Styles.INPUT_MESSAGE_CONTAINER}>
{textArea}
<div
className={
`${ScmCommitWidget.Styles.VALIDATION_MESSAGE} ${ScmCommitWidget.Styles.NO_SELECT}
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 1e3fad0

Please sign in to comment.