@abyss-project/commons-front-core 20.1.0 → 20.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog — @abyss-project/commons-front-core
2
2
 
3
+ ## 20.2.0
4
+
5
+ Card #286 (satellites, S1).
6
+
7
+ - `QuotaReachedDialog` at the root (`components/business`): the « Limite atteinte » dialog on `Modal` (`Small`, bottom sheet below 768 px), driven by the root `useQuotaDialogStore` and the `quota-reached.*` keys. The blocked service is a neutral `StatusBadge`, the metric is in the header description, the hint is a warning `Callout`. Same contract as the `/legacy` one: optional `onUpgrade`, called after `hide`; without it there is no upgrade button. The `/legacy` homonym stays: `codemod-legacy-imports.mjs` keeps the name in `LEGACY_NAMES` and sends its imports to `/legacy`, an application moves to the root dialog by hand.
8
+
3
9
  ## 20.1.0
4
10
 
5
11
  Card #286 (global review, lot 2).
@@ -104,6 +104,9 @@ export const CATALOG_ENTRIES: CatalogEntry[] = [
104
104
  mobileCapture: true,
105
105
  }),
106
106
  entry('QRCodeModal', 'business', 'qr-code-modal', { mobileCapture: true }),
107
+ entry('QuotaReachedDialog', 'business', 'quota-reached-dialog', {
108
+ mobileCapture: true,
109
+ }),
107
110
  entry('CookieConsent', 'business', 'cookie-consent', {
108
111
  mobileCapture: true,
109
112
  }),
@@ -0,0 +1,38 @@
1
+ import { useEffect } from 'react';
2
+ import Button from '@mui/material/Button';
3
+ import { BillingMetric, BillingService } from '@abyss-project/main';
4
+ import { QuotaReachedDialog } from '../../src/components/business/QuotaReachedDialog/QuotaReachedDialog';
5
+ import { useQuotaDialogStore } from '../../src/hooks/quota-dialog.store';
6
+ import { Example, LastEvent, Showcase, useEventLog } from '../frame';
7
+
8
+ const showCryptQuota = () =>
9
+ useQuotaDialogStore.getState().show({
10
+ metric: BillingMetric.CRYPT_ENCRYPTIONS_MONTH,
11
+ service: BillingService.ABYSS_CRYPT,
12
+ });
13
+
14
+ export const QuotaReachedDialogPage = () => {
15
+ const { log } = useEventLog();
16
+
17
+ // Opened on arrival, as the billing-quota interceptor would, so the captures show the dialog.
18
+ useEffect(() => {
19
+ showCryptQuota();
20
+ return () => useQuotaDialogStore.getState().hide();
21
+ }, []);
22
+
23
+ return (
24
+ <Showcase
25
+ family="Métier"
26
+ name="QuotaReachedDialog"
27
+ description="Ouverte par l'intercepteur de quota : nomme le service et la métrique bloqués ; « Voir les plans » n'existe que si l'hôte passe onUpgrade."
28
+ >
29
+ <Example title="Chiffrements / mois, AbyssCrypt">
30
+ <Button variant="outlined" onClick={showCryptQuota}>
31
+ Chiffrer un fichier
32
+ </Button>
33
+ </Example>
34
+ <LastEvent />
35
+ <QuotaReachedDialog onUpgrade={() => log('voir les plans')} />
36
+ </Showcase>
37
+ );
38
+ };
@@ -59,6 +59,7 @@ import { PageStatePage } from './PageState';
59
59
  import { PreviewDrawerPage } from './PreviewDrawer';
60
60
  import { ProductTourPage } from './ProductTour';
61
61
  import { QRCodeModalPage } from './QRCodeModal';
62
+ import { QuotaReachedDialogPage } from './QuotaReachedDialog';
62
63
  import { RichSelectPage } from './RichSelect';
63
64
  import { RoleBadgePage } from './RoleBadge';
64
65
  import { ScanBadgePage } from './ScanBadge';
@@ -145,6 +146,7 @@ export const CATALOG_PAGES: Record<string, ComponentType> = {
145
146
  PreviewDrawer: PreviewDrawerPage,
146
147
  ProductTour: ProductTourPage,
147
148
  QRCodeModal: QRCodeModalPage,
149
+ QuotaReachedDialog: QuotaReachedDialogPage,
148
150
  RichSelect: RichSelectPage,
149
151
  RoleBadge: RoleBadgePage,
150
152
  ScanBadge: ScanBadgePage,
@@ -0,0 +1,13 @@
1
+ export interface QuotaReachedDialogProps {
2
+ /**
3
+ * Called after the dialog is hidden, from the upgrade button; the host decides where to send the
4
+ * user. Without it the dialog has no upgrade button.
5
+ */
6
+ onUpgrade?(): void;
7
+ }
8
+ /**
9
+ * The "quota reached" dialog of every Abyss front: mounted once at the app root, it opens when the
10
+ * billing-quota interceptor pushes a payload into `useQuotaDialogStore`, and names the blocked
11
+ * service and metric.
12
+ */
13
+ export declare const QuotaReachedDialog: ({ onUpgrade }: QuotaReachedDialogProps) => import("react/jsx-runtime").JSX.Element | null;
@@ -2,6 +2,7 @@ export * from './InfectedDownloadModal/InfectedDownloadModal';
2
2
  export * from './CloudImport/CloudImport';
3
3
  export * from './ImportFromCloudModal/ImportFromCloudModal';
4
4
  export * from './QRCodeModal/QRCodeModal';
5
+ export * from './QuotaReachedDialog/QuotaReachedDialog';
5
6
  export * from './CookieConsent/AbyssCookieConsentProvider';
6
7
  export * from './CookieConsent/CookieConsentBanner';
7
8
  export * from './CookieConsent/CookieConsentSettings';