Skip to content

Commit

Permalink
Add support for usages with 30 days period (#6401)
Browse files Browse the repository at this point in the history
  • Loading branch information
4ian authored Feb 28, 2024
1 parent f3ee18c commit 5118f13
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 12 deletions.
36 changes: 24 additions & 12 deletions newIDE/app/src/Profile/CurrentUsageDisplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,30 @@ const CurrentUsageDisplayer = ({
const usedBuilds = Math.min(quota.current + numberOfPendingBuilds, quota.max);
const remainingBuilds = Math.max(quota.max - usedBuilds, 0);
const usageRatio = `${usedBuilds}/${quota.max}`;
const remainingMultipleMessage = (
<Trans>
You have {remainingBuilds} builds remaining (you have used {usageRatio} in
the last 24h).
</Trans>
);
const remainingSingleMessage = (
<Trans>
You have {remainingBuilds} build remaining (you have used {usageRatio} in
the last 24h).
</Trans>
);
const remainingMultipleMessage =
quota.period === '30days' ? (
<Trans>
You have <b>{remainingBuilds}</b> builds remaining — you have used
{usageRatio} in the past 30 days.
</Trans>
) : (
<Trans>
You have <b>{remainingBuilds}</b> builds remaining — you have used
{usageRatio} in the past 24h.
</Trans>
);
const remainingSingleMessage =
quota.period === '30days' ? (
<Trans>
You have <b>{remainingBuilds}</b> build remaining — you have used
{usageRatio} in the past 30 days.
</Trans>
) : (
<Trans>
You have <b>{remainingBuilds}</b> build remaining — you have used
{usageRatio} in the past 24h.
</Trans>
);
return (
<ColumnStackLayout noMargin>
{hasSubscription ? (
Expand Down
1 change: 1 addition & 0 deletions newIDE/app/src/Utils/GDevelopServices/Usage.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export type Quota = {|
limitReached: boolean,
current: number,
max: number,
period?: '1day' | '30days',
|};

export type Quotas = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,21 @@ export const Default = () => (
current: 2,
max: 10,
limitReached: false,
period: '1day',
}}
onChangeSubscription={action('on change subscription callback')}
numberOfPendingBuilds={0}
/>
);

export const Default30Days = () => (
<CurrentUsageDisplayer
subscription={subscriptionForIndieUser}
quota={{
current: 2,
max: 10,
limitReached: false,
period: '30days',
}}
onChangeSubscription={action('on change subscription callback')}
numberOfPendingBuilds={0}
Expand All @@ -39,6 +54,7 @@ export const With2BuildsRunning = () => (
current: 0,
max: 5,
limitReached: false,
period: '1day',
}}
onChangeSubscription={action('on change subscription callback')}
numberOfPendingBuilds={2}
Expand All @@ -52,6 +68,21 @@ export const With1BuildRemaining = () => (
current: 4,
max: 5,
limitReached: false,
period: '1day',
}}
onChangeSubscription={action('on change subscription callback')}
numberOfPendingBuilds={0}
/>
);

export const With1BuildRemaining30Days = () => (
<CurrentUsageDisplayer
subscription={subscriptionForIndieUser}
quota={{
current: 4,
max: 5,
limitReached: false,
period: '30days',
}}
onChangeSubscription={action('on change subscription callback')}
numberOfPendingBuilds={0}
Expand All @@ -65,6 +96,21 @@ export const With1BuildRemainingBut1BuildRunning = () => (
current: 4,
max: 5,
limitReached: false,
period: '1day',
}}
onChangeSubscription={action('on change subscription callback')}
numberOfPendingBuilds={1}
/>
);

export const With1BuildRemainingBut1BuildRunning30Days = () => (
<CurrentUsageDisplayer
subscription={subscriptionForIndieUser}
quota={{
current: 4,
max: 5,
limitReached: false,
period: '30days',
}}
onChangeSubscription={action('on change subscription callback')}
numberOfPendingBuilds={1}
Expand All @@ -78,6 +124,7 @@ export const WithRedemptionCode = () => (
current: 2,
max: 10,
limitReached: false,
period: '1day',
}}
onChangeSubscription={action('on change subscription callback')}
numberOfPendingBuilds={0}
Expand All @@ -91,6 +138,7 @@ export const WithExpiredRedemptionCode = () => (
current: 2,
max: 10,
limitReached: false,
period: '1day',
}}
onChangeSubscription={action('on change subscription callback')}
numberOfPendingBuilds={0}
Expand Down

0 comments on commit 5118f13

Please sign in to comment.