Sfoglia il codice sorgente

Updates EnrichedItem with entityUrl

main
Keith Daulton 1 anno fa
parent
commit
de6a0bb3a9
2 ha cambiato i file con 14 aggiunte e 49 eliminazioni
  1. +10
    -49
      src/plus/focus/focusService.ts
  2. +4
    -0
      src/plus/webviews/focus/focusWebview.ts

+ 10
- 49
src/plus/focus/focusService.ts Vedi File

@ -11,6 +11,7 @@ export interface FocusItem {
type: EnrichedItemResponse['entityType'];
id: string;
remote: GitRemote<RichRemoteProvider>;
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}`,
);
}

+ 4
- 0
src/plus/webviews/focus/focusWebview.ts Vedi File

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

Caricamento…
Annulla
Salva