-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: New Private apps limitations (#33316)
* feat: New empty state for upgrading private Apps * chore: Change Marketplace info modal text (#33239) * feat: New tooltips and color behavior for private apps bar (#33243) * feat: New tooltips and behavior for private apps bar * Create brown-pants-press.md * feat: new modal on Private Apps install (#33275) * feat: new modal on Private Apps install * add more variations * Create eleven-rockets-hug.md * chore: change grandfathered modal text (#33291) * chore: Use apps provider to check maxPrivateApps * fix: adds minor fixes to UI and changes requested on review * Update changeset * Replace negative boolean * Refactor `AppsUsageCard` * Add unit test for `AppsUsageCard` * Add unit test for `PrivateEmptyState` * Add unit test for `EnabledAppsCount` * Move tooltip logic away from `useAppsCountQuery` --------- Co-authored-by: Lucas Pelegrino <[email protected]> Co-authored-by: Tasso <[email protected]>
- Loading branch information
Showing
31 changed files
with
582 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@rocket.chat/meteor": major | ||
"@rocket.chat/i18n": major | ||
--- | ||
|
||
Changes some displays to reflect new rules for private apps and adds a new modal before uploading a private app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
apps/meteor/client/components/GenericResourceUsage/GenericResourceUsageSkeleton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
apps/meteor/client/views/admin/subscription/components/InfoTextIconModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 0 additions & 71 deletions
71
apps/meteor/client/views/admin/subscription/components/cards/AppsUsageCard.tsx
This file was deleted.
Oops, something went wrong.
84 changes: 84 additions & 0 deletions
84
...eor/client/views/admin/subscription/components/cards/AppsUsageCard/AppsUsageCard.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { mockAppRoot } from '@rocket.chat/mock-providers'; | ||
import { render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import React from 'react'; | ||
|
||
import AppsUsageCard from './AppsUsageCard'; | ||
|
||
const appRoot = mockAppRoot().withTranslations('en', 'core', { | ||
Apps_InfoText_limited: | ||
'Community workspaces can enable up to {{marketplaceAppsMaxCount}} marketplace apps. Private apps can only be enabled in <1>premium plans</1>.', | ||
Apps_InfoText: | ||
'Community allows up to {{privateAppsMaxCount}} private apps and {{marketplaceAppsMaxCount}} marketplace apps to be enabled', | ||
}); | ||
|
||
it('should render a skeleton if no data', () => { | ||
render(<AppsUsageCard />, { wrapper: appRoot.build(), legacyRoot: true }); | ||
|
||
expect(screen.getByRole('heading', { name: 'Apps' })).toBeInTheDocument(); | ||
expect(screen.getByRole('presentation')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render data as progress bars', async () => { | ||
render(<AppsUsageCard privateAppsLimit={{ value: 1, max: 3 }} marketplaceAppsLimit={{ value: 2, max: 5 }} />, { | ||
wrapper: appRoot.build(), | ||
legacyRoot: true, | ||
}); | ||
|
||
expect(screen.getByRole('heading', { name: 'Apps' })).toBeInTheDocument(); | ||
expect(screen.getByRole('button', { name: 'Click_here_for_more_info' })).toBeInTheDocument(); | ||
|
||
expect(screen.getByRole('progressbar', { name: 'Marketplace_apps' })).toBeInTheDocument(); | ||
expect(screen.getByRole('progressbar', { name: 'Marketplace_apps' })).toHaveAttribute('aria-valuenow', '40'); | ||
expect(screen.getByText('2 / 5')).toBeInTheDocument(); | ||
|
||
expect(screen.getByRole('progressbar', { name: 'Private_apps' })).toBeInTheDocument(); | ||
expect(screen.getByRole('progressbar', { name: 'Private_apps' })).toHaveAttribute('aria-valuenow', '33'); | ||
expect(screen.getByText('1 / 3')).toBeInTheDocument(); | ||
|
||
await userEvent.click(screen.getByRole('button', { name: 'Click_here_for_more_info' })); | ||
|
||
expect( | ||
screen.getByText('Community workspaces can enable up to 5 marketplace apps. Private apps can only be enabled in premium plans.'), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render an upgrade button if marketplace apps reached 80% of the limit', async () => { | ||
render(<AppsUsageCard privateAppsLimit={{ value: 1, max: 3 }} marketplaceAppsLimit={{ value: 4, max: 5 }} />, { | ||
wrapper: appRoot.build(), | ||
legacyRoot: true, | ||
}); | ||
|
||
expect(screen.getByRole('heading', { name: 'Apps' })).toBeInTheDocument(); | ||
expect(screen.getByRole('button', { name: 'Click_here_for_more_info' })).toBeInTheDocument(); | ||
|
||
expect(screen.getByRole('button', { name: 'Upgrade' })).toBeInTheDocument(); | ||
|
||
await userEvent.click(screen.getByRole('button', { name: 'Click_here_for_more_info' })); | ||
|
||
expect( | ||
screen.getByText('Community workspaces can enable up to 5 marketplace apps. Private apps can only be enabled in premium plans.'), | ||
).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render a full progress bar with private apps disabled', async () => { | ||
render(<AppsUsageCard privateAppsLimit={{ value: 0, max: 0 }} marketplaceAppsLimit={{ value: 2, max: 5 }} />, { | ||
wrapper: appRoot.build(), | ||
legacyRoot: true, | ||
}); | ||
|
||
expect(screen.getByRole('heading', { name: 'Apps' })).toBeInTheDocument(); | ||
expect(screen.getByRole('button', { name: 'Click_here_for_more_info' })).toBeInTheDocument(); | ||
|
||
expect(screen.getByRole('progressbar', { name: 'Marketplace_apps' })).toBeInTheDocument(); | ||
expect(screen.getByRole('progressbar', { name: 'Marketplace_apps' })).toHaveAttribute('aria-valuenow', '40'); | ||
expect(screen.getByText('2 / 5')).toBeInTheDocument(); | ||
|
||
expect(screen.getByRole('progressbar', { name: 'Private_apps' })).toBeInTheDocument(); | ||
expect(screen.getByRole('progressbar', { name: 'Private_apps' })).toHaveAttribute('aria-valuenow', '100'); | ||
expect(screen.getByText('0 / 0')).toBeInTheDocument(); | ||
|
||
await userEvent.click(screen.getByRole('button', { name: 'Click_here_for_more_info' })); | ||
|
||
expect(screen.getByText('Community allows up to 0 private apps and 5 marketplace apps to be enabled')).toBeInTheDocument(); | ||
}); |
84 changes: 84 additions & 0 deletions
84
apps/meteor/client/views/admin/subscription/components/cards/AppsUsageCard/AppsUsageCard.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { Box, Skeleton } from '@rocket.chat/fuselage'; | ||
import type { ReactElement } from 'react'; | ||
import React from 'react'; | ||
import { Trans, useTranslation } from 'react-i18next'; | ||
|
||
import type { CardProps } from '../../FeatureUsageCard'; | ||
import FeatureUsageCard from '../../FeatureUsageCard'; | ||
import UpgradeButton from '../../UpgradeButton'; | ||
import AppsUsageCardSection from './AppsUsageCardSection'; | ||
|
||
// Magic numbers | ||
const marketplaceAppsMaxCountFallback = 5; | ||
const privateAppsMaxCountFallback = 0; | ||
const defaultWarningThreshold = 80; | ||
|
||
type AppsUsageCardProps = { | ||
privateAppsLimit?: { value?: number; max: number }; | ||
marketplaceAppsLimit?: { value?: number; max: number }; | ||
}; | ||
|
||
const AppsUsageCard = ({ privateAppsLimit, marketplaceAppsLimit }: AppsUsageCardProps): ReactElement => { | ||
const { t } = useTranslation(); | ||
|
||
if (!privateAppsLimit || !marketplaceAppsLimit) { | ||
// FIXME: not accessible enough | ||
return ( | ||
<FeatureUsageCard card={{ title: t('Apps') }}> | ||
<Skeleton variant='rect' width='x112' height='x112' role='presentation' /> | ||
</FeatureUsageCard> | ||
); | ||
} | ||
|
||
const marketplaceAppsCount = marketplaceAppsLimit?.value || 0; | ||
const marketplaceAppsMaxCount = marketplaceAppsLimit?.max || marketplaceAppsMaxCountFallback; | ||
const marketplaceAppsPercentage = Math.round((marketplaceAppsCount / marketplaceAppsMaxCount) * 100) || 0; | ||
const marketplaceAppsAboveWarning = marketplaceAppsPercentage >= defaultWarningThreshold; | ||
|
||
const privateAppsCount = privateAppsLimit?.value || 0; | ||
const privateAppsMaxCount = privateAppsLimit?.max || privateAppsMaxCountFallback; | ||
|
||
const card: CardProps = { | ||
title: t('Apps'), | ||
infoText: | ||
privateAppsCount > 0 ? ( | ||
<Trans i18nKey='Apps_InfoText_limited' tOptions={{ marketplaceAppsMaxCount }}> | ||
Community workspaces can enable up to {{ marketplaceAppsMaxCount }} marketplace apps. Private apps can only be enabled in{' '} | ||
<Box is='a' href='https://www.rocket.chat/pricing' target='_blank' color='info'> | ||
premium plans | ||
</Box> | ||
. | ||
</Trans> | ||
) : ( | ||
t('Apps_InfoText', { privateAppsMaxCount, marketplaceAppsMaxCount }) | ||
), | ||
...(marketplaceAppsAboveWarning && { | ||
upgradeButton: ( | ||
<UpgradeButton target='app-usage-card' action='upgrade' small> | ||
{t('Upgrade')} | ||
</UpgradeButton> | ||
), | ||
}), | ||
}; | ||
|
||
return ( | ||
<FeatureUsageCard card={card}> | ||
<AppsUsageCardSection | ||
title={t('Marketplace_apps')} | ||
appsCount={marketplaceAppsCount} | ||
appsMaxCount={marketplaceAppsMaxCount} | ||
warningThreshold={defaultWarningThreshold} | ||
/> | ||
|
||
<AppsUsageCardSection | ||
title={t('Private_apps')} | ||
tip={privateAppsMaxCount === 0 ? t('Private_apps_premium_message') : undefined} | ||
appsCount={privateAppsCount} | ||
appsMaxCount={privateAppsMaxCount} | ||
warningThreshold={defaultWarningThreshold} | ||
/> | ||
</FeatureUsageCard> | ||
); | ||
}; | ||
|
||
export default AppsUsageCard; |
Oops, something went wrong.