@burdenoff/microfe-planmagnet 2026.930.19 → 2026.930.21
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/dist/index.js +2 -1
- package/dist/planmagnet/PlanMagnetRoutes.d.ts.map +1 -1
- package/dist/planmagnet/PlanMagnetRoutes.js +17 -5
- package/dist/planmagnet/PlanMagnetRoutes.js.map +1 -1
- package/dist/planmagnet/automation/AutomationExecutionsPanel.d.ts.map +1 -1
- package/dist/planmagnet/automation/AutomationExecutionsPanel.js +43 -39
- package/dist/planmagnet/automation/AutomationExecutionsPanel.js.map +1 -1
- package/dist/planmagnet/automation/AutomationRuleFields.d.ts +23 -4
- package/dist/planmagnet/automation/AutomationRuleFields.d.ts.map +1 -1
- package/dist/planmagnet/automation/AutomationRuleFields.js +255 -108
- package/dist/planmagnet/automation/AutomationRuleFields.js.map +1 -1
- package/dist/planmagnet/automation/automationRuleTypes.d.ts +138 -15
- package/dist/planmagnet/automation/automationRuleTypes.d.ts.map +1 -1
- package/dist/planmagnet/automation/automationRuleTypes.js +162 -22
- package/dist/planmagnet/automation/automationRuleTypes.js.map +1 -1
- package/dist/planmagnet/controls/AutomationRuleControls.d.ts.map +1 -1
- package/dist/planmagnet/controls/AutomationRuleControls.js +76 -71
- package/dist/planmagnet/controls/AutomationRuleControls.js.map +1 -1
- package/dist/planmagnet/controls/SyncControls.d.ts +101 -0
- package/dist/planmagnet/controls/SyncControls.d.ts.map +1 -0
- package/dist/planmagnet/controls/SyncControls.js +616 -0
- package/dist/planmagnet/controls/SyncControls.js.map +1 -0
- package/dist/planmagnet/index.d.ts +1 -0
- package/dist/planmagnet/index.d.ts.map +1 -1
- package/dist/planmagnet/index.js +1 -0
- package/dist/planmagnet/integrations/routes.d.ts +13 -0
- package/dist/planmagnet/integrations/routes.d.ts.map +1 -0
- package/dist/planmagnet/integrations/routes.js +9 -0
- package/dist/planmagnet/integrations/routes.js.map +1 -0
- package/dist/planmagnet/integrations/syncTypes.d.ts +143 -0
- package/dist/planmagnet/integrations/syncTypes.d.ts.map +1 -0
- package/dist/planmagnet/integrations/syncTypes.js +71 -0
- package/dist/planmagnet/integrations/syncTypes.js.map +1 -0
- package/dist/planmagnet/integrations/useSyncProviderCapabilities.d.ts +8 -0
- package/dist/planmagnet/integrations/useSyncProviderCapabilities.d.ts.map +1 -0
- package/dist/planmagnet/integrations/useSyncProviderCapabilities.js +27 -0
- package/dist/planmagnet/integrations/useSyncProviderCapabilities.js.map +1 -0
- package/dist/planmagnet/pages/AutomationAutomationRuleDetailPagePage.d.ts.map +1 -1
- package/dist/planmagnet/pages/AutomationAutomationRuleDetailPagePage.js +85 -76
- package/dist/planmagnet/pages/AutomationAutomationRuleDetailPagePage.js.map +1 -1
- package/dist/planmagnet/pages/AutomationAutomationRulesPagePage.js +12 -12
- package/dist/planmagnet/pages/AutomationAutomationRulesPagePage.js.map +1 -1
- package/dist/planmagnet/pages/AutomationCreateAutomationRulePagePage.d.ts.map +1 -1
- package/dist/planmagnet/pages/AutomationCreateAutomationRulePagePage.js +48 -44
- package/dist/planmagnet/pages/AutomationCreateAutomationRulePagePage.js.map +1 -1
- package/dist/planmagnet/pages/IntegrationsNewSyncPagePage.d.ts +2 -0
- package/dist/planmagnet/pages/IntegrationsNewSyncPagePage.d.ts.map +1 -0
- package/dist/planmagnet/pages/IntegrationsNewSyncPagePage.js +411 -0
- package/dist/planmagnet/pages/IntegrationsNewSyncPagePage.js.map +1 -0
- package/dist/planmagnet/pages/IntegrationsSyncDetailPagePage.d.ts +2 -0
- package/dist/planmagnet/pages/IntegrationsSyncDetailPagePage.d.ts.map +1 -0
- package/dist/planmagnet/pages/IntegrationsSyncDetailPagePage.js +593 -0
- package/dist/planmagnet/pages/IntegrationsSyncDetailPagePage.js.map +1 -0
- package/dist/planmagnet/pages/IntegrationsSyncsPagePage.d.ts +2 -0
- package/dist/planmagnet/pages/IntegrationsSyncsPagePage.d.ts.map +1 -0
- package/dist/planmagnet/pages/IntegrationsSyncsPagePage.js +267 -0
- package/dist/planmagnet/pages/IntegrationsSyncsPagePage.js.map +1 -0
- package/dist/planmagnet/people/People.d.ts.map +1 -1
- package/dist/planmagnet/people/People.js +30 -17
- package/dist/planmagnet/people/People.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"automationRuleTypes.js","names":[],"sources":["../../../src/planmagnet/automation/automationRuleTypes.ts"],"sourcesContent":["/**\n * Automation rules (BOFF-8047). Shared trigger/condition/action vocabulary, kept in one place so the create\n * page, the edit page and the list's summaries can never drift from each other or from the engine.\n *\n * Scope note (from `automation-engine.ts`, the source of truth): only two triggers fire automatically today —\n * `WORK_ITEM_CREATED` and `WORK_ITEM_STATUS_CHANGED` — and only four action types can be dispatched —\n * `ASSIGN_TO_USER`, `ADD_LABEL`, `SET_STATUS`, `SET_PRIORITY`. The other five trigger types are real schema\n * values the service accepts and stores (so a rule can be prepared ahead of a future engine change), but they\n * never fire on their own; \"Run now\" (`planmagnetExecuteAutomationRule`) works for a rule of ANY trigger type,\n * including `MANUAL`, because it targets one named work item directly rather than listening for an event.\n *\n * The actions builder below offers ONLY the four dispatchable types: offering the others would create a rule\n * whose own execution log immediately reports \"declared action(s) are not supported\" — a UI that can build a\n * rule the backend documents as silently dropping is worse than not offering the option.\n */\n\nexport const AUTOMATIC_TRIGGER_TYPES = new Set(['WORK_ITEM_CREATED', 'WORK_ITEM_STATUS_CHANGED']);\n\nexport const TRIGGER_TYPES = [\n 'WORK_ITEM_CREATED',\n 'WORK_ITEM_STATUS_CHANGED',\n 'WORK_ITEM_UPDATED',\n 'WORK_ITEM_ASSIGNED',\n 'SPRINT_STARTED',\n 'SPRINT_COMPLETED',\n 'MILESTONE_DUE',\n 'SCHEDULE',\n 'WEBHOOK',\n 'MANUAL',\n] as const;\nexport type TriggerType = (typeof TRIGGER_TYPES)[number];\n\nexport const TRIGGER_TYPE_LABEL: Record<TriggerType, string> = {\n WORK_ITEM_CREATED: 'Work item created',\n WORK_ITEM_STATUS_CHANGED: 'Work item status changed',\n WORK_ITEM_UPDATED: 'Work item updated',\n WORK_ITEM_ASSIGNED: 'Work item assigned',\n SPRINT_STARTED: 'Sprint started',\n SPRINT_COMPLETED: 'Sprint completed',\n MILESTONE_DUE: 'Milestone due',\n SCHEDULE: 'Schedule',\n WEBHOOK: 'Webhook',\n MANUAL: 'Manual only',\n};\n\n/** Looks up a trigger type's label; falls back to the raw value for one this UI does not yet know (forward\n * compatible with a value the service adds later). Cast: `TRIGGER_TYPE_LABEL` is keyed by the known union, but\n * a value read back from the API is a plain string. */\nexport function triggerTypeLabel(value: string): string {\n return (TRIGGER_TYPE_LABEL as Record<string, string>)[value] ?? value;\n}\n\nexport const RULE_STATUSES = ['ACTIVE', 'PAUSED', 'DISABLED', 'ERROR'] as const;\nexport type RuleStatus = (typeof RULE_STATUSES)[number];\n\nexport const ACTION_TYPES = ['ASSIGN_TO_USER', 'ADD_LABEL', 'SET_STATUS', 'SET_PRIORITY'] as const;\nexport type ActionType = (typeof ACTION_TYPES)[number];\n\nexport const ACTION_TYPE_LABEL: Record<ActionType, string> = {\n ASSIGN_TO_USER: 'Assign to user',\n ADD_LABEL: 'Add label',\n SET_STATUS: 'Set status',\n SET_PRIORITY: 'Set priority',\n};\n\nexport interface RuleAction {\n type: ActionType;\n value: string;\n}\n\nexport const CONDITION_OPERATORS = [\n 'eq',\n 'neq',\n 'in',\n 'notIn',\n 'contains',\n 'gt',\n 'gte',\n 'lt',\n 'lte',\n 'exists',\n] as const;\nexport type ConditionOperator = (typeof CONDITION_OPERATORS)[number];\n\nexport const CONDITION_OPERATOR_LABEL: Record<ConditionOperator, string> = {\n eq: 'is',\n neq: 'is not',\n in: 'is one of',\n notIn: 'is not one of',\n contains: 'contains',\n gt: '>',\n gte: '>=',\n lt: '<',\n lte: '<=',\n exists: 'is set',\n};\n\n/** Fields present on every automatic trigger's snapshot (`TriggerData` in automation-engine.ts). */\nexport const CONDITION_FIELDS = [\n 'status',\n 'previousStatus',\n 'priority',\n 'type',\n 'assigneeId',\n 'title',\n 'labels',\n 'sprintId',\n 'projectId',\n] as const;\n\nexport interface RuleCondition {\n field: string;\n operator: ConditionOperator;\n /** Raw editor value; for `in`/`notIn` this is a comma-separated list, converted to an array on submit. */\n value: string;\n}\n\n/** actions[] (form shape) -> actions JSON the API accepts. */\nexport function actionsToApi(actions: RuleAction[]): { type: ActionType; value: string }[] {\n return actions\n .filter((a) => a.value.trim() !== '')\n .map((a) => ({ type: a.type, value: a.value.trim() }));\n}\n\n/** conditions[] (form shape) -> conditions JSON the API accepts, or undefined when there are none. */\nexport function conditionsToApi(\n conditions: RuleCondition[]\n): { field: string; operator: ConditionOperator; value?: unknown }[] | undefined {\n const usable = conditions.filter((c) => c.field.trim() !== '');\n if (usable.length === 0) return undefined;\n return usable.map((c) => {\n if (c.operator === 'exists') return { field: c.field.trim(), operator: c.operator };\n if (c.operator === 'in' || c.operator === 'notIn') {\n return {\n field: c.field.trim(),\n operator: c.operator,\n value: c.value\n .split(',')\n .map((v) => v.trim())\n .filter(Boolean),\n };\n }\n return { field: c.field.trim(), operator: c.operator, value: c.value };\n });\n}\n\n/** API conditions JSON -> form shape, for the edit page. Unrecognised shapes are dropped rather than crashing the form. */\nexport function conditionsFromApi(raw: unknown): RuleCondition[] {\n if (!Array.isArray(raw)) return [];\n return raw\n .filter(\n (v): v is { field: string; operator: string; value?: unknown } =>\n !!v && typeof v === 'object' && typeof (v as { field?: unknown }).field === 'string'\n )\n .map((c) => ({\n field: c.field,\n operator: (CONDITION_OPERATORS as readonly string[]).includes(c.operator)\n ? (c.operator as ConditionOperator)\n : 'eq',\n value: Array.isArray(c.value) ? c.value.join(', ') : c.value == null ? '' : String(c.value),\n }));\n}\n\n/** API actions JSON -> form shape, for the edit page. Action types this builder does not offer are kept (so an\n * existing rule's own configuration is never silently dropped by opening the edit page) but shown as read-only. */\nexport function actionsFromApi(raw: unknown): RuleAction[] {\n if (!Array.isArray(raw)) return [];\n return raw\n .filter(\n (v): v is { type: string; value?: unknown } =>\n !!v && typeof v === 'object' && typeof (v as { type?: unknown }).type === 'string'\n )\n .map((a) => ({ type: a.type as ActionType, value: a.value == null ? '' : String(a.value) }));\n}\n"],"mappings":";AAgBA,IAAa,IAA0B,IAAI,IAAI,CAAC,qBAAqB,2BAA2B,CAAC,EAEpF,IAAgB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,EAGY,IAAkD;CAC7D,mBAAmB;CACnB,0BAA0B;CAC1B,mBAAmB;CACnB,oBAAoB;CACpB,gBAAgB;CAChB,kBAAkB;CAClB,eAAe;CACf,UAAU;CACV,SAAS;CACT,QAAQ;CACT;AAKD,SAAgB,EAAiB,GAAuB;AACtD,QAAQ,EAA8C,MAAU;;AAGlE,IAAa,IAAgB;CAAC;CAAU;CAAU;CAAY;CAAQ,EAGzD,IAAe;CAAC;CAAkB;CAAa;CAAc;CAAe,EAG5E,IAAgD;CAC3D,gBAAgB;CAChB,WAAW;CACX,YAAY;CACZ,cAAc;CACf,EAOY,IAAsB;CACjC;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,EAGY,IAA8D;CACzE,IAAI;CACJ,KAAK;CACL,IAAI;CACJ,OAAO;CACP,UAAU;CACV,IAAI;CACJ,KAAK;CACL,IAAI;CACJ,KAAK;CACL,QAAQ;CACT,EAGY,IAAmB;CAC9B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAUD,SAAgB,EAAa,GAA8D;AACzF,QAAO,EACJ,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAK,GAAG,CACpC,KAAK,OAAO;EAAE,MAAM,EAAE;EAAM,OAAO,EAAE,MAAM,MAAM;EAAE,EAAE;;AAI1D,SAAgB,EACd,GAC+E;CAC/E,IAAM,IAAS,EAAW,QAAQ,MAAM,EAAE,MAAM,MAAM,KAAK,GAAG;AAC1D,OAAO,WAAW,EACtB,QAAO,EAAO,KAAK,MACb,EAAE,aAAa,WAAiB;EAAE,OAAO,EAAE,MAAM,MAAM;EAAE,UAAU,EAAE;EAAU,GAC/E,EAAE,aAAa,QAAQ,EAAE,aAAa,UACjC;EACL,OAAO,EAAE,MAAM,MAAM;EACrB,UAAU,EAAE;EACZ,OAAO,EAAE,MACN,MAAM,IAAI,CACV,KAAK,MAAM,EAAE,MAAM,CAAC,CACpB,OAAO,QAAQ;EACnB,GAEI;EAAE,OAAO,EAAE,MAAM,MAAM;EAAE,UAAU,EAAE;EAAU,OAAO,EAAE;EAAO,CACtE;;AAIJ,SAAgB,EAAkB,GAA+B;AAE/D,QADK,MAAM,QAAQ,EAAI,GAChB,EACJ,QACE,MACC,CAAC,CAAC,KAAK,OAAO,KAAM,YAAY,OAAQ,EAA0B,SAAU,SAC/E,CACA,KAAK,OAAO;EACX,OAAO,EAAE;EACT,UAAW,EAA0C,SAAS,EAAE,SAAS,GACpE,EAAE,WACH;EACJ,OAAO,MAAM,QAAQ,EAAE,MAAM,GAAG,EAAE,MAAM,KAAK,KAAK,GAAG,EAAE,SAAS,OAAO,KAAK,OAAO,EAAE,MAAM;EAC5F,EAAE,GAZ2B,EAAE;;AAiBpC,SAAgB,EAAe,GAA4B;AAEzD,QADK,MAAM,QAAQ,EAAI,GAChB,EACJ,QACE,MACC,CAAC,CAAC,KAAK,OAAO,KAAM,YAAY,OAAQ,EAAyB,QAAS,SAC7E,CACA,KAAK,OAAO;EAAE,MAAM,EAAE;EAAoB,OAAO,EAAE,SAAS,OAAO,KAAK,OAAO,EAAE,MAAM;EAAE,EAAE,GAN9D,EAAE"}
|
|
1
|
+
{"version":3,"file":"automationRuleTypes.js","names":[],"sources":["../../../src/planmagnet/automation/automationRuleTypes.ts"],"sourcesContent":["/**\n * Automation rules (BOFF-8047). Shared trigger/condition/action vocabulary, kept in one place so the create\n * page, the edit page and the list's summaries can never drift from each other or from the engine.\n *\n * Scope note, rewritten from the real engine (wspace-planmagnet-svc `src/modules/automation/services/\n * automation-engine.ts` + `automation-scheduler.ts`, both merged and prod-verified — svc PR #64):\n *\n * - Triggers that fire AUTOMATICALLY: `WORK_ITEM_CREATED`, `WORK_ITEM_STATUS_CHANGED`, `WORK_ITEM_ASSIGNED`\n * (from every WorkItem write that changes status/assignee), `SPRINT_STARTED`/`SPRINT_COMPLETED` (a sprint\n * transition), `RELEASE_RELEASED` (a release's real transition into RELEASED — not a re-send) and `SCHEDULE`\n * (a daily background scan — see `automation-scheduler.ts`, NOT dispatched from a write path at all). Still\n * real, accepted, saved schema values but INERT — never fire on their own: `WORK_ITEM_UPDATED`,\n * `MILESTONE_DUE`, `WEBHOOK`. `MANUAL` is not inert, it is intentionally manual-only: it runs only via\n * \"Run now\" (`planmagnetExecuteAutomationRule`), which works for a rule of ANY trigger type because it\n * targets one named work item directly instead of listening for an event.\n * - Dispatchable actions: `ASSIGN_TO_USER`, `ADD_LABEL`, `SET_STATUS`, `SET_PRIORITY` (the four WorkItem\n * fields an automation can mutate), `POST_COMMENT` (a templated comment on the triggering work item,\n * authored by the fixed `automation:engine` identity — see `AUTOMATION_ACTOR_NAMES` in `../people/People`)\n * and `POST_TO_CHANNEL` (a templated message to a Conversations channel) — but `POST_TO_CHANNEL` is gated\n * OFF in prod (`isChannelPostingEnabled()` in the engine) until Platform ticket BOFF-8240 ships: saving one\n * is refused server-side with \"Posting to a chat channel from an automation is not available yet\", so this\n * UI never lets it be selected or saved either (see `CHANNEL_POSTING_AVAILABLE` below).\n * - `SPRINT_STARTED`/`SPRINT_COMPLETED`/`RELEASE_RELEASED` carry NO target work item (`sprint.service.ts`/\n * `release.service.ts` never set `workItemId` on their `TriggerData`), so every work-item action — all five\n * above except `POST_TO_CHANNEL` — cannot run for them. Today that leaves such a rule able to do nothing\n * (the only action that *could* apply, `POST_TO_CHANNEL`, is itself gated off), so the builder below refuses\n * to offer work-item actions for these triggers and blocks Save entirely rather than let someone build a\n * rule that silently never fires anything.\n */\n\nexport const TRIGGER_TYPES = [\n 'WORK_ITEM_CREATED',\n 'WORK_ITEM_STATUS_CHANGED',\n 'WORK_ITEM_ASSIGNED',\n 'SPRINT_STARTED',\n 'SPRINT_COMPLETED',\n 'RELEASE_RELEASED',\n 'SCHEDULE',\n 'WORK_ITEM_UPDATED',\n 'MILESTONE_DUE',\n 'WEBHOOK',\n 'MANUAL',\n] as const;\nexport type TriggerType = (typeof TRIGGER_TYPES)[number];\n\nexport const TRIGGER_TYPE_LABEL: Record<TriggerType, string> = {\n WORK_ITEM_CREATED: 'Work item created',\n WORK_ITEM_STATUS_CHANGED: 'Work item status changed',\n WORK_ITEM_ASSIGNED: 'Work item assigned',\n SPRINT_STARTED: 'Sprint started',\n SPRINT_COMPLETED: 'Sprint completed',\n RELEASE_RELEASED: 'Release shipped',\n SCHEDULE: 'Schedule',\n WORK_ITEM_UPDATED: 'Work item updated',\n MILESTONE_DUE: 'Milestone due',\n WEBHOOK: 'Webhook',\n MANUAL: 'Manual only',\n};\n\n/** Looks up a trigger type's label; falls back to the raw value for one this UI does not yet know (forward\n * compatible with a value the service adds later). Cast: `TRIGGER_TYPE_LABEL` is keyed by the known union, but\n * a value read back from the API is a plain string. */\nexport function triggerTypeLabel(value: string): string {\n return (TRIGGER_TYPE_LABEL as Record<string, string>)[value] ?? value;\n}\n\n/** Fires on its own — dispatched from a real write path or the daily SCHEDULE scan (automation-engine.ts's\n * `AutomationTriggerType` union, 7 values). Everything else in `TRIGGER_TYPES` is either inert (accepted,\n * saved, never fires) or intentionally manual-only. */\nexport const AUTOMATIC_TRIGGER_TYPES: ReadonlySet<TriggerType> = new Set([\n 'WORK_ITEM_CREATED',\n 'WORK_ITEM_STATUS_CHANGED',\n 'WORK_ITEM_ASSIGNED',\n 'SPRINT_STARTED',\n 'SPRINT_COMPLETED',\n 'RELEASE_RELEASED',\n 'SCHEDULE',\n]);\n\n/** Accepted and saved (so a rule can be prepared ahead of a future engine change) but never fires on its own —\n * no dispatcher call site exists yet for these (automation-engine.ts's header). Distinct from `MANUAL`, which\n * is deliberately manual-only rather than an unfinished trigger. */\nexport const INERT_TRIGGER_TYPES: ReadonlySet<TriggerType> = new Set([\n 'WORK_ITEM_UPDATED',\n 'MILESTONE_DUE',\n 'WEBHOOK',\n]);\n\n/** Fires automatically but its `TriggerData` never carries a `workItemId` (sprint.service.ts / release.service.ts\n * build it without one) — so no work-item action can ever dispatch for it. */\nexport const NO_WORK_ITEM_TRIGGER_TYPES: ReadonlySet<TriggerType> = new Set([\n 'SPRINT_STARTED',\n 'SPRINT_COMPLETED',\n 'RELEASE_RELEASED',\n]);\n\n/** The trigger-select option suffix — mirrors what the rule can actually do, not just whether it is automatic. */\nexport function triggerOptionSuffix(trigger: TriggerType): string {\n if (trigger === 'SCHEDULE') return ' (runs daily)';\n if (NO_WORK_ITEM_TRIGGER_TYPES.has(trigger)) return ' (no target work item)';\n if (INERT_TRIGGER_TYPES.has(trigger)) return ' (not yet automatic)';\n if (trigger === 'MANUAL') return ' (run manually)';\n return '';\n}\n\n/** The explanatory note shown under the trigger select — `null` for a trigger that needs no caveat (an\n * ordinary automatic, work-item-bearing trigger). Rendered with `data-testid=\"automation-trigger-hint\"`. */\nexport function triggerHint(trigger: TriggerType): string | null {\n if (NO_WORK_ITEM_TRIGGER_TYPES.has(trigger)) {\n return 'This trigger fires automatically, but it has no target work item — only \"Post to a channel\" could apply, and that is not available yet (waiting on a platform change). A rule with this trigger cannot do anything right now, so it cannot be saved yet.';\n }\n if (trigger === 'SCHEDULE') {\n return 'Runs once a day against every work item matching the statuses and staleness window below, and acts on each matching item at most once per day.';\n }\n if (INERT_TRIGGER_TYPES.has(trigger)) {\n return 'This trigger is saved but does not fire on its own yet — use Run now to run it against a work item.';\n }\n if (trigger === 'MANUAL') {\n return 'Manual rules never fire on their own — use Run now to run this rule against a work item.';\n }\n return null;\n}\n\nexport const RULE_STATUSES = ['ACTIVE', 'PAUSED', 'DISABLED', 'ERROR'] as const;\nexport type RuleStatus = (typeof RULE_STATUSES)[number];\n\nexport const ACTION_TYPES = [\n 'ASSIGN_TO_USER',\n 'ADD_LABEL',\n 'SET_STATUS',\n 'SET_PRIORITY',\n 'POST_COMMENT',\n 'POST_TO_CHANNEL',\n] as const;\nexport type ActionType = (typeof ACTION_TYPES)[number];\n\nexport const ACTION_TYPE_LABEL: Record<ActionType, string> = {\n ASSIGN_TO_USER: 'Assign to user',\n ADD_LABEL: 'Add label',\n SET_STATUS: 'Set status',\n SET_PRIORITY: 'Set priority',\n POST_COMMENT: 'Post a comment',\n POST_TO_CHANNEL: 'Post to a channel',\n};\n\n/** Every action that mutates/comments on the triggering WORK ITEM (automation-engine.ts's `dispatchAction`: only\n * `POST_TO_CHANNEL` is handled without one). These are the actions `NO_WORK_ITEM_TRIGGER_TYPES` cannot run. */\nexport const WORK_ITEM_ACTION_TYPES: ReadonlySet<ActionType> = new Set([\n 'ASSIGN_TO_USER',\n 'ADD_LABEL',\n 'SET_STATUS',\n 'SET_PRIORITY',\n 'POST_COMMENT',\n]);\n\n/** `POST_TO_CHANNEL` is gated off (BOFF-8240) — mirrors `isChannelPostingEnabled()` in automation-engine.ts,\n * which this frontend has no way to read directly (it is a server env flag). Flip this only once that ships\n * AND the option below is meant to become selectable — until then it stays visible but disabled everywhere. */\nexport const CHANNEL_POSTING_AVAILABLE = false;\n/** Short reason shown on the disabled option itself. */\nexport const CHANNEL_POSTING_OPTION_REASON = 'Not available yet — waiting on a platform change';\n/** The engine's own refusal message (`automation.errors.channelPostingUnavailable`), reused so a blocked save\n * never contradicts what the server would say if the block were somehow bypassed. */\nexport const CHANNEL_POSTING_BLOCKED_MESSAGE =\n 'Posting to a chat channel from an automation is not available yet.';\n\nexport interface RuleAction {\n type: ActionType;\n value: string;\n}\n\nexport const CONDITION_OPERATORS = [\n 'eq',\n 'neq',\n 'in',\n 'notIn',\n 'contains',\n 'gt',\n 'gte',\n 'lt',\n 'lte',\n 'exists',\n] as const;\nexport type ConditionOperator = (typeof CONDITION_OPERATORS)[number];\n\nexport const CONDITION_OPERATOR_LABEL: Record<ConditionOperator, string> = {\n eq: 'is',\n neq: 'is not',\n in: 'is one of',\n notIn: 'is not one of',\n contains: 'contains',\n gt: '>',\n gte: '>=',\n lt: '<',\n lte: '<=',\n exists: 'is set',\n};\n\n/** Fields present on every automatic trigger's snapshot (`TriggerData` in automation-engine.ts). Only meaningful\n * for non-`SCHEDULE` triggers — `SCHEDULE` has its own dedicated condition shape, see `ScheduleConditions` below. */\nexport const CONDITION_FIELDS = [\n 'status',\n 'previousStatus',\n 'priority',\n 'type',\n 'assigneeId',\n 'title',\n 'labels',\n 'sprintId',\n 'projectId',\n] as const;\n\nexport interface RuleCondition {\n field: string;\n operator: ConditionOperator;\n /** Raw editor value; for `in`/`notIn` this is a comma-separated list, converted to an array on submit. */\n value: string;\n}\n\n/** actions[] (form shape) -> actions JSON the API accepts. Never emits a `POST_TO_CHANNEL` action — nothing in\n * this builder can produce one while `CHANNEL_POSTING_AVAILABLE` is false (see `saveBlockReason`, which refuses\n * to save a form that somehow still carries one). */\nexport function actionsToApi(actions: RuleAction[]): { type: ActionType; value: string }[] {\n return actions\n .filter((a) => a.value.trim() !== '')\n .map((a) => ({ type: a.type, value: a.value.trim() }));\n}\n\n/** conditions[] (form shape) -> conditions JSON the API accepts, or undefined when there are none. Only used for\n * non-`SCHEDULE` triggers — see `scheduleConditionsToApi` for `SCHEDULE`'s own shape. */\nexport function conditionsToApi(\n conditions: RuleCondition[]\n): { field: string; operator: ConditionOperator; value?: unknown }[] | undefined {\n const usable = conditions.filter((c) => c.field.trim() !== '');\n if (usable.length === 0) return undefined;\n return usable.map((c) => {\n if (c.operator === 'exists') return { field: c.field.trim(), operator: c.operator };\n if (c.operator === 'in' || c.operator === 'notIn') {\n return {\n field: c.field.trim(),\n operator: c.operator,\n value: c.value\n .split(',')\n .map((v) => v.trim())\n .filter(Boolean),\n };\n }\n return { field: c.field.trim(), operator: c.operator, value: c.value };\n });\n}\n\n/** API conditions JSON -> form shape, for the edit page. Unrecognised shapes are dropped rather than crashing the form. */\nexport function conditionsFromApi(raw: unknown): RuleCondition[] {\n if (!Array.isArray(raw)) return [];\n return raw\n .filter(\n (v): v is { field: string; operator: string; value?: unknown } =>\n !!v && typeof v === 'object' && typeof (v as { field?: unknown }).field === 'string'\n )\n .map((c) => ({\n field: c.field,\n operator: (CONDITION_OPERATORS as readonly string[]).includes(c.operator)\n ? (c.operator as ConditionOperator)\n : 'eq',\n value: Array.isArray(c.value) ? c.value.join(', ') : c.value == null ? '' : String(c.value),\n }));\n}\n\n/** API actions JSON -> form shape, for the edit page. Action types this builder does not offer are kept (so an\n * existing rule's own configuration is never silently dropped by opening the edit page) but shown as read-only. */\nexport function actionsFromApi(raw: unknown): RuleAction[] {\n if (!Array.isArray(raw)) return [];\n return raw\n .filter(\n (v): v is { type: string; value?: unknown } =>\n !!v && typeof v === 'object' && typeof (v as { type?: unknown }).type === 'string'\n )\n .map((a) => ({ type: a.type as ActionType, value: a.value == null ? '' : String(a.value) }));\n}\n\n// ============================================================================\n// SCHEDULE conditions (AUT-27) — a DIFFERENT shape from the field/operator/value array above.\n//\n// automation-scheduler.ts's `parseScheduleConditions` reads a SCHEDULE rule's `conditions` as the plain object\n// `{ status: string[] (non-empty), notUpdatedForDays: number > 0 }`: which statuses are candidates, and how many\n// days since a matching item last changed before the rule considers it stale. Anything else (missing, an empty\n// status list, a non-positive/non-numeric window) makes the scheduler skip the rule silently every tick — so this\n// form gates Save on the same shape being valid, rather than letting a SCHEDULE rule be saved in a way that never\n// runs.\n// ============================================================================\n\nexport interface ScheduleConditions {\n status: string[];\n notUpdatedForDays: number;\n}\n\n/** A whole number of days, 1 or more — a stricter (but compatible) subset of the engine's own `number > 0` check,\n * chosen because \"half a day\" has no sensible UI meaning here. */\nexport function parseScheduleDays(raw: string): number | null {\n const trimmed = raw.trim();\n if (!/^\\d+$/.test(trimmed)) return null;\n const n = Number(trimmed);\n return n >= 1 ? n : null;\n}\n\n/** API `conditions` JSON -> the SCHEDULE editor's own form fields. Lenient (shows whatever is there, even if it\n * would fail `parseScheduleConditions` server-side) so an existing malformed rule can still be opened and fixed,\n * rather than silently reset. */\nexport function scheduleConditionsFromApi(raw: unknown): { statuses: string[]; days: string } {\n if (!raw || typeof raw !== 'object') return { statuses: [], days: '' };\n const status = (raw as Record<string, unknown>).status;\n const notUpdatedForDays = (raw as Record<string, unknown>).notUpdatedForDays;\n const statuses = Array.isArray(status)\n ? status.filter((s): s is string => typeof s === 'string')\n : [];\n const days =\n typeof notUpdatedForDays === 'number' && Number.isFinite(notUpdatedForDays)\n ? String(notUpdatedForDays)\n : '';\n return { statuses, days };\n}\n\n/** The SCHEDULE editor's own form fields -> exactly the `{ status, notUpdatedForDays }` shape\n * `parseScheduleConditions` reads. `undefined` when not yet valid — callers gate Save on this instead of ever\n * submitting an unreadable value. */\nexport function scheduleConditionsToApi(\n statuses: string[],\n daysText: string\n): ScheduleConditions | undefined {\n const days = parseScheduleDays(daysText);\n if (statuses.length === 0 || days === null) return undefined;\n return { status: statuses, notUpdatedForDays: days };\n}\n\nexport function isScheduleConditionsValid(statuses: string[], daysText: string): boolean {\n return statuses.length > 0 && parseScheduleDays(daysText) !== null;\n}\n\n// ============================================================================\n// POST_COMMENT / POST_TO_CHANNEL templating — mirrors automation-engine.ts's `renderAutomationTemplate` +\n// `buildAutomationTemplateValues` for a client-side PREVIEW only. The server re-renders for real at dispatch\n// time against the live trigger data; this never substitutes for that, it only shows what the template would\n// look like with representative sample values.\n// ============================================================================\n\n/** `AUTOMATION_TEMPLATE_MAX_LENGTH` in automation-engine.ts — the longest a template's raw `value` may be,\n * checked at rule create/update. */\nexport const AUTOMATION_TEMPLATE_MAX_LENGTH = 2_000;\n/** `POST_COMMENT_MAX_RENDERED_LENGTH` in automation-engine.ts — the longest a RENDERED comment body may be. */\nexport const POST_COMMENT_MAX_RENDERED_LENGTH = 2_000;\n/** `POST_TO_CHANNEL_MAX_RENDERED_LENGTH` in automation-engine.ts — shorter, matching a chat message. */\nexport const POST_TO_CHANNEL_MAX_RENDERED_LENGTH = 500;\n\nconst TEMPLATE_PLACEHOLDER_RE = /\\{\\{\\s*([a-zA-Z][a-zA-Z0-9_.]*)\\s*\\}\\}/g;\n\n/** Mirrors `escapeAutomationTemplateValue` in automation-engine.ts: a substituted value never carries a raw\n * control character or the exact bracket/paren characters CWF-13's `@[Name](actorId)` mention token uses. */\nfunction escapeTemplateValue(value: string): string {\n let out = '';\n for (const ch of value) {\n const code = ch.codePointAt(0) ?? 0;\n out +=\n code <= 0x1f || code === 0x7f || ch === '[' || ch === ']' || ch === '(' || ch === ')'\n ? ' '\n : ch;\n }\n return out.trim();\n}\n\n/** Mirrors `renderAutomationTemplate` in automation-engine.ts: an unknown or unpopulated `{{key}}` renders empty,\n * the result is trimmed, and it is truncated (with an ellipsis) to `maxLength`. */\nexport function renderTemplatePreview(\n template: string,\n values: Record<string, string | undefined>,\n maxLength: number\n): string {\n const rendered = template.replace(TEMPLATE_PLACEHOLDER_RE, (_match, key: string) => {\n const raw = values[key];\n return raw === undefined ? '' : escapeTemplateValue(raw);\n });\n const trimmed = rendered.trim();\n if (trimmed.length <= maxLength) return trimmed;\n return `${trimmed.slice(0, Math.max(0, maxLength - 1))}…`;\n}\n\n/** Every placeholder token `buildAutomationTemplateValues` (automation-engine.ts) knows how to fill, with a\n * short label for the picker and a representative sample value for the preview. */\nexport const TEMPLATE_PLACEHOLDER_INFO: Record<string, { label: string; sample: string }> = {\n 'workItem.key': { label: 'Work item key', sample: 'PM-42' },\n 'workItem.title': { label: 'Work item title', sample: 'Fix checkout crash' },\n fromStatus: { label: 'Previous status', sample: 'In Progress' },\n toStatus: { label: 'New status', sample: 'Done' },\n actor: { label: 'Actor', sample: 'Jane Doe' },\n 'sprint.name': { label: 'Sprint name', sample: 'Sprint 14' },\n 'release.version': { label: 'Release version', sample: '2026.930.1' },\n 'release.name': { label: 'Release name', sample: 'September release' },\n};\n\n/**\n * Exactly which placeholders will actually render something (non-empty) for a POST_COMMENT/POST_TO_CHANNEL\n * template on a rule of this trigger type — read from `buildAutomationTemplateValues` plus every call site that\n * builds a `TriggerData` for it (`workitem.service.ts`'s `toTriggerData`/`fireAutomationTrigger`,\n * `sprint.service.ts`'s `fireSprintAutomationTrigger`, `release.service.ts`'s `fireReleaseAutomationTrigger`,\n * `automation-scheduler.ts`'s `toScheduleTriggerData`, and `automation.service.ts`'s `execute()` for \"Run now\",\n * which every inert/manual trigger relies on):\n *\n * - `SPRINT_STARTED`/`SPRINT_COMPLETED`: `{ projectId, sprintId, sprintName }` only — no work item, no status.\n * - `RELEASE_RELEASED`: `{ projectId, releaseId, releaseVersion, releaseName }` only — no work item, no status.\n * - `WORK_ITEM_STATUS_CHANGED`: the only automatic trigger that sets `previousStatus` (to the status before the\n * write) alongside the new `status` — every other trigger either omits it or sets it to `null`.\n * - `WORK_ITEM_CREATED`/`WORK_ITEM_ASSIGNED`/`SCHEDULE` carry the work item's key/title/status but never a\n * `fromStatus` — their real dispatch paths (`workitem.service.ts`'s `toTriggerData`, `automation-scheduler.ts`'s\n * `toScheduleTriggerData`) both set `key: item.key` from the live row.\n * - `WORK_ITEM_UPDATED`/`MILESTONE_DUE`/`WEBHOOK`/`MANUAL` are the same \"work item title/status, no fromStatus\"\n * shape MINUS `workItem.key`: `automation.service.ts#execute()` — the ONLY path these ever run through, since\n * none of the four has a real dispatcher — builds its `mergedTriggerData` from the FE's `{ workItemId }`\n * payload (`AutomationRuleControls.tsx`'s `RunAutomationRuleDialog`) plus a fresh `prisma.workItem` read, and\n * that object never assigns a `key` field. Offering `{{workItem.key}}` here would let someone build a template\n * that is GUARANTEED to render an empty string every single time it runs — not merely omitted when unset like\n * a normal \"no value for this trigger\" placeholder, but structurally unreachable for these four trigger types.\n *\n * `actor` is always populated (the real triggering actor, `AUTOMATION_SCHEDULER_ACTOR_ID` for SCHEDULE, or the\n * \"Run now\" caller) so it is available for every trigger.\n */\nexport function templatePlaceholdersForTrigger(trigger: TriggerType): readonly string[] {\n if (trigger === 'SPRINT_STARTED' || trigger === 'SPRINT_COMPLETED')\n return ['sprint.name', 'actor'];\n if (trigger === 'RELEASE_RELEASED') return ['release.version', 'release.name', 'actor'];\n if (trigger === 'WORK_ITEM_STATUS_CHANGED')\n return ['workItem.key', 'workItem.title', 'fromStatus', 'toStatus', 'actor'];\n if (INERT_TRIGGER_TYPES.has(trigger) || trigger === 'MANUAL')\n return ['workItem.title', 'toStatus', 'actor'];\n return ['workItem.key', 'workItem.title', 'toStatus', 'actor'];\n}\n\n/** Sample values for exactly the placeholders `templatePlaceholdersForTrigger` says apply to this trigger — any\n * other `{{...}}` in the template previews empty, matching what the real engine would do. */\nexport function templateSampleValues(trigger: TriggerType): Record<string, string | undefined> {\n const values: Record<string, string | undefined> = {};\n for (const token of templatePlaceholdersForTrigger(trigger)) {\n values[token] = TEMPLATE_PLACEHOLDER_INFO[token]?.sample;\n }\n return values;\n}\n\n// ============================================================================\n// Save gating — a rule this builder would otherwise let someone save but that can never do anything, or that\n// carries an action this engine refuses to dispatch.\n// ============================================================================\n\n/** `null` when this trigger needs no explanation blocking Save; the reason string otherwise (same text as\n * `triggerHint` for a `NO_WORK_ITEM_TRIGGER_TYPES` trigger — the one case that blocks Save outright). */\nexport function triggerSaveBlockReason(trigger: TriggerType): string | null {\n return NO_WORK_ITEM_TRIGGER_TYPES.has(trigger) ? triggerHint(trigger) : null;\n}\n\n/** Combines every reason a rule form cannot be saved yet: a trigger with no possible action, a `POST_TO_CHANNEL`\n * action while channel posting is gated off, or (for `SCHEDULE`) a not-yet-valid schedule window. `null` means\n * the form is save-able as far as these rules are concerned (the caller still checks name/project separately). */\nexport function saveBlockReason(form: {\n triggerType: TriggerType;\n actions: RuleAction[];\n scheduleStatuses: string[];\n scheduleNotUpdatedForDays: string;\n}): string | null {\n const triggerReason = triggerSaveBlockReason(form.triggerType);\n if (triggerReason) return triggerReason;\n if (!CHANNEL_POSTING_AVAILABLE && form.actions.some((a) => a.type === 'POST_TO_CHANNEL')) {\n return CHANNEL_POSTING_BLOCKED_MESSAGE;\n }\n if (\n form.triggerType === 'SCHEDULE' &&\n !isScheduleConditionsValid(form.scheduleStatuses, form.scheduleNotUpdatedForDays)\n ) {\n return 'Choose at least one status and a whole number of days (1 or more) before saving this schedule.';\n }\n return null;\n}\n\n// ============================================================================\n// Execution errors — automation-engine.ts's `errorMessage` is one `'; '`-joined string (each action's\n// `\"<label>: <message>\"`, plus an optional \"N declared action(s) are not supported…\" summary). There is no\n// structured per-action array in the API (`PlanmagnetAutomationExecution.result` only carries\n// `dispatched`/`skipped`/counts — see the schema), so this is the best available split of what the API returns.\n// ============================================================================\n\nexport function splitExecutionErrors(message: string | null | undefined): string[] {\n if (!message) return [];\n return message\n .split('; ')\n .map((s) => s.trim())\n .filter(Boolean);\n}\n"],"mappings":";AA8BA,IAAa,IAAgB;CAC3B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,EAGY,IAAkD;CAC7D,mBAAmB;CACnB,0BAA0B;CAC1B,oBAAoB;CACpB,gBAAgB;CAChB,kBAAkB;CAClB,kBAAkB;CAClB,UAAU;CACV,mBAAmB;CACnB,eAAe;CACf,SAAS;CACT,QAAQ;CACT;AAKD,SAAgB,EAAiB,GAAuB;AACtD,QAAQ,EAA8C,MAAU;;AAmBlE,IAAa,IAAgD,IAAI,IAAI;CACnE;CACA;CACA;CACD,CAAC,EAIW,IAAuD,IAAI,IAAI;CAC1E;CACA;CACA;CACD,CAAC;AAGF,SAAgB,EAAoB,GAA8B;AAKhE,QAJI,MAAY,aAAmB,kBAC/B,EAA2B,IAAI,EAAQ,GAAS,2BAChD,EAAoB,IAAI,EAAQ,GAAS,yBACzC,MAAY,WAAiB,oBAC1B;;AAKT,SAAgB,EAAY,GAAqC;AAa/D,QAZI,EAA2B,IAAI,EAAQ,GAClC,+PAEL,MAAY,aACP,mJAEL,EAAoB,IAAI,EAAQ,GAC3B,wGAEL,MAAY,WACP,6FAEF;;AAGT,IAAa,IAAgB;CAAC;CAAU;C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AgB;EAAkB;EAAc;EAAY;EAAQ,GAC1E,EAAoB,IAAI,EAAQ,IAAI,MAAY,WAC3C;EAAC;EAAkB;EAAY;EAAQ,GACzC;EAAC;EAAgB;EAAkB;EAAY;EAAQ;;AAKhE,SAAgB,EAAqB,GAA0D;CAC7F,IAAM,IAA6C,EAAE;AACrD,MAAK,IAAM,KAAS,EAA+B,EAAQ,CACzD,GAAO,KAAS,EAA0B,IAAQ;AAEpD,QAAO;;AAUT,SAAgB,EAAuB,GAAqC;AAC1E,QAAO,EAA2B,IAAI,EAAQ,GAAG,EAAY,EAAQ,GAAG;;AAM1E,SAAgB,EAAgB,GAKd;AAYhB,QAXsB,EAAuB,EAAK,YAAY,KAE5B,EAAK,QAAQ,MAAM,MAAM,EAAE,SAAS,kBAAkB,GAC/E,IAGP,EAAK,gBAAgB,cACrB,CAAC,EAA0B,EAAK,kBAAkB,EAAK,0BAA0B,GAE1E,mGAEF;;AAUT,SAAgB,EAAqB,GAA8C;AAEjF,QADK,IACE,EACJ,MAAM,KAAK,CACX,KAAK,MAAM,EAAE,MAAM,CAAC,CACpB,OAAO,QAAQ,GAJG,EAAE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutomationRuleControls.d.ts","sourceRoot":"","sources":["../../../src/planmagnet/controls/AutomationRuleControls.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AutomationRuleControls.d.ts","sourceRoot":"","sources":["../../../src/planmagnet/controls/AutomationRuleControls.tsx"],"names":[],"mappings":"AAuBA;;;;GAIG;AAEH,eAAO,MAAM,uBAAuB,UAA+C,CAAC;AA0BpF;6FAC6F;AAC7F,wBAAgB,0BAA0B,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,2CAyChG;AAED,wBAAgB,0BAA0B,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,2CAsC5F;AAcD;8GAC8G;AAC9G,wBAAgB,uBAAuB,CAAC,EACtC,MAAM,EACN,SAAS,GACV,EAAE;IACD,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,2CA4GA"}
|
|
@@ -2,25 +2,27 @@ import { usePlanMagnetNavigate as e } from "../providers/PlanMagnetProvider.js";
|
|
|
2
2
|
import { LEAVES_PAGE_CONTEXT as t, throwOnError as n } from "../utils/mutationResult.js";
|
|
3
3
|
import { ConfirmButton as r, ErrorLine as i } from "./ConfirmButton.js";
|
|
4
4
|
import { WorkItemSearchSelect as a } from "./Pickers.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
5
|
+
import { isForbidden as o, mutationErrorMessage as s } from "../utils/graphqlErrors.js";
|
|
6
|
+
import { splitExecutionErrors as c } from "../automation/automationRuleTypes.js";
|
|
7
|
+
import { useState as l } from "react";
|
|
8
|
+
import { Play as u, Trash2 as d } from "lucide-react";
|
|
9
|
+
import { gql as f } from "@apollo/client";
|
|
10
|
+
import { useMutation as p } from "@apollo/client/react";
|
|
11
|
+
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
12
|
+
import { Badge as g, Button as _, ResponsiveDialog as v, ResponsiveDialogContent as y, ResponsiveDialogDescription as b, ResponsiveDialogFooter as x, ResponsiveDialogHeader as S, ResponsiveDialogTitle as C, ResponsiveDialogTrigger as w, Switch as T } from "@burdenoff/fe-libs/ui";
|
|
11
13
|
//#region src/planmagnet/controls/AutomationRuleControls.tsx
|
|
12
|
-
var
|
|
14
|
+
var E = ["AutomationRulesList", "GetAutomationRule"], D = f`
|
|
13
15
|
mutation AutomationRuleControlsToggle($id: ID!, $status: PlanmagnetAutomationStatus!) {
|
|
14
16
|
planmagnetToggleAutomationRule(id: $id, status: $status) {
|
|
15
17
|
id
|
|
16
18
|
status
|
|
17
19
|
}
|
|
18
20
|
}
|
|
19
|
-
`,
|
|
21
|
+
`, O = f`
|
|
20
22
|
mutation AutomationRuleControlsDelete($id: ID!) {
|
|
21
23
|
planmagnetDeleteAutomationRule(id: $id)
|
|
22
24
|
}
|
|
23
|
-
`,
|
|
25
|
+
`, k = f`
|
|
24
26
|
mutation AutomationRuleControlsExecute($id: ID!, $triggerData: JSON) {
|
|
25
27
|
planmagnetExecuteAutomationRule(id: $id, triggerData: $triggerData) {
|
|
26
28
|
id
|
|
@@ -30,143 +32,146 @@ var C = ["AutomationRulesList", "GetAutomationRule"], w = l`
|
|
|
30
32
|
}
|
|
31
33
|
}
|
|
32
34
|
`;
|
|
33
|
-
function
|
|
34
|
-
let [r, { loading: a }] =
|
|
35
|
-
|
|
35
|
+
function A({ ruleId: e, status: t }) {
|
|
36
|
+
let [r, { loading: a }] = p(D, { refetchQueries: E }), [c, u] = l(null), d = t === "ACTIVE", f = async (t) => {
|
|
37
|
+
u(null);
|
|
36
38
|
try {
|
|
37
39
|
await n(r({ variables: {
|
|
38
40
|
id: e,
|
|
39
41
|
status: t ? "ACTIVE" : "PAUSED"
|
|
40
42
|
} }));
|
|
41
43
|
} catch (e) {
|
|
42
|
-
|
|
44
|
+
u(o(e) ? "Your role can view automation rules but not change them." : s(e, "The rule could not be changed."));
|
|
43
45
|
}
|
|
44
46
|
};
|
|
45
|
-
return /* @__PURE__ */
|
|
47
|
+
return /* @__PURE__ */ h("div", {
|
|
46
48
|
className: "flex flex-col items-end gap-1",
|
|
47
|
-
children: [/* @__PURE__ */
|
|
49
|
+
children: [/* @__PURE__ */ h("div", {
|
|
48
50
|
className: "flex items-center gap-2",
|
|
49
|
-
children: [t !== "ACTIVE" && t !== "PAUSED" && /* @__PURE__ */
|
|
51
|
+
children: [t !== "ACTIVE" && t !== "PAUSED" && /* @__PURE__ */ m(g, {
|
|
50
52
|
variant: t === "ERROR" ? "destructive" : "secondary",
|
|
51
53
|
children: t.toLowerCase()
|
|
52
|
-
}), /* @__PURE__ */
|
|
53
|
-
"aria-label":
|
|
54
|
+
}), /* @__PURE__ */ m(T, {
|
|
55
|
+
"aria-label": d ? "Active — turn off to pause" : "Paused — turn on to activate",
|
|
54
56
|
"data-testid": "automation-rule-toggle",
|
|
55
|
-
checked:
|
|
57
|
+
checked: d,
|
|
56
58
|
disabled: a,
|
|
57
|
-
onCheckedChange: (e) => void
|
|
59
|
+
onCheckedChange: (e) => void f(e)
|
|
58
60
|
})]
|
|
59
|
-
}),
|
|
61
|
+
}), c && /* @__PURE__ */ m(i, { message: c })]
|
|
60
62
|
});
|
|
61
63
|
}
|
|
62
|
-
function
|
|
63
|
-
let
|
|
64
|
-
refetchQueries:
|
|
64
|
+
function j({ ruleId: a, name: c }) {
|
|
65
|
+
let u = e(), [f, { loading: g }] = p(O, {
|
|
66
|
+
refetchQueries: E.filter((e) => e !== "GetAutomationRule"),
|
|
65
67
|
context: t
|
|
66
|
-
}), [
|
|
67
|
-
|
|
68
|
+
}), [_, v] = l(null), y = async () => {
|
|
69
|
+
v(null);
|
|
68
70
|
try {
|
|
69
|
-
await n(
|
|
71
|
+
await n(f({ variables: { id: a } })), u("/automation/automation-rules-page");
|
|
70
72
|
} catch (e) {
|
|
71
|
-
|
|
73
|
+
v(o(e) ? "Your role can view automation rules but not delete them." : s(e, "The rule could not be deleted."));
|
|
72
74
|
}
|
|
73
75
|
};
|
|
74
|
-
return /* @__PURE__ */
|
|
76
|
+
return /* @__PURE__ */ h("div", {
|
|
75
77
|
className: "flex flex-col items-end gap-1",
|
|
76
|
-
children: [/* @__PURE__ */
|
|
78
|
+
children: [/* @__PURE__ */ m(r, {
|
|
77
79
|
label: "Delete",
|
|
78
80
|
variant: "outline",
|
|
79
|
-
icon: /* @__PURE__ */ d
|
|
80
|
-
title: `Delete "${
|
|
81
|
+
icon: /* @__PURE__ */ m(d, { className: "mr-1 h-4 w-4" }),
|
|
82
|
+
title: `Delete "${c}"?`,
|
|
81
83
|
description: "The rule stops running and its history stays as a record. This cannot be undone here.",
|
|
82
84
|
confirmLabel: "Delete rule",
|
|
83
85
|
destructive: !0,
|
|
84
|
-
disabled:
|
|
85
|
-
onConfirm: () => void
|
|
86
|
-
}),
|
|
86
|
+
disabled: g,
|
|
87
|
+
onConfirm: () => void y()
|
|
88
|
+
}), _ && /* @__PURE__ */ m(i, { message: _ })]
|
|
87
89
|
});
|
|
88
90
|
}
|
|
89
|
-
var
|
|
91
|
+
var M = {
|
|
90
92
|
SUCCESS: "success",
|
|
91
93
|
PARTIAL_FAILURE: "warning",
|
|
92
94
|
FAILURE: "destructive",
|
|
93
95
|
SKIPPED: "secondary"
|
|
94
96
|
};
|
|
95
|
-
function
|
|
96
|
-
let [r,
|
|
97
|
-
refetchQueries: ["AutomationExecutionsForRule", ...
|
|
97
|
+
function N({ ruleId: e, projectId: t }) {
|
|
98
|
+
let [r, d] = l(!1), [f, T] = l(""), [D, O] = l(null), [A, j] = l(null), [N, { loading: P }] = p(k, {
|
|
99
|
+
refetchQueries: ["AutomationExecutionsForRule", ...E],
|
|
98
100
|
awaitRefetchQueries: !0
|
|
99
|
-
}),
|
|
100
|
-
if (
|
|
101
|
-
|
|
101
|
+
}), F = async () => {
|
|
102
|
+
if (f) {
|
|
103
|
+
O(null), j(null);
|
|
102
104
|
try {
|
|
103
|
-
|
|
105
|
+
j((await n(N({ variables: {
|
|
104
106
|
id: e,
|
|
105
|
-
triggerData: { workItemId:
|
|
107
|
+
triggerData: { workItemId: f }
|
|
106
108
|
} }))).data?.planmagnetExecuteAutomationRule ?? null);
|
|
107
109
|
} catch (e) {
|
|
108
|
-
|
|
110
|
+
O(o(e) ? "Your role can view automation rules but not run them." : s(e, "The rule could not be run."));
|
|
109
111
|
}
|
|
110
112
|
}
|
|
111
113
|
};
|
|
112
|
-
return /* @__PURE__ */
|
|
114
|
+
return /* @__PURE__ */ h(v, {
|
|
113
115
|
open: r,
|
|
114
116
|
onOpenChange: (e) => {
|
|
115
|
-
|
|
117
|
+
d(e), e && (T(""), O(null), j(null));
|
|
116
118
|
},
|
|
117
|
-
children: [/* @__PURE__ */
|
|
119
|
+
children: [/* @__PURE__ */ m(w, {
|
|
118
120
|
asChild: !0,
|
|
119
|
-
children: /* @__PURE__ */
|
|
121
|
+
children: /* @__PURE__ */ h(_, {
|
|
120
122
|
size: "sm",
|
|
121
123
|
variant: "outline",
|
|
122
124
|
"data-testid": "automation-run-now",
|
|
123
|
-
children: [/* @__PURE__ */
|
|
125
|
+
children: [/* @__PURE__ */ m(u, { className: "mr-1 h-4 w-4" }), "Run now"]
|
|
124
126
|
})
|
|
125
|
-
}), /* @__PURE__ */
|
|
127
|
+
}), /* @__PURE__ */ h(y, {
|
|
126
128
|
className: "max-w-lg",
|
|
127
129
|
children: [
|
|
128
|
-
/* @__PURE__ */
|
|
129
|
-
/* @__PURE__ */
|
|
130
|
+
/* @__PURE__ */ h(S, { children: [/* @__PURE__ */ m(C, { children: "Run this rule now" }), /* @__PURE__ */ m(b, { children: "Evaluates the rule's conditions against one work item and, if they match, dispatches its actions for real. The outcome is recorded below and in Recent executions either way." })] }),
|
|
131
|
+
/* @__PURE__ */ h("div", {
|
|
130
132
|
className: "space-y-3",
|
|
131
133
|
children: [
|
|
132
|
-
/* @__PURE__ */
|
|
134
|
+
/* @__PURE__ */ h("div", { children: [/* @__PURE__ */ m("label", {
|
|
133
135
|
htmlFor: "automation-run-work-item",
|
|
134
136
|
className: "text-sm font-medium",
|
|
135
137
|
children: "Work item"
|
|
136
|
-
}), /* @__PURE__ */
|
|
138
|
+
}), /* @__PURE__ */ m("div", {
|
|
137
139
|
className: "mt-1",
|
|
138
|
-
children: /* @__PURE__ */
|
|
140
|
+
children: /* @__PURE__ */ m(a, {
|
|
139
141
|
id: "automation-run-work-item",
|
|
140
142
|
projectId: t,
|
|
141
|
-
value:
|
|
142
|
-
onChange:
|
|
143
|
+
value: f,
|
|
144
|
+
onChange: T
|
|
143
145
|
})
|
|
144
146
|
})] }),
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
D && /* @__PURE__ */ m(i, { message: D }),
|
|
148
|
+
A && /* @__PURE__ */ h("div", {
|
|
147
149
|
role: "status",
|
|
148
150
|
className: "rounded-md border p-3 text-sm space-y-1",
|
|
149
|
-
children: [/* @__PURE__ */
|
|
150
|
-
variant:
|
|
151
|
-
children:
|
|
152
|
-
}),
|
|
153
|
-
className:
|
|
154
|
-
children:
|
|
151
|
+
children: [/* @__PURE__ */ m(g, {
|
|
152
|
+
variant: M[A.status] ?? "secondary",
|
|
153
|
+
children: A.status.toLowerCase().replace("_", " ")
|
|
154
|
+
}), A.errorMessage && /* @__PURE__ */ m("ul", {
|
|
155
|
+
className: "space-y-0.5",
|
|
156
|
+
children: c(A.errorMessage).map((e, t) => /* @__PURE__ */ m("li", {
|
|
157
|
+
className: A.status === "SUCCESS" ? "text-muted-foreground" : "text-destructive",
|
|
158
|
+
children: e
|
|
159
|
+
}, t))
|
|
155
160
|
})]
|
|
156
161
|
})
|
|
157
162
|
]
|
|
158
163
|
}),
|
|
159
|
-
/* @__PURE__ */
|
|
160
|
-
onClick: () => void
|
|
161
|
-
disabled: !
|
|
164
|
+
/* @__PURE__ */ m(x, { children: /* @__PURE__ */ m(_, {
|
|
165
|
+
onClick: () => void F(),
|
|
166
|
+
disabled: !f || P,
|
|
162
167
|
"data-testid": "automation-run-submit",
|
|
163
|
-
children:
|
|
168
|
+
children: P ? "Running…" : "Run"
|
|
164
169
|
}) })
|
|
165
170
|
]
|
|
166
171
|
})]
|
|
167
172
|
});
|
|
168
173
|
}
|
|
169
174
|
//#endregion
|
|
170
|
-
export {
|
|
175
|
+
export { E as AUTOMATION_RULE_QUERIES, j as AutomationRuleDeleteButton, A as AutomationRuleStatusSwitch, N as RunAutomationRuleDialog };
|
|
171
176
|
|
|
172
177
|
//# sourceMappingURL=AutomationRuleControls.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutomationRuleControls.js","names":[],"sources":["../../../src/planmagnet/controls/AutomationRuleControls.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation } from '@apollo/client/react';\nimport {\n Badge,\n Button,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n ResponsiveDialogTrigger,\n Switch,\n} from '@burdenoff/fe-libs/ui';\nimport { Play, Trash2 } from 'lucide-react';\nimport { WorkItemSearchSelect } from './Pickers';\nimport { ConfirmButton, ErrorLine } from './ConfirmButton';\nimport { throwOnError, LEAVES_PAGE_CONTEXT } from '../utils/mutationResult';\nimport { usePlanMagnetNavigate } from '../providers/PlanMagnetProvider';\n\n/**\n * Automation rule controls (BOFF-8047): enable/disable, delete and \"run now\". Every automation rule row and its\n * detail page carry these — before this, `planmagnetToggleAutomationRule`, `planmagnetDeleteAutomationRule` and\n * `planmagnetExecuteAutomationRule` were real, prod-verified mutations with no UI trigger anywhere.\n */\n\nexport const AUTOMATION_RULE_QUERIES = ['AutomationRulesList', 'GetAutomationRule'];\n\nconst TOGGLE = gql`\n mutation AutomationRuleControlsToggle($id: ID!, $status: PlanmagnetAutomationStatus!) {\n planmagnetToggleAutomationRule(id: $id, status: $status) {\n id\n status\n }\n }\n`;\nconst DELETE = gql`\n mutation AutomationRuleControlsDelete($id: ID!) {\n planmagnetDeleteAutomationRule(id: $id)\n }\n`;\nconst EXECUTE = gql`\n mutation AutomationRuleControlsExecute($id: ID!, $triggerData: JSON) {\n planmagnetExecuteAutomationRule(id: $id, triggerData: $triggerData) {\n id\n status\n errorMessage\n result\n }\n }\n`;\n\n/** ACTIVE <-> PAUSED. A rule stuck in DISABLED or ERROR is re-activated by turning this on; the raw status is\n * shown alongside so a paused-by-error rule is never confused with a manually paused one. */\nexport function AutomationRuleStatusSwitch({ ruleId, status }: { ruleId: string; status: string }) {\n const [toggle, { loading }] = useMutation(TOGGLE, {\n refetchQueries: AUTOMATION_RULE_QUERIES,\n });\n const [error, setError] = useState<string | null>(null);\n const active = status === 'ACTIVE';\n\n const onChange = async (checked: boolean) => {\n setError(null);\n try {\n await throwOnError(\n toggle({ variables: { id: ruleId, status: checked ? 'ACTIVE' : 'PAUSED' } })\n );\n } catch (e) {\n setError(e instanceof Error ? e.message : 'The rule could not be changed.');\n }\n };\n\n return (\n <div className=\"flex flex-col items-end gap-1\">\n <div className=\"flex items-center gap-2\">\n {status !== 'ACTIVE' && status !== 'PAUSED' && (\n <Badge variant={status === 'ERROR' ? 'destructive' : 'secondary'}>\n {status.toLowerCase()}\n </Badge>\n )}\n <Switch\n aria-label={active ? 'Active — turn off to pause' : 'Paused — turn on to activate'}\n data-testid=\"automation-rule-toggle\"\n checked={active}\n disabled={loading}\n onCheckedChange={(checked) => void onChange(checked)}\n />\n </div>\n {error && <ErrorLine message={error} />}\n </div>\n );\n}\n\nexport function AutomationRuleDeleteButton({ ruleId, name }: { ruleId: string; name: string }) {\n const navigate = usePlanMagnetNavigate();\n const [remove, { loading }] = useMutation(DELETE, {\n refetchQueries: AUTOMATION_RULE_QUERIES.filter((q) => q !== 'GetAutomationRule'),\n context: LEAVES_PAGE_CONTEXT,\n });\n const [error, setError] = useState<string | null>(null);\n\n const onDelete = async () => {\n setError(null);\n try {\n await throwOnError(remove({ variables: { id: ruleId } }));\n navigate('/automation/automation-rules-page');\n } catch (e) {\n setError(e instanceof Error ? e.message : 'The rule could not be deleted.');\n }\n };\n\n return (\n <div className=\"flex flex-col items-end gap-1\">\n <ConfirmButton\n label=\"Delete\"\n variant=\"outline\"\n icon={<Trash2 className=\"mr-1 h-4 w-4\" />}\n title={`Delete \"${name}\"?`}\n description=\"The rule stops running and its history stays as a record. This cannot be undone here.\"\n confirmLabel=\"Delete rule\"\n destructive\n disabled={loading}\n onConfirm={() => void onDelete()}\n />\n {error && <ErrorLine message={error} />}\n </div>\n );\n}\n\ninterface ExecuteResult {\n status: string;\n errorMessage: string | null;\n}\n\nconst OUTCOME_VARIANT: Record<string, 'success' | 'warning' | 'destructive' | 'secondary'> = {\n SUCCESS: 'success',\n PARTIAL_FAILURE: 'warning',\n FAILURE: 'destructive',\n SKIPPED: 'secondary',\n};\n\n/** Runs a rule against one chosen work item — works for a rule of ANY trigger type, including the ones that\n * cannot fire on their own (see automationRuleTypes.ts). Always records an outcome, including a non-match. */\nexport function RunAutomationRuleDialog({\n ruleId,\n projectId,\n}: {\n ruleId: string;\n projectId?: string;\n}) {\n const [open, setOpen] = useState(false);\n const [workItemId, setWorkItemId] = useState('');\n const [error, setError] = useState<string | null>(null);\n const [outcome, setOutcome] = useState<ExecuteResult | null>(null);\n const [execute, { loading }] = useMutation<{ planmagnetExecuteAutomationRule: ExecuteResult }>(\n EXECUTE,\n {\n refetchQueries: ['AutomationExecutionsForRule', ...AUTOMATION_RULE_QUERIES],\n awaitRefetchQueries: true,\n }\n );\n\n const run = async () => {\n if (!workItemId) return;\n setError(null);\n setOutcome(null);\n try {\n const result = await throwOnError(\n execute({ variables: { id: ruleId, triggerData: { workItemId } } })\n );\n const execution = result.data?.planmagnetExecuteAutomationRule ?? null;\n setOutcome(execution);\n } catch (e) {\n setError(e instanceof Error ? e.message : 'The rule could not be run.');\n }\n };\n\n return (\n <ResponsiveDialog\n open={open}\n onOpenChange={(next) => {\n setOpen(next);\n if (next) {\n setWorkItemId('');\n setError(null);\n setOutcome(null);\n }\n }}\n >\n <ResponsiveDialogTrigger asChild>\n <Button size=\"sm\" variant=\"outline\" data-testid=\"automation-run-now\">\n <Play className=\"mr-1 h-4 w-4\" />\n Run now\n </Button>\n </ResponsiveDialogTrigger>\n <ResponsiveDialogContent className=\"max-w-lg\">\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>Run this rule now</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n Evaluates the rule's conditions against one work item and, if they match,\n dispatches its actions for real. The outcome is recorded below and in Recent executions\n either way.\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n <div className=\"space-y-3\">\n <div>\n <label htmlFor=\"automation-run-work-item\" className=\"text-sm font-medium\">\n Work item\n </label>\n <div className=\"mt-1\">\n <WorkItemSearchSelect\n id=\"automation-run-work-item\"\n projectId={projectId}\n value={workItemId}\n onChange={setWorkItemId}\n />\n </div>\n </div>\n {error && <ErrorLine message={error} />}\n {outcome && (\n <div role=\"status\" className=\"rounded-md border p-3 text-sm space-y-1\">\n <Badge variant={OUTCOME_VARIANT[outcome.status] ?? 'secondary'}>\n {outcome.status.toLowerCase().replace('_', ' ')}\n </Badge>\n {outcome.errorMessage && (\n <p\n className={\n outcome.status === 'SUCCESS' ? 'text-muted-foreground' : 'text-destructive'\n }\n >\n {outcome.errorMessage}\n </p>\n )}\n </div>\n )}\n </div>\n <ResponsiveDialogFooter>\n <Button\n onClick={() => void run()}\n disabled={!workItemId || loading}\n data-testid=\"automation-run-submit\"\n >\n {loading ? 'Running…' : 'Run'}\n </Button>\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n}\n"],"mappings":";;;;;;;;;;;AA2BA,IAAa,IAA0B,CAAC,uBAAuB,oBAAoB,EAE7E,IAAS,CAAG;;;;;;;GAQZ,IAAS,CAAG;;;;GAKZ,IAAU,CAAG;;;;;;;;;;AAanB,SAAgB,EAA2B,EAAE,WAAQ,aAA8C;CACjG,IAAM,CAAC,GAAQ,EAAE,gBAAa,EAAY,GAAQ,EAChD,gBAAgB,GACjB,CAAC,EACI,CAAC,GAAO,KAAY,EAAwB,KAAK,EACjD,IAAS,MAAW,UAEpB,IAAW,OAAO,MAAqB;AAC3C,IAAS,KAAK;AACd,MAAI;AACF,SAAM,EACJ,EAAO,EAAE,WAAW;IAAE,IAAI;IAAQ,QAAQ,IAAU,WAAW;IAAU,EAAE,CAAC,CAC7E;WACM,GAAG;AACV,KAAS,aAAa,QAAQ,EAAE,UAAU,iCAAiC;;;AAI/E,QACE,kBAAC,OAAD;E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L,KAAS,kBAAC,GAAD,EAAW,SAAS,GAAS,CAAA;MACtC,KACC,kBAAC,OAAD;OAAK,MAAK;OAAS,WAAU;iBAA7B,CACE,kBAAC,GAAD;QAAO,SAAS,EAAgB,EAAQ,WAAW;kBAChD,EAAQ,OAAO,aAAa,CAAC,QAAQ,KAAK,IAAI;QACzC,CAAA,EACP,EAAQ,gBACP,kBAAC,KAAD;QACE,WACE,EAAQ,WAAW,YAAY,0BAA0B;kBAG1D,EAAQ;QACP,CAAA,CAEF;;MAEJ;;IACN,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;KACE,eAAe,KAAK,GAAK;KACzB,UAAU,CAAC,KAAc;KACzB,eAAY;eAEX,IAAU,aAAa;KACjB,CAAA,EACc,CAAA;IACD;KACT"}
|
|
1
|
+
{"version":3,"file":"AutomationRuleControls.js","names":[],"sources":["../../../src/planmagnet/controls/AutomationRuleControls.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation } from '@apollo/client/react';\nimport {\n Badge,\n Button,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n ResponsiveDialogTrigger,\n Switch,\n} from '@burdenoff/fe-libs/ui';\nimport { Play, Trash2 } from 'lucide-react';\nimport { WorkItemSearchSelect } from './Pickers';\nimport { ConfirmButton, ErrorLine } from './ConfirmButton';\nimport { throwOnError, LEAVES_PAGE_CONTEXT } from '../utils/mutationResult';\nimport { isForbidden, mutationErrorMessage } from '../utils/graphqlErrors';\nimport { usePlanMagnetNavigate } from '../providers/PlanMagnetProvider';\nimport { splitExecutionErrors } from '../automation/automationRuleTypes';\n\n/**\n * Automation rule controls (BOFF-8047): enable/disable, delete and \"run now\". Every automation rule row and its\n * detail page carry these — before this, `planmagnetToggleAutomationRule`, `planmagnetDeleteAutomationRule` and\n * `planmagnetExecuteAutomationRule` were real, prod-verified mutations with no UI trigger anywhere.\n */\n\nexport const AUTOMATION_RULE_QUERIES = ['AutomationRulesList', 'GetAutomationRule'];\n\nconst TOGGLE = gql`\n mutation AutomationRuleControlsToggle($id: ID!, $status: PlanmagnetAutomationStatus!) {\n planmagnetToggleAutomationRule(id: $id, status: $status) {\n id\n status\n }\n }\n`;\nconst DELETE = gql`\n mutation AutomationRuleControlsDelete($id: ID!) {\n planmagnetDeleteAutomationRule(id: $id)\n }\n`;\nconst EXECUTE = gql`\n mutation AutomationRuleControlsExecute($id: ID!, $triggerData: JSON) {\n planmagnetExecuteAutomationRule(id: $id, triggerData: $triggerData) {\n id\n status\n errorMessage\n result\n }\n }\n`;\n\n/** ACTIVE <-> PAUSED. A rule stuck in DISABLED or ERROR is re-activated by turning this on; the raw status is\n * shown alongside so a paused-by-error rule is never confused with a manually paused one. */\nexport function AutomationRuleStatusSwitch({ ruleId, status }: { ruleId: string; status: string }) {\n const [toggle, { loading }] = useMutation(TOGGLE, {\n refetchQueries: AUTOMATION_RULE_QUERIES,\n });\n const [error, setError] = useState<string | null>(null);\n const active = status === 'ACTIVE';\n\n const onChange = async (checked: boolean) => {\n setError(null);\n try {\n await throwOnError(\n toggle({ variables: { id: ruleId, status: checked ? 'ACTIVE' : 'PAUSED' } })\n );\n } catch (e) {\n setError(\n isForbidden(e)\n ? 'Your role can view automation rules but not change them.'\n : mutationErrorMessage(e, 'The rule could not be changed.')\n );\n }\n };\n\n return (\n <div className=\"flex flex-col items-end gap-1\">\n <div className=\"flex items-center gap-2\">\n {status !== 'ACTIVE' && status !== 'PAUSED' && (\n <Badge variant={status === 'ERROR' ? 'destructive' : 'secondary'}>\n {status.toLowerCase()}\n </Badge>\n )}\n <Switch\n aria-label={active ? 'Active — turn off to pause' : 'Paused — turn on to activate'}\n data-testid=\"automation-rule-toggle\"\n checked={active}\n disabled={loading}\n onCheckedChange={(checked) => void onChange(checked)}\n />\n </div>\n {error && <ErrorLine message={error} />}\n </div>\n );\n}\n\nexport function AutomationRuleDeleteButton({ ruleId, name }: { ruleId: string; name: string }) {\n const navigate = usePlanMagnetNavigate();\n const [remove, { loading }] = useMutation(DELETE, {\n refetchQueries: AUTOMATION_RULE_QUERIES.filter((q) => q !== 'GetAutomationRule'),\n context: LEAVES_PAGE_CONTEXT,\n });\n const [error, setError] = useState<string | null>(null);\n\n const onDelete = async () => {\n setError(null);\n try {\n await throwOnError(remove({ variables: { id: ruleId } }));\n navigate('/automation/automation-rules-page');\n } catch (e) {\n setError(\n isForbidden(e)\n ? 'Your role can view automation rules but not delete them.'\n : mutationErrorMessage(e, 'The rule could not be deleted.')\n );\n }\n };\n\n return (\n <div className=\"flex flex-col items-end gap-1\">\n <ConfirmButton\n label=\"Delete\"\n variant=\"outline\"\n icon={<Trash2 className=\"mr-1 h-4 w-4\" />}\n title={`Delete \"${name}\"?`}\n description=\"The rule stops running and its history stays as a record. This cannot be undone here.\"\n confirmLabel=\"Delete rule\"\n destructive\n disabled={loading}\n onConfirm={() => void onDelete()}\n />\n {error && <ErrorLine message={error} />}\n </div>\n );\n}\n\ninterface ExecuteResult {\n status: string;\n errorMessage: string | null;\n}\n\nconst OUTCOME_VARIANT: Record<string, 'success' | 'warning' | 'destructive' | 'secondary'> = {\n SUCCESS: 'success',\n PARTIAL_FAILURE: 'warning',\n FAILURE: 'destructive',\n SKIPPED: 'secondary',\n};\n\n/** Runs a rule against one chosen work item — works for a rule of ANY trigger type, including the ones that\n * cannot fire on their own (see automationRuleTypes.ts). Always records an outcome, including a non-match. */\nexport function RunAutomationRuleDialog({\n ruleId,\n projectId,\n}: {\n ruleId: string;\n projectId?: string;\n}) {\n const [open, setOpen] = useState(false);\n const [workItemId, setWorkItemId] = useState('');\n const [error, setError] = useState<string | null>(null);\n const [outcome, setOutcome] = useState<ExecuteResult | null>(null);\n const [execute, { loading }] = useMutation<{ planmagnetExecuteAutomationRule: ExecuteResult }>(\n EXECUTE,\n {\n refetchQueries: ['AutomationExecutionsForRule', ...AUTOMATION_RULE_QUERIES],\n awaitRefetchQueries: true,\n }\n );\n\n const run = async () => {\n if (!workItemId) return;\n setError(null);\n setOutcome(null);\n try {\n const result = await throwOnError(\n execute({ variables: { id: ruleId, triggerData: { workItemId } } })\n );\n const execution = result.data?.planmagnetExecuteAutomationRule ?? null;\n setOutcome(execution);\n } catch (e) {\n setError(\n isForbidden(e)\n ? 'Your role can view automation rules but not run them.'\n : mutationErrorMessage(e, 'The rule could not be run.')\n );\n }\n };\n\n return (\n <ResponsiveDialog\n open={open}\n onOpenChange={(next) => {\n setOpen(next);\n if (next) {\n setWorkItemId('');\n setError(null);\n setOutcome(null);\n }\n }}\n >\n <ResponsiveDialogTrigger asChild>\n <Button size=\"sm\" variant=\"outline\" data-testid=\"automation-run-now\">\n <Play className=\"mr-1 h-4 w-4\" />\n Run now\n </Button>\n </ResponsiveDialogTrigger>\n <ResponsiveDialogContent className=\"max-w-lg\">\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>Run this rule now</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n Evaluates the rule's conditions against one work item and, if they match,\n dispatches its actions for real. The outcome is recorded below and in Recent executions\n either way.\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n <div className=\"space-y-3\">\n <div>\n <label htmlFor=\"automation-run-work-item\" className=\"text-sm font-medium\">\n Work item\n </label>\n <div className=\"mt-1\">\n <WorkItemSearchSelect\n id=\"automation-run-work-item\"\n projectId={projectId}\n value={workItemId}\n onChange={setWorkItemId}\n />\n </div>\n </div>\n {error && <ErrorLine message={error} />}\n {outcome && (\n <div role=\"status\" className=\"rounded-md border p-3 text-sm space-y-1\">\n <Badge variant={OUTCOME_VARIANT[outcome.status] ?? 'secondary'}>\n {outcome.status.toLowerCase().replace('_', ' ')}\n </Badge>\n {outcome.errorMessage && (\n <ul className=\"space-y-0.5\">\n {splitExecutionErrors(outcome.errorMessage).map((line, i) => (\n <li\n key={i}\n className={\n outcome.status === 'SUCCESS' ? 'text-muted-foreground' : 'text-destructive'\n }\n >\n {line}\n </li>\n ))}\n </ul>\n )}\n </div>\n )}\n </div>\n <ResponsiveDialogFooter>\n <Button\n onClick={() => void run()}\n disabled={!workItemId || loading}\n data-testid=\"automation-run-submit\"\n >\n {loading ? 'Running…' : 'Run'}\n </Button>\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AA6BA,IAAa,IAA0B,CAAC,uBAAuB,oBAAoB,EAE7E,IAAS,CAAG;;;;;;;GAQZ,IAAS,CAAG;;;;GAKZ,IAAU,CAAG;;;;;;;;;;AAanB,SAAgB,EAA2B,EAAE,WAAQ,aAA8C;CACjG,IAAM,CAAC,GAAQ,EAAE,gBAAa,EAAY,GAAQ,EAChD,gBAAgB,GACjB,CAAC,EACI,CAAC,GAAO,KAAY,EAAwB,KAAK,EACjD,IAAS,MAAW,UAEpB,IAAW,OAAO,MAAqB;AAC3C,IAAS,KAAK;AACd,MAAI;AACF,SAAM,EACJ,EAAO,EAAE,WAAW;IAAE,IAAI;IAAQ,QAAQ,IAAU,WAAW;IAAU,EAAE,CAAC,CAC7E;WACM,GAAG;AACV,KACE,EAAY,EAAE,GACV,6DACA,EAAqB,GAAG,iCAAiC,CAC9D;;;AAIL,QACE,kBAAC,OAAD;EAAK,WAAU;YAAf,CACE,kBAAC,OAAD;GAAK,WAAU;aAAf,CACG,MAAW,YAAY,MAAW,YACjC,kBAAC,GAAD;IAAO,SAAS,MAAW,UAAU,gBAAgB;cAClD,EAAO,aAAa;IACf,CAAA,EAEV,kBAAC,GAAD;IACE,cAAY,IAAS,+BAA+B;IACpD,eAAY;IACZ,SAAS;IACT,UAAU;IACV,kBAAkB,MAAY,KAAK,EAAS,EAAQ;IACpD,CAAA,CACE;MACL,KAAS,kBAAC,GAAD,EAAW,SAAS,GAAS,CAAA,CACnC;;;AAIV,SAAgB,EAA2B,EAAE,WAAQ,WAA0C;CAC7F,IAAM,IAAW,GAAuB,EAClC,CAAC,GAAQ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CAEH;;MAEJ;;IACN,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;KACE,eAAe,KAAK,GAAK;KACzB,UAAU,CAAC,KAAc;KACzB,eAAY;eAEX,IAAU,aAAa;KACjB,CAAA,EACc,CAAA;IACD;KACT"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { ConflictResolution, RunHealth, SyncDirection, SyncRunResult } from '../integrations/syncTypes';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Shared row/detail controls for External Sync (AUT-09/10/24/40): status badges, health, run/pause/resume/test
|
|
5
|
+
* actions and conflict resolution. Every write here follows the same two rules the rest of this MFE does
|
|
6
|
+
* (`utils/mutationResult.ts`, `utils/graphqlErrors.ts`): a refused mutation is surfaced, never swallowed, and a
|
|
7
|
+
* FORBIDDEN refusal reads as "your role can view but not change this" rather than a raw GraphQL error string —
|
|
8
|
+
* this page cannot know ahead of time whether the viewer's role allows a given write, so it always offers the
|
|
9
|
+
* action and reports the refusal if and when it happens, rather than guessing at a client-side role check.
|
|
10
|
+
*/
|
|
11
|
+
export declare const SYNC_LIST_QUERIES: string[];
|
|
12
|
+
export declare const SYNC_DETAIL_QUERIES: string[];
|
|
13
|
+
export declare function SyncStatusBadge({ status }: {
|
|
14
|
+
status: string;
|
|
15
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare function SyncRunStatusBadge({ status }: {
|
|
17
|
+
status: string;
|
|
18
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
export declare function ConflictStatusBadge({ status }: {
|
|
20
|
+
status: string;
|
|
21
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
/** A long string (a sync's `lastSyncError`, an issue body) collapsed to `max` chars with an expand toggle. */
|
|
23
|
+
export declare function TruncatedText({ text, max, className, testId, }: {
|
|
24
|
+
text: string;
|
|
25
|
+
max?: number;
|
|
26
|
+
className?: string;
|
|
27
|
+
testId?: string;
|
|
28
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
/**
|
|
30
|
+
* Last run time/status + consecutive-failure streak (AUT-09/22). `consecutiveFailures` is 0 once the latest run
|
|
31
|
+
* did not fail — highlighted only while it is actually nonzero, never merely because the last run failed once
|
|
32
|
+
* and then recovered.
|
|
33
|
+
*/
|
|
34
|
+
export declare function SyncHealthSummary({ health }: {
|
|
35
|
+
health: RunHealth;
|
|
36
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
/** "Run now" (AUT-40): starts a sync in the direction `ExternalSync.direction` already records, and reports the
|
|
38
|
+
* real result — including an honest `NOT_IMPLEMENTED` outcome for a provider with no live connector, never a
|
|
39
|
+
* fabricated success. */
|
|
40
|
+
export declare function RunNowButton({ syncId, onResult, size, }: {
|
|
41
|
+
syncId: string;
|
|
42
|
+
onResult?: (result: SyncRunResult) => void;
|
|
43
|
+
size?: 'sm' | 'default';
|
|
44
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
/**
|
|
46
|
+
* What `planmagnetStartSync` actually did (AUT-40). A completed run is a normal GraphQL success even when the
|
|
47
|
+
* sync itself failed on every item — bad token, unreachable provider, a refused status transition, … — the
|
|
48
|
+
* service records `success: false` with `errors` populated rather than throwing (see
|
|
49
|
+
* `sync.service.ts`'s `runGithubImport`/`runGithubExport`). This is the one place that outcome is rendered, so
|
|
50
|
+
* every `RunNowButton` call site wires its `onResult` here instead of relying on a delayed list/detail refetch.
|
|
51
|
+
*/
|
|
52
|
+
export declare function SyncRunResultSummary({ result }: {
|
|
53
|
+
result: SyncRunResult;
|
|
54
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
55
|
+
/** Pause when active, Resume when PAUSED — the only two states these two mutations move between. */
|
|
56
|
+
export declare function PauseResumeButton({ syncId, status }: {
|
|
57
|
+
syncId: string;
|
|
58
|
+
status: string;
|
|
59
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
60
|
+
/** AUT-23/20 — probes the connection through the real connector, writing nothing. Offered whenever the page can
|
|
61
|
+
* reach it; a provider with no live connector still answers, honestly, with `ok: false`. */
|
|
62
|
+
export declare function TestConnectionButton({ syncId }: {
|
|
63
|
+
syncId: string;
|
|
64
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
65
|
+
export declare function DeleteSyncButton({ syncId, label,
|
|
66
|
+
/** Passed by the detail page, which leaves for the list afterward — see LEAVES_PAGE_CONTEXT's own doc. */
|
|
67
|
+
onDeleted, }: {
|
|
68
|
+
syncId: string;
|
|
69
|
+
label: string;
|
|
70
|
+
onDeleted?: () => void;
|
|
71
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
72
|
+
/** AUT-10/24 — SOURCE_WINS/TARGET_WINS actually push/pull the winning side's data; MANUAL just closes the flag.
|
|
73
|
+
* A refused or failed resolution (e.g. the provider call itself fails) throws server-side and leaves the
|
|
74
|
+
* conflict OPEN rather than recording a resolution that never happened — so on error this shows the reason and
|
|
75
|
+
* the conflict stays in the list exactly as it was. */
|
|
76
|
+
export declare function ConflictResolveActions({ conflictId }: {
|
|
77
|
+
conflictId: string;
|
|
78
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
79
|
+
export declare const CONFLICT_STRATEGY_EXPLANATION: Record<ConflictResolution, string>;
|
|
80
|
+
export interface EditableSync {
|
|
81
|
+
id: string;
|
|
82
|
+
provider: string;
|
|
83
|
+
direction: SyncDirection;
|
|
84
|
+
conflictStrategy: ConflictResolution;
|
|
85
|
+
fieldMapping: unknown;
|
|
86
|
+
syncFilters: unknown;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The one "Edit settings" surface for a sync: direction, conflict strategy, field mapping and sync filters, plus
|
|
90
|
+
* — for GITHUB only, where `connectionConfig`'s shape is real and known (`{ token, owner, repo }`) — an explicit
|
|
91
|
+
* "Replace connection" group. The token is never pre-filled (it reads back as `[REDACTED]`, which must never be
|
|
92
|
+
* echoed into the input or resent as if it were real); owner/repo are not secret and DO read back real values, so
|
|
93
|
+
* they pre-fill and stay editable. Because `PlanmagnetUpdateExternalSyncInput.connectionConfig` REPLACES the
|
|
94
|
+
* whole stored config rather than merging, changing owner or repo without also supplying a fresh token would
|
|
95
|
+
* discard the stored token — so the form requires all three together whenever any of the three changed, and
|
|
96
|
+
* sends none of them (keeping the stored connection untouched) when none did.
|
|
97
|
+
*/
|
|
98
|
+
export declare function EditSyncDialog({ sync }: {
|
|
99
|
+
sync: EditableSync;
|
|
100
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
101
|
+
//# sourceMappingURL=SyncControls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SyncControls.d.ts","sourceRoot":"","sources":["../../../src/planmagnet/controls/SyncControls.tsx"],"names":[],"mappings":"AAgCA,OAAO,EASL,KAAK,kBAAkB,EACvB,KAAK,SAAS,EAEd,KAAK,aAAa,EAClB,KAAK,aAAa,EAEnB,MAAM,2BAA2B,CAAC;AAEnC;;;;;;;GAOG;AAEH,eAAO,MAAM,iBAAiB,UAAgB,CAAC;AAC/C,eAAO,MAAM,mBAAmB,UAA8C,CAAC;AAc/E,wBAAgB,eAAe,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,2CAM7D;AAQD,wBAAgB,kBAAkB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,2CAMhE;AAED,wBAAgB,mBAAmB,CAAC,EAAE,MAAM,EAAE,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,2CAMjE;AAED,8GAA8G;AAC9G,wBAAgB,aAAa,CAAC,EAC5B,IAAI,EACJ,GAAS,EACT,SAAmC,EACnC,MAAM,GACP,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,2CAwBA;AAED;;;;GAIG;AACH,wB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