Browse Source

Adds confirm if skipConfirmations is unset

Avoids `as` casts
Removes unneeded imports
main
Eric Amodio 2 years ago
parent
commit
6a29833501
2 changed files with 25 additions and 10 deletions
  1. +9
    -0
      src/configuration.ts
  2. +16
    -10
      src/plus/webviews/graph/graphWebview.ts

+ 9
- 0
src/configuration.ts View File

@ -120,6 +120,15 @@ export class Configuration {
return workspace.getConfiguration(undefined, scope).inspect<T>(section);
}
isUnset<T extends ConfigPath>(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<T extends ConfigPath>(
from: string,
to: T,

+ 16
- 10
src/plus/webviews/graph/graphWebview.ts View File

@ -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();

Loading…
Cancel
Save