Skip to content

Commit a8a4962

Browse files
committed
chore: pro device license working in Linux
1 parent cf8dbed commit a8a4962

File tree

3 files changed

+70
-46
lines changed

3 files changed

+70
-46
lines changed

src/nls/root/strings.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,9 +1709,9 @@ define({
17091709
"LICENSE_STATUS_UNKNOWN": "Unknown",
17101710
"LICENSE_VALID_NEVER": "Never",
17111711
"LICENSE_STATUS_ERROR_CHECK": "Error checking license status",
1712-
"LICENSE_ACTIVATE_SUCCESS": "License activated successfully!",
1713-
"LICENSE_ACTIVATE_SUCCESS_PARTIAL": "License activated for your account only (not system-wide).",
1712+
"LICENSE_ACTIVATE_SUCCESS": "License activated system-wide. Please restart {APP_NAME} for the changes to take effect.",
1713+
"LICENSE_ACTIVATE_SUCCESS_PARTIAL": "License activated for your account only (not system-wide). Please restart {APP_NAME} for the changes to take effect.",
17141714
"LICENSE_ACTIVATE_FAIL": "Failed to activate license",
17151715
"LICENSE_ENTER_KEY": "Please enter a license key",
1716-
"LICENSE_REAPPLY_TO_DEVICE": "Already activated? Reapply to this device"
1716+
"LICENSE_REAPPLY_TO_DEVICE": "Already activated? Reapply system-wide"
17171717
});

