Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
  • Loading branch information
SailReal committed Jan 5, 2023
1 parent 339ac92 commit 9a7e1d4
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,13 @@ public DecodedJWT get() {
public boolean isExpired() {
return Optional.ofNullable(license) //
.map(l -> l.getExpiresAt().toInstant().isBefore(Instant.now())) //
.orElseGet(() -> {
if (!managedInstance) {
return CommunityLicenseConstants.IS_EXPIRED;
} else {
return ManagedInstanceNoLicenseConstants.IS_EXPIRED;
}
});
.orElse(false);
}

/**
* Gets the number of available seats of the license
*
* @return Number of available seats, if license is not null. Otherwise {@value CommunityLicenseConstants#SEATS}.
* @return Number of available seats, if license is not null. Otherwise {@value SelfHostedNoLicenseConstants#SEATS}.
*/
public long getAvailableSeats() {
return Optional.ofNullable(license) //
Expand All @@ -98,7 +92,7 @@ public long getAvailableSeats() {

public long getNoLicenseSeats() {
if (!managedInstance) {
return CommunityLicenseConstants.SEATS;
return SelfHostedNoLicenseConstants.SEATS;
} else {
return ManagedInstanceNoLicenseConstants.SEATS;
}
Expand All @@ -108,18 +102,16 @@ public boolean isManagedInstance() {
return managedInstance;
}

public static class CommunityLicenseConstants {
public static class SelfHostedNoLicenseConstants {
public static final long SEATS = 5;
static final boolean IS_EXPIRED = false;

private CommunityLicenseConstants() {
private SelfHostedNoLicenseConstants() {
throw new IllegalStateException("Utility class");
}
}

public static class ManagedInstanceNoLicenseConstants {
public static final long SEATS = 0;
static final boolean IS_EXPIRED = false;

private ManagedInstanceNoLicenseConstants() {
throw new IllegalStateException("Utility class");
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/AdminSettings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
{{ t('admin.licenseInfo.title') }}
</h3>
<p v-if="!admin.managedInstance" class="mt-1 text-sm text-gray-500">
{{ t('admin.licenseInfo.communityLicense.description') }}
{{ t('admin.licenseInfo.selfHostedNoLicense.description') }}
</p>
<p v-else class="mt-1 text-sm text-gray-500">
{{ t('admin.licenseInfo.managedNoLicense.description') }}
Expand Down Expand Up @@ -183,7 +183,7 @@
<div class="flex justify-end items-center px-4 py-3 bg-gray-50 sm:px-6">
<button type="button" class="flex-none inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-primary hover:bg-primary-d1 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary disabled:opacity-50 disabled:hover:bg-primary disabled:cursor-not-allowed" @click="manageSubscription()">
<ArrowTopRightOnSquareIcon class="-ml-1 mr-2 h-5 w-5" aria-hidden="true" />
{{ t('admin.licenseInfo.upgradeLicense') }}
{{ t('admin.licenseInfo.getLicense') }}
</button>
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions frontend/src/i18n/de-DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@
"admin.licenseInfo.expiresAt.description.valid": "Deine Lizenz ist gültig.",
"admin.licenseInfo.expiresAt.description.expired": "Deine Lizenz ist abgelaufen.",
"admin.licenseInfo.manageSubscription": "Abonnement verwalten",
"admin.licenseInfo.communityLicense.description": "Vielen Dank, dass du Cryptomator Hub nutzt! Du hast die Community-Lizenz erhalten. Wenn du mehr Sitze benötigst, erweiter deine Lizenz.",
"admin.licenseInfo.communityLicense.type.title": "Typ",
"admin.licenseInfo.communityLicense.upgradeLicense": "Lizenz erhalten",
"admin.licenseInfo.type.title": "Typ",
"admin.licenseInfo.getLicense": "Lizenz erhalten",
"admin.licenseInfo.selfHostedNoLicense.description": "Vielen Dank, dass du Cryptomator Hub nutzt! Du hast die Community-Lizenz erhalten. Wenn du mehr Sitze benötigst, erweiter deine Lizenz.",
"admin.licenseInfo.managedNoLicense.description": "Vielen Dank, dass du Cryptomator Hub nutzt! Du hast aktuell keine aktive Lizenz.",

"authenticateVaultAdminDialog.title": "Tresor verwalten",
"authenticateVaultAdminDialog.description": "Gib das Vault-Admin-Passwort des Tresors ein, um ihn zu verwalten.",
Expand Down
5 changes: 2 additions & 3 deletions frontend/src/i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,9 @@
"admin.licenseInfo.expiresAt.description.expired": "Your license has expired.",
"admin.licenseInfo.manageSubscription": "Manage Subscription",
"admin.licenseInfo.type.title": "Type",
"admin.licenseInfo.upgradeLicense": "Get License",
"admin.licenseInfo.communityLicense.description": "Thank you for using Cryptomator Hub! You have been granted the Community License. If you need more seats, upgrade your license.",
"admin.licenseInfo.getLicense": "Get License",
"admin.licenseInfo.selfHostedNoLicense.description": "Thank you for using Cryptomator Hub! You have been granted the Community License. If you need more seats, upgrade your license.",
"admin.licenseInfo.managedNoLicense.description": "Thank you for using Cryptomator Hub! You currently have no active license.",


"authenticateVaultAdminDialog.title": "Manage Vault",
"authenticateVaultAdminDialog.description": "Type in the vault admin password to manage it.",
Expand Down

0 comments on commit 9a7e1d4

Please sign in to comment.