Skip to content

Commit

Permalink
fix: display non-commercial license on self-hosted (#2783)
Browse files Browse the repository at this point in the history
  • Loading branch information
stepan662 authored Dec 17, 2024
1 parent aba6059 commit 54c6019
Show file tree
Hide file tree
Showing 10 changed files with 59 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@ open class EeSubscriptionModel(
val cancelAtPeriodEnd: Boolean,
val currentUserCount: Long,
val status: SubscriptionStatus,
val nonCommerical: Boolean,
var lastValidCheck: Date?,
) : RepresentationModel<EeSubscriptionModel>(), Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ data class EeSubscriptionDto(
var enabledFeatures: Array<Feature>,
var status: SubscriptionStatus = SubscriptionStatus.ACTIVE,
var lastValidCheck: Date? = null,
var nonCommercial: Boolean = false,
)
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class EeSubscriptionModelAssembler(
currentUserCount = currentUserCount,
status = eeSubscription.status,
lastValidCheck = eeSubscription.lastValidCheck,
nonCommerical = eeSubscription.nonCommercial,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ class EeSubscription : AuditModel(), IEeSubscription {

override var lastValidCheck: Date? = null

@ColumnDefault("false")
var nonCommercial: Boolean = false

fun toDto(): EeSubscriptionDto {
return EeSubscriptionDto(
licenseKey = licenseKey,
Expand All @@ -56,6 +59,7 @@ class EeSubscription : AuditModel(), IEeSubscription {
enabledFeatures = enabledFeatures,
status = status,
lastValidCheck = lastValidCheck,
nonCommercial = nonCommercial,
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class EeSubscriptionServiceImpl(
entity.name = responseBody.plan.name
entity.currentPeriodEnd = responseBody.currentPeriodEnd?.let { Date(it) }
entity.enabledFeatures = responseBody.plan.enabledFeatures
entity.nonCommercial = responseBody.plan.nonCommercial
return self.save(entity)
}

Expand Down Expand Up @@ -197,6 +198,7 @@ class EeSubscriptionServiceImpl(
subscription.enabledFeatures = responseBody.plan.enabledFeatures
subscription.status = responseBody.status
subscription.lastValidCheck = currentDateProvider.date
subscription.nonCommercial = responseBody.plan.nonCommercial
self.save(subscription)
}
}
Expand Down
7 changes: 7 additions & 0 deletions ee/backend/app/src/main/resources/db/changelog/ee-schema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,11 @@
<changeSet author="jenik (generated)" id="1706777078864-1">
<dropNotNullConstraint columnDataType="timestamp(6)" columnName="current_period_end" tableName="ee_subscription"/>
</changeSet>
<changeSet author="stepangranat (generated)" id="1734364086358-1">
<addColumn tableName="ee_subscription">
<column defaultValueBoolean="false" name="non_commercial" type="boolean">
<constraints nullable="false"/>
</column>
</addColumn>
</changeSet>
</databaseChangeLog>
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const SelfHostedEeActiveSubscription: FC<Props> = ({
<Box display="flex" justifyContent="space-between">
<ActivePlanTitle
name={plan.name}
nonCommercial={plan.nonCommercial}
status={subscription.status}
createdAt={subscription.createdAt}
periodStart={subscription.currentPeriodStart}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { T } from '@tolgee/react';
import { Box, Typography } from '@mui/material';
import { T, useTranslate } from '@tolgee/react';
import { Box, Chip, Tooltip, Typography } from '@mui/material';

import { components } from 'tg.service/billingApiSchema.generated';
import { useDateFormatter } from 'tg.hooks/useLocale';
Expand All @@ -14,6 +14,7 @@ type Props = {
periodStart?: number;
periodEnd?: number;
highlightColor: string;
nonCommercial: boolean;
};

export const ActivePlanTitle = ({
Expand All @@ -22,14 +23,28 @@ export const ActivePlanTitle = ({
periodStart,
periodEnd,
highlightColor,
nonCommercial,
}: Props) => {
const formatDate = useDateFormatter();
const { t } = useTranslate();

return (
<Box sx={{ mb: 1 }}>
<PlanTitleText sx={{ color: highlightColor, mb: 1 }}>
{name}
</PlanTitleText>
<Box display="flex" alignItems="center" gap={2}>
<PlanTitleText sx={{ color: highlightColor, mb: 1 }}>
{name}
</PlanTitleText>
{nonCommercial && (
<Tooltip title={t('billing_plan_non_commercial_hint')}>
<Chip
sx={{ mt: -1 }}
label={t('billing_plan_non_commercial_label')}
size="small"
color="success"
/>
</Tooltip>
)}
</Box>
<Box display="grid">
{createdAt && (
<Typography variant="caption">
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/ee/eeLicense/ActiveEeLicense.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@ export const ActiveEeLicense = ({ info }: Props) => {
name={info.name}
status={info.status}
highlightColor={highlightColor}
nonCommercial={info.nonCommerical}
/>
<RefreshButton />
</Box>

{info.status === 'ACTIVE' ? (
<PlanFeaturesBox sx={{ gap: '18px', mb: 1 }}>
<StyledFeatures features={info.enabledFeatures} />
Expand Down
39 changes: 20 additions & 19 deletions webapp/src/service/apiSchema.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1200,14 +1200,6 @@ export interface components {
| "SERVER_ADMIN";
/** @description The user's permission type. This field is null if uses granular permissions */
type?: "NONE" | "VIEW" | "TRANSLATE" | "REVIEW" | "EDIT" | "MANAGE";
/**
* @deprecated
* @description Deprecated (use translateLanguageIds).
*
* List of languages current user has TRANSLATE permission to. If null, all languages edition is permitted.
* @example 200001,200004
*/
permittedLanguageIds?: number[];
/**
* @description List of languages user can translate to. If null, all languages editing is permitted.
* @example 200001,200004
Expand All @@ -1218,6 +1210,14 @@ export interface components {
* @example 200001,200004
*/
stateChangeLanguageIds?: number[];
/**
* @deprecated
* @description Deprecated (use translateLanguageIds).
*
* List of languages current user has TRANSLATE permission to. If null, all languages edition is permitted.
* @example 200001,200004
*/
permittedLanguageIds?: number[];
/**
* @description Granted scopes to the user. When user has type permissions, this field contains permission scopes of the type.
* @example KEYS_EDIT,TRANSLATIONS_VIEW
Expand Down Expand Up @@ -2197,10 +2197,10 @@ export interface components {
createNewKeys: boolean;
};
ImportSettingsModel: {
/** @description If true, key descriptions will be overridden by the import */
overrideKeyDescriptions: boolean;
/** @description If true, placeholders from other formats will be converted to ICU when possible */
convertPlaceholdersToIcu: boolean;
/** @description If true, key descriptions will be overridden by the import */
overrideKeyDescriptions: boolean;
/** @description If false, only updates keys, skipping the creation of new keys */
createNewKeys: boolean;
};
Expand Down Expand Up @@ -2472,6 +2472,7 @@ export interface components {
| "UNPAID"
| "ERROR"
| "KEY_USED_BY_ANOTHER_INSTANCE";
nonCommerical: boolean;
/** Format: date-time */
lastValidCheck?: string;
};
Expand Down Expand Up @@ -2527,16 +2528,16 @@ export interface components {
key: string;
/** Format: int64 */
id: number;
projectName: string;
username?: string;
description: string;
/** Format: int64 */
expiresAt?: number;
scopes: string[];
/** Format: int64 */
projectId: number;
/** Format: int64 */
expiresAt?: number;
/** Format: int64 */
lastUsedAt?: number;
projectName: string;
userFullName?: string;
};
SuperTokenRequest: {
Expand Down Expand Up @@ -3743,13 +3744,13 @@ export interface components {
avatar?: components["schemas"]["Avatar"];
/** @example btforg */
slug: string;
basePermissions: components["schemas"]["PermissionModel"];
/**
* @description The role of currently authorized user.
*
* Can be null when user has direct access to one of the projects owned by the organization.
*/
currentUserRole?: "MEMBER" | "OWNER";
basePermissions: components["schemas"]["PermissionModel"];
};
PublicBillingConfigurationDTO: {
enabled: boolean;
Expand Down Expand Up @@ -3924,19 +3925,19 @@ export interface components {
name: string;
/** Format: int64 */
id: number;
translation?: string;
namespace?: string;
description?: string;
translation?: string;
baseTranslation?: string;
};
KeySearchSearchResultModel: {
view?: components["schemas"]["KeySearchResultView"];
name: string;
/** Format: int64 */
id: number;
translation?: string;
namespace?: string;
description?: string;
translation?: string;
baseTranslation?: string;
};
PagedModelKeySearchSearchResultModel: {
Expand Down Expand Up @@ -4665,16 +4666,16 @@ export interface components {
permittedLanguageIds?: number[];
/** Format: int64 */
id: number;
projectName: string;
username?: string;
description: string;
/** Format: int64 */
expiresAt?: number;
scopes: string[];
/** Format: int64 */
projectId: number;
/** Format: int64 */
expiresAt?: number;
/** Format: int64 */
lastUsedAt?: number;
projectName: string;
userFullName?: string;
};
PagedModelUserAccountModel: {
Expand Down

0 comments on commit 54c6019

Please sign in to comment.