Skip to content

Commit

Permalink
fixup! Add Scm component and bind Git to it
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Vinokur <ivinokur@redhat.com>
  • Loading branch information
vinokurig committed May 21, 2019
1 parent 3bed733 commit 48e0599
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 17 deletions.
4 changes: 2 additions & 2 deletions packages/git/src/browser/git-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ export class GitCommands implements Disposable {
});
}

async openChange(change: GitFileChange, options?: EditorOpenerOptions): Promise<EditorWidget | undefined> {
async openChange(change: GitFileChange, options?: EditorOpenerOptions): Promise<EditorWidget> {
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<void> {
Expand Down
12 changes: 6 additions & 6 deletions packages/git/src/browser/git-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ export class GitContribution implements
);
}

private async getGroups(status: WorkingDirectoryStatus | undefined, provider: ScmProvider): Promise<ScmResourceGroup[]> {
protected async getGroups(status: WorkingDirectoryStatus | undefined, provider: ScmProvider): Promise<ScmResourceGroup[]> {
const groups: ScmResourceGroup[] = [];
const stagedChanges = [];
const unstagedChanges = [];
Expand Down Expand Up @@ -358,7 +358,7 @@ export class GitContribution implements
return groups;
}

private async getGroup(label: string, provider: ScmProvider, changes: GitFileChange[]): Promise<ScmResourceGroup> {
protected async getGroup(label: string, provider: ScmProvider, changes: GitFileChange[]): Promise<ScmResourceGroup> {
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 = {
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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<void>();
Expand Down Expand Up @@ -770,7 +770,7 @@ export class GitContribution implements
}

async openChanges(widget?: Widget): Promise<EditorWidget | undefined> {
const options = await this.getOpenChangesOptions(widget);
const options = this.getOpenChangesOptions(widget);
if (options) {
return this.gitCommands.openChange(options.change, options.options);
}
Expand Down
6 changes: 6 additions & 0 deletions packages/plugin-ext/src/plugin/plugin-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {});
}
};

Expand Down
8 changes: 4 additions & 4 deletions packages/plugin-ext/src/plugin/scm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 };
}));
}

Expand Down
5 changes: 4 additions & 1 deletion packages/scm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions packages/scm/src/browser/scm-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ export class ScmWidget extends ScmNavigableListWidget<ScmResource> 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);
Expand All @@ -336,7 +336,7 @@ export class ScmWidget extends ScmNavigableListWidget<ScmResource> 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 <div className='buttons'>
Expand All @@ -350,7 +350,7 @@ export class ScmWidget extends ScmNavigableListWidget<ScmResource> 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 = {
Expand Down Expand Up @@ -549,7 +549,7 @@ class ScmResourceGroupsContainer extends React.Component<ScmResourceGroupsContai
);
}

private renderGroup(group: ScmResourceGroup): React.ReactNode {
protected renderGroup(group: ScmResourceGroup): React.ReactNode {
if (group.resources.length > 0) {
return <ScmResourceGroupContainer
group={group}
Expand Down

0 comments on commit 48e0599

Please sign in to comment.