Skip to content
This repository has been archived by the owner on Apr 1, 2020. It is now read-only.

Commit

Permalink
Feature/add git commit functionality (#2441)
Browse files Browse the repository at this point in the history
As part of fleshing out the VCS this pr adds the ability to commit a file using the git sidebar.

Additions:
* Menu command toggle vcs visibility
* Recent Commits Section: commits made whilst in oni (later might be preferable to get a git log rather than commits from oni)

* Commiting: see below

![vcs_commit](https://user-images.githubusercontent.com/22454918/43024011-bd3e27ac-8c64-11e8-8d2e-944047d7ed8d.gif)
  • Loading branch information
akinsho committed Jul 24, 2018
1 parent 4ce7b50 commit ecbd4af
Show file tree
Hide file tree
Showing 35 changed files with 1,495 additions and 435 deletions.
12 changes: 10 additions & 2 deletions browser/src/Input/KeyBindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@ export const applyDefaultKeyBindings = (oni: Oni.Plugin.Api, config: Configurati
editors.activeEditor.mode === "insert" || editors.activeEditor.mode === "cmdline_normal"

const oniWithSidebar = oni as Oni.Plugin.Api & ISidebar
const isExplorerActive = () =>
oniWithSidebar.sidebar.activeEntryId === "oni.sidebar.explorer" &&
const isSidebarPaneOpen = (paneId: string) =>
oniWithSidebar.sidebar.activeEntryId === paneId &&
oniWithSidebar.sidebar.isFocused &&
!isInsertOrCommandMode() &&
!isMenuOpen()

const isExplorerActive = () => isSidebarPaneOpen("oni.sidebar.explorer")
const isVCSActive = () => isSidebarPaneOpen("oni.sidebar.vcs")

const isMenuOpen = () => menu.isMenuOpen()

if (Platform.isMac()) {
Expand Down Expand Up @@ -159,4 +162,9 @@ export const applyDefaultKeyBindings = (oni: Oni.Plugin.Api, config: Configurati
input.bind("j", "browser.scrollDown")
input.bind("h", "browser.scrollLeft")
input.bind("l", "browser.scrollRight")

// VCS
input.bind("e", "vcs.openFile", isVCSActive)
input.bind("<c-r>", "vcs.refresh", isVCSActive)
input.bind("?", "vcs.showHelp", isVCSActive)
}
4 changes: 4 additions & 0 deletions browser/src/Services/Sidebar/SidebarStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ export class SidebarManager {
return this._contentSplit.isFocused
}

get isVisible(): boolean {
return this._contentSplit.isVisible
}

public get store(): Store<ISidebarState> {
return this._store
}
Expand Down
30 changes: 23 additions & 7 deletions browser/src/Services/VersionControl/VersionControlManager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as React from "react"

import { store, SupportedProviders, VersionControlPane, VersionControlProvider } from "./"
import { Notifications } from "./../../Services/Notifications"
import { Branch } from "./../../UI/components/VersionControl"
import { Branch } from "./../../UI/components/VersionControl/Branch"
import { MenuManager } from "./../Menu"
import { SidebarManager } from "./../Sidebar"
import { IWorkspace } from "./../Workspace"
Expand All @@ -15,6 +15,7 @@ interface ISendNotificationsArgs {
detail: string
level: "info" | "warn"
title: string
expiration?: number
}

export type ISendVCSNotification = (args: ISendNotificationsArgs) => void
Expand Down Expand Up @@ -62,11 +63,11 @@ export class VersionControlManager {
}

// Use arrow function to maintain this binding of sendNotification
public sendNotification: ISendVCSNotification = ({ detail, level, title }) => {
public sendNotification: ISendVCSNotification = ({ expiration = 3_000, ...args }) => {
const notification = this._notifications.createItem()
notification.setContents(title, detail)
notification.setExpiration(3_000)
notification.setLevel(level)
notification.setContents(args.title, args.detail)
notification.setExpiration(expiration)
notification.setLevel(args.level)
notification.show()
}

Expand Down Expand Up @@ -140,6 +141,8 @@ export class VersionControlManager {
this._workspace,
this._vcsProvider,
this.sendNotification,
this._commands,
this._sidebar,
store,
)
this._sidebar.add("code-fork", vcsPane)
Expand Down Expand Up @@ -170,15 +173,27 @@ export class VersionControlManager {
}

private _registerCommands = () => {
const toggleVCS = () => {
this._sidebar.toggleVisibilityById("oni.sidebar.vcs")
}

this._commands.registerCommand({
command: "vcs.sidebar.toggle",
name: "Version Control: Toggle Visibility",
detail: "Toggles the vcs pane in the sidebar",
execute: toggleVCS,
enabled: () => this._configuration.getValue("experimental.vcs.sidebar"),
})

this._commands.registerCommand({
command: `oni.${this._vcs}.fetch`,
command: `vcs.fetch`,
name: "Fetch the selected branch",
detail: "",
execute: this._fetchBranch,
})

this._commands.registerCommand({
command: `oni.${this._vcs}.branches`,
command: `vcs.branches`,
name: `Local ${capitalize(this._vcs)} Branches`,
detail: "Open a menu with a list of all local branches",
execute: this._createBranchList,
Expand All @@ -194,6 +209,7 @@ export class VersionControlManager {
}

try {
// FIXME: there is race condition on deactivation of the provider
const branch = await this._vcsProvider.getBranch()
const diff = await this._vcsProvider.getDiff()

Expand Down
Loading

0 comments on commit ecbd4af

Please sign in to comment.