From de6a0bb3a9df4ece829ecc2d136076ae17d2dd4c Mon Sep 17 00:00:00 2001 From: Keith Daulton Date: Mon, 18 Sep 2023 17:27:09 -0400 Subject: [PATCH] Updates EnrichedItem with entityUrl --- src/plus/focus/focusService.ts | 59 ++++++--------------------------- src/plus/webviews/focus/focusWebview.ts | 4 +++ 2 files changed, 14 insertions(+), 49 deletions(-) diff --git a/src/plus/focus/focusService.ts b/src/plus/focus/focusService.ts index fe9eacc..ccfabd2 100644 --- a/src/plus/focus/focusService.ts +++ b/src/plus/focus/focusService.ts @@ -11,6 +11,7 @@ export interface FocusItem { type: EnrichedItemResponse['entityType']; id: string; remote: GitRemote; + url: string; } export type EnrichedItem = { @@ -21,44 +22,17 @@ export type EnrichedItem = { provider: EnrichedItemResponse['provider']; entityType: EnrichedItemResponse['entityType']; entityId: string; + entityUrl: string; createdAt: number; updatedAt: number; -} & ( - | { gitRepositoryId: string } - | { - repositoryName: string; - repositoryOwner: string; - } -); - -type GitRepositoryDataRequest = - | { - readonly initialCommitSha: string; - readonly remoteUrl?: undefined; - readonly remoteDomain?: undefined; - readonly remotePath?: undefined; - } - | ({ - readonly initialCommitSha?: string; - readonly remoteUrl: string; - readonly remoteDomain: string; - readonly remotePath: string; - } & ( - | { readonly remoteProvider?: undefined } - | { - readonly remoteProvider: string; - readonly remoteProviderRepoDomain: string; - readonly remoteProviderRepoName: string; - readonly remoteProviderRepoOwnerDomain?: string; - } - )); +}; type EnrichedItemRequest = { provider: EnrichedItemResponse['provider']; entityType: EnrichedItemResponse['entityType']; entityId: string; - gitRepoData: GitRepositoryDataRequest; + entityUrl: string; }; type EnrichedItemResponse = { @@ -69,16 +43,11 @@ type EnrichedItemResponse = { provider: 'azure' | 'bitbucket' | 'github' | 'gitlab' | 'gitkraken'; entityType: 'issue' | 'pr'; entityId: string; + entityUrl: string; createdAt: number; updatedAt: number; -} & ( - | { gitRepositoryId: string } - | { - repositoryName: string; - repositoryOwner: string; - } -); +}; export class FocusService implements Disposable { constructor( @@ -141,11 +110,7 @@ export class FocusService implements Disposable { provider: item.remote.provider.id as EnrichedItemResponse['provider'], entityType: item.type, entityId: item.id, - gitRepoData: { - remoteUrl: item.remote.url, - remotePath: item.remote.provider.path, - remoteDomain: item.remote.provider.domain, - }, + entityUrl: item.url, }; const rsp = await this.connection.fetchGkDevApi('v1/enrich-items/pin', { @@ -155,7 +120,7 @@ export class FocusService implements Disposable { if (!rsp.ok) { throw new Error( - `Unable to pin item '${rq.provider}|${rq.gitRepoData.remoteDomain}/${rq.gitRepoData.remotePath}#${item.id}': (${rsp.status}) ${rsp.statusText}`, + `Unable to pin item '${rq.provider}|${rq.entityUrl}#${item.id}': (${rsp.status}) ${rsp.statusText}`, ); } @@ -184,11 +149,7 @@ export class FocusService implements Disposable { provider: item.remote.provider.id as EnrichedItemResponse['provider'], entityType: item.type, entityId: item.id, - gitRepoData: { - remoteUrl: item.remote.url, - remotePath: item.remote.provider.path, - remoteDomain: item.remote.provider.domain, - }, + entityUrl: item.url, }; const rsp = await this.connection.fetchGkDevApi('v1/enrich-items/snooze', { @@ -198,7 +159,7 @@ export class FocusService implements Disposable { if (!rsp.ok) { throw new Error( - `Unable to snooze item '${rq.provider}|${rq.gitRepoData.remoteDomain}/${rq.gitRepoData.remotePath}#${item.id}': (${rsp.status}) ${rsp.statusText}`, + `Unable to snooze item '${rq.provider}|${rq.entityUrl}#${item.id}': (${rsp.status}) ${rsp.statusText}`, ); } diff --git a/src/plus/webviews/focus/focusWebview.ts b/src/plus/webviews/focus/focusWebview.ts index e03e0a6..0717dbb 100644 --- a/src/plus/webviews/focus/focusWebview.ts +++ b/src/plus/webviews/focus/focusWebview.ts @@ -141,6 +141,7 @@ export class FocusWebviewProvider implements WebviewProvider { type: 'issue', id: issueWithRemote.issue.id, remote: issueWithRemote.repoAndRemote.remote, + url: issueWithRemote.issue.url, }; const enrichedItem = await this.container.focus.pinItem(focusItem); if (enrichedItem == null) return; @@ -170,6 +171,7 @@ export class FocusWebviewProvider implements WebviewProvider { type: 'issue', id: issueWithRemote.issue.id, remote: issueWithRemote.repoAndRemote.remote, + url: issueWithRemote.issue.url, }; const enrichedItem = await this.container.focus.snoozeItem(focusItem); if (enrichedItem == null) return; @@ -199,6 +201,7 @@ export class FocusWebviewProvider implements WebviewProvider { type: 'pr', id: prWithRemote.pullRequest.id, remote: prWithRemote.repoAndRemote.remote, + url: prWithRemote.pullRequest.url, }; const enrichedItem = await this.container.focus.pinItem(focusItem); if (enrichedItem == null) return; @@ -228,6 +231,7 @@ export class FocusWebviewProvider implements WebviewProvider { type: 'pr', id: prWithRemote.pullRequest.id, remote: prWithRemote.repoAndRemote.remote, + url: prWithRemote.pullRequest.url, }; const enrichedItem = await this.container.focus.snoozeItem(focusItem); if (enrichedItem == null) return;