-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show file changes as a tree in Source Control view
Signed-off-by: Nigel Westbury <nigelipse@miegel.org>
- Loading branch information
Showing
19 changed files
with
1,719 additions
and
724 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/******************************************************************************** | ||
* Copyright (C) 2020 Arm and others. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v. 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0. | ||
* | ||
* This Source Code may also be made available under the following Secondary | ||
* Licenses when the conditions for such availability set forth in the Eclipse | ||
* Public License v. 2.0 are satisfied: GNU General Public License, version 2 | ||
* with the GNU Classpath Exception which is available at | ||
* https://www.gnu.org/software/classpath/license.html. | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 | ||
********************************************************************************/ | ||
|
||
import { injectable, inject } from 'inversify'; | ||
import { Message } from '@phosphor/messaging'; | ||
import { SelectionService } from '@theia/core/lib/common'; | ||
import * as React from 'react'; | ||
import { | ||
ContextMenuRenderer, ReactWidget, LabelProvider, KeybindingRegistry, StorageService | ||
} from '@theia/core/lib/browser'; | ||
import { ScmService } from './scm-service'; | ||
import { ScmAvatarService } from './scm-avatar-service'; | ||
import { ScmAmendComponent } from './scm-amend-component'; | ||
|
||
@injectable() | ||
export class ScmAmendWidget extends ReactWidget { | ||
|
||
static ID = 'scm-amend-widget'; | ||
|
||
@inject(ScmService) protected readonly scmService: ScmService; | ||
@inject(ScmAvatarService) protected readonly avatarService: ScmAvatarService; | ||
@inject(StorageService) protected readonly storageService: StorageService; | ||
@inject(SelectionService) protected readonly selectionService: SelectionService; | ||
@inject(LabelProvider) protected readonly labelProvider: LabelProvider; | ||
@inject(KeybindingRegistry) protected readonly keybindings: KeybindingRegistry; | ||
|
||
protected shouldScrollToRow = true; | ||
|
||
constructor( | ||
@inject(ContextMenuRenderer) protected readonly contextMenuRenderer: ContextMenuRenderer, | ||
) { | ||
super(); | ||
this.scrollOptions = { | ||
suppressScrollX: true, | ||
minScrollbarLength: 35 | ||
}; | ||
this.addClass('theia-scm-commit-container'); | ||
this.id = ScmAmendWidget.ID; | ||
} | ||
|
||
protected onUpdateRequest(msg: Message): void { | ||
if (!this.isAttached || !this.isVisible) { | ||
return; | ||
} | ||
super.onUpdateRequest(msg); | ||
} | ||
|
||
protected render(): React.ReactNode { | ||
const repository = this.scmService.selectedRepository; | ||
if (repository && repository.provider.amendSupport) { | ||
return React.createElement( | ||
ScmAmendComponent, | ||
{ | ||
key: `amend:${repository.provider.rootUri}`, | ||
style: { flexGrow: 0 }, | ||
repository: repository, | ||
scmAmendSupport: repository.provider.amendSupport, | ||
setCommitMessage: this.setInputValue, | ||
avatarService: this.avatarService, | ||
storageService: this.storageService, | ||
} | ||
); | ||
} | ||
} | ||
|
||
protected setInputValue = (event: React.FormEvent<HTMLTextAreaElement> | React.ChangeEvent<HTMLTextAreaElement> | string) => { | ||
const repository = this.scmService.selectedRepository; | ||
if (repository) { | ||
repository.input.value = typeof event === 'string' ? event : event.currentTarget.value; | ||
} | ||
}; | ||
|
||
} |
Oops, something went wrong.