Skip to content

Commit 5b4181f

Browse files
committed
Adds repo visibility to FeatureAccess
1 parent deba6e6 commit 5b4181f

File tree

2 files changed

+29
-4
lines changed

2 files changed

+29
-4
lines changed

src/features.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { RepositoryVisibility } from './git/gitProvider';
12
import type { RequiredSubscriptionPlans, Subscription } from './subscription';
23

34
export const enum Features {
@@ -7,10 +8,19 @@ export const enum Features {
78
}
89

910
export type FeatureAccess =
10-
| { allowed: true; subscription: { current: Subscription; required?: undefined } }
11-
| { allowed: false; subscription: { current: Subscription; required?: RequiredSubscriptionPlans } };
11+
| {
12+
allowed: true;
13+
subscription: { current: Subscription; required?: undefined };
14+
visibility?: RepositoryVisibility;
15+
}
16+
| {
17+
allowed: false;
18+
subscription: { current: Subscription; required?: RequiredSubscriptionPlans };
19+
visibility?: RepositoryVisibility;
20+
};
1221

1322
export const enum PlusFeatures {
1423
Timeline = 'timeline',
1524
Worktrees = 'worktrees',
25+
Graph = 'graph',
1626
}

src/git/gitProviderService.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ import { ContextKeys, CoreGitConfiguration, GlyphChars, Schemes } from '../const
1616
import type { Container } from '../container';
1717
import { setContext } from '../context';
1818
import { AccessDeniedError, ProviderNotFoundError } from '../errors';
19-
import type { FeatureAccess, Features, PlusFeatures } from '../features';
19+
import type { FeatureAccess, Features } from '../features';
20+
import { PlusFeatures } from '../features';
2021
import { Logger } from '../logger';
2122
import type { SubscriptionChangeEvent } from '../plus/subscription/subscriptionService';
2223
import type { RepoComparisonKey } from '../repositories';
@@ -552,18 +553,32 @@ export class GitProviderService implements Disposable {
552553
if (visibility !== RepositoryVisibility.Private) {
553554
switch (plan) {
554555
case SubscriptionPlanId.Free:
556+
if (feature === PlusFeatures.Graph) {
557+
return {
558+
allowed: true,
559+
subscription: { current: subscription },
560+
visibility: visibility,
561+
};
562+
}
563+
555564
return {
556565
allowed: false,
557566
subscription: { current: subscription, required: SubscriptionPlanId.FreePlus },
567+
visibility: visibility,
558568
};
559569
case SubscriptionPlanId.FreePlus:
560-
return { allowed: true, subscription: { current: subscription } };
570+
return {
571+
allowed: true,
572+
subscription: { current: subscription },
573+
visibility: visibility,
574+
};
561575
}
562576
}
563577

564578
return {
565579
allowed: false,
566580
subscription: { current: subscription, required: SubscriptionPlanId.Pro },
581+
visibility: visibility,
567582
};
568583
});
569584

0 commit comments

Comments
 (0)