Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: non-commercial licences indication #2748

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ open class SelfHostedEePlanModel(
val includedUsage: PlanIncludedUsageModel = PlanIncludedUsageModel(),
val hasYearlyPrice: Boolean = false,
val free: Boolean,
val nonCommercial: Boolean,
) : RepresentationModel<SelfHostedEePlanModel>()
1 change: 1 addition & 0 deletions e2e/cypress/support/dataCyType.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ declare namespace DataCy {
"administration-cloud-plan-field-included-mt-credits" |
"administration-cloud-plan-field-included-translations" |
"administration-cloud-plan-field-name" |
"administration-cloud-plan-field-non-commercial" |
"administration-cloud-plan-field-price-monthly" |
"administration-cloud-plan-field-price-per-thousand-mt-credits" |
"administration-cloud-plan-field-price-per-thousand-translations" |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class EeLicensingMockRequestUtil {
subscriptionMonthly = 200.toBigDecimal(),
),
free = false,
nonCommercial = false,
)

final val mockedSubscriptionResponse =
Expand Down
21 changes: 19 additions & 2 deletions webapp/src/component/billing/Plan/Plan.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import { PlanType } from './types';
import { IncludedUsage } from './IncludedUsage';
import { ContactUsButton } from './ContactUsButton';
import { isPlanLegacy } from './plansTools';
import { Box, useTheme } from '@mui/material';
import { Box, Chip, Tooltip, useTheme } from '@mui/material';
import { useTranslate } from '@tolgee/react';

type Features = PlanType['enabledFeatures'];

Expand All @@ -31,6 +32,7 @@ type Props = {
featuresMinHeight?: string;
action: React.ReactNode;
custom?: boolean;
nonCommercial: boolean;
};

export const Plan: FC<Props> = ({
Expand All @@ -44,25 +46,40 @@ export const Plan: FC<Props> = ({
featuresMinHeight,
action,
custom,
nonCommercial,
}) => {
const theme = useTheme();
const highlightColor = custom
? theme.palette.tokens.info.main
: theme.palette.tokens.primary.main;
const { t } = useTranslate();

return (
<PlanContainer className={clsx({ active })} data-cy="billing-plan">
<PlanActiveBanner active={active} ended={ended} custom={custom} />
<PlanContent>
<PlanTitle sx={{ paddingBottom: '20px', color: highlightColor }}>
<PlanTitle sx={{ pb: '10px', color: highlightColor }}>
{plan.name}
</PlanTitle>

{nonCommercial && (
<Box display="flex" justifyContent="center">
<Tooltip title={t('billing_plan_non_commercial_hint')}>
<Chip
label={t('billing_plan_non_commercial_label')}
size="small"
color="success"
/>
</Tooltip>
</Box>
)}

<Box
display="flex"
flexDirection="column"
alignItems="stretch"
flexGrow={1}
sx={{ pt: '10px' }}
>
<PlanFeaturesBox sx={{ gap: '18px' }}>
<IncludedFeatures
Expand Down
2 changes: 2 additions & 0 deletions webapp/src/ee/billing/Subscriptions/cloud/PlansCloudList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const PlansCloudList: React.FC<BillingPlansProps> = ({
free: false,
hasYearlyPrice: false,
public: true,
nonCommercial: false,
});

const parentForPublic: PlanType[] = [];
Expand Down Expand Up @@ -124,6 +125,7 @@ export const PlansCloudList: React.FC<BillingPlansProps> = ({
filteredFeatures={filteredFeatures}
featuresMinHeight="155px"
custom={custom}
nonCommercial={plan.nonCommercial}
topFeature={
parentPlan && <AllFromPlanFeature planName={parentPlan} />
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const PlansSelfHostedList: React.FC<BillingPlansProps> = ({
free: false,
hasYearlyPrice: false,
public: true,
nonCommercial: false,
});

const parentForPublic: PlanType[] = [];
Expand Down Expand Up @@ -87,6 +88,7 @@ export const PlansSelfHostedList: React.FC<BillingPlansProps> = ({
period={period}
filteredFeatures={filteredFeatures}
featuresMinHeight="210px"
nonCommercial={plan.nonCommercial}
topFeature={
previousPlanName ? (
<AllFromPlanFeature planName={previousPlanName} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ export const AdministrationCloudPlanCreateView = () => {
public: true,
forOrganizationIds: [],
free: false,
nonCommercial: false,
autoAssignOrganizationIds: [],
}}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ export const AdministrationEePlanCreateView = () => {
enabledFeatures: [],
public: true,
free: false,
nonCommercial: false,
}}
/>
</Box>
Expand Down
14 changes: 14 additions & 0 deletions webapp/src/ee/billing/administration/components/CloudPlanForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export type CloudPlanFormData = {
public: boolean;
free: boolean;
autoAssignOrganizationIds: CloudPlanModel['autoAssignOrganizationIds'];
nonCommercial: boolean;
};

type Props = {
Expand Down Expand Up @@ -309,6 +310,19 @@ export function CloudPlanForm({
label={t('administration_cloud_plan_field_free')}
/>

<FormControlLabel
control={
<Switch
checked={values.nonCommercial}
onChange={() =>
setFieldValue('nonCommercial', !values.nonCommercial)
}
/>
}
data-cy="administration-cloud-plan-field-non-commercial"
label="Non-commercial"
/>

{!values.public && (
<Box>
<CloudPlanOrganizations
Expand Down
15 changes: 15 additions & 0 deletions webapp/src/ee/billing/administration/components/EePlanForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type FormData = {
public: boolean;
forOrganizationIds: number[];
free: boolean;
nonCommercial: boolean;
};

type Props = {
Expand Down Expand Up @@ -66,6 +67,7 @@ export function EePlanForm({ planId, initialData, onSubmit, loading }: Props) {
public: initialData.public,
forOrganizationIds: initialData.forOrganizationIds,
free: initialData.free,
nonCommercial: initialData.nonCommercial,
}}
enableReinitialize
onSubmit={onSubmit}
Expand Down Expand Up @@ -242,6 +244,19 @@ export function EePlanForm({ planId, initialData, onSubmit, loading }: Props) {
label={t('administration_ee_plan_field_free')}
/>

<FormControlLabel
control={
<Switch
checked={values.nonCommercial}
onChange={() =>
setFieldValue('nonCommercial', !values.nonCommercial)
}
/>
}
data-cy="administration-cloud-plan-field-non-commercial"
label="Non-commercial"
/>

{!values.public && (
<Box>
<EePlanOrganizations
Expand Down
Loading
Loading