Skip to content

Commit

Permalink
Fixes display states for worktrees welcome view
Browse files Browse the repository at this point in the history
  • Loading branch information
eamodio committed Mar 25, 2022
1 parent 75b9a8f commit 3f1ff95
Show file tree
Hide file tree
Showing 13 changed files with 150 additions and 106 deletions.
62 changes: 36 additions & 26 deletions package.json
Expand Up @@ -64,15 +64,15 @@
"onView:gitlens.views.worktrees",
"onWebviewPanel:gitlens.welcome",
"onWebviewPanel:gitlens.settings",
"onCommand:gitlens.premium.learn",
"onCommand:gitlens.premium.login",
"onCommand:gitlens.premium.loginOrSignUp",
"onCommand:gitlens.premium.signUp",
"onCommand:gitlens.premium.logout",
"onCommand:gitlens.premium.startPreview",
"onCommand:gitlens.premium.startPreviewTrial",
"onCommand:gitlens.premium.purchase",
"onCommand:gitlens.premium.reset",
"onCommand:gitlens.getStarted",
"onCommand:gitlens.learnAboutPremium",
"onCommand:gitlens.showSettingsPage",
"onCommand:gitlens.showSettingsPage#views",
"onCommand:gitlens.showSettingsPage#branches-view",
Expand Down Expand Up @@ -3590,6 +3590,11 @@
}
],
"commands": [
{
"command": "gitlens.premium.learn",
"title": "Learn about Premium Features",
"category": "GitLens"
},
{
"command": "gitlens.premium.login",
"title": "Login...",
Expand All @@ -3602,7 +3607,7 @@
},
{
"command": "gitlens.premium.signUp",
"title": "Sign Up for Free+...",
"title": "Create Free Account...",
"category": "GitLens Premium"
},
{
Expand All @@ -3611,7 +3616,7 @@
"category": "GitLens Premium"
},
{
"command": "gitlens.premium.startPreview",
"command": "gitlens.premium.startPreviewTrial",
"title": "Try Premium Features...",
"category": "GitLens Premium"
},
Expand All @@ -3630,11 +3635,6 @@
"title": "Get Started",
"category": "GitLens"
},
{
"command": "gitlens.learnAboutPremium",
"title": "Learn about Premium Features",
"category": "GitLens"
},
{
"command": "gitlens.showSettingsPage",
"title": "Open Settings",
Expand Down Expand Up @@ -5893,23 +5893,23 @@
"commandPalette": [
{
"command": "gitlens.premium.login",
"when": "gitlens:premium == free"
"when": "!gitlens:premium"
},
{
"command": "gitlens.premium.loginOrSignUp",
"when": "gitlens:premium == free"
"when": "!gitlens:premium"
},
{
"command": "gitlens.premium.signUp",
"when": "gitlens:premium == free"
"when": "!gitlens:premium"
},
{
"command": "gitlens.premium.logout",
"when": "gitlens:premium != free"
"when": "gitlens:premium"
},
{
"command": "gitlens.premium.startPreview",
"when": "gitlens:premium == free"
"command": "gitlens.premium.startPreviewTrial",
"when": "!gitlens:premium"
},
{
"command": "gitlens.premium.purchase",
Expand Down Expand Up @@ -10547,37 +10547,47 @@
},
{
"view": "gitlens.views.worktrees",
"contents": "Worktrees allow you to easily work on different branches of a repository simultaneously. You can create multiple working trees, each of which can be opened in individual windows or all together in a single workspace."
"contents": "[Worktrees](command:gitlens.openWalkthrough?%22gitlens.premium%7Cgitlens.premium.worktrees%22 \"Learn more about worktrees\") allow you to easily work on different branches of a repository simultaneously. You can create multiple working trees, each of which can be opened in individual windows or all together in a single workspace."
},
{
"view": "gitlens.views.worktrees",
"contents": "To use premium GitLens features, please verify the email for the account you created.\n\n[Resend verification email](command:gitlens.premium.resendVerification)",
"when": "gitlens:premium:requiresVerification"
},
{
"view": "gitlens.views.worktrees",
"contents": "[Create Worktree...](command:gitlens.views.createWorktree)",
"when": "!gitlens:premium:upgradeRequired"
"when": "gitlens:premium || gitlens:premium:trial && !gitlens:premium:required && !gitlens:premium:requiresVerification"
},
{
"view": "gitlens.views.worktrees",
"contents": "To use premium GitLens features, please verify the email for the account you created.\n\n[Resend verification email](command:gitlens.premium.resendVerification)",
"when": "gitlens:premium:requiresVerification"
"contents": "Worktrees are a premium feature, which require a free account for public repos.\n\nYou can try these premium features for free, without an account, for 3 days. All non-premium features will continue to be free without an account.",
"when": "!gitlens:premium:trial && gitlens:premium:required == free+ && !gitlens:premium:requiresVerification"
},
{
"view": "gitlens.views.worktrees",
"contents": "Worktrees are a premium feature, which require at least a Pro subscription for private repos.",
"when": "!gitlens:premium:trial && gitlens:premium:required == paid && !gitlens:premium:requiresVerification"
},
{
"view": "gitlens.views.worktrees",
"contents": "Worktrees are a premium feature, which require a free account for public repos. [Learn more](https://dev.gitkraken.com/gitlens/premium-features).\n\nYou can try these premium features for free, without an account, for 3 days. All non-premium features will continue to be free without an account.",
"when": "gitlens:premium:upgradeRequired == free+ && !gitlens:premium:requiresVerification"
"contents": "[Learn about premium features](command:gitlens.premium.learn)",
"when": "!gitlens:premium:paid && gitlens:premium:required && !gitlens:premium:requiresVerification"
},
{
"view": "gitlens.views.worktrees",
"contents": "[Try premium features now](command:gitlens.premium.startPreview)\n\n[Create a free account](command:gitlens.premium.loginOrSignUp)",
"when": "gitlens:premium:upgradeRequired == free+ && !gitlens:premium:requiresVerification"
"contents": "[Try premium features now](command:gitlens.premium.startPreviewTrial)",
"when": "!gitlens:premium && !gitlens:premium:trial && !gitlens:premium:previewTrial:expired"
},
{
"view": "gitlens.views.worktrees",
"contents": "Worktrees are a premium feature, which require at least a Pro subscription for private repos. [Learn more](https://dev.gitkraken.com/gitlens/premium-features).",
"when": "gitlens:premium:upgradeRequired == paid"
"contents": "[Create a free account](command:gitlens.premium.loginOrSignUp)\n\nHave an existing account? [Sign in](command:gitlens.premium.loginOrSignUp)",
"when": "!gitlens:premium && gitlens:premium:required && !gitlens:premium:requiresVerification"
},
{
"view": "gitlens.views.worktrees",
"contents": "[Upgrade your account](command:gitlens.premium.purchase)",
"when": "gitlens:premium:upgradeRequired == paid"
"when": "gitlens:premium && gitlens:premium:required == paid && !gitlens:premium:requiresVerification"
}
],
"views": {
Expand Down
2 changes: 1 addition & 1 deletion src/commands.ts
Expand Up @@ -16,7 +16,6 @@ export * from './commands/diffWithRevision';
export * from './commands/diffWithRevisionFrom';
export * from './commands/diffWithWorking';
export * from './commands/externalDiff';
export * from './commands/getStarted';
export * from './commands/gitCommands';
export * from './commands/inviteToLiveShare';
export * from './commands/logging';
Expand Down Expand Up @@ -59,3 +58,4 @@ export * from './commands/switchMode';
export * from './commands/toggleCodeLens';
export * from './commands/toggleFileAnnotations';
export * from './commands/toggleLineBlame';
export * from './commands/walkthroughs';
4 changes: 2 additions & 2 deletions src/commands/gitCommands.ts
Expand Up @@ -709,8 +709,8 @@ export class GitCommandsCommand extends Command {
void loadMore();
return;

case Directive.StartPreview:
void Container.instance.subscription.startPreview();
case Directive.StartPreviewTrial:
void Container.instance.subscription.startPreviewTrial();
resolve(undefined);
return;

Expand Down
19 changes: 13 additions & 6 deletions src/commands/quickCommand.steps.ts
Expand Up @@ -66,7 +66,7 @@ import {
CopyRemoteResourceCommandQuickPickItem,
OpenRemoteResourceCommandQuickPickItem,
} from '../quickpicks/remoteProviderPicker';
import { isPaidSubscriptionPlan } from '../subscription';
import { isSubscriptionPaidPlan, isSubscriptionPreviewTrialExpired } from '../subscription';
import { filterMap, intersection, isStringArray } from '../system/array';
import { formatPath } from '../system/formatPath';
import { map } from '../system/iterable';
Expand Down Expand Up @@ -2244,14 +2244,21 @@ export async function* ensureAccessStep<
} else {
if (access.subscription.required == null) return undefined;

if (isPaidSubscriptionPlan(access.subscription.required)) {
if (isSubscriptionPaidPlan(access.subscription.required) && access.subscription.current.account != null) {
directives.push(DirectiveQuickPickItem.create(Directive.RequiresPaidSubscription, true));
placeholder = 'Premium features require an upgraded account';
} else {
directives.push(
DirectiveQuickPickItem.create(Directive.StartPreview, true),
DirectiveQuickPickItem.create(Directive.RequiresFreeSubscription),
);
if (
access.subscription.current.account == null &&
!isSubscriptionPreviewTrialExpired(access.subscription.current)
) {
directives.push(
DirectiveQuickPickItem.create(Directive.StartPreviewTrial, true),
DirectiveQuickPickItem.create(Directive.RequiresFreeSubscription),
);
} else {
directives.push(DirectiveQuickPickItem.create(Directive.RequiresFreeSubscription));
}
placeholder = 'Premium features require an account';
}
}
Expand Down
9 changes: 5 additions & 4 deletions src/commands/getStarted.ts → src/commands/walkthroughs.ts
Expand Up @@ -22,12 +22,13 @@ export class GetStartedCommand extends Command {
}

@command()
export class LearnAboutPremiumCommand extends Command {
export class OpenWalkthroughCommand extends Command {
constructor(private readonly container: Container) {
super(Commands.LearnAboutPremium);
super(Commands.OpenWalkthrough);
}

execute() {
void openWalkthrough(this.container.context.extension.id, 'gitlens.premium');
execute(walkthroughAndStep?: string) {
const [walkthroughId, stepId] = walkthroughAndStep?.split('|') ?? 'gitlens.welcome';
void openWalkthrough(this.container.context.extension.id, walkthroughId, stepId);
}
}
16 changes: 14 additions & 2 deletions src/constants.ts
Expand Up @@ -100,7 +100,6 @@ export const enum Commands {
FetchRepositories = 'gitlens.fetchRepositories',
GetStarted = 'gitlens.getStarted',
InviteToLiveShare = 'gitlens.inviteToLiveShare',
LearnAboutPremium = 'gitlens.learnAboutPremium',
OpenBlamePriorToChange = 'gitlens.openBlamePriorToChange',
OpenBranchesOnRemote = 'gitlens.openBranchesOnRemote',
OpenBranchOnRemote = 'gitlens.openBranchOnRemote',
Expand All @@ -122,6 +121,7 @@ export const enum Commands {
OpenRevisionFile = 'gitlens.openRevisionFile',
OpenRevisionFileInDiffLeft = 'gitlens.openRevisionFileInDiffLeft',
OpenRevisionFileInDiffRight = 'gitlens.openRevisionFileInDiffRight',
OpenWalkthrough = 'gitlens.openWalkthrough',
OpenWorkingFile = 'gitlens.openWorkingFile',
OpenWorkingFileInDiffLeft = 'gitlens.openWorkingFileInDiffLeft',
OpenWorkingFileInDiffRight = 'gitlens.openWorkingFileInDiffRight',
Expand All @@ -137,6 +137,16 @@ export const enum Commands {
GitCommandsSwitch = 'gitlens.gitCommands.switch',
GitCommandsTag = 'gitlens.gitCommands.tag',
GitCommandsWorktree = 'gitlens.gitCommands.worktree',
PremiumLearn = 'gitlens.premium.learn',
PremiumLogin = 'gitlens.premium.login',
PremiumLoginOrSignUp = 'gitlens.premium.loginOrSignUp',
PremiumLogout = 'gitlens.premium.logout',
PremiumPurchase = 'gitlens.premium.purchase',
PremiumResendVerification = 'gitlens.premium.resendVerification',
PremiumShowPlans = 'gitlens.premium.showPlans',
PremiumSignUp = 'gitlens.premium.signUp',
PremiumStartPreviewTrial = 'gitlens.premium.startPreviewTrial',
PremiumValidate = 'gitlens.premium.validate',
QuickOpenFileHistory = 'gitlens.quickOpenFileHistory',
RefreshHover = 'gitlens.refreshHover',
ResetAvatarCache = 'gitlens.resetAvatarCache',
Expand Down Expand Up @@ -243,8 +253,10 @@ export const enum ContextKeys {

Premium = 'gitlens:premium',
PremiumPaid = 'gitlens:premium:paid',
PremiumRequired = 'gitlens:premium:required',
PremiumRequiresVerification = 'gitlens:premium:requiresVerification',
PremiumUpgradeRequired = 'gitlens:premium:upgradeRequired',
PremiumTrial = 'gitlens:premium:trial',
PremiumPreviewTrialExpired = 'gitlens:premium:previewTrial:expired',
}

export const enum CoreCommands {
Expand Down
4 changes: 2 additions & 2 deletions src/errors.ts
@@ -1,5 +1,5 @@
import { Uri } from 'vscode';
import { isPaidSubscriptionPlan, RequiredSubscriptionPlans, Subscription } from './subscription';
import { isSubscriptionPaidPlan, RequiredSubscriptionPlans, Subscription } from './subscription';

export class AccessDeniedError extends Error {
public readonly subscription: Subscription;
Expand All @@ -9,7 +9,7 @@ export class AccessDeniedError extends Error {
let message;
if (subscription.account?.verified === false) {
message = 'Email verification required';
} else if (required != null && isPaidSubscriptionPlan(required)) {
} else if (required != null && isSubscriptionPaidPlan(required)) {
message = 'Paid subscription required';
} else {
message = 'Subscription required';
Expand Down
4 changes: 2 additions & 2 deletions src/git/gitProviderService.ts
Expand Up @@ -28,7 +28,7 @@ import { WorkspaceStorageKeys } from '../storage';
import {
FreeSubscriptionPlans,
getSubscriptionPlanPriority,
isPaidSubscriptionPlan,
isSubscriptionPaidPlan,
RequiredSubscriptionPlans,
Subscription,
SubscriptionPlanId,
Expand Down Expand Up @@ -559,7 +559,7 @@ export class GitProviderService implements Disposable {
}

const plan = subscription.plan.effective.id;
if (isPaidSubscriptionPlan(plan) || GitProviderService.previewFeatures?.get(feature)) {
if (isSubscriptionPaidPlan(plan) || GitProviderService.previewFeatures?.get(feature)) {
return { allowed: true, subscription: { current: subscription } };
}

Expand Down

0 comments on commit 3f1ff95

Please sign in to comment.