From 48e059908090d2a730bd17cc5fa2c8318a3a231b Mon Sep 17 00:00:00 2001 From: Igor Vinokur Date: Tue, 21 May 2019 11:39:34 +0300 Subject: [PATCH] fixup! Add Scm component and bind Git to it Signed-off-by: Igor Vinokur --- packages/git/src/browser/git-commands.ts | 4 ++-- packages/git/src/browser/git-contribution.ts | 12 ++++++------ packages/plugin-ext/src/plugin/plugin-context.ts | 6 ++++++ packages/plugin-ext/src/plugin/scm.ts | 8 ++++---- packages/scm/package.json | 5 ++++- packages/scm/src/browser/scm-widget.tsx | 8 ++++---- 6 files changed, 26 insertions(+), 17 deletions(-) diff --git a/packages/git/src/browser/git-commands.ts b/packages/git/src/browser/git-commands.ts index a8fb0ab98a88f..a98bdcb8ccdcf 100644 --- a/packages/git/src/browser/git-commands.ts +++ b/packages/git/src/browser/git-commands.ts @@ -120,9 +120,9 @@ export class GitCommands implements Disposable { }); } - async openChange(change: GitFileChange, options?: EditorOpenerOptions): Promise { + async openChange(change: GitFileChange, options?: EditorOpenerOptions): Promise { const uriToOpen = this.getUriToOpen(change); - return this.editorManager.open(await uriToOpen, options); + return this.editorManager.open(uriToOpen, options); } async doCommit(repository?: Repository, options?: 'amend' | 'sign-off', message: string = this.scmWidget.messageInput.value): Promise { diff --git a/packages/git/src/browser/git-contribution.ts b/packages/git/src/browser/git-contribution.ts index 56efc8ed8d47a..0a74010ae402f 100644 --- a/packages/git/src/browser/git-contribution.ts +++ b/packages/git/src/browser/git-contribution.ts @@ -326,7 +326,7 @@ export class GitContribution implements ); } - private async getGroups(status: WorkingDirectoryStatus | undefined, provider: ScmProvider): Promise { + protected async getGroups(status: WorkingDirectoryStatus | undefined, provider: ScmProvider): Promise { const groups: ScmResourceGroup[] = []; const stagedChanges = []; const unstagedChanges = []; @@ -358,7 +358,7 @@ export class GitContribution implements return groups; } - private async getGroup(label: string, provider: ScmProvider, changes: GitFileChange[]): Promise { + protected async getGroup(label: string, provider: ScmProvider, changes: GitFileChange[]): Promise { const sort = (l: ScmResource, r: ScmResource) => l.sourceUri.toString().substring(l.sourceUri.toString().lastIndexOf('/')).localeCompare(r.sourceUri.toString().substring(r.sourceUri.toString().lastIndexOf('/'))); const group: ScmResourceGroup = { @@ -390,7 +390,7 @@ export class GitContribution implements } }; const open = async () => { - const uriToOpen = await this.gitCommands.getUriToOpen(change); + const uriToOpen = this.gitCommands.getUriToOpen(change); this.editorManager.open(uriToOpen, { mode: 'reveal' }); }; return resource; @@ -401,7 +401,7 @@ export class GitContribution implements } /** Detect and handle added or removed repositories. */ - private checkNewOrRemovedRepositories(): void { + protected checkNewOrRemovedRepositories(): void { const added = this.repositoryProvider .allRepositories @@ -426,7 +426,7 @@ export class GitContribution implements } } - private registerScmProvider(repository: Repository): ScmRepository { + protected registerScmProvider(repository: Repository): ScmRepository { const uri = repository.localUri; const disposableCollection: Disposable[] = []; const onDidChangeResourcesEmitter = new Emitter(); @@ -770,7 +770,7 @@ export class GitContribution implements } async openChanges(widget?: Widget): Promise { - const options = await this.getOpenChangesOptions(widget); + const options = this.getOpenChangesOptions(widget); if (options) { return this.gitCommands.openChange(options.change, options.options); } diff --git a/packages/plugin-ext/src/plugin/plugin-context.ts b/packages/plugin-ext/src/plugin/plugin-context.ts index 22e856ec601ed..ae6f1fdb6d1b7 100644 --- a/packages/plugin-ext/src/plugin/plugin-context.ts +++ b/packages/plugin-ext/src/plugin/plugin-context.ts @@ -363,6 +363,12 @@ export function createAPIFactory( console.error('Progress location \'SourceControl\' is not supported.'); }); } + }, + registerDecorationProvider(provider: DecorationProvider): theia.Disposable { + return decorationsExt.registerDecorationProvider(provider); + }, + registerUriHandler(handler: theia.UriHandler): theia.Disposable { + return new Disposable(() => {}); } }; diff --git a/packages/plugin-ext/src/plugin/scm.ts b/packages/plugin-ext/src/plugin/scm.ts index 1ae1af0a9eb87..d305bfcaa4895 100644 --- a/packages/plugin-ext/src/plugin/scm.ts +++ b/packages/plugin-ext/src/plugin/scm.ts @@ -305,11 +305,11 @@ class SourceControlResourceGroupImpl implements theia.SourceControlResourceGroup this.resourceStatesMap.clear(); this.proxy.$updateResourceState(this.sourceControlHandle, this.handle, resources.map(resourceState => { const handle = SourceControlResourceGroupImpl.resourceHandle ++; - let command; + let resourceCommand; let decorations; if (resourceState.command) { - const { id, title, tooltip } = resourceState.command; - command = { id : id ? id : '', title: title ? title : '', tooltip }; + const { command, title, tooltip } = resourceState.command; + resourceCommand = { id : command ? command : '', title: title ? title : '', tooltip }; } if (resourceState.decorations) { const { strikeThrough, faded, tooltip, light, dark } = resourceState.decorations; @@ -323,7 +323,7 @@ class SourceControlResourceGroupImpl implements theia.SourceControlResourceGroup this.resourceStatesMap.set(handle, resourceState); // tslint:disable-next-line:no-any const resource: any = resourceState; - return { handle, resourceUri: resourceState.resourceUri.path, command, decorations, letter: resource.letter, colorId: resource.color.id }; + return { handle, resourceUri: resourceState.resourceUri.path, command: resourceCommand, decorations, letter: resource.letter, colorId: resource.color.id }; })); } diff --git a/packages/scm/package.json b/packages/scm/package.json index eb0a76ce9ed4b..ef59f4ec677e5 100644 --- a/packages/scm/package.json +++ b/packages/scm/package.json @@ -6,7 +6,10 @@ "@theia/core": "^0.6.0", "@theia/editor": "^0.6.0", "@theia/filesystem": "^0.6.0", - "@theia/plugin-ext": "^0.6.0" + "@theia/navigator": "^0.6.0", + "@theia/plugin-ext": "^0.6.0", + "@types/diff": "^3.2.2", + "ts-md5": "^1.2.2" }, "publishConfig": { "access": "public" diff --git a/packages/scm/src/browser/scm-widget.tsx b/packages/scm/src/browser/scm-widget.tsx index aae53e6a8219e..58a527e263f5f 100644 --- a/packages/scm/src/browser/scm-widget.tsx +++ b/packages/scm/src/browser/scm-widget.tsx @@ -312,7 +312,7 @@ export class ScmWidget extends ScmNavigableListWidget implements St } } - private renderButton(item: ScmTitleItem): React.ReactNode { + protected renderButton(item: ScmTitleItem): React.ReactNode { const command = this.commandRegistry.getCommand(item.command); if (item.when) { const provider = item.when.substring(item.when.indexOf('scmProvider == ') + 15); @@ -336,7 +336,7 @@ export class ScmWidget extends ScmNavigableListWidget implements St } } - private renderInputCommand(repository: ScmRepository | undefined): React.ReactNode { + protected renderInputCommand(repository: ScmRepository | undefined): React.ReactNode { if (repository && repository.provider.acceptInputCommand) { const command = repository.provider.acceptInputCommand; return
@@ -350,7 +350,7 @@ export class ScmWidget extends ScmNavigableListWidget implements St } } - private executeInputCommand(commandId: string, providerId: number): void { + protected executeInputCommand(commandId: string, providerId: number): void { this.inputCommandMessageValidation = undefined; if (this.message.trim().length === 0) { this.inputCommandMessageValidation = { @@ -549,7 +549,7 @@ class ScmResourceGroupsContainer extends React.Component 0) { return