src/services/login-service.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -585,15 +585,16 @@ define(function (require, exports, module) {
585585
return serverEntitlements;
586586
}
587587

588-
// User has active trial
588+
// now we need to grant trial, as user is entitled to trial if he is here.
589+
// User has active server plan(either with login or device license)
589590
if (serverEntitlements && serverEntitlements.plan) {
590-
// Logged-in user with trial
591591
if (serverEntitlements.plan.paidSubscriber) {
592-
// Already a paid subscriber, return as-is
592+
// Already a paid subscriber(or has device license), return as-is
593+
// never inject trail data in this case.
593594
return serverEntitlements;
594595
}
595596
// Enhance entitlements for trial user
596-
// ie if any entitlement has valid till expired, we need to deactivate that entitlement
597+
// user in not a paid subscriber(nor he has device license), inject trial
597598
return {
598599
...serverEntitlements,
599600
plan: {
@@ -617,7 +618,7 @@ define(function (require, exports, module) {
617618
};
618619
}
619620

620-
// Non-logged-in user with trial - return synthetic entitlements
621+
// Non-logged-in, non licensed user with trial - return synthetic entitlements
621622
return {
622623
plan: {
623624
paidSubscriber: true,

src/services/profile-menu.js

Lines changed: 61 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -162,23 +162,41 @@ define(function (require, exports, module) {
162162

163163
positionPopup();
164164

165-
// Check for trial info asynchronously and update popup
165+
// Check for trial info or device license asynchronously and update popup
166166
KernalModeTrust.loginService.getEffectiveEntitlements().then(effectiveEntitlements => {
167-
if (effectiveEntitlements && effectiveEntitlements.isInProTrial && isPopupVisible && $popup) {
168-
// Add trial info to the existing popup
169-
const planName = StringUtils.format(Strings.PROMO_PRO_TRIAL_DAYS_LEFT,
170-
effectiveEntitlements.trialDaysRemaining);
171-
const trialInfoHtml = `<div class="trial-plan-info">
172-
<span class="phoenix-pro-title-plain">
173-
<span class="pro-plan-name user-plan-name">${planName}</span>
174-
<i class="fa-solid fa-feather" style="margin-left: 3px;"></i>
175-
</span>
176-
</div>`;
177-
$popup.find('.popup-title').after(trialInfoHtml);
178-
positionPopup(); // Reposition after adding content
167+
// this is the login popup, so user is not logged in yet if we are here.
168+
if (effectiveEntitlements && isPopupVisible && $popup) {
169+
let proInfoHtml = null;
170+
171+
if (effectiveEntitlements.isInProTrial) {
172+
// isInProTrial will never be set if user has a pro device license(or a pro sub,
173+
// but that isn't relevant here). Add trial info to the existing popup.
174+
const planName = StringUtils.format(Strings.PROMO_PRO_TRIAL_DAYS_LEFT,
175+
effectiveEntitlements.trialDaysRemaining);
176+
proInfoHtml = `<div class="trial-plan-info">
177+
<span class="phoenix-pro-title-plain">
178+
<span class="pro-plan-name user-plan-name">${planName}</span>
179+
<i class="fa-solid fa-feather" style="margin-left: 3px;"></i>
180+
</span>
181+
</div>`;
182+
} else if (effectiveEntitlements.plan && effectiveEntitlements.plan.paidSubscriber) {
183+
// Device-licensed user: show Phoenix Pro branding
184+
const planName = effectiveEntitlements.plan.fullName || brackets.config.main_pro_plan;
185+
proInfoHtml = `<div class="trial-plan-info">
186+
<span class="phoenix-pro-title-plain">
187+
<span class="pro-plan-name user-plan-name">${planName}</span>
188+
<i class="fa-solid fa-feather" style="margin-left: 3px;"></i>
189+
</span>
190+
</div>`;
191+
}
192+
193+
if (proInfoHtml) {
194+
$popup.find('.popup-title').after(proInfoHtml);
195+
positionPopup(); // Reposition after adding content
196+
}
179197
}
180198
}).catch(error => {
181-
console.error('Failed to check trial info for login popup:', error);
199+
console.error('Failed to check entitlements for login popup:', error);
182200
});
183201

184202
PopUpManager.addPopUp($popup, function() {
@@ -570,33 +588,38 @@ define(function (require, exports, module) {
570588
}
571589

572590
/**
573-
* Check if user has an active trial (works for both logged-in and non-logged-in users)
591+
* Check if user has Pro access (active trial or device license)
592+
* Works for both logged-in and non-logged-in users
574593
*/
575-
async function _hasActiveTrial() {
594+
async function _hasProActive() {
576595
try {
577596
const effectiveEntitlements = await KernalModeTrust.loginService.getEffectiveEntitlements();
578-
return effectiveEntitlements && effectiveEntitlements.isInProTrial;
597+
return effectiveEntitlements &&
598+
(effectiveEntitlements.isInProTrial ||
599+
(effectiveEntitlements.plan && effectiveEntitlements.plan.paidSubscriber));
579600
} catch (error) {
580-
console.error('Failed to check trial status:', error);
601+
console.error('Failed to check Pro access status:', error);
581602
return false;
582603
}
583604
}
584605

585606
/**
586-
* Initialize branding for non-logged-in trial users on startup
607+
* Initialize branding for non-logged-in users with Pro access (trial or device license) on startup
587608
*/
588-
async function _initializeBrandingForTrialUsers() {
609+
async function _setBrandingForNonLoggedInUser() {
589610
try {
590611
const effectiveEntitlements = await KernalModeTrust.loginService.getEffectiveEntitlements();
591-
if (effectiveEntitlements && effectiveEntitlements.isInProTrial) {
592-
console.log('Profile Menu: Found active trial, updating branding...');
612+
if (effectiveEntitlements &&
613+
(effectiveEntitlements.isInProTrial ||
614+
(effectiveEntitlements.plan && effectiveEntitlements.plan.paidSubscriber))) {
615+
console.log('Profile Menu: Found Pro entitlements (trial or device license), updating branding...');
593616
_updateBranding(effectiveEntitlements);
594617
} else {
595-
console.log('Profile Menu: No active trial found');
618+
console.log('Profile Menu: No Pro entitlements found');
596619
_updateBranding(null);
597620
}
598621
} catch (error) {
599-
console.error('Failed to initialize branding for trial users:', error);
622+
console.error('Failed to initialize branding for non-logged-in Pro users:', error);
600623
}
601624
}
602625

@@ -619,14 +642,14 @@ define(function (require, exports, module) {
619642
togglePopup();
620643
});
621644

622-
// Initialize branding for non-logged-in trial users
623-
_initializeBrandingForTrialUsers();
645+
// Initialize branding for non-logged-in users with Pro access (trial or device license)
646+
_setBrandingForNonLoggedInUser();
624647

625-
// Listen for entitlements changes to update branding for non-logged-in trial users
648+
// Listen for entitlements changes to update branding for non-logged-in Pro users
626649
KernalModeTrust.loginService.on(KernalModeTrust.loginService.EVENT_ENTITLEMENTS_CHANGED, () => {
627-
// When entitlements change (including trial activation) for non-logged-in users, update branding
650+
// When entitlements change (trial activation or device license) for non-logged-in users, update branding
628651
if (!KernalModeTrust.loginService.isLoggedIn()) {
629-
_initializeBrandingForTrialUsers();
652+
_setBrandingForNonLoggedInUser();
630653
}
631654
});
632655
}
@@ -638,19 +661,19 @@ define(function (require, exports, module) {
638661
}
639662
_removeProfileIcon();
640663

641-
// Reset branding, but preserve trial branding if user has active trial
642-
_hasActiveTrial().then(hasActiveTrial => {
643-
if (!hasActiveTrial) {
644-
// Only reset branding if no trial exists
645-
console.log('Profile Menu: No trial, resetting branding to free');
664+
// Reset branding, but preserve Pro branding if user has active trial or device license
665+
_hasProActive().then(hasProActive => {
666+
if (!hasProActive) {
667+
// Only reset branding if no trial or device license exists
668+
console.log('Profile Menu: No Pro access, resetting branding to free');
646669
_updateBranding(null);
647670
} else {
648-
// User has trial, maintain pro branding
649-
console.log('Profile Menu: Trial exists, maintaining pro branding');
650-
_initializeBrandingForTrialUsers();
671+
// User has trial or device license, maintain pro branding
672+
console.log('Profile Menu: Pro access exists, maintaining pro branding');
673+
_setBrandingForNonLoggedInUser();
651674
}
652675
}).catch(error => {
653-
console.error('Failed to check trial status during logout:', error);
676+
console.error('Failed to check Pro access status during logout:', error);
654677
// Fallback to resetting branding
655678
_updateBranding(null);
656679
});

0 commit comments

Comments
 (0)