From 6a29833501593b37f92334bd510a576c23fc7967 Mon Sep 17 00:00:00 2001 From: Eric Amodio Date: Thu, 13 Oct 2022 12:45:01 -0400 Subject: [PATCH] Adds confirm if skipConfirmations is unset Avoids `as` casts Removes unneeded imports --- src/configuration.ts | 9 +++++++++ src/plus/webviews/graph/graphWebview.ts | 26 ++++++++++++++++---------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/src/configuration.ts b/src/configuration.ts index 4122e9f..bfba157 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -120,6 +120,15 @@ export class Configuration { return workspace.getConfiguration(undefined, scope).inspect(section); } + isUnset(section: T, scope?: ConfigurationScope | null): boolean { + const inspect = configuration.inspect(section, scope)!; + if (inspect.workspaceFolderValue !== undefined) return false; + if (inspect.workspaceValue !== undefined) return false; + if (inspect.globalValue !== undefined) return false; + + return true; + } + async migrate( from: string, to: T, diff --git a/src/plus/webviews/graph/graphWebview.ts b/src/plus/webviews/graph/graphWebview.ts index 70d3747..851fd41 100644 --- a/src/plus/webviews/graph/graphWebview.ts +++ b/src/plus/webviews/graph/graphWebview.ts @@ -1,5 +1,3 @@ -import type { Head } from '@gitkraken/gitkraken-components'; -import { stringify } from 'json5'; import type { ColorTheme, ConfigurationChangeEvent, @@ -107,7 +105,7 @@ import type { UpdateColumnParams, UpdateRefsVisibilityParams, UpdateSelectedRepositoryParams, - UpdateSelectionParams + UpdateSelectionParams, } from './protocol'; import { DidChangeAvatarsNotificationType, @@ -570,15 +568,23 @@ export class GraphWebview extends WebviewBase { private onDoubleClickRef(e: DoubleClickedRefParams) { if (e.ref.context) { - const item: GraphItemContext = typeof e.ref.context === 'string' - ? JSON.parse(e.ref.context) - : e.ref.context as GraphItemContext; + const item = typeof e.ref.context === 'string' ? JSON.parse(e.ref.context) : e.ref.context; + if (!('webview' in item)) { + item.webview = this.id; + } + if (isGraphItemRefContext(item)) { + const { ref } = item.webviewItemValue; + if (e.ref.refType === 'head' && e.ref.isCurrentHead) { + return GitActions.switchTo(ref.repoPath); + } - const { ref } = item.webviewItemValue as GraphItemRefContextValue; - if (e.ref.refType === 'head' && (e.ref as Head).isCurrentHead) { - return GitActions.switchTo(ref.repoPath); + // Override the default confirmation if the setting is unset + return GitActions.switchTo( + ref.repoPath, + ref, + configuration.isUnset('gitCommands.skipConfirmations') ? true : undefined, + ); } - return GitActions.switchTo(ref.repoPath, ref); } return Promise.resolve();