@camunda/ccma-saas-frontend 0.8.4 → 0.10.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.
Files changed (32) hide show
  1. package/lib/esm/components/c4-delete-account-modal/c4-delete-account-modal.d.ts +10 -0
  2. package/lib/esm/components/c4-delete-account-modal/c4-delete-account-modal.js +54 -0
  3. package/lib/esm/components/c4-delete-account-modal/c4-delete-account-modal.types.d.ts +47 -0
  4. package/lib/esm/components/c4-delete-account-modal/c4-delete-account-modal.types.js +33 -0
  5. package/lib/esm/components/c4-help-center/c4-help-center.d.ts +9 -1
  6. package/lib/esm/components/c4-help-center/c4-help-center.js +34 -4
  7. package/lib/esm/components/c4-help-center/help-center-app-host.d.ts +23 -0
  8. package/lib/esm/components/c4-help-center/help-center-app-host.js +69 -0
  9. package/lib/esm/components/c4-help-center/help-center-placeholders.d.ts +26 -0
  10. package/lib/esm/components/c4-help-center/help-center-placeholders.js +49 -0
  11. package/lib/esm/components/c4-navigation/c4-navigation.d.ts +12 -0
  12. package/lib/esm/components/c4-navigation/c4-navigation.js +2 -2
  13. package/lib/esm/externalUrls.const.d.ts +2 -0
  14. package/lib/esm/externalUrls.const.js +4 -0
  15. package/lib/esm/i18n/en/modals/users.json +8 -2
  16. package/lib/esm/index.d.ts +9 -1
  17. package/lib/esm/index.js +5 -1
  18. package/lib/esm/runtime/c4-console-authz.d.ts +13 -0
  19. package/lib/esm/runtime/c4-console-authz.js +17 -0
  20. package/lib/esm/runtime/c4-console-runtime-context.d.ts +13 -3
  21. package/lib/esm/runtime/c4-console-runtime-context.js +14 -2
  22. package/lib/esm/runtime/index.d.ts +1 -1
  23. package/lib/esm/runtime/index.js +1 -1
  24. package/lib/esm/runtime/use-hub-api-naming.d.ts +15 -7
  25. package/lib/esm/runtime/use-hub-api-naming.js +16 -8
  26. package/lib/esm/widgets/user-account/c4-delete-account-widget.d.ts +5 -0
  27. package/lib/esm/widgets/user-account/c4-delete-account-widget.js +65 -0
  28. package/lib/esm/widgets/user-account/c4-delete-account-widget.types.d.ts +13 -0
  29. package/lib/esm/widgets/user-account/c4-delete-account-widget.types.js +6 -0
  30. package/lib/esm/widgets/user-account/use-delete-account-eligibility.d.ts +41 -0
  31. package/lib/esm/widgets/user-account/use-delete-account-eligibility.js +97 -0
  32. package/package.json +2 -2
@@ -0,0 +1,10 @@
1
+ import { type JSX } from 'react';
2
+ import { type C4DeleteAccountModalProps } from './c4-delete-account-modal.types.js';
3
+ /**
4
+ * Look up a translation, and fall back to English when the host has no
5
+ * `t` function or no translation for `key`. Exported so the widget can use
6
+ * the same fallback for copy that does not live inside this component (the
7
+ * generic delete error).
8
+ */
9
+ export declare function safeTranslate(t: ((key: string, options?: Record<string, unknown>) => string) | undefined, key: string, fallback: string, options?: Record<string, unknown>): string;
10
+ export declare const C4DeleteAccountModal: ({ t, open, isEnterpriseOwner, isEnterpriseAdmin, loading, onRequestClose, onRequestSubmit, preventCloseOnClickOutside, }: C4DeleteAccountModalProps) => JSX.Element;
@@ -0,0 +1,54 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
4
+ * under one or more contributor license agreements. Licensed under a commercial license.
5
+ * You may not use this file except in compliance with the commercial license.
6
+ */
7
+ import { useEffect, useState } from 'react';
8
+ import { C4_EXTERNAL_URLS } from '../../externalUrls.const.js';
9
+ import { Link, Modal, Stack, TextInput } from '../../ui/index.js';
10
+ import { useRadioFamily } from '../../ui/families.js';
11
+ import { C4AsyncModal } from '../c4-async-modal/c4-async-modal.js';
12
+ import { C4InlineNotification } from '../c4-inline-notification/c4-inline-notification.js';
13
+ import { C4_DELETE_ACCOUNT_REASONS, } from './c4-delete-account-modal.types.js';
14
+ /**
15
+ * Look up a translation, and fall back to English when the host has no
16
+ * `t` function or no translation for `key`. Exported so the widget can use
17
+ * the same fallback for copy that does not live inside this component (the
18
+ * generic delete error).
19
+ */
20
+ export function safeTranslate(t, key, fallback, options) {
21
+ try {
22
+ const translated = t?.(key, options);
23
+ if (!translated || translated === key) {
24
+ return fallback;
25
+ }
26
+ if (key.includes(':')) {
27
+ const withoutNamespace = key.split(':').slice(1).join(':');
28
+ if (translated === withoutNamespace) {
29
+ return fallback;
30
+ }
31
+ }
32
+ return translated;
33
+ }
34
+ catch {
35
+ return fallback;
36
+ }
37
+ }
38
+ export const C4DeleteAccountModal = ({ t, open, isEnterpriseOwner, isEnterpriseAdmin, loading, onRequestClose, onRequestSubmit, preventCloseOnClickOutside, }) => {
39
+ const { RadioButton, RadioButtonGroup } = useRadioFamily();
40
+ const [reason, setReason] = useState('');
41
+ const [explanation, setExplanation] = useState('');
42
+ useEffect(() => {
43
+ if (!open) {
44
+ setReason('');
45
+ setExplanation('');
46
+ }
47
+ }, [open]);
48
+ if (isEnterpriseOwner) {
49
+ return (_jsx(Modal, { modalHeading: safeTranslate(t, 'users:delete.headingSubscriptionOwner', 'Trying to delete this account?'), open: open, onRequestClose: onRequestClose, size: 'sm', passiveModal: true, id: 'c4-delete-account-modal', children: _jsx(Stack, { gap: 6, children: _jsxs("p", { children: [safeTranslate(t, 'users:delete.subscriptionOwner.intro', 'Since you are the owner for an organization with an active subscription, you should contact '), _jsx(Link, { inline: true, target: '_blank', href: C4_EXTERNAL_URLS.help.deleteAccountTechnicalSupport, children: "technical support" }), ' ', safeTranslate(t, 'users:delete.subscriptionOwner.middle', 'or our '), _jsx(Link, { inline: true, href: `mailto:${C4_EXTERNAL_URLS.help.deleteAccountCustomerSuccessEmail}`, children: "customer success" }), ' ', safeTranslate(t, 'users:delete.subscriptionOwner.outro', 'team to delete your account.')] }) }) }));
50
+ }
51
+ const explanationLabel = C4_DELETE_ACCOUNT_REASONS.find((candidate) => candidate.category === reason)
52
+ ?.label ?? '';
53
+ return (_jsx(C4AsyncModal, { modalHeading: safeTranslate(t, 'users:delete.heading', 'Are you sure you want to delete this account?'), open: open, onRequestClose: onRequestClose, onRequestSubmit: () => onRequestSubmit({ reason, explanation }), primaryButtonText: safeTranslate(t, 'users:delete.finish.buttons.primary', 'Delete'), primaryButtonDisabled: loading || !reason, secondaryButtonText: safeTranslate(t, 'users:delete.finish.buttons.secondary', 'Cancel'), loadingText: safeTranslate(t, 'users:delete.loadingText', 'Deleting...'), danger: true, size: 'sm', preventCloseOnClickOutside: preventCloseOnClickOutside ?? true, children: _jsxs(Stack, { gap: 6, children: [isEnterpriseAdmin && (_jsx(C4InlineNotification, { kind: 'info', title: safeTranslate(t, 'users:delete.subscriptionAdmin.enterpriseTitle', 'Please note that deleting the account will not cancel your Enterprise subscription.'), subtitle: safeTranslate(t, 'users:delete.subscriptionAdmin.enterpriseSubtitle', "If you'd like to cancel your subscription, please contact customer-success@camunda.com.") })), _jsx("b", { children: safeTranslate(t, 'users:delete.finish.message', "We are sad to see you go. If we can't address your problem, we can at least improve our product for other users.") }), _jsx(RadioButtonGroup, { name: 'c4-delete-account-reason', valueSelected: reason, legendText: safeTranslate(t, 'users:delete.finish.reasonSelectionLabel', 'Why do you want to delete your account?'), orientation: 'vertical', onChange: (value) => setReason(value), children: C4_DELETE_ACCOUNT_REASONS.map((candidate) => (_jsx(RadioButton, { labelText: candidate.category, value: candidate.category }, candidate.category))) }), reason && (_jsx(TextInput, { id: 'c4-delete-account-explanation', labelText: explanationLabel, value: explanation, onChange: (event) => setExplanation(event.target.value) }))] }) }));
54
+ };
@@ -0,0 +1,47 @@
1
+ import type { C4AsyncModalSubmitResponse } from '../c4-async-modal/c4-async-modal.types.js';
2
+ export interface C4DeleteAccountReason {
3
+ category: string;
4
+ label: string;
5
+ }
6
+ /**
7
+ * The six reasons on the account-deletion form, and the follow-up question for
8
+ * each. Copied from console's `deleteAccountModel.ts`. A change to this list
9
+ * needs a separate ticket (see the Delete Account widget handoff plan).
10
+ */
11
+ export declare const C4_DELETE_ACCOUNT_REASONS: C4DeleteAccountReason[];
12
+ export interface C4DeleteAccountModalProps {
13
+ t?: (key: string, options?: Record<string, unknown>) => string;
14
+ open: boolean;
15
+ /**
16
+ * True for an enterprise-org owner. This variant shows a passive
17
+ * "contact support" message instead of the reason form: a self-service
18
+ * delete would leave the org without an owner.
19
+ */
20
+ isEnterpriseOwner: boolean;
21
+ /**
22
+ * True for an enterprise-org admin who is not an owner. The reason form
23
+ * still shows, with a reminder that the delete does not cancel the
24
+ * subscription of the org.
25
+ */
26
+ isEnterpriseAdmin?: boolean;
27
+ /**
28
+ * True while the caller still resolves which variant applies. The submit
29
+ * button stays disabled, thus no delete can start before the gate settles
30
+ * and shows an enterprise owner the contact-support variant instead.
31
+ */
32
+ loading?: boolean;
33
+ onRequestClose: () => void;
34
+ /**
35
+ * Called only for the reason-form variant, when the user picks a reason
36
+ * and submits. The owner variant has no submit action.
37
+ */
38
+ onRequestSubmit: (params: {
39
+ reason: string;
40
+ explanation: string;
41
+ }) => Promise<C4AsyncModalSubmitResponse>;
42
+ /**
43
+ * Defaults to `true`, like `C4DeleteOrganizationModal`: an outside click
44
+ * must not discard a reason the user already typed.
45
+ */
46
+ preventCloseOnClickOutside?: boolean;
47
+ }
@@ -0,0 +1,33 @@
1
+ /*
2
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
3
+ * under one or more contributor license agreements. Licensed under a commercial license.
4
+ * You may not use this file except in compliance with the commercial license.
5
+ */
6
+ /**
7
+ * The six reasons on the account-deletion form, and the follow-up question for
8
+ * each. Copied from console's `deleteAccountModel.ts`. A change to this list
9
+ * needs a separate ticket (see the Delete Account widget handoff plan).
10
+ */
11
+ export const C4_DELETE_ACCOUNT_REASONS = [
12
+ {
13
+ category: 'Technical issues',
14
+ label: 'What technical issues did you run into?',
15
+ },
16
+ {
17
+ category: 'Too expensive',
18
+ label: 'What price would be more reasonable for you?',
19
+ },
20
+ {
21
+ category: 'Switching to another product',
22
+ label: 'Which product are you switching to?',
23
+ },
24
+ {
25
+ category: 'Not sure how to use the product',
26
+ label: 'Where did you get stuck?',
27
+ },
28
+ {
29
+ category: 'Missing features I need',
30
+ label: 'What feature(s) would you like to see?',
31
+ },
32
+ { category: 'Other', label: 'Please explain below' },
33
+ ];
@@ -1,5 +1,6 @@
1
1
  import { type JSX } from 'react';
