Skip to content

Commit 54251a7

Browse files
committed
Add linear provider and implement getting linear teams
(#4543, #4579)
1 parent 3e3d673 commit 54251a7

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
@@ -630,7 +630,7 @@ void
630630
```typescript
631631
{
632632
'hostingProvider.key': string,
633-
'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'
633+
'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'
634634
}
635635
```
636636

@@ -641,7 +641,7 @@ void
641641
```typescript
642642
{
643643
'hostingProvider.key': string,
644-
'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'
644+
'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'
645645
}
646646
```
647647

@@ -652,7 +652,7 @@ void
652652
```typescript
653653
{
654654
'issueProvider.key': string,
655-
'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'
655+
'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'
656656
}
657657
```
658658

@@ -663,7 +663,7 @@ void
663663
```typescript
664664
{
665665
'issueProvider.key': string,
666-
'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'
666+
'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'
667667
}
668668
```
669669

@@ -697,7 +697,7 @@ or when connection refresh is skipped due to being a non-cloud session
697697
698698
```typescript
699699
{
700-
'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'
700+
'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'
701701
}
702702
```
703703

@@ -2819,7 +2819,7 @@ void
28192819
```typescript
28202820
{
28212821
'hostingProvider.key': string,
2822-
'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',
2822+
'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',
28232823
// @deprecated: true
28242824
'remoteProviders.key': string
28252825
}
@@ -2832,7 +2832,7 @@ void
28322832
```typescript
28332833
{
28342834
'hostingProvider.key': string,
2835-
'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',
2835+
'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',
28362836
// @deprecated: true
28372837
'remoteProviders.key': string
28382838
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25009,7 +25009,7 @@
2500925009
},
2501025010
"dependencies": {
2501125011
"@gitkraken/gitkraken-components": "13.0.0-vnext.8",
25012-
"@gitkraken/provider-apis": "0.29.6",
25012+
"@gitkraken/provider-apis": "0.29.7",
2501325013
"@gitkraken/shared-web-components": "0.1.1-rc.15",
2501425014
"@gk-nzaytsev/fast-string-truncated-width": "1.1.0",
2501525015
"@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
@@ -537,6 +537,16 @@ export class IntegrationService implements Disposable {
537537
) as IssuesIntegration as IntegrationById<T>;
538538
break;
539539

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

0 commit comments

Comments
 (0)