@aglyn/plugins-crm 1.18.0 → 1.20.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/package.json +14 -14
- package/src/lib/components/log-activity-dialog.d.ts +2 -0
- package/src/lib/components/log-activity-dialog.js +11 -2
- package/src/lib/components/log-activity-dialog.js.map +1 -1
- package/src/lib/components/record-sharing-card.js +8 -7
- package/src/lib/components/record-sharing-card.js.map +1 -1
- package/src/lib/components/settings-section.d.ts +10 -3
- package/src/lib/components/settings-section.js +286 -35
- package/src/lib/components/settings-section.js.map +1 -1
- package/src/lib/components/share-records-dialog.d.ts +17 -3
- package/src/lib/components/share-records-dialog.js +59 -45
- package/src/lib/components/share-records-dialog.js.map +1 -1
- package/src/lib/components/sharing-rule-drawer.d.ts +13 -3
- package/src/lib/components/sharing-rule-drawer.js +51 -40
- package/src/lib/components/sharing-rule-drawer.js.map +1 -1
- package/src/lib/components/sharing-rules-card.js +2 -1
- package/src/lib/components/sharing-rules-card.js.map +1 -1
- package/src/lib/declarations.server.js +10 -1
- package/src/lib/declarations.server.js.map +1 -1
- package/src/lib/hooks/use-campaign-filing-log.js +10 -2
- package/src/lib/hooks/use-campaign-filing-log.js.map +1 -1
- package/src/lib/hooks/use-crm-sharing.d.ts +8 -0
- package/src/lib/hooks/use-crm-sharing.js +20 -0
- package/src/lib/hooks/use-crm-sharing.js.map +1 -1
- package/src/lib/model/crm-sharing-api.d.ts +5 -2
- package/src/lib/model/crm-sharing-api.js +3 -0
- package/src/lib/model/crm-sharing-api.js.map +1 -1
- package/src/lib/model/crm-sharing.d.ts +153 -5
- package/src/lib/model/crm-sharing.js +243 -20
- package/src/lib/model/crm-sharing.js.map +1 -1
- package/src/lib/model/lead-filters.d.ts +1 -1
- package/src/lib/server/add-contact-by-hand.js +11 -4
- package/src/lib/server/add-contact-by-hand.js.map +1 -1
- package/src/lib/server/api-v1/crm-activities.js +2 -2
- package/src/lib/server/api-v1/crm-activities.js.map +1 -1
- package/src/lib/server/api-v1/crm-companies.js +2 -2
- package/src/lib/server/api-v1/crm-companies.js.map +1 -1
- package/src/lib/server/api-v1/crm-deals.js +2 -2
- package/src/lib/server/api-v1/crm-deals.js.map +1 -1
- package/src/lib/server/api-v1/crm-shared.d.ts +16 -0
- package/src/lib/server/api-v1/crm-shared.js +12 -1
- package/src/lib/server/api-v1/crm-shared.js.map +1 -1
- package/src/lib/server/api-v1/crm-tasks.js +2 -2
- package/src/lib/server/api-v1/crm-tasks.js.map +1 -1
- package/src/lib/server/associate-company-by-domain.d.ts +1 -1
- package/src/lib/server/associate-company-by-domain.js +4 -4
- package/src/lib/server/associate-company-by-domain.js.map +1 -1
- package/src/lib/server/automation-steps.js +24 -12
- package/src/lib/server/automation-steps.js.map +1 -1
- package/src/lib/server/campaign-filing-activity.js +7 -3
- package/src/lib/server/campaign-filing-activity.js.map +1 -1
- package/src/lib/server/convert-host-lead.js +13 -4
- package/src/lib/server/convert-host-lead.js.map +1 -1
- package/src/lib/server/crm-default-sharing.d.ts +86 -0
- package/src/lib/server/crm-default-sharing.js +409 -0
- package/src/lib/server/crm-default-sharing.js.map +1 -0
- package/src/lib/server/crm-inbound-email.js +2 -2
- package/src/lib/server/crm-inbound-email.js.map +1 -1
- package/src/lib/server/crm-sharing-runs.d.ts +71 -0
- package/src/lib/server/crm-sharing-runs.js +221 -0
- package/src/lib/server/crm-sharing-runs.js.map +1 -0
- package/src/lib/server/crm-sharing.d.ts +24 -1
- package/src/lib/server/crm-sharing.js +183 -31
- package/src/lib/server/crm-sharing.js.map +1 -1
- package/src/lib/server/email-send.js +5 -2
- package/src/lib/server/email-send.js.map +1 -1
- package/src/lib/server/record-timeline.d.ts +2 -1
- package/src/lib/server/record-timeline.js +11 -6
- package/src/lib/server/record-timeline.js.map +1 -1
- package/src/lib/server/task-routes.js +10 -6
- package/src/lib/server/task-routes.js.map +1 -1
- package/src/lib/server.js +23 -1
- package/src/lib/server.js.map +1 -1
- package/src/lib/transfer/common.d.ts +5 -1
- package/src/lib/transfer/common.js +8 -5
- package/src/lib/transfer/common.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aglyn/plugins-crm",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"homepage": "https://aglyn.com",
|
|
6
6
|
"repository": {
|
|
@@ -25,19 +25,19 @@
|
|
|
25
25
|
"./package.json": "./package.json"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@aglyn/aglyn": "1.
|
|
29
|
-
"@aglyn/shared-data-enums": "1.
|
|
30
|
-
"@aglyn/shared-data-mdi": "1.
|
|
31
|
-
"@aglyn/shared-ui-jsx": "1.
|
|
32
|
-
"@aglyn/shared-ui-next": "1.
|
|
33
|
-
"@aglyn/shared-ui-snackstack": "1.
|
|
34
|
-
"@aglyn/shared-util-email": "1.
|
|
35
|
-
"@aglyn/shared-util-http": "1.
|
|
36
|
-
"@aglyn/shared-util-timestamp": "1.
|
|
37
|
-
"@aglyn/shared-util-tools": "1.
|
|
38
|
-
"@aglyn/tenant-data-admin": "1.
|
|
39
|
-
"@aglyn/tenant-feature-instance": "1.
|
|
40
|
-
"@aglyn/tenant-runtime": "1.
|
|
28
|
+
"@aglyn/aglyn": "1.20.0",
|
|
29
|
+
"@aglyn/shared-data-enums": "1.20.0",
|
|
30
|
+
"@aglyn/shared-data-mdi": "1.20.0",
|
|
31
|
+
"@aglyn/shared-ui-jsx": "1.20.0",
|
|
32
|
+
"@aglyn/shared-ui-next": "1.20.0",
|
|
33
|
+
"@aglyn/shared-ui-snackstack": "1.20.0",
|
|
34
|
+
"@aglyn/shared-util-email": "1.20.0",
|
|
35
|
+
"@aglyn/shared-util-http": "1.20.0",
|
|
36
|
+
"@aglyn/shared-util-timestamp": "1.20.0",
|
|
37
|
+
"@aglyn/shared-util-tools": "1.20.0",
|
|
38
|
+
"@aglyn/tenant-data-admin": "1.20.0",
|
|
39
|
+
"@aglyn/tenant-feature-instance": "1.20.0",
|
|
40
|
+
"@aglyn/tenant-runtime": "1.20.0",
|
|
41
41
|
"@dnd-kit/core": "^6.3.1",
|
|
42
42
|
"@dnd-kit/utilities": "^3.2.2",
|
|
43
43
|
"@swc/helpers": "0.5.23",
|
|
@@ -54,6 +54,8 @@ export interface LogActivityDialogProps {
|
|
|
54
54
|
* author, the name denormalized because a colleague reading the log cannot
|
|
55
55
|
* resolve a uid (see `CrmActivity.byName`); `atMs` for when it HAPPENED,
|
|
56
56
|
* which the reader picks and which defaults to now; and the timestamps.
|
|
57
|
+
* Under the CRM default "All sites except…" the server then adds the marker a
|
|
58
|
+
* site added later joins by, which the rules refuse from a browser (AGL-4047).
|
|
57
59
|
*
|
|
58
60
|
* An edit rewrites only the fields the dialog shows. `visibleTo` is never
|
|
59
61
|
* touched — the rules refuse a scoped member changing it, and widening a
|
|
@@ -24,6 +24,7 @@ import { addDoc, collection, deleteField, doc, getCountFromServer, query, update
|
|
|
24
24
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
25
25
|
import { crmActivityClientReads } from "../hooks/crm-activity-client-reads.js";
|
|
26
26
|
import { crmVisibleToClause } from "../hooks/use-crm-scope.js";
|
|
27
|
+
import { useCrmDefaultMarkFollowUp } from "../hooks/use-crm-sharing.js";
|
|
27
28
|
import { crmActivityLinkFromPicks, crmActivityPicksEqual, crmActivityPicksFrom, resolveCrmActivityCompany } from "../model/crm-activity-link.js";
|
|
28
29
|
import { ActivityLinkFields } from "./activity-link-fields.js";
|
|
29
30
|
import { CrmSitePicker } from "./crm-site-picker.js";
|
|
@@ -89,6 +90,8 @@ const draftFrom = (activity)=>{
|
|
|
89
90
|
* author, the name denormalized because a colleague reading the log cannot
|
|
90
91
|
* resolve a uid (see `CrmActivity.byName`); `atMs` for when it HAPPENED,
|
|
91
92
|
* which the reader picks and which defaults to now; and the timestamps.
|
|
93
|
+
* Under the CRM default "All sites except…" the server then adds the marker a
|
|
94
|
+
* site added later joins by, which the rules refuse from a browser (AGL-4047).
|
|
92
95
|
*
|
|
93
96
|
* An edit rewrites only the fields the dialog shows. `visibleTo` is never
|
|
94
97
|
* touched — the rules refuse a scoped member changing it, and widening a
|
|
@@ -106,10 +109,11 @@ const draftFrom = (activity)=>{
|
|
|
106
109
|
* this dialog for an edit checks the author itself (`useCanEditActivity`),
|
|
107
110
|
* so what reaches here has already passed the console's verdict.
|
|
108
111
|
*/ export function LogActivityDialog(props) {
|
|
109
|
-
var _Aglyn_CRM_ACTIVITY_DIRECTIONS_draft_kind;
|
|
112
|
+
var _ref, _Aglyn_CRM_ACTIVITY_DIRECTIONS_draft_kind;
|
|
110
113
|
const { open, onClose, scope, link, deal, activity, kind: presetKind } = props;
|
|
111
114
|
const { firestore, dataScope, hostId, mountedHostId, readTokens, writeTokens, needsSite } = scope;
|
|
112
115
|
const { consentGroup, org } = scope;
|
|
116
|
+
const markUnderDefault = useCrmDefaultMarkFollowUp(mountedHostId, (_ref = dataScope == null ? void 0 : dataScope[1]) != null ? _ref : null, org);
|
|
113
117
|
const { data: user } = useUser();
|
|
114
118
|
const authorName = useUserName();
|
|
115
119
|
const { enqueueSnackbar } = useSnackbar();
|
|
@@ -225,7 +229,7 @@ const draftFrom = (activity)=>{
|
|
|
225
229
|
}
|
|
226
230
|
}
|
|
227
231
|
const links = await stamped();
|
|
228
|
-
await addDoc(collection(firestore, dataScope[0], dataScope[1], Aglyn.CRM_COLLECTIONS.activities), _extends({}, said, outcome ? {
|
|
232
|
+
const added = await addDoc(collection(firestore, dataScope[0], dataScope[1], Aglyn.CRM_COLLECTIONS.activities), _extends({}, said, outcome ? {
|
|
229
233
|
outcome
|
|
230
234
|
} : {}, durationMinutes !== null ? {
|
|
231
235
|
durationMinutes
|
|
@@ -241,6 +245,10 @@ const draftFrom = (activity)=>{
|
|
|
241
245
|
createdAt: new Date(),
|
|
242
246
|
updatedAt: new Date()
|
|
243
247
|
}));
|
|
248
|
+
// Under "All sites except…", the marker a site added later joins by (AGL-4047).
|
|
249
|
+
markUnderDefault([
|
|
250
|
+
added.id
|
|
251
|
+
]);
|
|
244
252
|
enqueueSnackbar('Activity logged', {
|
|
245
253
|
variant: 'success',
|
|
246
254
|
persist: false
|
|
@@ -279,6 +287,7 @@ const draftFrom = (activity)=>{
|
|
|
279
287
|
writeTokens,
|
|
280
288
|
hostId,
|
|
281
289
|
authorName,
|
|
290
|
+
markUnderDefault,
|
|
282
291
|
onClose
|
|
283
292
|
]);
|
|
284
293
|
return /*#__PURE__*/ _jsxs(Dialog, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/components/log-activity-dialog.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport type { CrmActivityKind, CrmActivityRow } from '@aglyn/aglyn'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { useUser, useUserName } from '@aglyn/tenant-feature-instance'\nimport {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n MenuItem,\n Stack,\n TextField,\n} from '@mui/material'\nimport {\n addDoc,\n collection,\n deleteField,\n doc,\n getCountFromServer,\n query,\n updateDoc,\n where,\n} from 'firebase/firestore'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { crmActivityClientReads } from '../hooks/crm-activity-client-reads'\nimport { crmVisibleToClause } from '../hooks/use-crm-scope'\nimport {\n crmActivityLinkFromPicks,\n crmActivityPicksEqual,\n crmActivityPicksFrom,\n type CrmActivityPicks,\n resolveCrmActivityCompany,\n} from '../model/crm-activity-link'\nimport { ActivityLinkFields } from './activity-link-fields'\nimport type { ActivityRecordLink, ActivityScope } from './activity-queries'\nimport { CrmSitePicker } from './crm-site-picker'\n\n/** The longest body a single activity stores — a call summary, not a document. */\nconst BODY_MAX = 4000\nconst OUTCOME_MAX = 200\nconst DURATION_MAX_MINUTES = 24 * 60\n\n/**\n * Epoch millis as the value a `datetime-local` input holds, in the LOCAL\n * zone — the input has no zone of its own, so an ISO string with a `Z`\n * would land the call an offset away from when it happened.\n */\nfunction toLocalInput(ms: number): string {\n if (!Number.isFinite(ms)) return ''\n const date = new Date(ms)\n const pad = (value: number) => String(value).padStart(2, '0')\n return (\n `${date.getFullYear()}-${pad(date.getMonth() + 1)}-` +\n `${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`\n )\n}\n\n/** The inverse: a `datetime-local` value parsed as local time, or `null`. */\nfunction fromLocalInput(value: string): number | null {\n if (!value) return null\n const ms = new Date(value).getTime()\n return Number.isFinite(ms) ? ms : null\n}\n\ninterface Draft {\n kind: CrmActivityKind\n body: string\n /** The `datetime-local` string, not millis — what the input holds. */\n at: string\n outcome: string\n /** Free text until save, so a half-typed number does not snap to zero. */\n durationMinutes: string\n /**\n * Which way a call or an email went (AGL-3517) — Salesforce's Call Type\n * for a call — or `''` for not said. Kept across a kind change and\n * written only when the kind takes it.\n */\n direction: string\n /** **Name** and **Related To**, as the reader has left them. */\n picks: CrmActivityPicks\n}\n\n/** The kind a new activity opens on when the caller names none. */\nconst DEFAULT_KIND: CrmActivityKind = 'call'\n\nconst freshDraft = (\n kind: CrmActivityKind = DEFAULT_KIND,\n picks: CrmActivityPicks = crmActivityPicksFrom({}),\n): Draft => ({\n kind,\n body: '',\n at: toLocalInput(Date.now()),\n outcome: '',\n durationMinutes: '',\n // Most logged calls and emails are the team's own.\n direction: 'outbound',\n picks,\n})\n\nconst draftFrom = (activity: CrmActivityRow): Draft => ({\n kind: Aglyn.isCrmActivityKind(activity.kind) ? activity.kind : 'other',\n body: activity.body ?? '',\n at: toLocalInput(activity.atMs),\n outcome: activity.outcome ?? '',\n durationMinutes:\n typeof activity.durationMinutes === 'number'\n ? String(activity.durationMinutes)\n : '',\n direction: Aglyn.crmActivityDirection(activity.kind, activity.direction) ?? '',\n picks: crmActivityPicksFrom(activity),\n})\n\nexport interface LogActivityDialogProps {\n open: boolean\n onClose: () => void\n /** Where the activity is written, from `useActivityScope`. */\n scope: ActivityScope\n /**\n * The record the dialog was opened on, which prefills **Name** and\n * **Related To** (AGL-4123). A lead's own log offers neither: the lead is\n * the entry's only link until it converts.\n */\n link: ActivityRecordLink\n /**\n * The deal the dialog was opened on, as its page read it: **Name** opens on\n * its Primary and its contact roles lead the list.\n */\n deal?: { contactId?: unknown; contactRoles?: unknown } | null\n /**\n * When set, the dialog EDITS this activity rather than logging a new one.\n * The author and the scope stay what they were; what was said, when, how\n * it went, and who and what it is about can change.\n */\n activity?: CrmActivityRow | null\n /**\n * What a NEW activity opens as (AGL-2661) — the click-to-call button\n * opens the dialog already a call, so logging one is the button and a\n * sentence rather than the button, the kind and a sentence. Ignored for\n * an edit, whose kind is the activity's own.\n */\n kind?: CrmActivityKind\n}\n\n/**\n * Log a call, an email, a meeting, a note or something else against a\n * record (AGL-2600) — or correct one already logged.\n *\n * ## Who, what and which account\n *\n * **Name** and **Related To** are Salesforce's Who and What (AGL-4123), and\n * the company an entry rolls up to is stamped from them when it is saved —\n * `model/crm-activity-link.ts` has the rule, shared with every other writer.\n * The fields open on the record the dialog was opened from and the reader may\n * change them: an entry named for a deal shows on the deal, on the person's\n * timeline and on the company, whichever page it was logged from.\n *\n * ## What is written\n *\n * A new activity carries the whole `CrmScoped` stamp: `visibleTo` from\n * `crmScopeTokens`, so it lands in exactly the scope a contact captured on\n * this site would; `hostId` as provenance; `byUid` and `byName` for the\n * author, the name denormalized because a colleague reading the log cannot\n * resolve a uid (see `CrmActivity.byName`); `atMs` for when it HAPPENED,\n * which the reader picks and which defaults to now; and the timestamps.\n *\n * An edit rewrites only the fields the dialog shows. `visibleTo` is never\n * touched — the rules refuse a scoped member changing it, and widening a\n * record is an act for an org-wide member on the record itself — and neither\n * is the author. The links are rewritten only when **Name** or **Related To**\n * changed, and then the company is worked out again, so an edit that corrects\n * a typo cannot move an entry off a timeline it was filed on. A kind that\n * stops taking an outcome takes the outcome and the duration off the document\n * rather than leaving a stale \"left a voicemail\" on what is now a note.\n *\n * ## Who may write\n *\n * The rules admit any member who may write scoped org data, on create and\n * on update alike; they do not distinguish the author. The card that opens\n * this dialog for an edit checks the author itself (`useCanEditActivity`),\n * so what reaches here has already passed the console's verdict.\n */\nexport function LogActivityDialog(props: LogActivityDialogProps) {\n const { open, onClose, scope, link, deal, activity, kind: presetKind } = props\n const { firestore, dataScope, hostId, mountedHostId, readTokens, writeTokens, needsSite } =\n scope\n const { consentGroup, org } = scope\n const { data: user } = useUser()\n const authorName = useUserName()\n const { enqueueSnackbar } = useSnackbar()\n const [draft, setDraft] = useState<Draft>(freshDraft)\n const [saving, setSaving] = useState(false)\n\n /*\n * Seeded on OPEN, not on mount: the dialog stays mounted between uses so\n * its state survives a close, and \"log another call\" must start from now\n * rather than from the last call's timestamp. The record is read through a\n * ref, because a deal is a live document and a colleague's save to it must\n * not wipe what the reader has typed so far.\n */\n const openedOn = useRef({ link, deal })\n useEffect(() => {\n openedOn.current = { link, deal }\n }, [link, deal])\n useEffect(() => {\n if (!open) return\n const seed = openedOn.current\n const primary = seed.deal ? Aglyn.dealPrimaryContactId(Aglyn.dealContactRolesOf(seed.deal)) : null\n setDraft(\n activity\n ? draftFrom(activity)\n : freshDraft(presetKind, crmActivityPicksFrom(seed.link, primary)),\n )\n }, [open, activity, presetKind])\n\n const hasOutcome = Aglyn.activityKindHasOutcome(draft.kind)\n const directions = Aglyn.CRM_ACTIVITY_DIRECTIONS[draft.kind] ?? []\n const direction = Aglyn.crmActivityDirection(draft.kind, draft.direction)\n const atMs = fromLocalInput(draft.at)\n const body = draft.body.trim()\n /*\n * A lead's own log shows neither field: a lead is not a contact **Name**\n * could hold, and in Salesforce's model too it names no What. A contact\n * beside the lead means it converted, and the entry reads like any other.\n */\n const filedOn = activity ?? link\n const leadOnly = Boolean(filedOn.leadId) && !filedOn.contactId\n const { picks } = draft\n // An activity attached to nothing is a sentence nobody can find (AGL-2606).\n const linked = leadOnly || Boolean(picks.contactId || picks.related)\n const duration = draft.durationMinutes.trim()\n ? Number(draft.durationMinutes)\n : null\n const durationValid =\n duration === null ||\n (Number.isInteger(duration) &&\n duration >= 0 &&\n duration <= DURATION_MAX_MINUTES)\n const canSave =\n Boolean(dataScope) &&\n Boolean(user?.uid) &&\n // A NEW activity is stamped with a scope: the whole org where every site\n // sees the CRM's records, else the picked site's — and in an org that\n // keeps its sites apart there is nothing to write until one is picked\n // (AGL-2630). An edit never touches either.\n (Boolean(activity) || writeTokens.length > 0) &&\n body.length > 0 &&\n atMs !== null &&\n durationValid &&\n linked &&\n !saving\n\n const handleSave = useCallback(async () => {\n // Every guard the button reads, again — a callback can outlive the\n // render that disabled it.\n if (!dataScope || !user?.uid || !body || atMs === null || !durationValid || !linked) {\n return\n }\n if (!activity && !writeTokens.length) return\n setSaving(true)\n try {\n const named = crmActivityLinkFromPicks(picks, filedOn.leadId)\n const stamped = () =>\n resolveCrmActivityCompany(\n named,\n { groupId: consentGroup?.groupId, org },\n crmActivityClientReads(firestore, dataScope[1]),\n )\n const said = {\n kind: draft.kind,\n body: body.slice(0, BODY_MAX),\n atMs,\n }\n const outcome = hasOutcome ? draft.outcome.trim().slice(0, OUTCOME_MAX) : ''\n const durationMinutes = hasOutcome && duration !== null ? duration : null\n if (activity) {\n const relinked = crmActivityPicksEqual(picks, crmActivityPicksFrom(activity))\n ? null\n : await stamped()\n await updateDoc(\n doc(\n firestore,\n dataScope[0],\n dataScope[1],\n Aglyn.CRM_COLLECTIONS.activities,\n activity.$id,\n ),\n {\n ...said,\n // Cleared rather than left: an entry moved off a deal must stop\n // showing on it. A lead's own link is never the fields' to change.\n ...(relinked\n ? {\n contactId: relinked.contactId ?? deleteField(),\n dealId: relinked.dealId ?? deleteField(),\n companyId: relinked.companyId ?? deleteField(),\n }\n : {}),\n // Cleared rather than left: a call turned into a note must not\n // keep the call's outcome, and Firestore refuses `undefined`.\n outcome: outcome ? outcome : deleteField(),\n direction: direction ?? deleteField(),\n durationMinutes:\n durationMinutes !== null ? durationMinutes : deleteField(),\n updatedAt: new Date(),\n },\n )\n enqueueSnackbar('Activity updated', { variant: 'success', persist: false })\n } else {\n /*\n * THE PER-RECORD CEILING (AGL-2611): one aggregate on the record\n * this dialog is filing under, before the write — the same count\n * the automation step and the REST create take, on the same link.\n * Scoped to the tokens this viewer may list, as every activity\n * listener is, so the rules admit the aggregate for a scoped\n * member exactly as they admit the timeline.\n */\n const lead = Aglyn.crmActivityCeilingLink(named)\n if (lead) {\n const logged = (\n await getCountFromServer(\n query(\n collection(\n firestore,\n dataScope[0],\n dataScope[1],\n Aglyn.CRM_COLLECTIONS.activities,\n ),\n ...crmVisibleToClause(readTokens),\n where(lead.field, '==', lead.id),\n ),\n )\n ).data().count\n if (!Aglyn.crmActivityLogHasRoom(logged)) {\n enqueueSnackbar(Aglyn.CRM_ACTIVITY_LOG_FULL_MESSAGE, {\n variant: 'warning',\n persist: false,\n })\n return\n }\n }\n const links = await stamped()\n await addDoc(\n collection(\n firestore,\n dataScope[0],\n dataScope[1],\n Aglyn.CRM_COLLECTIONS.activities,\n ),\n {\n ...said,\n ...(outcome ? { outcome } : {}),\n ...(durationMinutes !== null ? { durationMinutes } : {}),\n ...(direction ? { direction } : {}),\n // Only the links it has: `stampCrmActivityCompany` leaves no blank\n // key, and Firestore refuses `undefined`.\n ...links,\n visibleTo: writeTokens,\n hostId,\n byUid: user.uid,\n // Absent rather than blank while the profile is still resolving:\n // the row reads a stored name over anything else, and an empty\n // string would be a name.\n ...(authorName ? { byName: authorName } : {}),\n createdAt: new Date(),\n updatedAt: new Date(),\n },\n )\n enqueueSnackbar('Activity logged', { variant: 'success', persist: false })\n }\n onClose()\n } catch (error) {\n console.error(error)\n enqueueSnackbar('An error has occurred', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n setSaving(false)\n }\n }, [\n dataScope,\n user,\n body,\n atMs,\n durationValid,\n draft.kind,\n draft.outcome,\n direction,\n hasOutcome,\n duration,\n activity,\n firestore,\n enqueueSnackbar,\n linked,\n picks,\n filedOn.leadId,\n consentGroup,\n org,\n readTokens,\n writeTokens,\n hostId,\n authorName,\n onClose,\n ])\n\n return (\n <Dialog open={open} onClose={onClose} maxWidth=\"sm\" fullWidth>\n <DialogTitle>{activity ? 'Edit activity' : 'Log activity'}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n {/* Only for a new activity at the organization level — see `canSave`. */}\n {activity ? null : (\n <CrmSitePicker\n hostId={mountedHostId}\n disabled={saving}\n optional={needsSite === false}\n helperText={\n needsSite === false\n ? undefined\n : 'The site this activity is logged from — it decides which of your sites may see it.'\n }\n />\n )}\n <Stack direction=\"row\" spacing={1} sx={{ mt: 1 }}>\n <TextField\n select\n size=\"small\"\n label=\"Kind\"\n value={draft.kind}\n onChange={(event) =>\n setDraft((prev) => ({\n ...prev,\n kind: Aglyn.isCrmActivityKind(event.target.value)\n ? event.target.value\n : prev.kind,\n }))\n }\n sx={{ minWidth: 140 }}\n >\n {Aglyn.CRM_ACTIVITY_KINDS.map((kind) => (\n <MenuItem key={kind} value={kind}>\n {Aglyn.CRM_ACTIVITY_KIND_LABELS[kind]}\n </MenuItem>\n ))}\n </TextField>\n {directions.length ? (\n <TextField\n select\n size=\"small\"\n label=\"Direction\"\n value={direction ?? ''}\n onChange={(event) =>\n setDraft((prev) => ({ ...prev, direction: String(event.target.value) }))\n }\n slotProps={{ select: { displayEmpty: true }, inputLabel: { shrink: true } }}\n sx={{ minWidth: 130 }}\n >\n <MenuItem value=\"\">{'Not said'}</MenuItem>\n {directions.map((entry) => (\n <MenuItem key={entry} value={entry}>\n {Aglyn.CRM_ACTIVITY_DIRECTION_LABELS[entry]}\n </MenuItem>\n ))}\n </TextField>\n ) : null}\n <TextField\n size=\"small\"\n label=\"When\"\n type=\"datetime-local\"\n value={draft.at}\n onChange={(event) =>\n setDraft((prev) => ({ ...prev, at: event.target.value }))\n }\n error={draft.at.length > 0 && atMs === null}\n slotProps={{ inputLabel: { shrink: true } }}\n sx={{ flex: 1 }}\n />\n </Stack>\n <TextField\n size=\"small\"\n label=\"What happened\"\n value={draft.body}\n onChange={(event) =>\n setDraft((prev) => ({ ...prev, body: event.target.value }))\n }\n multiline\n minRows={3}\n autoFocus\n slotProps={{ htmlInput: { maxLength: BODY_MAX } }}\n />\n {hasOutcome ? (\n <Stack direction=\"row\" spacing={1}>\n <TextField\n size=\"small\"\n label=\"Outcome\"\n placeholder=\"Left a voicemail\"\n value={draft.outcome}\n onChange={(event) =>\n setDraft((prev) => ({ ...prev, outcome: event.target.value }))\n }\n slotProps={{ htmlInput: { maxLength: OUTCOME_MAX } }}\n sx={{ flex: 1 }}\n />\n <TextField\n size=\"small\"\n label=\"Minutes\"\n type=\"number\"\n value={draft.durationMinutes}\n onChange={(event) =>\n setDraft((prev) => ({\n ...prev,\n durationMinutes: event.target.value,\n }))\n }\n error={!durationValid}\n slotProps={{\n htmlInput: { min: 0, max: DURATION_MAX_MINUTES, step: 1 },\n }}\n sx={{ width: 120 }}\n />\n </Stack>\n ) : null}\n {leadOnly ? null : (\n <ActivityLinkFields\n scope={scope}\n picks={picks}\n onChange={(next) => setDraft((prev) => ({ ...prev, picks: next }))}\n link={link}\n deal={deal}\n disabled={saving}\n />\n )}\n </DialogContent>\n <DialogActions>\n <Button onClick={onClose} disabled={saving}>\n {'Cancel'}\n </Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={!canSave}\n onClick={handleSave}\n >\n {activity ? 'Save' : 'Log'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\nLogActivityDialog.displayName = 'LogActivityDialog'\n\nexport default LogActivityDialog\n"],"names":["Aglyn","useSnackbar","useUser","useUserName","Button","Dialog","DialogActions","DialogContent","DialogTitle","MenuItem","Stack","TextField","addDoc","collection","deleteField","doc","getCountFromServer","query","updateDoc","where","useCallback","useEffect","useRef","useState","crmActivityClientReads","crmVisibleToClause","crmActivityLinkFromPicks","crmActivityPicksEqual","crmActivityPicksFrom","resolveCrmActivityCompany","ActivityLinkFields","CrmSitePicker","BODY_MAX","OUTCOME_MAX","DURATION_MAX_MINUTES","toLocalInput","ms","Number","isFinite","date","Date","pad","value","String","padStart","getFullYear","getMonth","getDate","getHours","getMinutes","fromLocalInput","getTime","DEFAULT_KIND","freshDraft","kind","picks","body","at","now","outcome","durationMinutes","direction","draftFrom","activity","isCrmActivityKind","atMs","crmActivityDirection","LogActivityDialog","props","open","onClose","scope","link","deal","presetKind","firestore","dataScope","hostId","mountedHostId","readTokens","writeTokens","needsSite","consentGroup","org","data","user","authorName","enqueueSnackbar","draft","setDraft","saving","setSaving","openedOn","current","seed","primary","dealPrimaryContactId","dealContactRolesOf","hasOutcome","activityKindHasOutcome","directions","CRM_ACTIVITY_DIRECTIONS","trim","filedOn","leadOnly","Boolean","leadId","contactId","linked","related","duration","durationValid","isInteger","canSave","uid","length","handleSave","named","stamped","groupId","said","slice","relinked","CRM_COLLECTIONS","activities","$id","dealId","companyId","updatedAt","variant","persist","lead","crmActivityCeilingLink","logged","field","id","count","crmActivityLogHasRoom","CRM_ACTIVITY_LOG_FULL_MESSAGE","links","visibleTo","byUid","byName","createdAt","error","console","allowDuplicate","maxWidth","fullWidth","sx","display","flexDirection","gap","disabled","optional","helperText","undefined","spacing","mt","select","size","label","onChange","event","prev","target","minWidth","CRM_ACTIVITY_KINDS","map","CRM_ACTIVITY_KIND_LABELS","slotProps","displayEmpty","inputLabel","shrink","entry","CRM_ACTIVITY_DIRECTION_LABELS","type","flex","multiline","minRows","autoFocus","htmlInput","maxLength","placeholder","min","max","step","width","next","onClick","color","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,YAAYA,WAAW,eAAc;AAErC,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,OAAO,EAAEC,WAAW,QAAQ,iCAAgC;AACrE,SACEC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,QAAQ,EACRC,KAAK,EACLC,SAAS,QACJ,gBAAe;AACtB,SACEC,MAAM,EACNC,UAAU,EACVC,WAAW,EACXC,GAAG,EACHC,kBAAkB,EAClBC,KAAK,EACLC,SAAS,EACTC,KAAK,QACA,qBAAoB;AAC3B,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAChE,SAASC,sBAAsB,QAAQ,wCAAoC;AAC3E,SAASC,kBAAkB,QAAQ,4BAAwB;AAC3D,SACEC,wBAAwB,EACxBC,qBAAqB,EACrBC,oBAAoB,EAEpBC,yBAAyB,QACpB,gCAA4B;AACnC,SAASC,kBAAkB,QAAQ,4BAAwB;AAE3D,SAASC,aAAa,QAAQ,uBAAmB;AAEjD,gFAAgF,GAChF,MAAMC,WAAW;AACjB,MAAMC,cAAc;AACpB,MAAMC,uBAAuB,KAAK;AAElC;;;;CAIC,GACD,SAASC,aAAaC,EAAU;IAC9B,IAAI,CAACC,OAAOC,QAAQ,CAACF,KAAK,OAAO;IACjC,MAAMG,OAAO,IAAIC,KAAKJ;IACtB,MAAMK,MAAM,CAACC,QAAkBC,OAAOD,OAAOE,QAAQ,CAAC,GAAG;IACzD,OACE,GAAGL,KAAKM,WAAW,GAAG,CAAC,EAAEJ,IAAIF,KAAKO,QAAQ,KAAK,GAAG,CAAC,CAAC,GACpD,GAAGL,IAAIF,KAAKQ,OAAO,IAAI,CAAC,EAAEN,IAAIF,KAAKS,QAAQ,IAAI,CAAC,EAAEP,IAAIF,KAA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F,WAAW,qBACV,KAAC1E;wBACCyC,OAAOA;wBACPhB,OAAOA;wBACP2G,UAAU,CAAC0B,OAASnG,SAAS,CAAC2E,OAAU,aAAKA;oCAAM7G,OAAOqI;;wBAC1DpH,MAAMA;wBACNC,MAAMA;wBACNgF,UAAU/D;;;;0BAIhB,MAACpF;;kCACC,KAACF;wBAAOyL,SAASvH;wBAASmF,UAAU/D;kCACjC;;kCAEH,KAACtF;wBACC6H,SAAQ;wBACR6D,OAAM;wBACNrC,UAAU,CAACxC;wBACX4E,SAASzE;kCAERrD,WAAW,SAAS;;;;;;AAK/B;AACAI,kBAAkB4H,WAAW,GAAG;AAEhC,eAAe5H,kBAAiB"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/components/log-activity-dialog.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport * as Aglyn from '@aglyn/aglyn'\nimport type { CrmActivityKind, CrmActivityRow } from '@aglyn/aglyn'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { useUser, useUserName } from '@aglyn/tenant-feature-instance'\nimport {\n Button,\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n MenuItem,\n Stack,\n TextField,\n} from '@mui/material'\nimport {\n addDoc,\n collection,\n deleteField,\n doc,\n getCountFromServer,\n query,\n updateDoc,\n where,\n} from 'firebase/firestore'\nimport { useCallback, useEffect, useRef, useState } from 'react'\nimport { crmActivityClientReads } from '../hooks/crm-activity-client-reads'\nimport { crmVisibleToClause } from '../hooks/use-crm-scope'\nimport { useCrmDefaultMarkFollowUp } from '../hooks/use-crm-sharing'\nimport {\n crmActivityLinkFromPicks,\n crmActivityPicksEqual,\n crmActivityPicksFrom,\n type CrmActivityPicks,\n resolveCrmActivityCompany,\n} from '../model/crm-activity-link'\nimport { ActivityLinkFields } from './activity-link-fields'\nimport type { ActivityRecordLink, ActivityScope } from './activity-queries'\nimport { CrmSitePicker } from './crm-site-picker'\n\n/** The longest body a single activity stores — a call summary, not a document. */\nconst BODY_MAX = 4000\nconst OUTCOME_MAX = 200\nconst DURATION_MAX_MINUTES = 24 * 60\n\n/**\n * Epoch millis as the value a `datetime-local` input holds, in the LOCAL\n * zone — the input has no zone of its own, so an ISO string with a `Z`\n * would land the call an offset away from when it happened.\n */\nfunction toLocalInput(ms: number): string {\n if (!Number.isFinite(ms)) return ''\n const date = new Date(ms)\n const pad = (value: number) => String(value).padStart(2, '0')\n return (\n `${date.getFullYear()}-${pad(date.getMonth() + 1)}-` +\n `${pad(date.getDate())}T${pad(date.getHours())}:${pad(date.getMinutes())}`\n )\n}\n\n/** The inverse: a `datetime-local` value parsed as local time, or `null`. */\nfunction fromLocalInput(value: string): number | null {\n if (!value) return null\n const ms = new Date(value).getTime()\n return Number.isFinite(ms) ? ms : null\n}\n\ninterface Draft {\n kind: CrmActivityKind\n body: string\n /** The `datetime-local` string, not millis — what the input holds. */\n at: string\n outcome: string\n /** Free text until save, so a half-typed number does not snap to zero. */\n durationMinutes: string\n /**\n * Which way a call or an email went (AGL-3517) — Salesforce's Call Type\n * for a call — or `''` for not said. Kept across a kind change and\n * written only when the kind takes it.\n */\n direction: string\n /** **Name** and **Related To**, as the reader has left them. */\n picks: CrmActivityPicks\n}\n\n/** The kind a new activity opens on when the caller names none. */\nconst DEFAULT_KIND: CrmActivityKind = 'call'\n\nconst freshDraft = (\n kind: CrmActivityKind = DEFAULT_KIND,\n picks: CrmActivityPicks = crmActivityPicksFrom({}),\n): Draft => ({\n kind,\n body: '',\n at: toLocalInput(Date.now()),\n outcome: '',\n durationMinutes: '',\n // Most logged calls and emails are the team's own.\n direction: 'outbound',\n picks,\n})\n\nconst draftFrom = (activity: CrmActivityRow): Draft => ({\n kind: Aglyn.isCrmActivityKind(activity.kind) ? activity.kind : 'other',\n body: activity.body ?? '',\n at: toLocalInput(activity.atMs),\n outcome: activity.outcome ?? '',\n durationMinutes:\n typeof activity.durationMinutes === 'number'\n ? String(activity.durationMinutes)\n : '',\n direction: Aglyn.crmActivityDirection(activity.kind, activity.direction) ?? '',\n picks: crmActivityPicksFrom(activity),\n})\n\nexport interface LogActivityDialogProps {\n open: boolean\n onClose: () => void\n /** Where the activity is written, from `useActivityScope`. */\n scope: ActivityScope\n /**\n * The record the dialog was opened on, which prefills **Name** and\n * **Related To** (AGL-4123). A lead's own log offers neither: the lead is\n * the entry's only link until it converts.\n */\n link: ActivityRecordLink\n /**\n * The deal the dialog was opened on, as its page read it: **Name** opens on\n * its Primary and its contact roles lead the list.\n */\n deal?: { contactId?: unknown; contactRoles?: unknown } | null\n /**\n * When set, the dialog EDITS this activity rather than logging a new one.\n * The author and the scope stay what they were; what was said, when, how\n * it went, and who and what it is about can change.\n */\n activity?: CrmActivityRow | null\n /**\n * What a NEW activity opens as (AGL-2661) — the click-to-call button\n * opens the dialog already a call, so logging one is the button and a\n * sentence rather than the button, the kind and a sentence. Ignored for\n * an edit, whose kind is the activity's own.\n */\n kind?: CrmActivityKind\n}\n\n/**\n * Log a call, an email, a meeting, a note or something else against a\n * record (AGL-2600) — or correct one already logged.\n *\n * ## Who, what and which account\n *\n * **Name** and **Related To** are Salesforce's Who and What (AGL-4123), and\n * the company an entry rolls up to is stamped from them when it is saved —\n * `model/crm-activity-link.ts` has the rule, shared with every other writer.\n * The fields open on the record the dialog was opened from and the reader may\n * change them: an entry named for a deal shows on the deal, on the person's\n * timeline and on the company, whichever page it was logged from.\n *\n * ## What is written\n *\n * A new activity carries the whole `CrmScoped` stamp: `visibleTo` from\n * `crmScopeTokens`, so it lands in exactly the scope a contact captured on\n * this site would; `hostId` as provenance; `byUid` and `byName` for the\n * author, the name denormalized because a colleague reading the log cannot\n * resolve a uid (see `CrmActivity.byName`); `atMs` for when it HAPPENED,\n * which the reader picks and which defaults to now; and the timestamps.\n * Under the CRM default \"All sites except…\" the server then adds the marker a\n * site added later joins by, which the rules refuse from a browser (AGL-4047).\n *\n * An edit rewrites only the fields the dialog shows. `visibleTo` is never\n * touched — the rules refuse a scoped member changing it, and widening a\n * record is an act for an org-wide member on the record itself — and neither\n * is the author. The links are rewritten only when **Name** or **Related To**\n * changed, and then the company is worked out again, so an edit that corrects\n * a typo cannot move an entry off a timeline it was filed on. A kind that\n * stops taking an outcome takes the outcome and the duration off the document\n * rather than leaving a stale \"left a voicemail\" on what is now a note.\n *\n * ## Who may write\n *\n * The rules admit any member who may write scoped org data, on create and\n * on update alike; they do not distinguish the author. The card that opens\n * this dialog for an edit checks the author itself (`useCanEditActivity`),\n * so what reaches here has already passed the console's verdict.\n */\nexport function LogActivityDialog(props: LogActivityDialogProps) {\n const { open, onClose, scope, link, deal, activity, kind: presetKind } = props\n const { firestore, dataScope, hostId, mountedHostId, readTokens, writeTokens, needsSite } =\n scope\n const { consentGroup, org } = scope\n const markUnderDefault = useCrmDefaultMarkFollowUp(mountedHostId, dataScope?.[1] ?? null, org)\n const { data: user } = useUser()\n const authorName = useUserName()\n const { enqueueSnackbar } = useSnackbar()\n const [draft, setDraft] = useState<Draft>(freshDraft)\n const [saving, setSaving] = useState(false)\n\n /*\n * Seeded on OPEN, not on mount: the dialog stays mounted between uses so\n * its state survives a close, and \"log another call\" must start from now\n * rather than from the last call's timestamp. The record is read through a\n * ref, because a deal is a live document and a colleague's save to it must\n * not wipe what the reader has typed so far.\n */\n const openedOn = useRef({ link, deal })\n useEffect(() => {\n openedOn.current = { link, deal }\n }, [link, deal])\n useEffect(() => {\n if (!open) return\n const seed = openedOn.current\n const primary = seed.deal ? Aglyn.dealPrimaryContactId(Aglyn.dealContactRolesOf(seed.deal)) : null\n setDraft(\n activity\n ? draftFrom(activity)\n : freshDraft(presetKind, crmActivityPicksFrom(seed.link, primary)),\n )\n }, [open, activity, presetKind])\n\n const hasOutcome = Aglyn.activityKindHasOutcome(draft.kind)\n const directions = Aglyn.CRM_ACTIVITY_DIRECTIONS[draft.kind] ?? []\n const direction = Aglyn.crmActivityDirection(draft.kind, draft.direction)\n const atMs = fromLocalInput(draft.at)\n const body = draft.body.trim()\n /*\n * A lead's own log shows neither field: a lead is not a contact **Name**\n * could hold, and in Salesforce's model too it names no What. A contact\n * beside the lead means it converted, and the entry reads like any other.\n */\n const filedOn = activity ?? link\n const leadOnly = Boolean(filedOn.leadId) && !filedOn.contactId\n const { picks } = draft\n // An activity attached to nothing is a sentence nobody can find (AGL-2606).\n const linked = leadOnly || Boolean(picks.contactId || picks.related)\n const duration = draft.durationMinutes.trim()\n ? Number(draft.durationMinutes)\n : null\n const durationValid =\n duration === null ||\n (Number.isInteger(duration) &&\n duration >= 0 &&\n duration <= DURATION_MAX_MINUTES)\n const canSave =\n Boolean(dataScope) &&\n Boolean(user?.uid) &&\n // A NEW activity is stamped with a scope: the whole org where every site\n // sees the CRM's records, else the picked site's — and in an org that\n // keeps its sites apart there is nothing to write until one is picked\n // (AGL-2630). An edit never touches either.\n (Boolean(activity) || writeTokens.length > 0) &&\n body.length > 0 &&\n atMs !== null &&\n durationValid &&\n linked &&\n !saving\n\n const handleSave = useCallback(async () => {\n // Every guard the button reads, again — a callback can outlive the\n // render that disabled it.\n if (!dataScope || !user?.uid || !body || atMs === null || !durationValid || !linked) {\n return\n }\n if (!activity && !writeTokens.length) return\n setSaving(true)\n try {\n const named = crmActivityLinkFromPicks(picks, filedOn.leadId)\n const stamped = () =>\n resolveCrmActivityCompany(\n named,\n { groupId: consentGroup?.groupId, org },\n crmActivityClientReads(firestore, dataScope[1]),\n )\n const said = {\n kind: draft.kind,\n body: body.slice(0, BODY_MAX),\n atMs,\n }\n const outcome = hasOutcome ? draft.outcome.trim().slice(0, OUTCOME_MAX) : ''\n const durationMinutes = hasOutcome && duration !== null ? duration : null\n if (activity) {\n const relinked = crmActivityPicksEqual(picks, crmActivityPicksFrom(activity))\n ? null\n : await stamped()\n await updateDoc(\n doc(\n firestore,\n dataScope[0],\n dataScope[1],\n Aglyn.CRM_COLLECTIONS.activities,\n activity.$id,\n ),\n {\n ...said,\n // Cleared rather than left: an entry moved off a deal must stop\n // showing on it. A lead's own link is never the fields' to change.\n ...(relinked\n ? {\n contactId: relinked.contactId ?? deleteField(),\n dealId: relinked.dealId ?? deleteField(),\n companyId: relinked.companyId ?? deleteField(),\n }\n : {}),\n // Cleared rather than left: a call turned into a note must not\n // keep the call's outcome, and Firestore refuses `undefined`.\n outcome: outcome ? outcome : deleteField(),\n direction: direction ?? deleteField(),\n durationMinutes:\n durationMinutes !== null ? durationMinutes : deleteField(),\n updatedAt: new Date(),\n },\n )\n enqueueSnackbar('Activity updated', { variant: 'success', persist: false })\n } else {\n /*\n * THE PER-RECORD CEILING (AGL-2611): one aggregate on the record\n * this dialog is filing under, before the write — the same count\n * the automation step and the REST create take, on the same link.\n * Scoped to the tokens this viewer may list, as every activity\n * listener is, so the rules admit the aggregate for a scoped\n * member exactly as they admit the timeline.\n */\n const lead = Aglyn.crmActivityCeilingLink(named)\n if (lead) {\n const logged = (\n await getCountFromServer(\n query(\n collection(\n firestore,\n dataScope[0],\n dataScope[1],\n Aglyn.CRM_COLLECTIONS.activities,\n ),\n ...crmVisibleToClause(readTokens),\n where(lead.field, '==', lead.id),\n ),\n )\n ).data().count\n if (!Aglyn.crmActivityLogHasRoom(logged)) {\n enqueueSnackbar(Aglyn.CRM_ACTIVITY_LOG_FULL_MESSAGE, {\n variant: 'warning',\n persist: false,\n })\n return\n }\n }\n const links = await stamped()\n const added = await addDoc(\n collection(\n firestore,\n dataScope[0],\n dataScope[1],\n Aglyn.CRM_COLLECTIONS.activities,\n ),\n {\n ...said,\n ...(outcome ? { outcome } : {}),\n ...(durationMinutes !== null ? { durationMinutes } : {}),\n ...(direction ? { direction } : {}),\n // Only the links it has: `stampCrmActivityCompany` leaves no blank\n // key, and Firestore refuses `undefined`.\n ...links,\n visibleTo: writeTokens,\n hostId,\n byUid: user.uid,\n // Absent rather than blank while the profile is still resolving:\n // the row reads a stored name over anything else, and an empty\n // string would be a name.\n ...(authorName ? { byName: authorName } : {}),\n createdAt: new Date(),\n updatedAt: new Date(),\n },\n )\n // Under \"All sites except…\", the marker a site added later joins by (AGL-4047).\n markUnderDefault([added.id])\n enqueueSnackbar('Activity logged', { variant: 'success', persist: false })\n }\n onClose()\n } catch (error) {\n console.error(error)\n enqueueSnackbar('An error has occurred', {\n variant: 'error',\n allowDuplicate: true,\n })\n } finally {\n setSaving(false)\n }\n }, [\n dataScope,\n user,\n body,\n atMs,\n durationValid,\n draft.kind,\n draft.outcome,\n direction,\n hasOutcome,\n duration,\n activity,\n firestore,\n enqueueSnackbar,\n linked,\n picks,\n filedOn.leadId,\n consentGroup,\n org,\n readTokens,\n writeTokens,\n hostId,\n authorName,\n markUnderDefault,\n onClose,\n ])\n\n return (\n <Dialog open={open} onClose={onClose} maxWidth=\"sm\" fullWidth>\n <DialogTitle>{activity ? 'Edit activity' : 'Log activity'}</DialogTitle>\n <DialogContent sx={{ display: 'flex', flexDirection: 'column', gap: 2 }}>\n {/* Only for a new activity at the organization level — see `canSave`. */}\n {activity ? null : (\n <CrmSitePicker\n hostId={mountedHostId}\n disabled={saving}\n optional={needsSite === false}\n helperText={\n needsSite === false\n ? undefined\n : 'The site this activity is logged from — it decides which of your sites may see it.'\n }\n />\n )}\n <Stack direction=\"row\" spacing={1} sx={{ mt: 1 }}>\n <TextField\n select\n size=\"small\"\n label=\"Kind\"\n value={draft.kind}\n onChange={(event) =>\n setDraft((prev) => ({\n ...prev,\n kind: Aglyn.isCrmActivityKind(event.target.value)\n ? event.target.value\n : prev.kind,\n }))\n }\n sx={{ minWidth: 140 }}\n >\n {Aglyn.CRM_ACTIVITY_KINDS.map((kind) => (\n <MenuItem key={kind} value={kind}>\n {Aglyn.CRM_ACTIVITY_KIND_LABELS[kind]}\n </MenuItem>\n ))}\n </TextField>\n {directions.length ? (\n <TextField\n select\n size=\"small\"\n label=\"Direction\"\n value={direction ?? ''}\n onChange={(event) =>\n setDraft((prev) => ({ ...prev, direction: String(event.target.value) }))\n }\n slotProps={{ select: { displayEmpty: true }, inputLabel: { shrink: true } }}\n sx={{ minWidth: 130 }}\n >\n <MenuItem value=\"\">{'Not said'}</MenuItem>\n {directions.map((entry) => (\n <MenuItem key={entry} value={entry}>\n {Aglyn.CRM_ACTIVITY_DIRECTION_LABELS[entry]}\n </MenuItem>\n ))}\n </TextField>\n ) : null}\n <TextField\n size=\"small\"\n label=\"When\"\n type=\"datetime-local\"\n value={draft.at}\n onChange={(event) =>\n setDraft((prev) => ({ ...prev, at: event.target.value }))\n }\n error={draft.at.length > 0 && atMs === null}\n slotProps={{ inputLabel: { shrink: true } }}\n sx={{ flex: 1 }}\n />\n </Stack>\n <TextField\n size=\"small\"\n label=\"What happened\"\n value={draft.body}\n onChange={(event) =>\n setDraft((prev) => ({ ...prev, body: event.target.value }))\n }\n multiline\n minRows={3}\n autoFocus\n slotProps={{ htmlInput: { maxLength: BODY_MAX } }}\n />\n {hasOutcome ? (\n <Stack direction=\"row\" spacing={1}>\n <TextField\n size=\"small\"\n label=\"Outcome\"\n placeholder=\"Left a voicemail\"\n value={draft.outcome}\n onChange={(event) =>\n setDraft((prev) => ({ ...prev, outcome: event.target.value }))\n }\n slotProps={{ htmlInput: { maxLength: OUTCOME_MAX } }}\n sx={{ flex: 1 }}\n />\n <TextField\n size=\"small\"\n label=\"Minutes\"\n type=\"number\"\n value={draft.durationMinutes}\n onChange={(event) =>\n setDraft((prev) => ({\n ...prev,\n durationMinutes: event.target.value,\n }))\n }\n error={!durationValid}\n slotProps={{\n htmlInput: { min: 0, max: DURATION_MAX_MINUTES, step: 1 },\n }}\n sx={{ width: 120 }}\n />\n </Stack>\n ) : null}\n {leadOnly ? null : (\n <ActivityLinkFields\n scope={scope}\n picks={picks}\n onChange={(next) => setDraft((prev) => ({ ...prev, picks: next }))}\n link={link}\n deal={deal}\n disabled={saving}\n />\n )}\n </DialogContent>\n <DialogActions>\n <Button onClick={onClose} disabled={saving}>\n {'Cancel'}\n </Button>\n <Button\n variant=\"contained\"\n color=\"primary\"\n disabled={!canSave}\n onClick={handleSave}\n >\n {activity ? 'Save' : 'Log'}\n </Button>\n </DialogActions>\n </Dialog>\n )\n}\nLogActivityDialog.displayName = 'LogActivityDialog'\n\nexport default LogActivityDialog\n"],"names":["Aglyn","useSnackbar","useUser","useUserName","Button","Dialog","DialogActions","DialogContent","DialogTitle","MenuItem","Stack","TextField","addDoc","collection","deleteField","doc","getCountFromServer","query","updateDoc","where","useCallback","useEffect","useRef","useState","crmActivityClientReads","crmVisibleToClause","useCrmDefaultMarkFollowUp","crmActivityLinkFromPicks","crmActivityPicksEqual","crmActivityPicksFrom","resolveCrmActivityCompany","ActivityLinkFields","CrmSitePicker","BODY_MAX","OUTCOME_MAX","DURATION_MAX_MINUTES","toLocalInput","ms","Number","isFinite","date","Date","pad","value","String","padStart","getFullYear","getMonth","getDate","getHours","getMinutes","fromLocalInput","getTime","DEFAULT_KIND","freshDraft","kind","picks","body","at","now","outcome","durationMinutes","direction","draftFrom","activity","isCrmActivityKind","atMs","crmActivityDirection","LogActivityDialog","props","open","onClose","scope","link","deal","presetKind","firestore","dataScope","hostId","mountedHostId","readTokens","writeTokens","needsSite","consentGroup","org","markUnderDefault","data","user","authorName","enqueueSnackbar","draft","setDraft","saving","setSaving","openedOn","current","seed","primary","dealPrimaryContactId","dealContactRolesOf","hasOutcome","activityKindHasOutcome","directions","CRM_ACTIVITY_DIRECTIONS","trim","filedOn","leadOnly","Boolean","leadId","contactId","linked","related","duration","durationValid","isInteger","canSave","uid","length","handleSave","named","stamped","groupId","said","slice","relinked","CRM_COLLECTIONS","activities","$id","dealId","companyId","updatedAt","variant","persist","lead","crmActivityCeilingLink","logged","field","id","count","crmActivityLogHasRoom","CRM_ACTIVITY_LOG_FULL_MESSAGE","links","added","visibleTo","byUid","byName","createdAt","error","console","allowDuplicate","maxWidth","fullWidth","sx","display","flexDirection","gap","disabled","optional","helperText","undefined","spacing","mt","select","size","label","onChange","event","prev","target","minWidth","CRM_ACTIVITY_KINDS","map","CRM_ACTIVITY_KIND_LABELS","slotProps","displayEmpty","inputLabel","shrink","entry","CRM_ACTIVITY_DIRECTION_LABELS","type","flex","multiline","minRows","autoFocus","htmlInput","maxLength","placeholder","min","max","step","width","next","onClick","color","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,YAAYA,WAAW,eAAc;AAErC,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,OAAO,EAAEC,WAAW,QAAQ,iCAAgC;AACrE,SACEC,MAAM,EACNC,MAAM,EACNC,aAAa,EACbC,aAAa,EACbC,WAAW,EACXC,QAAQ,EACRC,KAAK,EACLC,SAAS,QACJ,gBAAe;AACtB,SACEC,MAAM,EACNC,UAAU,EACVC,WAAW,EACXC,GAAG,EACHC,kBAAkB,EAClBC,KAAK,EACLC,SAAS,EACTC,KAAK,QACA,qBAAoB;AAC3B,SAASC,WAAW,EAAEC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAO;AAChE,SAASC,sBAAsB,QAAQ,wCAAoC;AAC3E,SAASC,kBAAkB,QAAQ,4BAAwB;AAC3D,SAASC,yBAAyB,QAAQ,8BAA0B;AACpE,SACEC,wBAAwB,EACxBC,qBAAqB,EACrBC,oBAAoB,EAEpBC,yBAAyB,QACpB,gCAA4B;AACnC,SAASC,kBAAkB,QAAQ,4BAAwB;AAE3D,SAASC,aAAa,QAAQ,uBAAmB;AAEjD,gFAAgF,GAChF,MAAMC,WAAW;AACjB,MAAMC,cAAc;AACpB,MAAMC,uBAAuB,KAAK;AAElC;;;;CAIC,GACD,SAASC,aAAaC,EAAU;IAC9B,IAAI,CAACC,OAAO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AM3G,SAAS0G,MAAME,MAAM,CAAC7H,KAAK;;gCAE5DkI,WAAW;oCAAEW,WAAW;wCAAEC,WAAWvJ;oCAAY;gCAAE;gCACnDsH,IAAI;oCAAE4B,MAAM;gCAAE;;0CAEhB,KAACzK;gCACCwJ,MAAK;gCACLC,OAAM;gCACNe,MAAK;gCACLxI,OAAO+C,MAAM7B,eAAe;gCAC5BwG,UAAU,CAACC,QACT3E,SAAS,CAAC4E,OAAU,aACfA;4CACH1G,iBAAiByG,MAAME,MAAM,CAAC7H,KAAK;;gCAGvCwG,OAAO,CAAClC;gCACR4D,WAAW;oCACTW,WAAW;wCAAEG,KAAK;wCAAGC,KAAKzJ;wCAAsB0J,MAAM;oCAAE;gCAC1D;gCACArC,IAAI;oCAAEsC,OAAO;gCAAI;;;yBAGnB;oBACHpF,WAAW,qBACV,KAAC3E;wBACCyC,OAAOA;wBACPhB,OAAOA;wBACP6G,UAAU,CAAC0B,OAASpG,SAAS,CAAC4E,OAAU,aAAKA;oCAAM/G,OAAOuI;;wBAC1DtH,MAAMA;wBACNC,MAAMA;wBACNkF,UAAUhE;;;;0BAIhB,MAACtF;;kCACC,KAACF;wBAAO4L,SAASzH;wBAASqF,UAAUhE;kCACjC;;kCAEH,KAACxF;wBACC+H,SAAQ;wBACR8D,OAAM;wBACNrC,UAAU,CAACzC;wBACX6E,SAAS1E;kCAERtD,WAAW,SAAS;;;;;;AAK/B;AACAI,kBAAkB8H,WAAW,GAAG;AAEhC,eAAe9H,kBAAiB"}
|
|
@@ -85,7 +85,7 @@ const when = (atMs)=>atMs > 0 ? new Date(atMs).toLocaleDateString() : '';
|
|
|
85
85
|
const label = CRM_SHARING_OBJECT_LABELS[object];
|
|
86
86
|
const shared = lines.some((line)=>line.kind !== 'held');
|
|
87
87
|
if (!record || !shared && !roleReady) return null;
|
|
88
|
-
const unshare = async (key, token)=>{
|
|
88
|
+
/** `token` is the site a hand share names, or `allExcept` for the share with all sites except some. */ const unshare = async (key, token)=>{
|
|
89
89
|
if (!scope) return;
|
|
90
90
|
setBusyKey(key);
|
|
91
91
|
try {
|
|
@@ -94,7 +94,7 @@ const when = (atMs)=>atMs > 0 ? new Date(atMs).toLocaleDateString() : '';
|
|
|
94
94
|
ids: [
|
|
95
95
|
id
|
|
96
96
|
],
|
|
97
|
-
targets: token === 'org' ? 'all' : [
|
|
97
|
+
targets: token === 'allExcept' ? 'allExcept' : token === 'org' ? 'all' : [
|
|
98
98
|
token.slice('host:'.length)
|
|
99
99
|
]
|
|
100
100
|
});
|
|
@@ -148,10 +148,11 @@ const when = (atMs)=>atMs > 0 ? new Date(atMs).toLocaleDateString() : '';
|
|
|
148
148
|
children: line.allSites ? 'Visible to every site in the organization.' : line.hostIds.length ? `Held by ${line.hostIds.map(sites.siteName).join(', ')} — where it was captured.` : 'Held by no site.'
|
|
149
149
|
}, "held");
|
|
150
150
|
}
|
|
151
|
-
if (line.kind === 'manual') {
|
|
152
|
-
const target = describeShareTargets([
|
|
151
|
+
if (line.kind === 'manual' || line.kind === 'manualExcept') {
|
|
152
|
+
const target = line.kind === 'manual' ? describeShareTargets([
|
|
153
153
|
line.token
|
|
154
|
-
], sites.siteName);
|
|
154
|
+
], sites.siteName) : describeShareTargets(line.tokens, sites.siteName, line.except);
|
|
155
|
+
const token = line.kind === 'manual' ? line.token : 'allExcept';
|
|
155
156
|
return /*#__PURE__*/ _jsxs(Stack, {
|
|
156
157
|
direction: "row",
|
|
157
158
|
spacing: 1,
|
|
@@ -173,7 +174,7 @@ const when = (atMs)=>atMs > 0 ? new Date(atMs).toLocaleDateString() : '';
|
|
|
173
174
|
children: /*#__PURE__*/ _jsxs(IconButton, {
|
|
174
175
|
size: "small",
|
|
175
176
|
disabled: busyKey !== null,
|
|
176
|
-
onClick: ()=>void unshare(line.key,
|
|
177
|
+
onClick: ()=>void unshare(line.key, token),
|
|
177
178
|
children: [
|
|
178
179
|
/*#__PURE__*/ _jsx(MdiIcon, {
|
|
179
180
|
path: mdiClose.path,
|
|
@@ -191,7 +192,7 @@ const when = (atMs)=>atMs > 0 ? new Date(atMs).toLocaleDateString() : '';
|
|
|
191
192
|
const rule = rules.find((entry)=>entry.id === line.ruleId);
|
|
192
193
|
return /*#__PURE__*/ _jsx(Typography, {
|
|
193
194
|
variant: "body2",
|
|
194
|
-
children: `${describeShareTargets(line.tokens, sites.siteName)} — by the rule ${rule ? `“${rule.name}”` : 'that shares it'}, ${line.access === 'edit' ? 'read and edit' : 'read-only'}`
|
|
195
|
+
children: `${describeShareTargets(line.tokens, sites.siteName, line.except)} — by the rule ${rule ? `“${rule.name}”` : 'that shares it'}, ${line.access === 'edit' ? 'read and edit' : 'read-only'}`
|
|
195
196
|
}, line.key);
|
|
196
197
|
}),
|
|
197
198
|
!shared ? /*#__PURE__*/ _jsx(Typography, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../../libs/plugins/crm/src/lib/components/record-sharing-card.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport { mdiClose } from '@aglyn/shared-data-mdi'\nimport { CardDisplay, MdiIcon, SrOnly } from '@aglyn/shared-ui-jsx'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport { Button, Chip, IconButton, Stack, Typography } from '@mui/material'\nimport { useMemo, useState } from 'react'\nimport { useCrmSharingRules, useCrmSharingSites } from '../hooks/use-crm-sharing'\nimport type { CrmOrgDoc } from '../hooks/use-crm-scope'\nimport {\n CRM_SHARING_OBJECT_LABELS,\n type CrmShareChip,\n crmShareChipFor,\n crmShareChipLabel,\n type CrmSharingObject,\n describeRecordSharing,\n describeShareTargets,\n} from '../model/crm-sharing'\nimport { crmSettingsPermissionRefusal } from '../model/crm-permissions'\nimport { callCrmSharing } from '../model/crm-sharing-api'\nimport { crmTaskCallScope } from '../model/task-routes'\nimport { useCanManageCrmSettings } from './settings-section'\nimport { ShareRecordsDialog } from './share-records-dialog'\n\n/**\n * The chip a list row or a record header shows when this site sees the\n * record only because it was shared with it: \"Shared by Dana\".\n */\nexport function CrmShareChipView(props: {\n chip: CrmShareChip | null\n org: CrmOrgDoc\n}) {\n const rules = useCrmSharingRules(props.org)\n if (!props.chip) return null\n return (\n <Chip\n size=\"small\"\n variant=\"outlined\"\n color=\"info\"\n label={crmShareChipLabel(props.chip, rules)}\n sx={{ maxWidth: 220 }}\n />\n )\n}\nCrmShareChipView.displayName = 'CrmShareChipView'\n\nexport interface RecordSharingCardProps {\n object: CrmSharingObject\n id: string\n record: Readonly<Record<string, unknown>> | null | undefined\n /** The mounted site, or `null` at the organization level. */\n hostId: string | null\n orgId: string | null\n org: CrmOrgDoc\n /** The viewing site's consent-group sites, for \"shared with this site\". */\n viewingHostIds?: readonly string[]\n}\n\nconst when = (atMs: number) => (atMs > 0 ? new Date(atMs).toLocaleDateString() : '')\n\n/**\n * SHARING — where this record is visible, and why (AGL-3336).\n *\n * One line for the sites that hold it (its consent group, or the site that\n * created it), then one per hand share, naming who shared it and when, with\n * the one-click unshare, and one per sharing rule. The held line has no\n * unshare: visibility a site holds is not the sharing's to take away. A\n * rule's line is removed by editing the rule, in Settings.\n *\n * The header's \"Share with sites…\" asks \"Change CRM settings\", and so does the\n * unshare; every other reader sees both switched off, with the permission\n * named. For a reader on a site that sees the record only through a read-only\n * share, the card says so, since the page's edits will be refused.\n */\nexport function RecordSharingCard(props: RecordSharingCardProps) {\n const { object, id, record, hostId, orgId, org, viewingHostIds = [] } = props\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { canManage, ready: roleReady } = useCanManageCrmSettings(orgId ?? undefined)\n const sites = useCrmSharingSites({ hostId, orgId, enabled: canManage })\n const rules = useCrmSharingRules(org)\n const lines = useMemo(() => describeRecordSharing(record), [record])\n const chip = useMemo(() => crmShareChipFor(record, viewingHostIds), [record, viewingHostIds])\n const [sharing, setSharing] = useState(false)\n const [busyKey, setBusyKey] = useState<string | null>(null)\n const scope = crmTaskCallScope(hostId, orgId)\n const label = CRM_SHARING_OBJECT_LABELS[object]\n const shared = lines.some((line) => line.kind !== 'held')\n if (!record || (!shared && !roleReady)) return null\n\n const unshare = async (key: string, token: string) => {\n if (!scope) return\n setBusyKey(key)\n try {\n await callCrmSharing(user, scope, 'unshare', {\n object,\n ids: [id],\n targets: token === 'org' ? 'all' : [token.slice('host:'.length)],\n })\n enqueueSnackbar('No longer shared', { variant: 'success', persist: false })\n } catch (error) {\n enqueueSnackbar((error as Error).message, { variant: 'error', allowDuplicate: true })\n } finally {\n setBusyKey(null)\n }\n }\n\n const heldLine = lines.find((line) => line.kind === 'held')\n const heldHostIds = heldLine?.kind === 'held' ? heldLine.hostIds : []\n return (\n <CardDisplay\n header={'Sharing'}\n help={pluginDocsHelp('crmSharing', { anchor: '#sharing-card' })}\n contentGutterX\n contentGutterY\n HeaderProps={{\n action: roleReady ? (\n <BlockedControl blocked={!canManage} reason={crmSettingsPermissionRefusal()}>\n <Button variant=\"contained\" size=\"small\" onClick={() => setSharing(true)}>\n {'Share with sites…'}\n </Button>\n </BlockedControl>\n ) : null,\n }}\n >\n <Stack spacing={1.5}>\n {chip ? (\n <Typography variant=\"body2\">\n {chip.access === 'edit'\n ? `Shared with this site to read and edit. ${crmShareChipLabel(chip, rules)}.`\n : `Shared with this site read-only: you can see this ${label.one} and log activity ` +\n `and tasks on it, but not change it. ${crmShareChipLabel(chip, rules)}.`}\n </Typography>\n ) : null}\n {lines.map((line) => {\n if (line.kind === 'held') {\n return (\n <Typography key=\"held\" variant=\"body2\" color=\"text.secondary\">\n {line.allSites\n ? 'Visible to every site in the organization.'\n : line.hostIds.length\n ? `Held by ${line.hostIds.map(sites.siteName).join(', ')} — where it was captured.`\n : 'Held by no site.'}\n </Typography>\n )\n }\n if (line.kind === 'manual') {\n const target = describeShareTargets([line.token], sites.siteName)\n return (\n <Stack key={line.key} direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Typography variant=\"body2\" sx={{ flex: 1, minWidth: 0 }}>\n {`${target} — shared by ${line.byName || 'a manager'}${\n line.atMs ? ` on ${when(line.atMs)}` : ''\n }, ${line.access === 'edit' ? 'read and edit' : 'read-only'}`}\n </Typography>\n {roleReady ? (\n <BlockedControl blocked={!canManage} reason={crmSettingsPermissionRefusal()}>\n <IconButton\n size=\"small\"\n disabled={busyKey !== null}\n onClick={() => void unshare(line.key, line.token)}\n >\n <MdiIcon path={mdiClose.path} size={0.7} />\n <SrOnly>{`Stop sharing with ${target}`}</SrOnly>\n </IconButton>\n </BlockedControl>\n ) : null}\n </Stack>\n )\n }\n const rule = rules.find((entry) => entry.id === line.ruleId)\n return (\n <Typography key={line.key} variant=\"body2\">\n {`${describeShareTargets(line.tokens, sites.siteName)} — by the rule ${\n rule ? `“${rule.name}”` : 'that shares it'\n }, ${line.access === 'edit' ? 'read and edit' : 'read-only'}`}\n </Typography>\n )\n })}\n {!shared ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Not shared with any other site. Sharing lets another site see this ${label.one}; it does not share the person's consent.`}\n </Typography>\n ) : null}\n </Stack>\n <ShareRecordsDialog\n open={sharing}\n onClose={() => setSharing(false)}\n object={object}\n ids={[id]}\n scope={scope}\n sites={sites.sites}\n sitesReady={sites.ready}\n heldHostIds={heldHostIds}\n />\n </CardDisplay>\n )\n}\nRecordSharingCard.displayName = 'RecordSharingCard'\n\n/**\n * \"Share with sites…\" on a list's bulk bar (AGL-3336): the same dialog as\n * the record page, over the selection. It asks \"Change CRM settings\"; a member\n * without it sees the button switched off, with the permission named.\n */\nexport function CrmBulkShareButton(props: {\n object: CrmSharingObject\n ids: readonly string[]\n hostId: string | null\n orgId: string | null\n disabled?: boolean\n}) {\n const { object, ids, hostId, orgId, disabled } = props\n const { canManage, ready } = useCanManageCrmSettings(orgId ?? undefined)\n const sites = useCrmSharingSites({ hostId, orgId, enabled: canManage })\n const [open, setOpen] = useState(false)\n if (!ready) return null\n return (\n <>\n <BlockedControl blocked={!canManage} reason={crmSettingsPermissionRefusal()}>\n <Button size=\"small\" disabled={disabled || !ids.length} onClick={() => setOpen(true)}>\n {'Share with sites…'}\n </Button>\n </BlockedControl>\n <ShareRecordsDialog\n open={open}\n onClose={() => setOpen(false)}\n object={object}\n ids={ids}\n scope={crmTaskCallScope(hostId, orgId)}\n sites={sites.sites}\n sitesReady={sites.ready}\n />\n </>\n )\n}\nCrmBulkShareButton.displayName = 'CrmBulkShareButton'\n\nexport default RecordSharingCard\n"],"names":["pluginDocsHelp","mdiClose","CardDisplay","MdiIcon","SrOnly","BlockedControl","useSnackbar","useUser","Button","Chip","IconButton","Stack","Typography","useMemo","useState","useCrmSharingRules","useCrmSharingSites","CRM_SHARING_OBJECT_LABELS","crmShareChipFor","crmShareChipLabel","describeRecordSharing","describeShareTargets","crmSettingsPermissionRefusal","callCrmSharing","crmTaskCallScope","useCanManageCrmSettings","ShareRecordsDialog","CrmShareChipView","props","rules","org","chip","size","variant","color","label","sx","maxWidth","displayName","when","atMs","Date","toLocaleDateString","RecordSharingCard","object","id","record","hostId","orgId","viewingHostIds","data","user","enqueueSnackbar","canManage","ready","roleReady","undefined","sites","enabled","lines","sharing","setSharing","busyKey","setBusyKey","scope","shared","some","line","kind","unshare","key","token","ids","targets","slice","length","persist","error","message","allowDuplicate","heldLine","find","heldHostIds","hostIds","header","help","anchor","contentGutterX","contentGutterY","HeaderProps","action","blocked","reason","onClick","spacing","access","one","map","allSites","siteName","join","target","direction","alignItems","flex","minWidth","byName","disabled","path","rule","entry","ruleId","tokens","name","open","onClose","sitesReady","CrmBulkShareButton","setOpen"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,cAAc,QAAQ,eAAc;AAC7C,SAASC,QAAQ,QAAQ,yBAAwB;AACjD,SAASC,WAAW,EAAEC,OAAO,EAAEC,MAAM,QAAQ,uBAAsB;AACnE,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SAASC,MAAM,EAAEC,IAAI,EAAEC,UAAU,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAe;AAC3E,SAASC,OAAO,EAAEC,QAAQ,QAAQ,QAAO;AACzC,SAASC,kBAAkB,EAAEC,kBAAkB,QAAQ,8BAA0B;AAEjF,SACEC,yBAAyB,EAEzBC,eAAe,EACfC,iBAAiB,EAEjBC,qBAAqB,EACrBC,oBAAoB,QACf,0BAAsB;AAC7B,SAASC,4BAA4B,QAAQ,8BAA0B;AACvE,SAASC,cAAc,QAAQ,8BAA0B;AACzD,SAASC,gBAAgB,QAAQ,0BAAsB;AACvD,SAASC,uBAAuB,QAAQ,wBAAoB;AAC5D,SAASC,kBAAkB,QAAQ,4BAAwB;AAE3D;;;CAGC,GACD,OAAO,SAASC,iBAAiBC,KAGhC;IACC,MAAMC,QAAQd,mBAAmBa,MAAME,GAAG;IAC1C,IAAI,CAACF,MAAMG,IAAI,EAAE,OAAO;IACxB,qBACE,KAACtB;QACCuB,MAAK;QACLC,SAAQ;QACRC,OAAM;QACNC,OAAOhB,kBAAkBS,MAAMG,IAAI,EAAEF;QACrCO,IAAI;YAAEC,UAAU;QAAI;;AAG1B;AACAV,iBAAiBW,WAAW,GAAG;AAc/B,MAAMC,OAAO,CAACC,OAAkBA,OAAO,IAAI,IAAIC,KAAKD,MAAME,kBAAkB,KAAK;AAEjF;;;;;;;;;;;;;CA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/record-sharing-card.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { pluginDocsHelp } from '@aglyn/aglyn'\nimport { mdiClose } from '@aglyn/shared-data-mdi'\nimport { CardDisplay, MdiIcon, SrOnly } from '@aglyn/shared-ui-jsx'\nimport { BlockedControl } from '@aglyn/shared-ui-jsx/components/blocked-control.component'\nimport { useSnackbar } from '@aglyn/shared-ui-snackstack'\nimport { useUser } from '@aglyn/tenant-feature-instance'\nimport { Button, Chip, IconButton, Stack, Typography } from '@mui/material'\nimport { useMemo, useState } from 'react'\nimport { useCrmSharingRules, useCrmSharingSites } from '../hooks/use-crm-sharing'\nimport type { CrmOrgDoc } from '../hooks/use-crm-scope'\nimport {\n CRM_SHARING_OBJECT_LABELS,\n type CrmShareChip,\n crmShareChipFor,\n crmShareChipLabel,\n type CrmSharingObject,\n describeRecordSharing,\n describeShareTargets,\n} from '../model/crm-sharing'\nimport { crmSettingsPermissionRefusal } from '../model/crm-permissions'\nimport { callCrmSharing } from '../model/crm-sharing-api'\nimport { crmTaskCallScope } from '../model/task-routes'\nimport { useCanManageCrmSettings } from './settings-section'\nimport { ShareRecordsDialog } from './share-records-dialog'\n\n/**\n * The chip a list row or a record header shows when this site sees the\n * record only because it was shared with it: \"Shared by Dana\".\n */\nexport function CrmShareChipView(props: {\n chip: CrmShareChip | null\n org: CrmOrgDoc\n}) {\n const rules = useCrmSharingRules(props.org)\n if (!props.chip) return null\n return (\n <Chip\n size=\"small\"\n variant=\"outlined\"\n color=\"info\"\n label={crmShareChipLabel(props.chip, rules)}\n sx={{ maxWidth: 220 }}\n />\n )\n}\nCrmShareChipView.displayName = 'CrmShareChipView'\n\nexport interface RecordSharingCardProps {\n object: CrmSharingObject\n id: string\n record: Readonly<Record<string, unknown>> | null | undefined\n /** The mounted site, or `null` at the organization level. */\n hostId: string | null\n orgId: string | null\n org: CrmOrgDoc\n /** The viewing site's consent-group sites, for \"shared with this site\". */\n viewingHostIds?: readonly string[]\n}\n\nconst when = (atMs: number) => (atMs > 0 ? new Date(atMs).toLocaleDateString() : '')\n\n/**\n * SHARING — where this record is visible, and why (AGL-3336).\n *\n * One line for the sites that hold it (its consent group, or the site that\n * created it), then one per hand share, naming who shared it and when, with\n * the one-click unshare, and one per sharing rule. The held line has no\n * unshare: visibility a site holds is not the sharing's to take away. A\n * rule's line is removed by editing the rule, in Settings.\n *\n * The header's \"Share with sites…\" asks \"Change CRM settings\", and so does the\n * unshare; every other reader sees both switched off, with the permission\n * named. For a reader on a site that sees the record only through a read-only\n * share, the card says so, since the page's edits will be refused.\n */\nexport function RecordSharingCard(props: RecordSharingCardProps) {\n const { object, id, record, hostId, orgId, org, viewingHostIds = [] } = props\n const { data: user } = useUser()\n const { enqueueSnackbar } = useSnackbar()\n const { canManage, ready: roleReady } = useCanManageCrmSettings(orgId ?? undefined)\n const sites = useCrmSharingSites({ hostId, orgId, enabled: canManage })\n const rules = useCrmSharingRules(org)\n const lines = useMemo(() => describeRecordSharing(record), [record])\n const chip = useMemo(() => crmShareChipFor(record, viewingHostIds), [record, viewingHostIds])\n const [sharing, setSharing] = useState(false)\n const [busyKey, setBusyKey] = useState<string | null>(null)\n const scope = crmTaskCallScope(hostId, orgId)\n const label = CRM_SHARING_OBJECT_LABELS[object]\n const shared = lines.some((line) => line.kind !== 'held')\n if (!record || (!shared && !roleReady)) return null\n\n /** `token` is the site a hand share names, or `allExcept` for the share with all sites except some. */\n const unshare = async (key: string, token: string) => {\n if (!scope) return\n setBusyKey(key)\n try {\n await callCrmSharing(user, scope, 'unshare', {\n object,\n ids: [id],\n targets:\n token === 'allExcept'\n ? 'allExcept'\n : token === 'org'\n ? 'all'\n : [token.slice('host:'.length)],\n })\n enqueueSnackbar('No longer shared', { variant: 'success', persist: false })\n } catch (error) {\n enqueueSnackbar((error as Error).message, { variant: 'error', allowDuplicate: true })\n } finally {\n setBusyKey(null)\n }\n }\n\n const heldLine = lines.find((line) => line.kind === 'held')\n const heldHostIds = heldLine?.kind === 'held' ? heldLine.hostIds : []\n return (\n <CardDisplay\n header={'Sharing'}\n help={pluginDocsHelp('crmSharing', { anchor: '#sharing-card' })}\n contentGutterX\n contentGutterY\n HeaderProps={{\n action: roleReady ? (\n <BlockedControl blocked={!canManage} reason={crmSettingsPermissionRefusal()}>\n <Button variant=\"contained\" size=\"small\" onClick={() => setSharing(true)}>\n {'Share with sites…'}\n </Button>\n </BlockedControl>\n ) : null,\n }}\n >\n <Stack spacing={1.5}>\n {chip ? (\n <Typography variant=\"body2\">\n {chip.access === 'edit'\n ? `Shared with this site to read and edit. ${crmShareChipLabel(chip, rules)}.`\n : `Shared with this site read-only: you can see this ${label.one} and log activity ` +\n `and tasks on it, but not change it. ${crmShareChipLabel(chip, rules)}.`}\n </Typography>\n ) : null}\n {lines.map((line) => {\n if (line.kind === 'held') {\n return (\n <Typography key=\"held\" variant=\"body2\" color=\"text.secondary\">\n {line.allSites\n ? 'Visible to every site in the organization.'\n : line.hostIds.length\n ? `Held by ${line.hostIds.map(sites.siteName).join(', ')} — where it was captured.`\n : 'Held by no site.'}\n </Typography>\n )\n }\n if (line.kind === 'manual' || line.kind === 'manualExcept') {\n const target =\n line.kind === 'manual'\n ? describeShareTargets([line.token], sites.siteName)\n : describeShareTargets(line.tokens, sites.siteName, line.except)\n const token = line.kind === 'manual' ? line.token : 'allExcept'\n return (\n <Stack key={line.key} direction=\"row\" spacing={1} sx={{ alignItems: 'center' }}>\n <Typography variant=\"body2\" sx={{ flex: 1, minWidth: 0 }}>\n {`${target} — shared by ${line.byName || 'a manager'}${\n line.atMs ? ` on ${when(line.atMs)}` : ''\n }, ${line.access === 'edit' ? 'read and edit' : 'read-only'}`}\n </Typography>\n {roleReady ? (\n <BlockedControl blocked={!canManage} reason={crmSettingsPermissionRefusal()}>\n <IconButton\n size=\"small\"\n disabled={busyKey !== null}\n onClick={() => void unshare(line.key, token)}\n >\n <MdiIcon path={mdiClose.path} size={0.7} />\n <SrOnly>{`Stop sharing with ${target}`}</SrOnly>\n </IconButton>\n </BlockedControl>\n ) : null}\n </Stack>\n )\n }\n const rule = rules.find((entry) => entry.id === line.ruleId)\n return (\n <Typography key={line.key} variant=\"body2\">\n {`${describeShareTargets(line.tokens, sites.siteName, line.except)} — by the rule ${\n rule ? `“${rule.name}”` : 'that shares it'\n }, ${line.access === 'edit' ? 'read and edit' : 'read-only'}`}\n </Typography>\n )\n })}\n {!shared ? (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {`Not shared with any other site. Sharing lets another site see this ${label.one}; it does not share the person's consent.`}\n </Typography>\n ) : null}\n </Stack>\n <ShareRecordsDialog\n open={sharing}\n onClose={() => setSharing(false)}\n object={object}\n ids={[id]}\n scope={scope}\n sites={sites.sites}\n sitesReady={sites.ready}\n heldHostIds={heldHostIds}\n />\n </CardDisplay>\n )\n}\nRecordSharingCard.displayName = 'RecordSharingCard'\n\n/**\n * \"Share with sites…\" on a list's bulk bar (AGL-3336): the same dialog as\n * the record page, over the selection. It asks \"Change CRM settings\"; a member\n * without it sees the button switched off, with the permission named.\n */\nexport function CrmBulkShareButton(props: {\n object: CrmSharingObject\n ids: readonly string[]\n hostId: string | null\n orgId: string | null\n disabled?: boolean\n}) {\n const { object, ids, hostId, orgId, disabled } = props\n const { canManage, ready } = useCanManageCrmSettings(orgId ?? undefined)\n const sites = useCrmSharingSites({ hostId, orgId, enabled: canManage })\n const [open, setOpen] = useState(false)\n if (!ready) return null\n return (\n <>\n <BlockedControl blocked={!canManage} reason={crmSettingsPermissionRefusal()}>\n <Button size=\"small\" disabled={disabled || !ids.length} onClick={() => setOpen(true)}>\n {'Share with sites…'}\n </Button>\n </BlockedControl>\n <ShareRecordsDialog\n open={open}\n onClose={() => setOpen(false)}\n object={object}\n ids={ids}\n scope={crmTaskCallScope(hostId, orgId)}\n sites={sites.sites}\n sitesReady={sites.ready}\n />\n </>\n )\n}\nCrmBulkShareButton.displayName = 'CrmBulkShareButton'\n\nexport default RecordSharingCard\n"],"names":["pluginDocsHelp","mdiClose","CardDisplay","MdiIcon","SrOnly","BlockedControl","useSnackbar","useUser","Button","Chip","IconButton","Stack","Typography","useMemo","useState","useCrmSharingRules","useCrmSharingSites","CRM_SHARING_OBJECT_LABELS","crmShareChipFor","crmShareChipLabel","describeRecordSharing","describeShareTargets","crmSettingsPermissionRefusal","callCrmSharing","crmTaskCallScope","useCanManageCrmSettings","ShareRecordsDialog","CrmShareChipView","props","rules","org","chip","size","variant","color","label","sx","maxWidth","displayName","when","atMs","Date","toLocaleDateString","RecordSharingCard","object","id","record","hostId","orgId","viewingHostIds","data","user","enqueueSnackbar","canManage","ready","roleReady","undefined","sites","enabled","lines","sharing","setSharing","busyKey","setBusyKey","scope","shared","some","line","kind","unshare","key","token","ids","targets","slice","length","persist","error","message","allowDuplicate","heldLine","find","heldHostIds","hostIds","header","help","anchor","contentGutterX","contentGutterY","HeaderProps","action","blocked","reason","onClick","spacing","access","one","map","allSites","siteName","join","target","tokens","except","direction","alignItems","flex","minWidth","byName","disabled","path","rule","entry","ruleId","name","open","onClose","sitesReady","CrmBulkShareButton","setOpen"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;AAEA,SAASA,cAAc,QAAQ,eAAc;AAC7C,SAASC,QAAQ,QAAQ,yBAAwB;AACjD,SAASC,WAAW,EAAEC,OAAO,EAAEC,MAAM,QAAQ,uBAAsB;AACnE,SAASC,cAAc,QAAQ,4DAA2D;AAC1F,SAASC,WAAW,QAAQ,8BAA6B;AACzD,SAASC,OAAO,QAAQ,iCAAgC;AACxD,SAASC,MAAM,EAAE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yF,MAAMvD;gBACNwD,SAAS,IAAMvD,WAAW;gBAC1BjB,QAAQA;gBACR4B,KAAK;oBAAC3B;iBAAG;gBACTmB,OAAOA;gBACPP,OAAOA,MAAMA,KAAK;gBAClB4D,YAAY5D,MAAMH,KAAK;gBACvB4B,aAAaA;;;;AAIrB;AACAvC,kBAAkBL,WAAW,GAAG;AAEhC;;;;CAIC,GACD,OAAO,SAASgF,mBAAmB1F,KAMlC;IACC,MAAM,EAAEgB,MAAM,EAAE4B,GAAG,EAAEzB,MAAM,EAAEC,KAAK,EAAE6D,QAAQ,EAAE,GAAGjF;IACjD,MAAM,EAAEyB,SAAS,EAAEC,KAAK,EAAE,GAAG7B,wBAAwBuB,gBAAAA,QAASQ;IAC9D,MAAMC,QAAQzC,mBAAmB;QAAE+B;QAAQC;QAAOU,SAASL;IAAU;IACrE,MAAM,CAAC8D,MAAMI,QAAQ,GAAGzG,SAAS;IACjC,IAAI,CAACwC,OAAO,OAAO;IACnB,qBACE;;0BACE,KAACjD;gBAAesF,SAAS,CAACtC;gBAAWuC,QAAQtE;0BAC3C,cAAA,KAACd;oBAAOwB,MAAK;oBAAQ6E,UAAUA,YAAY,CAACrC,IAAIG,MAAM;oBAAEkB,SAAS,IAAM0B,QAAQ;8BAC5E;;;0BAGL,KAAC7F;gBACCyF,MAAMA;gBACNC,SAAS,IAAMG,QAAQ;gBACvB3E,QAAQA;gBACR4B,KAAKA;gBACLR,OAAOxC,iBAAiBuB,QAAQC;gBAChCS,OAAOA,MAAMA,KAAK;gBAClB4D,YAAY5D,MAAMH,KAAK;;;;AAI/B;AACAgE,mBAAmBhF,WAAW,GAAG;AAEjC,eAAeK,kBAAiB"}
|
|
@@ -61,15 +61,22 @@ export declare namespace AutoCreateCompaniesCard {
|
|
|
61
61
|
* defaults for new datasets and media.
|
|
62
62
|
*
|
|
63
63
|
* Changes nothing that already exists: narrowing an address book from a
|
|
64
|
-
*
|
|
65
|
-
* confirmation. Each record's own sharing is where that is decided
|
|
64
|
+
* setting would hide records from sites already working them, with no
|
|
65
|
+
* confirmation. Each record's own sharing is where that is decided, and
|
|
66
|
+
* under "All sites except…" (AGL-4047) the explicit "Apply to existing
|
|
67
|
+
* records" run below, which says what it does before it starts.
|
|
66
68
|
*
|
|
67
|
-
* Reads `
|
|
69
|
+
* Reads `crmDefaultSharingOf`, the same reader the capture door and every CRM
|
|
68
70
|
* creator stamp from, so the control cannot show one thing while records
|
|
69
71
|
* get another — including for an org that has never set it, which shares
|
|
70
72
|
* with every site unless it set the older dataset default to keep them
|
|
71
73
|
* apart. Keeping each site's records apart is the agency's choice: one
|
|
72
74
|
* client's collaborator then sees only that client's people.
|
|
75
|
+
*
|
|
76
|
+
* Radios and a visible list of sites, never a dropdown: the sites left out
|
|
77
|
+
* are the part people come to check. "All sites except…" is stored beside
|
|
78
|
+
* `defaultRecordScope: 'host'`, so a reader that predates it keeps new
|
|
79
|
+
* records to the site they came in on rather than sharing them wider.
|
|
73
80
|
*/
|
|
74
81
|
export declare function DefaultRecordSharingCard(props: AutoCreateCompaniesCardProps): import("react").JSX.Element;
|
|
75
82
|
export declare namespace DefaultRecordSharingCard {
|