2
2
  import { type C4FeedbackPayload } from '../c4-feedback-modal/c4-feedback-modal.js';
3
+ import { type C4HelpCenterLinkPlaceholders } from './help-center-placeholders.js';
3
4
  /** Reserved tab ID for the inline feedback form. */
4
5
  export declare const FEEDBACK_TAB_ID = "feedback";
5
6
  export interface C4HelpCenterTile {
@@ -46,5 +47,12 @@ export interface C4HelpCenterProps {
46
47
  * directly to the feedback tab (e.g. from `openHelpCenter('feedback')`).
47
48
  */
48
49
  initialTabId?: string;
50
+ /**
51
+ * Values for the placeholder tokens that the CMS writes into tile and link
52
+ * URLs (`{cloudAudience}`, `{currentOrgId}`, `{clusterId}`, `{email}`). A
53
+ * link that still holds a token after the replacement does not work, thus
54
+ * this component hides it.
55
+ */
56
+ linkPlaceholders?: C4HelpCenterLinkPlaceholders;
49
57
  }
50
- export declare function C4HelpCenter({ open, onOpenChange, data, isLoading, helpLinks, onSubmitFeedback, feedbackEnterprise, initialTabId, }: C4HelpCenterProps): JSX.Element;
58
+ export declare function C4HelpCenter({ open, onOpenChange, data, isLoading, helpLinks, onSubmitFeedback, feedbackEnterprise, initialTabId, linkPlaceholders, }: C4HelpCenterProps): JSX.Element;
@@ -8,10 +8,13 @@ import { Badge, Button, Card, CardContent, CardDescription, CardFooter, CardHead
8
8
  import { ArrowRight, ExternalLink, MessageSquare } from 'lucide-react';
9
9
  import { useEffect, useState } from 'react';
10
10
  import ReactMarkdown from 'react-markdown';
11
+ import { useC4ConsoleStage, useC4FeatureFlag, } from '../../runtime/c4-console-runtime-context.js';
11
12
  import { C4FeedbackForm, } from '../c4-feedback-modal/c4-feedback-modal.js';
13
+ import { HUB_HELP_CENTER_LINKS_FLAG, isHubLinkStage, rewriteAppHostToHub, } from './help-center-app-host.js';
14
+ import { hasUnresolvedHelpCenterPlaceholder, resolveHelpCenterPlaceholders, } from './help-center-placeholders.js';
12
15
  /** Reserved tab ID for the inline feedback form. */
13
16
  export const FEEDBACK_TAB_ID = 'feedback';
14
- export function C4HelpCenter({ open, onOpenChange, data, isLoading, helpLinks, onSubmitFeedback, feedbackEnterprise, initialTabId, }) {
17
+ export function C4HelpCenter({ open, onOpenChange, data, isLoading, helpLinks, onSubmitFeedback, feedbackEnterprise, initialTabId, linkPlaceholders, }) {
15
18
  const [activeTabId, setActiveTabId] = useState('');
16
19
  // Set the active tab when the modal opens/closes or initialTabId changes.
17
20
  useEffect(() => {
@@ -23,7 +26,32 @@ export function C4HelpCenter({ open, onOpenChange, data, isLoading, helpLinks, o
23
26
  setActiveTabId(initialTabId);
24
27
  }
25
28
  }, [open, initialTabId]);
26
- const tabs = data?.tabs ?? [];
29
+ // Camunda Hub serves the org-scoped routes of Console and Web Modeler, but
30
+ // the CMS still writes the host of the old app into its links. Where Hub is
31
+ // live, every link of this panel goes to it — the stage of the host decides,
32
+ // and a client with a flag system can widen that (see `help-center-app-host`).
33
+ const stage = useC4ConsoleStage();
34
+ const isHubLinkFlagOn = useC4FeatureFlag(HUB_HELP_CENTER_LINKS_FLAG);
35
+ const linksGoToHub = isHubLinkStage(stage) || isHubLinkFlagOn;
36
+ // The CMS gives every URL with its placeholder tokens in place. The tokens
37
+ // are resolved here, once, so that the render below reads one shape of URL.
38
+ const resolveUrl = (url) => {
39
+ const resolved = resolveHelpCenterPlaceholders(url, linkPlaceholders);
40
+ return linksGoToHub ? rewriteAppHostToHub(resolved) : resolved;
41
+ };
42
+ const tabs = (data?.tabs ?? []).map((tab) => ({
43
+ ...tab,
44
+ tiles: tab.tiles.map((tile) => ({
45
+ ...tile,
46
+ link: resolveUrl(tile.link),
47
+ })),
48
+ }));
49
+ const sidebarLinks = (data?.links ?? [])
50
+ .map((link) => ({
51
+ ...link,
52
+ link: resolveUrl(link.link) ?? '',
53
+ }))
54
+ .filter((link) => !hasUnresolvedHelpCenterPlaceholder(link.link));
27
55
  const hasFeedbackTab = !!onSubmitFeedback;
28
56
  const isActiveIdValid = (activeTabId === FEEDBACK_TAB_ID && hasFeedbackTab) ||
29
57
  tabs.some((t) => t.id === activeTabId);
@@ -31,10 +59,12 @@ export function C4HelpCenter({ open, onOpenChange, data, isLoading, helpLinks, o
31
59
  ? activeTabId
32
60
  : (tabs[0]?.id ?? '');
33
61
  const showFullUI = isLoading || tabs.length > 0 || hasFeedbackTab;
34
- return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsx(DialogContent, { className: 'c4-ui flex flex-col gap-0 overflow-hidden overflow-y-hidden p-0', style: { maxWidth: 'min(900px, calc(100% - 2rem))', height: '80vh' }, children: showFullUI ? (_jsxs(_Fragment, { children: [_jsx(DialogHeader, { className: 'flex-shrink-0 border-b px-6 py-4', children: _jsx(DialogTitle, { children: "Help Center" }) }), _jsxs(Tabs, { orientation: 'vertical', value: effectiveActiveTabId, onValueChange: (id) => setActiveTabId(id), className: 'flex min-h-0 flex-1 flex-row overflow-hidden', children: [_jsxs("div", { className: 'flex w-52 flex-shrink-0 flex-col overflow-hidden border-r', children: [_jsx("p", { className: 'px-5 pb-2 pt-4 text-xs font-semibold uppercase text-neutral-foreground-subtle', children: "Topics" }), isLoading ? (_jsx("div", { className: 'flex flex-col gap-2 px-3', children: [1, 2, 3].map((i) => (_jsx("div", { className: 'h-8 animate-pulse rounded bg-neutral-background-strong' }, i))) })) : (_jsxs(TabsList, { variant: 'line', className: 'h-auto w-full flex-col items-start gap-1 rounded-none bg-transparent px-3', children: [tabs.map((tab) => (_jsx(TabsTrigger, { value: tab.id, className: 'w-full justify-start text-sm font-normal', children: tab.label }, tab.id))), hasFeedbackTab && tabs.length > 0 && (_jsx("div", { role: 'none', className: 'my-1 w-full px-2', children: _jsx("div", { className: 'h-px bg-border' }) })), hasFeedbackTab && (_jsxs(TabsTrigger, { value: FEEDBACK_TAB_ID, className: 'w-full justify-start gap-2 text-sm font-normal', children: [_jsx(MessageSquare, { className: 'size-4', "aria-hidden": true }), "Share your feedback"] }))] })), !isLoading && data?.links && data.links.length > 0 && (_jsx("div", { className: 'border-t px-3 py-2', children: data.links.map((link) => (_jsxs("a", { href: link.link, target: '_blank', rel: 'noopener noreferrer', className: 'flex items-center gap-1 px-2 py-1 text-xs text-neutral-foreground-subtle hover:underline', children: [link.label, _jsx(ExternalLink, { className: 'size-3', "aria-hidden": true })] }, link.id))) }))] }), isLoading ? (_jsx("div", { className: 'flex-1 p-6', children: _jsx("div", { className: 'grid grid-cols-2 gap-4', children: [1, 2, 3, 4].map((i) => (_jsx("div", { className: 'h-64 animate-pulse rounded-xl bg-neutral-background-strong' }, i))) }) })) : (_jsxs(ScrollArea, { className: 'flex-1', children: [tabs.map((tab) => (_jsx(TabsContent, { value: tab.id, className: 'mt-0 p-6', children: tab.tiles.length === 0 ? (_jsx("p", { className: 'text-sm text-neutral-foreground-subtle', children: "No content available." })) : (_jsx("div", { className: 'grid grid-cols-2 gap-4', children: tab.tiles.map((tile) => (_jsxs(Card, { className: 'flex flex-col', children: [tile.image && (_jsx("img", { src: tile.image, alt: '', className: 'h-32 w-full object-cover' })), _jsxs(CardHeader, { children: [_jsx(CardTitle, { className: 'text-sm', children: tile.title }), tile.timeToComplete && (_jsx(Badge, { variant: 'neutral', className: 'self-start text-xs', children: tile.timeToComplete }))] }), _jsx(CardContent, { className: 'flex-1', children: _jsx(CardDescription, { children: _jsx(ReactMarkdown, { components: {
62
+ return (_jsx(Dialog, { open: open, onOpenChange: onOpenChange, children: _jsx(DialogContent, { className: 'c4-ui flex flex-col gap-0 overflow-hidden overflow-y-hidden p-0', style: { maxWidth: 'min(900px, calc(100% - 2rem))', height: '80vh' }, children: showFullUI ? (_jsxs(_Fragment, { children: [_jsx(DialogHeader, { className: 'flex-shrink-0 border-b px-6 py-4', children: _jsx(DialogTitle, { children: "Help Center" }) }), _jsxs(Tabs, { orientation: 'vertical', value: effectiveActiveTabId, onValueChange: (id) => setActiveTabId(id), className: 'flex min-h-0 flex-1 flex-row overflow-hidden', children: [_jsxs("div", { className: 'flex w-52 flex-shrink-0 flex-col overflow-hidden border-r', children: [_jsx("p", { className: 'px-5 pb-2 pt-4 text-xs font-semibold uppercase text-neutral-foreground-subtle', children: "Topics" }), isLoading ? (_jsx("div", { className: 'flex flex-col gap-2 px-3', children: [1, 2, 3].map((i) => (_jsx("div", { className: 'h-8 animate-pulse rounded bg-neutral-background-strong' }, i))) })) : (_jsxs(TabsList, { variant: 'line', className: 'h-auto w-full flex-col items-start gap-1 rounded-none bg-transparent px-3', children: [tabs.map((tab) => (_jsx(TabsTrigger, { value: tab.id, className: 'w-full justify-start text-sm font-normal', children: tab.label }, tab.id))), hasFeedbackTab && tabs.length > 0 && (_jsx("div", { role: 'none', className: 'my-1 w-full px-2', children: _jsx("div", { className: 'h-px bg-border' }) })), hasFeedbackTab && (_jsxs(TabsTrigger, { value: FEEDBACK_TAB_ID, className: 'w-full justify-start gap-2 text-sm font-normal', children: [_jsx(MessageSquare, { className: 'size-4', "aria-hidden": true }), "Share your feedback"] }))] })), !isLoading && sidebarLinks.length > 0 && (_jsx("div", { className: 'border-t px-3 py-2', children: sidebarLinks.map((link) => (_jsxs("a", { href: link.link, target: '_blank', rel: 'noopener noreferrer', className: 'flex items-center gap-1 px-2 py-1 text-xs text-neutral-foreground-subtle hover:underline', children: [link.label, _jsx(ExternalLink, { className: 'size-3', "aria-hidden": true })] }, link.id))) }))] }), isLoading ? (_jsx("div", { className: 'flex-1 p-6', children: _jsx("div", { className: 'grid grid-cols-2 gap-4', children: [1, 2, 3, 4].map((i) => (_jsx("div", { className: 'h-64 animate-pulse rounded-xl bg-neutral-background-strong' }, i))) }) })) : (_jsxs(ScrollArea, { className: 'flex-1', children: [tabs.map((tab) => (_jsx(TabsContent, { value: tab.id, className: 'mt-0 p-6', children: tab.tiles.length === 0 ? (_jsx("p", { className: 'text-sm text-neutral-foreground-subtle', children: "No content available." })) : (_jsx("div", { className: 'grid grid-cols-2 gap-4', children: tab.tiles.map((tile) => (_jsxs(Card, { className: 'flex flex-col', children: [tile.image && (_jsx("img", { src: tile.image, alt: '', className: 'h-32 w-full object-cover' })), _jsxs(CardHeader, { children: [_jsx(CardTitle, { className: 'text-sm', children: tile.title }), tile.timeToComplete && (_jsx(Badge, { variant: 'neutral', className: 'self-start text-xs', children: tile.timeToComplete }))] }), _jsx(CardContent, { className: 'flex-1', children: _jsx(CardDescription, { children: _jsx(ReactMarkdown, { components: {
35
63
  p: ({ children }) => _jsx(_Fragment, { children: children }),
36
64
  a: ({ children, href }) => (_jsx("a", { href: href, target: '_blank', rel: 'noopener noreferrer', children: children })),
37
- }, children: tile.description }) }) }), tile.link && tile.cta && (_jsx(CardFooter, { children: _jsx(Button, { variant: 'secondary', size: 'sm', asChild: true, children: _jsxs("a", { href: tile.link, target: '_blank', rel: 'noopener noreferrer', children: [tile.cta, _jsx(ArrowRight, { className: 'ml-1 size-3', "aria-hidden": true })] }) }) }))] }, tile.card_id))) })) }, tab.id))), hasFeedbackTab && onSubmitFeedback && (_jsx(TabsContent, { value: FEEDBACK_TAB_ID, className: 'mt-0 p-6', children: _jsxs("div", { className: 'max-w-xl', children: [_jsx("p", { className: 'mb-4 text-sm text-neutral-foreground-subtle', children: "We actively use this information to fix problems and improve your experience with our products." }), _jsx(C4FeedbackForm, { onSubmit: onSubmitFeedback, isEnterprise: feedbackEnterprise, resetKey: open })] }) }))] }))] })] })) : (
65
+ }, children: tile.description }) }) }), tile.link &&
66
+ tile.cta &&
67
+ !hasUnresolvedHelpCenterPlaceholder(tile.link) && (_jsx(CardFooter, { children: _jsx(Button, { variant: 'secondary', size: 'sm', asChild: true, children: _jsxs("a", { href: tile.link, target: '_blank', rel: 'noopener noreferrer', children: [tile.cta, _jsx(ArrowRight, { className: 'ml-1 size-3', "aria-hidden": true })] }) }) }))] }, tile.card_id))) })) }, tab.id))), hasFeedbackTab && onSubmitFeedback && (_jsx(TabsContent, { value: FEEDBACK_TAB_ID, className: 'mt-0 p-6', children: _jsxs("div", { className: 'max-w-xl', children: [_jsx("p", { className: 'mb-4 text-sm text-neutral-foreground-subtle', children: "We actively use this information to fix problems and improve your experience with our products." }), _jsx(C4FeedbackForm, { onSubmit: onSubmitFeedback, isEnterprise: feedbackEnterprise, resetKey: open })] }) }))] }))] })] })) : (
38
68
  /* Fallback: simple link list when no CMS data and no feedback tab */
39
69
  _jsxs(_Fragment, { children: [_jsx(DialogHeader, { className: 'p-6', children: _jsx(DialogTitle, { children: "Help & support" }) }), _jsx("div", { className: 'flex flex-col gap-1 px-4', children: helpLinks &&
40
70
  helpLinks.map((link) => (_jsx(Button, { variant: 'ghost', className: 'w-full justify-between', asChild: true, children: _jsxs("a", { href: link.href, target: '_blank', rel: 'noopener noreferrer', children: [link.label, _jsx(ExternalLink, { className: 'size-3.5 text-neutral-foreground-subtle', "aria-hidden": true })] }) }, link.key))) })] })) }) }));
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Flag key that widens the Hub link rewrite past {@link HUB_LINK_STAGES}. A
3
+ * client with its own flag system can thus reach int or prod without a release
4
+ * of this package. Read through `useC4FeatureFlag`, which is off for a client
5
+ * that gives the runtime no `featureFlags`.
6
+ */
7
+ export declare const HUB_HELP_CENTER_LINKS_FLAG = "console.hubHelpCenterLinks";
8
+ /** True where Hub serves the org-scoped routes of Console and Web Modeler. */
9
+ export declare function isHubLinkStage(stage: string | undefined): boolean;
10
+ /**
11
+ * Sends a link of an org-scoped app to Camunda Hub. The CMS writes the host of
12
+ * the old app into its links, in either of its two forms
13
+ * (`https://console.<domain>/org/<id>/clusters`,
14
+ * `https://modeler.cloud.<domain>/...`), and both become
15
+ * `https://hub.<domain>/...`. The path does not change, because Hub serves the
16
+ * same path.
17
+ *
18
+ * A URL of another host, a relative URL, and a URL of a cluster-scoped app all
19
+ * come back unchanged. A `cloud.` label of another host also stays: only the
20
+ * app hosts move, and a service host such as `api.cloud.<domain>` or
21
+ * `helpcenter.cloud.<domain>` answers on the `cloud.` form alone.
22
+ */
23
+ export declare function rewriteAppHostToHub(url: string | undefined): string | undefined;
@@ -0,0 +1,69 @@
1
+ /*
2
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
3
+ * under one or more contributor license agreements. Licensed under a commercial license.
4
+ * You may not use this file except in compliance with the commercial license.
5
+ */
6
+ /**
7
+ * Flag key that widens the Hub link rewrite past {@link HUB_LINK_STAGES}. A
8
+ * client with its own flag system can thus reach int or prod without a release
9
+ * of this package. Read through `useC4FeatureFlag`, which is off for a client
10
+ * that gives the runtime no `featureFlags`.
11
+ */
12
+ export const HUB_HELP_CENTER_LINKS_FLAG = 'console.hubHelpCenterLinks';
13
+ /**
14
+ * Stages where Camunda Hub serves the org-scoped routes. Every client of this
15
+ * package gives `stage` in its runtime config, thus the default needs no work
16
+ * in a client and no flag system. Widen this set as the Hub rollout reaches int
17
+ * and prod, or use {@link HUB_HELP_CENTER_LINKS_FLAG} to widen one client
18
+ * sooner.
19
+ */
20
+ const HUB_LINK_STAGES = new Set([
21
+ 'dev',
22
+ 'devAws',
23
+ 'local',
24
+ 'localconsole',
25
+ 'localaccounts',
26
+ ]);
27
+ // Camunda Hub replaces the two org-scoped apps, Console and Web Modeler, and
28
+ // serves the routes of both under one host. The cluster-scoped apps (operate,
29
+ // tasklist, optimize, admin, identity) keep their own per-cluster hosts, thus
30
+ // this list holds two names and not every value of `CamundaWebApp`. `hub` is
31
+ // here for its own sake: a link that already names Hub still goes through the
32
+ // `cloud.` rule below.
33
+ const UNIFIED_APP_HOST_LABELS = ['console', 'modeler', 'hub'];
34
+ // Matches the scheme, the label of the app, an optional `cloud.` label, and the
35
+ // domain that follows. The `cloud.` label goes: Hub answers on `hub.<domain>`
36
+ // and on nothing else — `hub.cloud.<domain>` resolves in no environment — and
37
+ // the CMS writes both forms of the old host. The rest of the URL is kept as it
38
+ // is. A string replacement, not `new URL()`, because `URL` normalizes what it
39
+ // parses (it adds a path to a host-only URL, for example) and a CMS link must
40
+ // reach the browser as its author wrote it, minus the host.
41
+ const UNIFIED_APP_HOST_PATTERN = new RegExp(`^(https?://)(?:${UNIFIED_APP_HOST_LABELS.join('|')})\\.(?:cloud\\.)?([^/?#]+)`, 'i');
42
+ /** True where Hub serves the org-scoped routes of Console and Web Modeler. */
43
+ export function isHubLinkStage(stage) {
44
+ return stage !== undefined && HUB_LINK_STAGES.has(stage);
45
+ }
46
+ /**
47
+ * Sends a link of an org-scoped app to Camunda Hub. The CMS writes the host of
48
+ * the old app into its links, in either of its two forms
49
+ * (`https://console.<domain>/org/<id>/clusters`,
50
+ * `https://modeler.cloud.<domain>/...`), and both become
51
+ * `https://hub.<domain>/...`. The path does not change, because Hub serves the
52
+ * same path.
53
+ *
54
+ * A URL of another host, a relative URL, and a URL of a cluster-scoped app all
55
+ * come back unchanged. A `cloud.` label of another host also stays: only the
56
+ * app hosts move, and a service host such as `api.cloud.<domain>` or
57
+ * `helpcenter.cloud.<domain>` answers on the `cloud.` form alone.
58
+ */
59
+ export function rewriteAppHostToHub(url) {
60
+ if (!url) {
61
+ return url;
62
+ }
63
+ const match = UNIFIED_APP_HOST_PATTERN.exec(url);
64
+ if (!match) {
65
+ return url;
66
+ }
67
+ const [matchedHost, scheme, domain] = match;
68
+ return `${scheme}hub.${domain}${url.slice(matchedHost.length)}`;
69
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Values for the placeholder tokens that the help center CMS writes into tile
3
+ * and link URLs. A host that omits a value keeps the token in the URL, and
4
+ * {@link C4HelpCenter} then hides the link that uses it.
5
+ */
6
+ export interface C4HelpCenterLinkPlaceholders {
7
+ /**
8
+ * The domain the host puts in a link to another Camunda app — the `domain`
9
+ * value of `useC3UserConfiguration()`, which the c3 help center substitutes
10
+ * too. A host that gives c3 `noCloudInUrl` must remove the `cloud.` prefix
11
+ * here as well (`camunda.io`, not `cloud.camunda.io`), or a resolved link
12
+ * goes to a different host than the same link in carbon mode.
13
+ */
14
+ cloudAudience?: string;
15
+ currentOrgId?: string;
16
+ /** One cluster of the organization. The CMS links to a cluster page with it. */
17
+ clusterId?: string;
18
+ email?: string;
19
+ }
20
+ /**
21
+ * Replaces every placeholder token in `url` that `placeholders` gives a value
22
+ * for. A token without a value stays in the URL.
23
+ */
24
+ export declare function resolveHelpCenterPlaceholders(url: string | undefined, placeholders: C4HelpCenterLinkPlaceholders | undefined): string | undefined;
25
+ /** True when `url` still holds a placeholder token, and thus does not work. */
26
+ export declare function hasUnresolvedHelpCenterPlaceholder(url: string | undefined): boolean;
@@ -0,0 +1,49 @@
1
+ /*
2
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
3
+ * under one or more contributor license agreements. Licensed under a commercial license.
4
+ * You may not use this file except in compliance with the commercial license.
5
+ */
6
+ const PLACEHOLDERS = [
7
+ { key: 'cloudAudience', token: 'cloudAudience', encode: false },
8
+ { key: 'currentOrgId', token: 'currentOrgId', encode: false },
9
+ { key: 'clusterId', token: 'clusterId', encode: false },
10
+ { key: 'email', token: 'email', encode: true },
11
+ ];
12
+ // The CMS writes a token in one of two forms. A token in a path or in a query
13
+ // value can arrive percent-encoded (`%7BcurrentOrgId%7D`), because an editor
14
+ // tool encoded the URL that holds it. The case of a token is also not stable:
15
+ // production content has `{cloudaudience}` in the host of a link, next to
16
+ // `{currentOrgId}` in the path of the same link. One pattern thus matches both
17
+ // forms, in any case. The pattern is built for each use, because a `g` regex
18
+ // keeps its `lastIndex` between calls to `test`.
19
+ function tokenPattern(token) {
20
+ return new RegExp(`\\{${token}\\}|%7B${token}%7D`, 'gi');
21
+ }
22
+ /**
23
+ * Replaces every placeholder token in `url` that `placeholders` gives a value
24
+ * for. A token without a value stays in the URL.
25
+ */
26
+ export function resolveHelpCenterPlaceholders(url, placeholders) {
27
+ if (!url || !placeholders) {
28
+ return url;
29
+ }
30
+ let resolved = url;
31
+ for (const { key, token, encode } of PLACEHOLDERS) {
32
+ const value = placeholders[key];
33
+ if (value) {
34
+ const replacement = encode ? encodeURIComponent(value) : value;
35
+ // A function, not the string: `String.replace` reads `$&`, `$'` and `$1`
36
+ // in a replacement string as references to the match. A value goes into
37
+ // the URL as it is.
38
+ resolved = resolved.replace(tokenPattern(token), () => replacement);
39
+ }
40
+ }
41
+ return resolved;
42
+ }
43
+ /** True when `url` still holds a placeholder token, and thus does not work. */
44
+ export function hasUnresolvedHelpCenterPlaceholder(url) {
45
+ if (!url) {
46
+ return false;
47
+ }
48
+ return PLACEHOLDERS.some(({ token }) => tokenPattern(token).test(url));
49
+ }
@@ -2,6 +2,7 @@ import { type C3NavigationProps } from '@camunda/camunda-composite-components';
2
2
  import { type JSX, type ReactNode } from 'react';
3
3
  import type { C4FeedbackPayload } from '../c4-feedback-modal/c4-feedback-modal.js';
4
4
  import { type C4HelpCenterData } from '../c4-help-center/c4-help-center.js';
5
+ import type { C4HelpCenterLinkPlaceholders } from '../c4-help-center/help-center-placeholders.js';
5
6
  export type C4NavigationProps = C3NavigationProps & {
6
7
  /**
7
8
  * ds-mode only: navigate to a cluster by uuid (the Cluster dropdown). Carbon
@@ -51,5 +52,16 @@ export type C4NavigationProps = C3NavigationProps & {
51
52
  * and links for {@link C4HelpCenter}. Carbon mode ignores it.
52
53
  */
53
54
  onFetchHelpCenterData?: () => Promise<C4HelpCenterData | undefined>;
55
+ /**
56
+ * ds-mode only: values for the placeholder tokens that the CMS writes into
57
+ * help center URLs. See {@link C4HelpCenterLinkPlaceholders}.
58
+ *
59
+ * Carbon mode ignores it. The c3 help center does a smaller version of the
60
+ * same work — it replaces the exact, unencoded token in a card link — thus
61
+ * carbon mode resolves less: no other case of a token, no percent-encoded
62
+ * form, no sidebar link, and no Camunda Hub host. c3 is a public package
63
+ * this one does not change, thus the two modes are not equal here.
64
+ */
65
+ helpCenterLinkPlaceholders?: C4HelpCenterLinkPlaceholders;
54
66
  };
55
67
  export declare const C4Navigation: (props: C4NavigationProps) => JSX.Element;
@@ -126,7 +126,7 @@ export const C4Navigation = (props) => {
126
126
  .finally(() => setHelpCenterLoading(false));
127
127
  }, [designSystem, isHelpCenterOpen, helpCenterData, helpCenterLoading]);
128
128
  if (designSystem !== 'ds') {
129
- const { onSelectCluster: _onSelectCluster, helpLinks: _helpLinks, appElements: _appElements, onSubmitFeedback: _onSubmitFeedback, feedbackEnterprise: _feedbackEnterprise, onFetchHelpCenterData: _onFetchHelpCenterData, children, ...c3Props } = props;
129
+ const { onSelectCluster: _onSelectCluster, helpLinks: _helpLinks, appElements: _appElements, onSubmitFeedback: _onSubmitFeedback, feedbackEnterprise: _feedbackEnterprise, onFetchHelpCenterData: _onFetchHelpCenterData, helpCenterLinkPlaceholders: _helpCenterLinkPlaceholders, children, ...c3Props } = props;
130
130
  return (_jsxs(_Fragment, { children: [_jsx(C3Navigation, { ...c3Props }), children] }));
131
131
  }
132
132
  const { onSelectCluster, helpLinks, children } = props;
@@ -179,5 +179,5 @@ export const C4Navigation = (props) => {
179
179
  return (_jsx(TooltipProvider, { delayDuration: 0, children: _jsx(SidebarProvider, { children: _jsxs("div", { className: 'min-h-screen bg-background text-neutral-foreground-strong', children: [_jsx(AppHeader, { skipToContentTargetId: 'main-content', logo: logoButton, appName: appName, breadcrumb: breadcrumb, trailing: trailing, children: tagBadges }), _jsx(AppSidebar, { ariaLabel: 'Camunda apps', items: appItems }), _jsx("main", { id: 'main-content', tabIndex: -1, style: { marginLeft: 'var(--app-sidebar-width, 16rem)' }, children: children }), _jsx(C4HelpCenter, { open: isHelpCenterOpen, onOpenChange: (open) => {
180
180
  if (!open)
181
181
  setIsHelpCenterOpen(false);
182
- }, data: helpCenterData, isLoading: helpCenterLoading, helpLinks: helpLinks, onSubmitFeedback: props.onSubmitFeedback, feedbackEnterprise: props.feedbackEnterprise, initialTabId: showTabId === 'feedback' ? FEEDBACK_TAB_ID : undefined })] }) }) }));
182
+ }, data: helpCenterData, isLoading: helpCenterLoading, helpLinks: helpLinks, onSubmitFeedback: props.onSubmitFeedback, feedbackEnterprise: props.feedbackEnterprise, linkPlaceholders: props.helpCenterLinkPlaceholders, initialTabId: showTabId === 'feedback' ? FEEDBACK_TAB_ID : undefined })] }) }) }));
183
183
  };
