scm viewlet title actions
parent
ba1ff30b57
commit
91800a45c2
|
@ -20,7 +20,25 @@
|
|||
"watch": "gulp watch-extension:git"
|
||||
},
|
||||
"contributes": {
|
||||
"commands": [],
|
||||
"commands": [
|
||||
{
|
||||
"command": "git.refresh",
|
||||
"title": "Git: Refresh",
|
||||
"category": "Git",
|
||||
"icon": {
|
||||
"light": "resources/icons/light/refresh.svg",
|
||||
"dark": "resources/icons/dark/refresh.svg"
|
||||
}
|
||||
}
|
||||
],
|
||||
"menus": {
|
||||
"scm/title": [
|
||||
{
|
||||
"command": "git.refresh",
|
||||
"group": "navigation"
|
||||
}
|
||||
]
|
||||
},
|
||||
"languages": [
|
||||
{
|
||||
"id": "git-commit",
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M13.451 5.609l-.579-.939-1.068.812-.076.094c-.335.415-.927 1.341-1.124 2.876l-.021.165.033.163.071.345c0 1.654-1.346 3-3 3-.795 0-1.545-.311-2.107-.868-.563-.567-.873-1.317-.873-2.111 0-1.431 1.007-2.632 2.351-2.929v2.926s2.528-2.087 2.984-2.461h.012l3.061-2.582-4.919-4.1h-1.137v2.404c-3.429.318-6.121 3.211-6.121 6.721 0 1.809.707 3.508 1.986 4.782 1.277 1.282 2.976 1.988 4.784 1.988 3.722 0 6.75-3.028 6.75-6.75 0-1.245-.349-2.468-1.007-3.536z" fill="#2D2D30"/><path d="M12.6 6.134l-.094.071c-.269.333-.746 1.096-.91 2.375.057.277.092.495.092.545 0 2.206-1.794 4-4 4-1.098 0-2.093-.445-2.817-1.164-.718-.724-1.163-1.718-1.163-2.815 0-2.206 1.794-4 4-4l.351.025v1.85s1.626-1.342 1.631-1.339l1.869-1.577-3.5-2.917v2.218l-.371-.03c-3.176 0-5.75 2.574-5.75 5.75 0 1.593.648 3.034 1.695 4.076 1.042 1.046 2.482 1.694 4.076 1.694 3.176 0 5.75-2.574 5.75-5.75-.001-1.106-.318-2.135-.859-3.012z" fill="#C5C5C5"/></svg>
|
After Width: | Height: | Size: 986 B |
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16"><path d="M13.451 5.609l-.579-.939-1.068.812-.076.094c-.335.415-.927 1.341-1.124 2.876l-.021.165.033.163.071.345c0 1.654-1.346 3-3 3-.795 0-1.545-.311-2.107-.868-.563-.567-.873-1.317-.873-2.111 0-1.431 1.007-2.632 2.351-2.929v2.926s2.528-2.087 2.984-2.461h.012l3.061-2.582-4.919-4.1h-1.137v2.404c-3.429.318-6.121 3.211-6.121 6.721 0 1.809.707 3.508 1.986 4.782 1.277 1.282 2.976 1.988 4.784 1.988 3.722 0 6.75-3.028 6.75-6.75 0-1.245-.349-2.468-1.007-3.536z" fill="#F6F6F6"/><path d="M12.6 6.134l-.094.071c-.269.333-.746 1.096-.91 2.375.057.277.092.495.092.545 0 2.206-1.794 4-4 4-1.098 0-2.093-.445-2.817-1.164-.718-.724-1.163-1.718-1.163-2.815 0-2.206 1.794-4 4-4l.351.025v1.85s1.626-1.342 1.631-1.339l1.869-1.577-3.5-2.917v2.218l-.371-.03c-3.176 0-5.75 2.574-5.75 5.75 0 1.593.648 3.034 1.695 4.076 1.042 1.046 2.482 1.694 4.076 1.694 3.176 0 5.75-2.574 5.75-5.75-.001-1.106-.318-2.135-.859-3.012z" fill="#424242"/></svg>
|
After Width: | Height: | Size: 986 B |
|
@ -0,0 +1,12 @@
|
|||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import { commands, Disposable } from 'vscode';
|
||||
|
||||
export function registerCommands(): Disposable {
|
||||
return commands.registerCommand('git.refresh', () => console.log('REFRESH'));
|
||||
}
|
|
@ -8,6 +8,7 @@
|
|||
import { scm, ExtensionContext, workspace, Uri } from 'vscode';
|
||||
import * as path from 'path';
|
||||
import { findGit, Git } from './git';
|
||||
import { registerCommands } from './commands';
|
||||
|
||||
export function log(...args: any[]): void {
|
||||
console.log.apply(console, ['git:', ...args]);
|
||||
|
@ -55,6 +56,8 @@ export function activate(context: ExtensionContext): any {
|
|||
}
|
||||
});
|
||||
|
||||
context.subscriptions.push(providerDisposable, contentProvider);
|
||||
const commands = registerCommands();
|
||||
|
||||
context.subscriptions.push(providerDisposable, contentProvider, commands);
|
||||
});
|
||||
}
|
|
@ -32,6 +32,7 @@ namespace schema {
|
|||
case 'editor/context': return MenuId.EditorContext;
|
||||
case 'explorer/context': return MenuId.ExplorerContext;
|
||||
case 'editor/title/context': return MenuId.EditorTitleContext;
|
||||
case 'scm/title': return MenuId.SCMTitle;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -42,6 +42,7 @@ export class MenuId {
|
|||
static readonly EditorContext = new MenuId('3');
|
||||
static readonly ExplorerContext = new MenuId('4');
|
||||
static readonly ProblemsPanelContext = new MenuId('5');
|
||||
static readonly SCMTitle = new MenuId('scm/title');
|
||||
|
||||
constructor(private _id: string) {
|
||||
|
||||
|
|
|
@ -24,9 +24,15 @@ import { CountBadge } from 'vs/base/browser/ui/countBadge/countBadge';
|
|||
import { ISCMService, ISCMResourceGroup, ISCMResource } from 'vs/workbench/services/scm/common/scm';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
|
||||
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
|
||||
import { IMessageService } from 'vs/platform/message/common/message';
|
||||
import { InputBox } from 'vs/base/browser/ui/inputbox/inputBox';
|
||||
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
|
||||
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { IMenuService, MenuId, IMenu } from 'vs/platform/actions/common/actions';
|
||||
import { IAction, IActionItem } from 'vs/base/common/actions';
|
||||
import { createActionItem, fillInActions } from 'vs/platform/actions/browser/menuItemActionItem';
|
||||
|
||||
// TODO@Joao remove
|
||||
import { GitSCMProvider } from 'vs/workbench/parts/git/browser/gitSCMProvider';
|
||||
|
@ -108,23 +114,43 @@ export class SCMViewlet extends Viewlet {
|
|||
|
||||
private static ACCEPT_KEYBINDING = platform.isMacintosh ? 'Cmd+Enter' : 'Ctrl+Enter';
|
||||
|
||||
private currentDimension: Dimension;
|
||||
private cachedDimension: Dimension;
|
||||
private inputBoxContainer: HTMLElement;
|
||||
private inputBox: InputBox;
|
||||
private listContainer: HTMLElement;
|
||||
private list: List<ISCMResourceGroup | ISCMResource>;
|
||||
|
||||
private titleMenu: IMenu;
|
||||
private _titleMenuActions: { primary: IAction[]; secondary: IAction[] };
|
||||
private get titleMenuActions() {
|
||||
if (!this._titleMenuActions) {
|
||||
this._titleMenuActions = { primary: [], secondary: [] };
|
||||
fillInActions(this.titleMenu, this._titleMenuActions);
|
||||
}
|
||||
return this._titleMenuActions;
|
||||
}
|
||||
|
||||
private disposables: IDisposable[] = [];
|
||||
|
||||
constructor(
|
||||
@ITelemetryService telemetryService: ITelemetryService,
|
||||
@ISCMService private scmService: ISCMService,
|
||||
@IInstantiationService private instantiationService: IInstantiationService,
|
||||
@IContextViewService private contextViewService: IContextViewService
|
||||
@IContextViewService private contextViewService: IContextViewService,
|
||||
@IContextKeyService private contextKeyService: IContextKeyService,
|
||||
@IKeybindingService protected keybindingService: IKeybindingService,
|
||||
@IMessageService protected messageService: IMessageService,
|
||||
@IMenuService private menuService: IMenuService
|
||||
) {
|
||||
super(VIEWLET_ID, telemetryService);
|
||||
|
||||
// TODO@Joao
|
||||
scmService.activeProvider = instantiationService.createInstance(GitSCMProvider);
|
||||
|
||||
this.titleMenu = menuService.createMenu(MenuId.SCMTitle, contextKeyService);
|
||||
|
||||
this.disposables.push(this.titleMenu);
|
||||
this.titleMenu.onDidChange(this.onTitleMenuChange, this, this.disposables);
|
||||
}
|
||||
|
||||
create(parent: Builder): TPromise<void> {
|
||||
|
@ -146,7 +172,7 @@ export class SCMViewlet extends Viewlet {
|
|||
.on(this.accept, this, this.disposables);
|
||||
|
||||
chain(this.inputBox.onDidHeightChange)
|
||||
.map(() => this.currentDimension)
|
||||
.map(() => this.cachedDimension)
|
||||
.on(this.layout, this, this.disposables);
|
||||
|
||||
this.listContainer = append(root, $('.scm-status.show-file-icons'));
|
||||
|
@ -163,7 +189,8 @@ export class SCMViewlet extends Viewlet {
|
|||
.on(this.open, this, this.disposables);
|
||||
|
||||
this.update();
|
||||
this.scmService.activeProvider.onChange(() => this.update());
|
||||
this.scmService.activeProvider.onChange(this.update, this, this.disposables);
|
||||
this.disposables.push(this.inputBox, this.list);
|
||||
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
@ -184,12 +211,12 @@ export class SCMViewlet extends Viewlet {
|
|||
this.list.splice(0, this.list.length, ...elements);
|
||||
}
|
||||
|
||||
layout(dimension: Dimension = this.currentDimension): void {
|
||||
layout(dimension: Dimension = this.cachedDimension): void {
|
||||
if (!dimension) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.currentDimension = dimension;
|
||||
this.cachedDimension = dimension;
|
||||
this.inputBox.layout();
|
||||
|
||||
const listHeight = dimension.height - (this.inputBox.height + 12 /* margin */);
|
||||
|
@ -211,6 +238,23 @@ export class SCMViewlet extends Viewlet {
|
|||
this.scmService.activeProvider.open(e);
|
||||
}
|
||||
|
||||
private onTitleMenuChange(): void {
|
||||
this._titleMenuActions = void 0;
|
||||
this.updateTitleArea();
|
||||
}
|
||||
|
||||
getActions(): IAction[] {
|
||||
return this.titleMenuActions.primary;
|
||||
}
|
||||
|
||||
getSecondaryActions(): IAction[] {
|
||||
return this.titleMenuActions.secondary;
|
||||
}
|
||||
|
||||
getActionItem(action: IAction): IActionItem {
|
||||
return createActionItem(action, this.keybindingService, this.messageService);
|
||||
}
|
||||
|
||||
dispose(): void {
|
||||
this.disposables = dispose(this.disposables);
|
||||
super.dispose();
|
||||
|
|
Loading…
Reference in New Issue