Skip to content

Commit

Permalink
feat: New Private apps limitations (#33316)
Browse files Browse the repository at this point in the history
* 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 <lucas.pelegrino@icloud.com>
Co-authored-by: Tasso <tasso.evangelista@rocket.chat>
  • Loading branch information
3 people authored and hugocostadev committed Oct 17, 2024
1 parent 4e1f8ef commit 0cde4e4
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,20 @@ const EnabledAppsCount = ({

const percentage = limit === 0 ? 100 : Math.round((enabled * 100) / limit);

const variant = useMemo(() => {
if (enabled + 1 === limit) {
return 'warning';
}

if (limit === 0 || enabled >= limit) {
return 'danger';
}

return 'success';
}, [enabled, limit]);

const percentage = limit === 0 ? 100 : Math.round((enabled * 100) / limit);

return (
<GenericResourceUsage
title={context === 'private' ? t('Private_Apps_Count_Enabled', { count: enabled }) : t('Apps_Count_Enabled', { count: enabled })}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useTranslation } from 'react-i18next';

import { GenericResourceUsageSkeleton } from '../../../components/GenericResourceUsage';
import { PageHeader } from '../../../components/Page';
import UpgradeButton from '../../admin/subscription/components/UpgradeButton';
import UnlimitedAppsUpsellModal from '../UnlimitedAppsUpsellModal';
import { useAppsCountQuery } from '../hooks/useAppsCountQuery';
import { usePrivateAppsEnabled } from '../hooks/usePrivateAppsEnabled';
Expand All @@ -19,7 +20,7 @@ const MarketplaceHeader = ({ title, unsupportedVersion }: { title: string; unsup
const context = (useRouteParameter('context') || 'explore') as 'private' | 'explore' | 'installed' | 'premium' | 'requested';
const route = useRoute('marketplace');
const setModal = useSetModal();
const result = useAppsCountQuery(context);
const { isLoading, isError, isSuccess, data } = useAppsCountQuery(context);

const privateAppsEnabled = usePrivateAppsEnabled();

Expand All @@ -37,7 +38,16 @@ const MarketplaceHeader = ({ title, unsupportedVersion }: { title: string; unsup
route.push({ context, page: 'install' });
};

if (result.isError) {
const handleClickPrivate = () => {
if (!privateAppsEnabled) {
setModal(<PrivateAppInstallModal onClose={() => setModal(null)} onProceed={handleProceed} />);
return;
}

route.push({ context, page: 'install' });
};

if (isError) {
return null;
}

Expand Down

0 comments on commit 0cde4e4

Please sign in to comment.