@@ -60,6 +60,8 @@ export declare const C4_EXTERNAL_URLS: {
60
60
  readonly enterpriseSupport: "https://camunda.com/services/support/";
61
61
  readonly talkToAnExpert: "https://camunda.com/platform/camunda-platform-enterprise-contact/?utm_medium=referral&utm_source=console&utm_campaign=ContactUs.CamundaPlatform.C8SaaS.Enterprise";
62
62
  readonly requestCelpLicence: "https://camunda.com/educationee/";
63
+ readonly deleteAccountTechnicalSupport: "https://jira.camunda.com/";
64
+ readonly deleteAccountCustomerSuccessEmail: "customer-success@camunda.com";
63
65
  };
64
66
  };
65
67
  export declare function getC4TalkToAnExpertUrl(properties?: {
@@ -60,6 +60,10 @@ export const C4_EXTERNAL_URLS = {
60
60
  enterpriseSupport: 'https://camunda.com/services/support/',
61
61
  talkToAnExpert: 'https://camunda.com/platform/camunda-platform-enterprise-contact/?utm_medium=referral&utm_source=console&utm_campaign=ContactUs.CamundaPlatform.C8SaaS.Enterprise',
62
62
  requestCelpLicence: 'https://camunda.com/educationee/',
63
+ // Same links console's delete-account modal uses today for an enterprise
64
+ // owner, who must contact support instead of self-deleting.
65
+ deleteAccountTechnicalSupport: 'https://jira.camunda.com/',
66
+ deleteAccountCustomerSuccessEmail: 'customer-success@camunda.com',
63
67
  },
64
68
  };
65
69
  export function getC4TalkToAnExpertUrl(properties) {
@@ -74,7 +74,9 @@
74
74
  "heading": "Are you sure you want to delete this account?",
75
75
  "headingSubscriptionOwner": "Trying to delete this account?",
76
76
  "subscriptionOwner": {
77
- "p1": "Since you are the owner for an organization with an active subscription, you should contact <0>technical support</0> or our <1>customer success</1> team to delete your account."
77
+ "intro": "Since you are the owner for an organization with an active subscription, you should contact ",
78
+ "middle": "or our ",
79
+ "outro": "team to delete your account."
78
80
  },
79
81
  "subscriptionAdmin": {
80
82
  "enterpriseTitle": "Please note that deleting the account will not cancel your Enterprise subscription.",
@@ -89,6 +91,10 @@
89
91
  "secondary": "Cancel"
90
92
  }
91
93
  },
92
- "loadingText": "Deleting..."
94
+ "loadingText": "Deleting...",
95
+ "error": {
96
+ "generic": "Couldn't delete your account. Try again.",
97
+ "subscriptionOwner": "You own an organization with an active subscription. Contact support to delete your account."
98
+ }
93
99
  }
