From 94429e9904e4344c57b5b5e2b4e2f6525a591a9c Mon Sep 17 00:00:00 2001 From: Sven Efftinge Date: Thu, 12 Aug 2021 11:15:06 +0000 Subject: [PATCH] [server] Allow anyone to use private repos --- components/dashboard/src/settings/Plans.tsx | 11 +++------- .../server/ee/src/user/eligibility-service.ts | 20 +++---------------- 2 files changed, 6 insertions(+), 25 deletions(-) diff --git a/components/dashboard/src/settings/Plans.tsx b/components/dashboard/src/settings/Plans.tsx index f511908bce5de0..7ba7845817ce44 100644 --- a/components/dashboard/src/settings/Plans.tsx +++ b/components/dashboard/src/settings/Plans.tsx @@ -44,7 +44,6 @@ export default function () { const [ availableCoupons, setAvailableCoupons ] = useState(); const [ appliedCoupons, setAppliedCoupons ] = useState(); const [ gitHubUpgradeUrls, setGitHubUpgradeUrls ] = useState(); - const [ privateRepoTrialEndDate, setPrivateRepoTrialEndDate ] = useState(); const [ teamClaimModal, setTeamClaimModal ] = useState(undefined); @@ -63,8 +62,7 @@ export default function () { }), server.getAvailableCoupons().then(v => () => setAvailableCoupons(v)), server.getAppliedCoupons().then(v => () => setAppliedCoupons(v)), - server.getGithubUpgradeUrls().then(v => () => setGitHubUpgradeUrls(v)), - server.getPrivateRepoTrialEndDate().then(v => () => setPrivateRepoTrialEndDate(v)), + server.getGithubUpgradeUrls().then(v => () => setGitHubUpgradeUrls(v)) ]).then(setters => setters.forEach(s => s())); return function cleanup() { @@ -72,8 +70,6 @@ export default function () { } }, []); - console.log('privateRepoTrialEndDate', privateRepoTrialEndDate); - const activeSubscriptions = (accountStatement?.subscriptions || []).filter(s => Subscription.isActive(s, new Date().toISOString())); const freeSubscription = activeSubscriptions.find(s => s.planId === Plans.FREE_OPEN_SOURCE.chargebeeId) // Prefer Pro Open Source plan @@ -335,7 +331,7 @@ export default function () { // Plan card: Free a.k.a. Open Source (or Professional Open Source) const openSourceFeatures = <> -

✓ Public Repositories

+

✓ Public & Private Repositories

✓ 4 Parallel Workspaces

✓ 30 min Timeout

; @@ -359,7 +355,6 @@ export default function () { // Plan card: Personal const personalFeatures = <>

← Everything in {freePlan.name}

-

✓ Private Repositories

; if (currentPlan.chargebeeId === personalPlan.chargebeeId) { const bottomLabel = ('pendingSince' in currentPlan) ?

Upgrade in progress

: undefined; @@ -434,7 +429,7 @@ export default function () { {showPaymentUI &&

You are currently using the {Plans.getById(assignedTs?.planId)?.name || currentPlan.name} plan.

{!assignedTs && ( -

Upgrade your plan to get access to private repositories or more parallel workspaces.

+

Upgrade your plan to get more hours and more parallel workspaces.

)} d.toLocaleDateString()).join(' - ')}`}>

Remaining hours: {typeof(accountStatement?.remainingHours) === 'number' diff --git a/components/server/ee/src/user/eligibility-service.ts b/components/server/ee/src/user/eligibility-service.ts index ad2fef7f6b4993..955e829651c989 100644 --- a/components/server/ee/src/user/eligibility-service.ts +++ b/components/server/ee/src/user/eligibility-service.ts @@ -201,28 +201,14 @@ export class EligibilityService { /** * Whether the given user may open a workspace on the given context. - * A user may open private repos if they either: - * - not started their free "private repo trial" yet - * - is has been no longer than 30 days since they started their "private repo trial" - * - has a paid subscription - * - has assigned team subscription + * A user may open private repos always. + * We previously limited private repo access to subscribed users. * @param user * @param context * @param date The date for which we want to know whether the user is allowed to set a timeout (depends on active subscription) */ async mayOpenContext(user: User, context: WorkspaceContext, date: Date): Promise { - if (!this.env.enablePayment) { - return true; - } - - if (!this.isPrivateRepoContext(context)) { - return true; - } - const mayOpenPrivateRepo = await this.mayOpenPrivateRepo(user, date) - this.ensureFreePrivateRepoTrialStarted(user, date.toISOString()) - .catch((err) => log.error(err)); - - return mayOpenPrivateRepo; + return true; } /**