Переглянути джерело

Adds patch storage confirmation

main
Keith Daulton 1 рік тому
джерело
коміт
2c75f68f70
3 змінених файлів з 36 додано та 3 видалено
  1. +1
    -0
      src/constants.ts
  2. +28
    -1
      src/plus/utils.ts
  3. +7
    -2
      src/plus/webviews/patchDetails/patchDetailsWebview.ts

+ 1
- 0
src/constants.ts Переглянути файл

@ -837,6 +837,7 @@ export type GlobalStorage = {
// Keep the pre-release version separate from the released version
preVersion: string;
'views:welcome:visible': boolean;
'confirm:draft:storage': boolean;
} & { [key in `confirm:ai:tos:${AIProviders}`]: boolean } & {
[key in `provider:authentication:skip:${string}`]: boolean;
};

+ 28
- 1
src/plus/utils.ts Переглянути файл

@ -1,4 +1,5 @@
import { window } from 'vscode';
import type { MessageItem } from 'vscode';
import { env, Uri, window } from 'vscode';
import type { Container } from '../container';
import { isSubscriptionPaidPlan } from './gk/account/subscription';
@ -107,3 +108,29 @@ export async function ensureAccount(title: string, container: Container): Promis
return true;
}
export async function confirmDraftStorage(container: Container): Promise<boolean> {
if (container.storage.get('confirm:draft:storage', false)) return true;
const accept: MessageItem = { title: 'Yes' };
const decline: MessageItem = { title: 'No', isCloseAffordance: true };
const moreInfo: MessageItem = { title: 'More Info' };
const result = await window.showInformationMessage(
`Creating a Cloud Patch will store code on GitKraken's servers.\n\nDo you want to continue?`,
{ modal: true },
accept,
decline,
moreInfo,
);
if (result === accept) {
void container.storage.store('confirm:draft:storage', true);
return true;
}
if (result === moreInfo) {
void env.openExternal(Uri.parse('https://help.gitkraken.com/gitlens/security'));
}
return false;
}

+ 7
- 2
src/plus/webviews/patchDetails/patchDetailsWebview.ts Переглянути файл

@ -28,7 +28,7 @@ import { onIpc } from '../../../webviews/protocol';
import type { WebviewController, WebviewProvider } from '../../../webviews/webviewController';
import type { WebviewShowOptions } from '../../../webviews/webviewsController';
import { showPatchesView } from '../../drafts/actions';
import { ensureAccount } from '../../utils';
import { confirmDraftStorage, ensureAccount } from '../../utils';
import type { ShowInCommitGraphCommandArgs } from '../graph/protocol';
import type {
ApplyPatchParams,
@ -311,7 +311,12 @@ export class PatchDetailsWebviewProvider
return;
}
if (!(await ensureAccount('Cloud Patches require a GitKraken account.', this.container))) return;
if (
!(await ensureAccount('Cloud Patches require a GitKraken account.', this.container)) ||
!(await confirmDraftStorage(this.container))
) {
return;
}
const changeset = this._context.draft.changesets?.[0];
if (changeset == null) return;

Завантаження…
Відмінити
Зберегти