94
100
  }
@@ -89,6 +89,8 @@ export { C4DashboardFirstLaunch } from './components/c4-dashboard-first-launch/c
89
89
  export type { C4DashboardFirstLaunchProps } from './components/c4-dashboard-first-launch/c4-dashboard-first-launch.types.js';
90
90
  export { C4DataTable } from './components/c4-data-table/c4-data-table.js';
91
91
  export { C4DataTableSkeleton } from './components/c4-data-table/c4-data-table-skeleton.js';
92
+ export { C4DeleteAccountModal } from './components/c4-delete-account-modal/c4-delete-account-modal.js';
93
+ export type { C4DeleteAccountModalProps } from './components/c4-delete-account-modal/c4-delete-account-modal.types.js';
92
94
  export { C4DeleteOrganizationModal } from './components/c4-delete-organization-modal/c4-delete-organization-modal.js';
93
95
  export type { C4DeleteOrganizationModalProps } from './components/c4-delete-organization-modal/c4-delete-organization-modal.types.js';
94
96
  export { C4Divider } from './components/c4-divider/c4-divider.js';
@@ -102,6 +104,8 @@ export type { C4FeedbackFormProps, C4FeedbackModalProps, C4FeedbackPayload, C4Fe
102
104
  export { C4FeedbackForm, C4FeedbackModal, } from './components/c4-feedback-modal/c4-feedback-modal.js';
103
105
  export type { C4HelpCenterData, C4HelpCenterLink, C4HelpCenterProps, C4HelpCenterTabData, C4HelpCenterTile, } from './components/c4-help-center/c4-help-center.js';
104
106
  export { C4HelpCenter, FEEDBACK_TAB_ID, } from './components/c4-help-center/c4-help-center.js';
107
+ export { HUB_HELP_CENTER_LINKS_FLAG, rewriteAppHostToHub, } from './components/c4-help-center/help-center-app-host.js';
108
+ export type { C4HelpCenterLinkPlaceholders } from './components/c4-help-center/help-center-placeholders.js';
105
109
  export { C4InfoTooltip } from './components/c4-info-tooltip/c4-info-tooltip.js';
106
110
  export type { C4InfoTooltipProps } from './components/c4-info-tooltip/c4-info-tooltip.types.js';
107
111
  export { C4InlineNotification } from './components/c4-inline-notification/c4-inline-notification.js';
@@ -200,7 +204,7 @@ export { openC4CreateConsoleApiClientModal, setC4CreateConsoleApiClientModalHand
200
204
  export { openC4InviteUserToOrganizationModal, setC4InviteUserToOrganizationModalHandle, } from './modals/c4-invite-user-to-organization-modal-handle.js';
201
205
  export { openC4RenameOrganizationModal, setC4RenameOrganizationModalHandle, } from './modals/c4-rename-organization-modal-handle.js';
202
206
  export type { AccountsPermissions, AddC4ConsoleNotificationOptions, C4BreadcrumbCrumb, C4BreadcrumbDropdownItem, C4ClusterNavAppEntry, C4ClusterNavEntry, C4ConsoleAuthzFeatures, C4ConsoleAuthzState, C4ConsoleDataState, C4ConsoleEventsProviderProps, C4ConsoleNotification, C4ConsoleNotificationAction, C4ConsoleNotificationKind, C4ConsoleNotificationsState, C4ConsoleRuntimeConfig, C4ConsoleVisibilities, C4ResolvedTheme, C4ThemePreference, C4UserNotificationsProviderProps, C4UserNotificationsState, C4UserThemeState, CacheState, CamundaWebApp, ConsoleAuth, ConsoleBackendUrls, ConsoleClickwrapConfig, ConsoleClusterDto, ConsolePermissions, ConsolePublicUrls, ConsoleStage, ConsoleTelemetry, ConsoleUser, ExternalClusterDto, ExternalOrganizationDto, NotificationDto, OrganizationPermissions, OrganizationRole, OrgCache, SseEntity, UpgradableGenerationsDto, UseC4ClusterNavEntriesOptions, UseC4WebappBreadcrumbDataOptions, } from './runtime/index.js';
203
- export { addC4ConsoleNotification, buildClusterSsoCallbackUrl, buildClusterSwaggerUrl, buildModelerOrgUrl, C4ConsoleDataProvider, C4ConsoleEventsProvider, C4ConsoleNotificationsProvider, C4ConsoleRuntimeProvider, C4UserNotificationsProvider, DEFAULT_NAV_APPS, getClusterStage, getEndpointForApp, getReadableAppName, hasReadPermissionForApp, isAdminApp, isAppHealthyOnCluster, removeC4ConsoleNotificationById, resolveAdminAppName, setC4ConsoleNotificationsHandle, useC4ClusterNavEntries, useC4ConsoleAuthz, useC4ConsoleData, useC4ConsoleEventsState, useC4ConsoleNotifications, useC4ConsoleRuntime, useC4DesignSystem, useC4FeatureFlag, useC4UserNotifications, useC4UserTheme, useC4WebappBreadcrumbData, } from './runtime/index.js';
207
+ export { addC4ConsoleNotification, buildClusterSsoCallbackUrl, buildClusterSwaggerUrl, buildModelerOrgUrl, C4ConsoleDataProvider, C4ConsoleEventsProvider, C4ConsoleNotificationsProvider, C4ConsoleRuntimeProvider, C4UserNotificationsProvider, DEFAULT_NAV_APPS, getClusterStage, getEndpointForApp, getReadableAppName, hasReadPermissionForApp, isAdminApp, isAppHealthyOnCluster, removeC4ConsoleNotificationById, resolveAdminAppName, setC4ConsoleNotificationsHandle, useC4ClusterNavEntries, useC4ConsoleAuthz, useC4ConsoleData, useC4ConsoleEventsState, useC4ConsoleNotifications, useC4ConsoleRuntime, useC4ConsoleStage, useC4DesignSystem, useC4FeatureFlag, useC4UserNotifications, useC4UserTheme, useC4WebappBreadcrumbData, } from './runtime/index.js';
204
208
  export type { TranslateFn } from './utils/safe-translate.js';
205
209
  export { ENVIRONMENT_KEY_SUFFIX, safeTranslate, scopedTranslate, } from './utils/safe-translate.js';
206
210
  export type { C4WidgetScope } from './widgets/c4-widget-scope.types.js';
@@ -245,5 +249,9 @@ export { C4ManagementPage } from './widgets/management/c4-management-page.js';
245
249
  export type { C4ManagementPageProps, C4ManagementTab, } from './widgets/management/c4-management-page.types.js';
246
250
  export { MANAGEMENT_TABS, type ManagementTabDescriptor, type ManagementTabId, managementTab, } from './widgets/management/management-tabs.js';
247
251
  export { useExtendTrial } from './widgets/use-extend-trial.js';
252
+ export { C4DeleteAccountWidget } from './widgets/user-account/c4-delete-account-widget.js';
253
+ export type { C4DeleteAccountWidgetProps } from './widgets/user-account/c4-delete-account-widget.types.js';
254
+ export type { DeleteAccountEligibility } from './widgets/user-account/use-delete-account-eligibility.js';
255
+ export { deriveDeleteAccountEligibility, useDeleteAccountEligibility, } from './widgets/user-account/use-delete-account-eligibility.js';
248
256
  export { C4UserDetailsPage } from './widgets/user-details/c4-user-details-page.js';
249
257
  export type { C4UserDetailsExternalLinks, C4UserDetailsNavigateEvent, C4UserDetailsPageProps, } from './widgets/user-details/c4-user-details-page.types.js';
package/lib/esm/index.js CHANGED
@@ -48,6 +48,7 @@ export { C4CreateTrialOrganizationModal } from './components/c4-create-trial-org
48
48
  export { C4DashboardFirstLaunch } from './components/c4-dashboard-first-launch/c4-dashboard-first-launch.js';
49
49
  export { C4DataTable } from './components/c4-data-table/c4-data-table.js';
50
50
  export { C4DataTableSkeleton } from './components/c4-data-table/c4-data-table-skeleton.js';
51
+ export { C4DeleteAccountModal } from './components/c4-delete-account-modal/c4-delete-account-modal.js';
51
52
  export { C4DeleteOrganizationModal } from './components/c4-delete-organization-modal/c4-delete-organization-modal.js';
52
53
  export { C4Divider } from './components/c4-divider/c4-divider.js';
53
54
  export { C4EmptyState, } from './components/c4-empty-state/c4-empty-state.js';
@@ -55,6 +56,7 @@ export { C4ExtendTrialModal } from './components/c4-extend-trial-modal/c4-extend
55
56
  export { C4ExternalLink } from './components/c4-external-link/c4-external-link.js';
56
57
  export { C4FeedbackForm, C4FeedbackModal, } from './components/c4-feedback-modal/c4-feedback-modal.js';
57
58
  export { C4HelpCenter, FEEDBACK_TAB_ID, } from './components/c4-help-center/c4-help-center.js';
59
+ export { HUB_HELP_CENTER_LINKS_FLAG, rewriteAppHostToHub, } from './components/c4-help-center/help-center-app-host.js';
58
60
  export { C4InfoTooltip } from './components/c4-info-tooltip/c4-info-tooltip.js';
59
61
  export { C4InlineNotification } from './components/c4-inline-notification/c4-inline-notification.js';
60
62
  export { C4InviteUserToOrganizationModal } from './components/c4-invite-user-to-organization-modal/c4-invite-user-to-organization-modal.js';
@@ -113,7 +115,7 @@ export { openC4RenameOrganizationModal, setC4RenameOrganizationModalHandle, } fr
113
115
  // re-listed per module, so the package root and the
114
116
  // `@camunda/ccma-saas-frontend/runtime` subpath expose one identical surface.
115
117
  // Add runtime exports in `src/runtime/index.ts` and mirror them here.
116
- export { addC4ConsoleNotification, buildClusterSsoCallbackUrl, buildClusterSwaggerUrl, buildModelerOrgUrl, C4ConsoleDataProvider, C4ConsoleEventsProvider, C4ConsoleNotificationsProvider, C4ConsoleRuntimeProvider, C4UserNotificationsProvider, DEFAULT_NAV_APPS, getClusterStage, getEndpointForApp, getReadableAppName, hasReadPermissionForApp, isAdminApp, isAppHealthyOnCluster, removeC4ConsoleNotificationById, resolveAdminAppName, setC4ConsoleNotificationsHandle, useC4ClusterNavEntries, useC4ConsoleAuthz, useC4ConsoleData, useC4ConsoleEventsState, useC4ConsoleNotifications, useC4ConsoleRuntime, useC4DesignSystem, useC4FeatureFlag, useC4UserNotifications, useC4UserTheme, useC4WebappBreadcrumbData, } from './runtime/index.js';
118
+ export { addC4ConsoleNotification, buildClusterSsoCallbackUrl, buildClusterSwaggerUrl, buildModelerOrgUrl, C4ConsoleDataProvider, C4ConsoleEventsProvider, C4ConsoleNotificationsProvider, C4ConsoleRuntimeProvider, C4UserNotificationsProvider, DEFAULT_NAV_APPS, getClusterStage, getEndpointForApp, getReadableAppName, hasReadPermissionForApp, isAdminApp, isAppHealthyOnCluster, removeC4ConsoleNotificationById, resolveAdminAppName, setC4ConsoleNotificationsHandle, useC4ClusterNavEntries, useC4ConsoleAuthz, useC4ConsoleData, useC4ConsoleEventsState, useC4ConsoleNotifications, useC4ConsoleRuntime, useC4ConsoleStage, useC4DesignSystem, useC4FeatureFlag, useC4UserNotifications, useC4UserTheme, useC4WebappBreadcrumbData, } from './runtime/index.js';
117
119
  export { ENVIRONMENT_KEY_SUFFIX, safeTranslate, scopedTranslate, } from './utils/safe-translate.js';
118
120
  export { C4ClusterClientDetailsApp } from './widgets/cluster-client-details/c4-cluster-client-details-app.js';
119
121
  export { C4ClusterDetailsApp } from './widgets/cluster-details/c4-cluster-details-app.js';
@@ -138,4 +140,6 @@ export { C4ManagementApp } from './widgets/management/c4-management-app.js';
138
140
  export { C4ManagementPage } from './widgets/management/c4-management-page.js';
139
141
  export { MANAGEMENT_TABS, managementTab, } from './widgets/management/management-tabs.js';
140
142
  export { useExtendTrial } from './widgets/use-extend-trial.js';
143
+ export { C4DeleteAccountWidget } from './widgets/user-account/c4-delete-account-widget.js';
144
+ export { deriveDeleteAccountEligibility, useDeleteAccountEligibility, } from './widgets/user-account/use-delete-account-eligibility.js';
141
145
  export { C4UserDetailsPage } from './widgets/user-details/c4-user-details-page.js';
@@ -28,6 +28,19 @@ export interface DeriveConsoleAuthzParams {
28
28
  accessToken: string;
29
29
  orgId: string;
30
30
  }
31
+ export interface OrgMembershipPermissions {
32
+ orgId: string;
33
+ roles: string[];
34
+ permissions?: OrganizationPermissions;
35
+ }
36
+ /**
37
+ * The org permissions of the user, for every org in the token, not just one.
38
+ *
39
+ * `useC4ConsoleAuthz` resolves one org (the current one). A widget that must
40
+ * check every org the user belongs to — the delete-account eligibility gate is
41
+ * the first case — needs this instead.
42
+ */
43
+ export declare function deriveAllOrgMembershipPermissionsFromAccessToken(accessToken: string): OrgMembershipPermissions[];
31
44
  export declare function deriveConsoleAuthzFromAccessToken(params: DeriveConsoleAuthzParams): Omit<C4ConsoleAuthzState, 'isLoading' | 'error'>;
32
45
  /**
33
46
  * Whether a developer-only org member is blocked from creating clusters by the
@@ -72,6 +72,23 @@ function inferOrgPermissionsFromRoles(roles) {
72
72
  }
73
73
  return { roles: normalizedRoles, permissions };
74
74
  }
75
+ /**
76
+ * The org permissions of the user, for every org in the token, not just one.
77
+ *
78
+ * `useC4ConsoleAuthz` resolves one org (the current one). A widget that must
79
+ * check every org the user belongs to — the delete-account eligibility gate is
80
+ * the first case — needs this instead.
81
+ */
82
+ export function deriveAllOrgMembershipPermissionsFromAccessToken(accessToken) {
83
+ const payload = tryDecodeJwtPayload(accessToken);
84
+ const orgsKey = `${AUTH0_BASE_CLAIM}/${AUTH0_TOKEN_ATTRIBUTE_ORGS}`;
85
+ const orgMemberships = orgMembershipsFromUnknown(payload?.[orgsKey]);
86
+ return orgMemberships.map((membership) => ({
87
+ orgId: membership.id,
88
+ roles: membership.roles,
89
+ permissions: inferOrgPermissionsFromRoles(membership.roles)?.permissions,
90
+ }));
91
+ }
75
92
  export function deriveConsoleAuthzFromAccessToken(params) {
76
93
  const payload = tryDecodeJwtPayload(params.accessToken);
77
94
  const tokenPermissions = stringArrayFromUnknown(payload?.permissions);
@@ -1,5 +1,5 @@
1
1
  import type React from 'react';
2
- import type { C4ConsoleRuntimeConfig, C4DesignSystem } from './c4-console-runtime.types.js';
2
+ import type { C4ConsoleRuntimeConfig, C4DesignSystem, ConsoleStage } from './c4-console-runtime.types.js';
3
3
  export interface C4ConsoleRuntimeProviderProps {
4
4
  config: C4ConsoleRuntimeConfig;
5
5
  children: React.ReactNode;
@@ -13,11 +13,21 @@ export declare const useC4ConsoleRuntime: () => C4ConsoleRuntimeConfig;
13
13
  * the Design System by setting `designSystem: 'ds'` on the runtime config.
14
14
  */
15
15
  export declare const useC4DesignSystem: () => C4DesignSystem;
16
+ /**
17
+ * The stage the host runs on. Non-throwing and provider-optional, like
18
+ * `useC4DesignSystem`: `undefined` with no runtime provider (a test, a
19
+ * Storybook story). Use it for a rule that follows the rollout of an
20
+ * environment; `useC4ConsoleRuntime()` stays the way to read the rest of the
21
+ * config.
22
+ */
23
+ export declare const useC4ConsoleStage: () => ConsoleStage | undefined;
16
24
  /**
17
25
  * Whether a feature flag is on for the host. Non-throwing and
18
26
  * provider-optional, like `useC4DesignSystem`: with no runtime provider (a
19
- * test, a Storybook story) every flag reads as off. Off is also what a
20
- * stage-gated flag gives on prod, so the default shows the public behavior.
27
+ * test, a Storybook story) every flag reads as off. A host that knows nothing
28
+ * about the flag reads it as off too, because the bridge below gives a plain
29
+ * boolean. Thus a flag must hold the behavior that the other hosts of this
30
+ * package must NOT get by default.
21
31
  *
22
32
  * The key is the dot path of the flag in `@camunda-cloud/featureflags`, for
23
33
  * example `console.optionalTelemetry`.
@@ -60,11 +60,23 @@ export const useC4ConsoleRuntime = () => {
60
60
  export const useC4DesignSystem = () => {
61
61
  return useContext(RuntimeContext)?.designSystem ?? 'carbon';
62
62
  };
63
+ /**
64
+ * The stage the host runs on. Non-throwing and provider-optional, like
65
+ * `useC4DesignSystem`: `undefined` with no runtime provider (a test, a
66
+ * Storybook story). Use it for a rule that follows the rollout of an
67
+ * environment; `useC4ConsoleRuntime()` stays the way to read the rest of the
68
+ * config.
69
+ */
70
+ export const useC4ConsoleStage = () => {
71
+ return useContext(RuntimeContext)?.stage;
72
+ };
63
73
  /**
64
74
  * Whether a feature flag is on for the host. Non-throwing and
65
75
  * provider-optional, like `useC4DesignSystem`: with no runtime provider (a
66
- * test, a Storybook story) every flag reads as off. Off is also what a
67
- * stage-gated flag gives on prod, so the default shows the public behavior.
76
+ * test, a Storybook story) every flag reads as off. A host that knows nothing
77
+ * about the flag reads it as off too, because the bridge below gives a plain
78
+ * boolean. Thus a flag must hold the behavior that the other hosts of this
79
+ * package must NOT get by default.
68
80
  *
69
81
  * The key is the dot path of the flag in `@camunda-cloud/featureflags`, for
70
82
  * example `console.optionalTelemetry`.
@@ -32,7 +32,7 @@ export { C4ConsoleEventsProvider, useC4ConsoleEventsState, } from './c4-console-
32
32
  export { C4ConsoleNotificationsProvider, useC4ConsoleNotifications, } from './c4-console-notifications-context.js';
33
33
  export type { AddC4ConsoleNotificationOptions, C4ConsoleNotification, C4ConsoleNotificationAction, C4ConsoleNotificationKind, C4ConsoleNotificationsState, } from './c4-console-notifications-context.types.js';
34
34
  export type { C4ConsoleRuntimeConfig, ConsoleAuth, ConsoleBackendUrls, ConsoleClickwrapConfig, ConsolePublicUrls, ConsoleStage, ConsoleTelemetry, ConsoleUser, } from './c4-console-runtime.types.js';
35
- export { C4ConsoleRuntimeProvider, useC4ConsoleRuntime, useC4DesignSystem, useC4FeatureFlag, } from './c4-console-runtime-context.js';
35
+ export { C4ConsoleRuntimeProvider, useC4ConsoleRuntime, useC4ConsoleStage, useC4DesignSystem, useC4FeatureFlag, } from './c4-console-runtime-context.js';
36
36
  export { C4UserNotificationsProvider, useC4UserNotifications, } from './c4-user-notifications-context.js';
37
37
  export type { C4UserNotificationsProviderProps, C4UserNotificationsState, } from './c4-user-notifications-context.types.js';
38
38
  export type { C4ResolvedTheme, C4ThemePreference, C4UserThemeState, } from './c4-user-theme.js';
@@ -13,7 +13,7 @@ export { useC4ConsoleAuthz } from './c4-console-authz.js';
13
13
  export { C4ConsoleDataProvider, useC4ConsoleData, } from './c4-console-data-context.js';
14
14
  export { C4ConsoleEventsProvider, useC4ConsoleEventsState, } from './c4-console-events-context.js';
15
15
  export { C4ConsoleNotificationsProvider, useC4ConsoleNotifications, } from './c4-console-notifications-context.js';
16
- export { C4ConsoleRuntimeProvider, useC4ConsoleRuntime, useC4DesignSystem, useC4FeatureFlag, } from './c4-console-runtime-context.js';
16
+ export { C4ConsoleRuntimeProvider, useC4ConsoleRuntime, useC4ConsoleStage, useC4DesignSystem, useC4FeatureFlag, } from './c4-console-runtime-context.js';
17
17
  export { C4UserNotificationsProvider, useC4UserNotifications, } from './c4-user-notifications-context.js';
18
18
  export { useC4UserTheme } from './c4-user-theme.js';
19
19
  export { buildModelerOrgUrl, DEFAULT_NAV_APPS, getClusterStage, getEndpointForApp, getReadableAppName, hasReadPermissionForApp, isAdminApp, isAppHealthyOnCluster, resolveAdminAppName, } from './nav/camunda-apps.js';
@@ -1,17 +1,25 @@
1
- export declare const HUB_API_NAMING_FLAG = "console.hubApiNaming";
1
+ export declare const LEGACY_MODELER_API_NAMING_FLAG = "console.legacyModelerApiNaming";
2
2
  /**
3
3
  * Whether the Administration API surfaces use the Hub wording.
4
4
  *
5
5
  * The Hub rollout renames the Modeler scopes: the scope group in the
6
6
  * create-client modal reads "Hub API" and the scope columns read "Hub Scopes".
7
- * The flag `console.hubApiNaming` is on for local, dev and int, so a prod user
8
- * keeps the "Web Modeler API" and "Modeler Scopes" wording until Hub is
9
- * public. Only the text changes. The scope values that go to the API
10
- * (`GetModel`, `CreateModel`, ...) are the same on every stage.
7
+ * The Hub wording is the DEFAULT of this package, because a host that embeds
8
+ * these widgets ships them for Hub. Only Console keeps the old wording, and
9
+ * only on prod, until Hub is public.
10
+ *
11
+ * The gate is thus the flag `console.legacyModelerApiNaming`, which holds the
12
+ * OLD wording and is on for prod. A host that does not know the flag reads it
13
+ * as off (see `useC4FeatureFlag`) and gets "Hub API" with no code of its own.
14
+ * An opt-in flag cannot do this: the runtime bridge gives a boolean, so c4
15
+ * cannot tell an unknown flag from a flag that the host turned off.
16
+ *
17
+ * Only the text changes. The scope values that go to the API (`GetModel`,
18
+ * `CreateModel`, ...) are the same for every host and every stage.
11
19
  *
12
20
  * Each renamed i18n key has a `Hub` sibling, for example
13
21
  * `apiclients:create.fields.scopes.modeler.label` and `…modeler.labelHub`.
14
- * When the flag widens to `true`, delete this hook, the Modeler variant of
15
- * each key, and the `hubNaming` branch at every call site.
22
+ * When Console prod gets the Hub wording too, delete this hook, the Modeler
23
+ * variant of each key, and the `hubNaming` branch at every call site.
16
24
  */
17
25
  export declare const useHubApiNaming: () => boolean;
@@ -4,20 +4,28 @@
4
4
  * You may not use this file except in compliance with the commercial license.
5
5
  */
6
6
  import { useC4FeatureFlag } from './c4-console-runtime-context.js';
7
- export const HUB_API_NAMING_FLAG = 'console.hubApiNaming';
7
+ export const LEGACY_MODELER_API_NAMING_FLAG = 'console.legacyModelerApiNaming';
8
8
  /**
9
9
  * Whether the Administration API surfaces use the Hub wording.
10
10
  *
11
11
  * The Hub rollout renames the Modeler scopes: the scope group in the
12
12
  * create-client modal reads "Hub API" and the scope columns read "Hub Scopes".
13
- * The flag `console.hubApiNaming` is on for local, dev and int, so a prod user
14
- * keeps the "Web Modeler API" and "Modeler Scopes" wording until Hub is
15
- * public. Only the text changes. The scope values that go to the API
16
- * (`GetModel`, `CreateModel`, ...) are the same on every stage.
13
+ * The Hub wording is the DEFAULT of this package, because a host that embeds
14
+ * these widgets ships them for Hub. Only Console keeps the old wording, and
15
+ * only on prod, until Hub is public.
16
+ *
17
+ * The gate is thus the flag `console.legacyModelerApiNaming`, which holds the
18
+ * OLD wording and is on for prod. A host that does not know the flag reads it
19
+ * as off (see `useC4FeatureFlag`) and gets "Hub API" with no code of its own.
20
+ * An opt-in flag cannot do this: the runtime bridge gives a boolean, so c4
21
+ * cannot tell an unknown flag from a flag that the host turned off.
22
+ *
23
+ * Only the text changes. The scope values that go to the API (`GetModel`,
24
+ * `CreateModel`, ...) are the same for every host and every stage.
17
25
  *
18
26
  * Each renamed i18n key has a `Hub` sibling, for example
19
27
  * `apiclients:create.fields.scopes.modeler.label` and `…modeler.labelHub`.
20
- * When the flag widens to `true`, delete this hook, the Modeler variant of
21
- * each key, and the `hubNaming` branch at every call site.
28
+ * When Console prod gets the Hub wording too, delete this hook, the Modeler
29
+ * variant of each key, and the `hubNaming` branch at every call site.
22
30
  */
23
- export const useHubApiNaming = () => useC4FeatureFlag(HUB_API_NAMING_FLAG);
31
+ export const useHubApiNaming = () => !useC4FeatureFlag(LEGACY_MODELER_API_NAMING_FLAG);
@@ -0,0 +1,5 @@
1
+ import { type JSX } from 'react';
2
+ import type { C4DeleteAccountWidgetProps } from './c4-delete-account-widget.types.js';
3
+ export declare const C4DeleteAccountWidget: (({ open, onRequestClose, onDeleted, }: C4DeleteAccountWidgetProps) => JSX.Element) & {
4
+ displayName: string;
5
+ };
@@ -0,0 +1,65 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { UsersService } from '@camunda/ccma-api';
3
+ import { observer } from 'mobx-react-lite';
4
+ import { useMemo } from 'react';
5
+ import { C4DeleteAccountModal, safeTranslate, } from '../../components/c4-delete-account-modal/c4-delete-account-modal.js';
6
+ import { useC4ConsoleRuntime } from '../../runtime/c4-console-runtime-context.js';
7
+ import { toApiConfig } from '../../runtime/to-api-config.js';
8
+ import { useDeleteAccountEligibility } from './use-delete-account-eligibility.js';
9
+ /**
10
+ * Whether the request was refused with 403.
11
+ *
12
+ * The server holds the same enterprise-owner rule as the gate in this widget
13
+ * (#9934). A 403 thus means the gate let through what the server refuses:
14
+ * either the gate did not settle before the submit, or the two derivations
15
+ * drifted apart. For both, "try again" is the wrong advice — only support can
16
+ * delete that account.
17
+ *
18
+ * This reads `status` instead of `instanceof HttpError`, because a bundled
19
+ * host can hold its own copy of the class.
20
+ */
21
+ function isForbidden(error) {
22
+ return error?.status === 403;
23
+ }
24
+ /**
25
+ * Self-service account deletion, as a standalone widget.
26
+ *
27
+ * A host passes only `open` / `onRequestClose` / `onDeleted`. The widget
28
+ * derives the enterprise-owner/admin gate and the translations from the c4
29
+ * runtime, and owns the delete request. The host still owns navigation: it
30
+ * must log the user out and pick a landing page after `onDeleted`, because
31
+ * that differs between Hub and console.
32
+ *
33
+ * Requires a `C4ConsoleRuntimeProvider` and a `C4ConsoleDataProvider` above it.
34
+ */
35
+ const C4DeleteAccountWidgetImpl = ({ open, onRequestClose, onDeleted, }) => {
36
+ const runtime = useC4ConsoleRuntime();
37
+ const t = runtime.i18n?.t;
38
+ const apiConfig = useMemo(() => toApiConfig(runtime), [runtime]);
39
+ const eligibility = useDeleteAccountEligibility();
40
+ const handleSubmit = async (params) => {
41
+ try {
42
+ await UsersService.deleteMe({ config: apiConfig, params });
43
+ onDeleted();
44
+ return { success: true };
45
+ }
46
+ catch (error) {
47
+ return {
48
+ success: false,
49
+ error: {
50
+ title: 'Error',
51
+ description: isForbidden(error)
52
+ ? safeTranslate(t, 'users:delete.error.subscriptionOwner', 'You own an organization with an active subscription. Contact support to delete your account.')
53
+ : safeTranslate(t, 'users:delete.error.generic', "Couldn't delete your account. Try again."),
54
+ },
55
+ };
56
+ }
57
+ };
58
+ return (_jsx(C4DeleteAccountModal, { t: t, open: open, isEnterpriseOwner: eligibility.isEnterpriseOwner, isEnterpriseAdmin: eligibility.isEnterpriseAdmin,
59
+ // Holds the submit until the gate settles: until then an enterprise
60
+ // owner would see the reason form, not the contact-support variant.
61
+ loading: eligibility.isLoading, onRequestClose: onRequestClose, onRequestSubmit: handleSubmit }));
62
+ };
63
+ // Reads console data (through `useDeleteAccountEligibility`) during render,
64
+ // so it must be an observer to re-render when that data changes.
65
+ export const C4DeleteAccountWidget = observer(C4DeleteAccountWidgetImpl);
@@ -0,0 +1,13 @@
1
+ export interface C4DeleteAccountWidgetProps {
2
+ /** The host owns this state, from its own navigation bar or menu. */
3
+ open: boolean;
4
+ onRequestClose: () => void;
5
+ /**
6
+ * Called after the account of the caller is gone.
7
+ *
8
+ * The widget does not log the user out and does not redirect. Hub and
9
+ * console send the user to different places after a delete, so the host
10
+ * must do both here.
11
+ */
12
+ onDeleted: () => void;
13
+ }
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
3
+ * under one or more contributor license agreements. Licensed under a commercial license.
4
+ * You may not use this file except in compliance with the commercial license.
5
+ */
6
+ export {};
@@ -0,0 +1,41 @@
1
+ import type { ExternalOrganizationDto } from '@camunda/ccma-shared-types';
2
+ export interface DeleteAccountEligibility {
3
+ /**
4
+ * The user owns an enterprise org. The widget must not offer self-service
5
+ * delete: it would leave the org without an owner.
6
+ */
7
+ isEnterpriseOwner: boolean;
8
+ /**
9
+ * The user administers (but does not own) an enterprise org. Self-service
10
+ * delete is still allowed, with a reminder that it does not cancel the
11
+ * subscription of the org.
12
+ */
13
+ isEnterpriseAdmin: boolean;
14
+ isLoading: boolean;
15
+ /**
16
+ * Set when the gate could not be derived, because the org list or the
17
+ * access token failed to load. Both flags are then false, thus the modal
18
+ * shows the reason form and the server stays the guard: `DELETE
19
+ * api/users/me` answers 403 for an enterprise owner (#9934).
20
+ */
21
+ error?: unknown;
22
+ }
23
+ /**
24
+ * The account-deletion gate, checked across every org the user belongs to.
25
+ *
26
+ * Console's own gate (`allOrgsPermissions()`) reads this from its internal org
27
+ * model. This hook derives the same result from data the c4 runtime already
28
+ * has: the sales plan of each org (`myOrgs`, the external-facing org list) and
29
+ * the org roles inside the access token. Both derive from the same roles
30
+ * today, but the source data differs, so pin the match with
31
+ * `use-delete-account-eligibility.spec.ts` rather than assume it holds.
32
+ */
33
+ export declare function useDeleteAccountEligibility(): DeleteAccountEligibility;
34
+ /**
35
+ * Pure derivation, split out from the hook so the parity test can call it
36
+ * directly with fixed input instead of a mocked runtime.
37
+ */
38
+ export declare function deriveDeleteAccountEligibility(params: {
39
+ accessToken: string;
40
+ myOrgs: ExternalOrganizationDto[];
41
+ }): DeleteAccountEligibility;
@@ -0,0 +1,97 @@
1
+ /*
2
+ * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
3
+ * under one or more contributor license agreements. Licensed under a commercial license.
4
+ * You may not use this file except in compliance with the commercial license.
5
+ */
6
+ import { useEffect, useState } from 'react';
7
+ import { deriveAllOrgMembershipPermissionsFromAccessToken } from '../../runtime/c4-console-authz.js';
8
+ import { useC4ConsoleData } from '../../runtime/c4-console-data-context.js';
9
+ import { useC4ConsoleRuntime } from '../../runtime/c4-console-runtime-context.js';
10
+ const PENDING_ELIGIBILITY = {
11
+ isEnterpriseOwner: false,
12
+ isEnterpriseAdmin: false,
13
+ isLoading: true,
14
+ };
15
+ const UNKNOWN_ELIGIBILITY = {
16
+ isEnterpriseOwner: false,
17
+ isEnterpriseAdmin: false,
18
+ isLoading: false,
19
+ };
20
+ /**
21
+ * The account-deletion gate, checked across every org the user belongs to.
22
+ *
23
+ * Console's own gate (`allOrgsPermissions()`) reads this from its internal org
24
+ * model. This hook derives the same result from data the c4 runtime already
25
+ * has: the sales plan of each org (`myOrgs`, the external-facing org list) and
26
+ * the org roles inside the access token. Both derive from the same roles
27
+ * today, but the source data differs, so pin the match with
28
+ * `use-delete-account-eligibility.spec.ts` rather than assume it holds.
29
+ */
30
+ export function useDeleteAccountEligibility() {
31
+ const runtime = useC4ConsoleRuntime();
32
+ const data = useC4ConsoleData();
33
+ const [eligibility, setEligibility] = useState(PENDING_ELIGIBILITY);
34
+ useEffect(() => {
35
+ void data.fetchMyOrgs();
36
+ }, [data]);
37
+ const myOrgs = data.getMyOrgs();
38
+ // The org list says which orgs are enterprise, thus the gate needs it. When
39
+ // the fetch failed, settle instead of waiting for data that never arrives.
40
+ const myOrgsError = data.myOrgs.error;
41
+ useEffect(() => {
42
+ if (myOrgsError) {
43
+ setEligibility({ ...UNKNOWN_ELIGIBILITY, error: myOrgsError });
44
+ return;
45
+ }
46
+ if (!myOrgs) {
47
+ return;
48
+ }
49
+ const resolvedMyOrgs = myOrgs;
50
+ let isCancelled = false;
51
+ async function run() {
52
+ try {
53
+ const accessToken = await runtime.auth.getAccessToken();
54
+ if (isCancelled) {
55
+ return;
56
+ }
57
+ setEligibility(deriveDeleteAccountEligibility({
58
+ accessToken,
59
+ myOrgs: resolvedMyOrgs,
60
+ }));
61
+ }
62
+ catch (error) {
63
+ if (isCancelled) {
64
+ return;
65
+ }
66
+ setEligibility({ ...UNKNOWN_ELIGIBILITY, error });
67
+ }
68
+ }
69
+ void run();
70
+ return () => {
71
+ isCancelled = true;
72
+ };
73
+ }, [myOrgs, myOrgsError, runtime.auth]);
74
+ return eligibility;
75
+ }
76
+ /**
77
+ * Pure derivation, split out from the hook so the parity test can call it
78
+ * directly with fixed input instead of a mocked runtime.
79
+ */
80
+ export function deriveDeleteAccountEligibility(params) {
81
+ const memberships = deriveAllOrgMembershipPermissionsFromAccessToken(params.accessToken);
82
+ let isEnterpriseOwner = false;
83
+ let isEnterpriseAdmin = false;
84
+ for (const org of params.myOrgs) {
85
+ if (org.salesPlan?.type !== 'enterprise') {
86
+ continue;
87
+ }
88
+ const permissions = memberships.find((membership) => membership.orgId === org.uuid)?.permissions;
89
+ if (permissions?.org.users.admin.create) {
90
+ isEnterpriseOwner = true;
91
+ }
92
+ else if (permissions?.org.users.member.create) {
93
+ isEnterpriseAdmin = true;
94
+ }
95
+ }
96
+ return { isEnterpriseOwner, isEnterpriseAdmin, isLoading: false };
97
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camunda/ccma-saas-frontend",
3
- "version": "0.8.4",
3
+ "version": "0.10.0",
4
4
  "description": "Camunda Composite Components",
5
5
  "bugs": {
6
6
  "url": "https://github.com/camunda/camunda-cloud-management-apps/issues"
@@ -96,7 +96,7 @@
96
96
  "react-markdown": "^8.0.7 || ^10.0.0"
97
97
  },
98
98
  "dependencies": {
99
- "@camunda/ccma-api": "1.0.0",
99
+ "@camunda/ccma-api": "1.0.1",
100
100
  "@camunda/ccma-shared-types": "1.0.0",
101
101
  "@pactsafe/pactsafe-react-sdk": "2.15.0",
102
102
  "cron-parser": "5.10.0",