Skip to content

Commit 4142815

Browse files
committed
Add linear provider and implement getting linear teams
(#4543, #4579)
1 parent c82f9bf commit 4142815

File tree

15 files changed

+233
-15
lines changed

15 files changed

+233
-15
lines changed

docs/telemetry-events.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ void
668668
```typescript
669669
{
670670
'hostingProvider.key': string,
671-
'hostingProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'bitbucket-server' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted' | 'cloud-gitlab-self-hosted' | 'azure-devops-server' | 'jira' | 'trello'
671+
'hostingProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'bitbucket-server' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted' | 'cloud-gitlab-self-hosted' | 'azure-devops-server' | 'jira' | 'linear' | 'trello'
672672
}
673673
```
674674

@@ -679,7 +679,7 @@ void
679679
```typescript
680680
{
681681
'hostingProvider.key': string,
682-
'hostingProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'bitbucket-server' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted' | 'cloud-gitlab-self-hosted' | 'azure-devops-server' | 'jira' | 'trello'
682+
'hostingProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'bitbucket-server' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted' | 'cloud-gitlab-self-hosted' | 'azure-devops-server' | 'jira' | 'linear' | 'trello'
683683
}
684684
```
685685

@@ -690,7 +690,7 @@ void
690690
```typescript
691691
{
692692
'issueProvider.key': string,
693-
'issueProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'bitbucket-server' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted' | 'cloud-gitlab-self-hosted' | 'azure-devops-server' | 'jira' | 'trello'
693+
'issueProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'bitbucket-server' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted' | 'cloud-gitlab-self-hosted' | 'azure-devops-server' | 'jira' | 'linear' | 'trello'
694694
}
695695
```
696696

@@ -701,7 +701,7 @@ void
701701
```typescript
702702
{
703703
'issueProvider.key': string,
704-
'issueProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'bitbucket-server' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted' | 'cloud-gitlab-self-hosted' | 'azure-devops-server' | 'jira' | 'trello'
704+
'issueProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'bitbucket-server' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted' | 'cloud-gitlab-self-hosted' | 'azure-devops-server' | 'jira' | 'linear' | 'trello'
705705
}
706706
```
707707

@@ -735,7 +735,7 @@ or when connection refresh is skipped due to being a non-cloud session
735735
736736
```typescript
737737
{
738-
'integration.id': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'bitbucket-server' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted' | 'cloud-gitlab-self-hosted' | 'azure-devops-server' | 'jira' | 'trello'
738+
'integration.id': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'bitbucket-server' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted' | 'cloud-gitlab-self-hosted' | 'azure-devops-server' | 'jira' | 'linear' | 'trello'
739739
}
740740
```
741741

@@ -2892,7 +2892,7 @@ void
28922892
```typescript
28932893
{
28942894
'hostingProvider.key': string,
2895-
'hostingProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'bitbucket-server' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted' | 'cloud-gitlab-self-hosted' | 'azure-devops-server' | 'jira' | 'trello',
2895+
'hostingProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'bitbucket-server' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted' | 'cloud-gitlab-self-hosted' | 'azure-devops-server' | 'jira' | 'linear' | 'trello',
28962896
// @deprecated: true
28972897
'remoteProviders.key': string
28982898
}
@@ -2905,7 +2905,7 @@ void
29052905
```typescript
29062906
{
29072907
'hostingProvider.key': string,
2908-
'hostingProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'bitbucket-server' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted' | 'cloud-gitlab-self-hosted' | 'azure-devops-server' | 'jira' | 'trello',
2908+
'hostingProvider.provider': 'github' | 'gitlab' | 'bitbucket' | 'azureDevOps' | 'bitbucket-server' | 'github-enterprise' | 'cloud-github-enterprise' | 'gitlab-self-hosted' | 'cloud-gitlab-self-hosted' | 'azure-devops-server' | 'jira' | 'linear' | 'trello',
29092909
// @deprecated: true
29102910
'remoteProviders.key': string
29112911
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25043,7 +25043,7 @@
2504325043
},
2504425044
"dependencies": {
2504525045
"@gitkraken/gitkraken-components": "13.0.0-vnext.8",
25046-
"@gitkraken/provider-apis": "0.29.6",
25046+
"@gitkraken/provider-apis": "0.29.7",
2504725047
"@gitkraken/shared-web-components": "0.1.1-rc.15",
2504825048
"@gk-nzaytsev/fast-string-truncated-width": "1.1.0",
2504925049
"@lit-labs/signals": "0.1.3",

pnpm-lock.yaml

Lines changed: 48 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import type { DateTimeFormat } from './system/date';
44
import type { LogLevel } from './system/logger.constants';
55

66
export interface Config {
7+
readonly 'temporary-configured-linear-config': string | null;
78
readonly advanced: AdvancedConfig;
89
readonly ai: AIConfig;
910
readonly autolinks: AutolinkConfig[] | null;

src/constants.integrations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export enum GitSelfManagedHostIntegrationId {
1616

1717
export enum IssuesCloudHostIntegrationId {
1818
Jira = 'jira',
19+
Linear = 'linear',
1920
Trello = 'trello',
2021
}
2122

src/plus/integrations/authentication/integrationAuthenticationService.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@ export class IntegrationAuthenticationService implements Disposable {
148148
await import(/* webpackChunkName: "integrations" */ './jira')
149149
).JiraAuthenticationProvider(this.container, this, this.configuredIntegrationService);
150150
break;
151+
case IssuesCloudHostIntegrationId.Linear:
152+
provider = new (
153+
await import(/* webpackChunkName: "integrations" */ './linear')
154+
).LinearAuthenticationProvider();
155+
break;
151156
default:
152157
provider = new BuiltInAuthenticationProvider(
153158
this.container,
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import type { Disposable, Event } from 'vscode';
2+
import type { Sources } from '../../../constants.telemetry';
3+
import { configuration } from '../../../system/-webview/configuration';
4+
import type {
5+
IntegrationAuthenticationProvider,
6+
IntegrationAuthenticationSessionDescriptor,
7+
} from './integrationAuthenticationProvider';
8+
import type { ProviderAuthenticationSession } from './models';
9+
10+
export class LinearAuthenticationProvider implements IntegrationAuthenticationProvider {
11+
// I want to read the token from the config "temporary-configured-linear-config":
12+
private currentToken: string | undefined =
13+
(configuration.get('temporary-configured-linear-config') as string) ?? undefined;
14+
15+
deleteSession(_descriptor: IntegrationAuthenticationSessionDescriptor): Promise<void> {
16+
//throw new Error('Method not implemented.');
17+
this.currentToken = undefined;
18+
return Promise.resolve();
19+
}
20+
deleteAllSessions(): Promise<void> {
21+
//throw new Error('Method not implemented.');
22+
this.currentToken = undefined;
23+
return Promise.resolve();
24+
}
25+
getSession(
26+
_descriptor: IntegrationAuthenticationSessionDescriptor,
27+
_options?:
28+
| { createIfNeeded?: boolean; forceNewSession?: boolean; sync?: never; source?: Sources }
29+
| { createIfNeeded?: never; forceNewSession?: never; sync: boolean; source?: Sources },
30+
): Promise<ProviderAuthenticationSession | undefined> {
31+
return Promise.resolve(
32+
this.currentToken
33+
? {
34+
accessToken: this.currentToken,
35+
id: 'linear',
36+
account: {
37+
id: 'linear',
38+
label: 'Linear',
39+
},
40+
scopes: ['read'],
41+
cloud: true,
42+
expiresAt: new Date(Date.now() + 1000 * 60 * 60 * 24 * 365),
43+
domain: 'linear.app',
44+
}
45+
: undefined,
46+
);
47+
}
48+
get onDidChange(): Event<void> {
49+
return (_listener: (e: void) => any, _thisArgs?: any, _disposables?: Disposable[]): Disposable => {
50+
return { dispose: () => {} };
51+
};
52+
}
53+
dispose(): void {}
54+
}

src/plus/integrations/authentication/models.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export interface CloudIntegrationConnection {
4444

4545
export type CloudIntegrationType =
4646
| 'jira'
47+
| 'linear'
4748
| 'trello'
4849
| 'gitlab'
4950
| 'github'
@@ -70,6 +71,7 @@ export function isSupportedCloudIntegrationId(id: string): id is SupportedCloudI
7071

7172
export const toIntegrationId: { [key in CloudIntegrationType]: IntegrationIds } = {
7273
jira: IssuesCloudHostIntegrationId.Jira,
74+
linear: IssuesCloudHostIntegrationId.Linear,
7375
trello: IssuesCloudHostIntegrationId.Trello,
7476
gitlab: GitCloudHostIntegrationId.GitLab,
7577
github: GitCloudHostIntegrationId.GitHub,
@@ -83,6 +85,7 @@ export const toIntegrationId: { [key in CloudIntegrationType]: IntegrationIds }
8385

8486
export const toCloudIntegrationType: { [key in IntegrationIds]: CloudIntegrationType | undefined } = {
8587
[IssuesCloudHostIntegrationId.Jira]: 'jira',
88+
[IssuesCloudHostIntegrationId.Linear]: 'linear',
8689
[IssuesCloudHostIntegrationId.Trello]: 'trello',
8790
[GitCloudHostIntegrationId.GitLab]: 'gitlab',
8891
[GitCloudHostIntegrationId.GitHub]: 'github',

src/plus/integrations/integrationService.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,16 @@ export class IntegrationService implements Disposable {
540540
) as IssuesIntegration as IntegrationById<T>;
541541
break;
542542

543+
case IssuesCloudHostIntegrationId.Linear:
544+
integration = new (
545+
await import(/* webpackChunkName: "integrations" */ './providers/linear')
546+
).LinearIntegration(
547+
this.container,
548+
this.authenticationService,
549+
this.getProvidersApi.bind(this),
550+
this._onDidChangeIntegrationConnection,
551+
) as IssuesIntegration as IntegrationById<T>;
552+
break;
543553
default:
544554
throw new Error(`Integration with '${id}' is not supported`);
545555
}

0 commit comments

Comments
 (0)