@e-llm-studio/instant-learning 1.3.0-alpha.19 → 1.3.0-alpha.20
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/README.md +150 -31
- package/dist/cjs/features/IL-OTJ/_components/MessageRendering/ClickableChatComponents.js +1 -1
- package/dist/cjs/features/LearningManagement/AuditLog/AuditLog.js +1 -1
- package/dist/cjs/features/LearningManagement/LearningManagement.js +1 -1
- package/dist/cjs/features/LearningManagement/RuleContent/AddScopeModal.js +1 -1
- package/dist/cjs/features/LearningManagement/RuleContent/ApprovalLearningDialog.js +1 -1
- package/dist/cjs/features/LearningManagement/RuleContent/RuleAccordionHeader.js +1 -1
- package/dist/cjs/features/LearningManagement/RuleContent/RuleContent.js +1 -1
- package/dist/cjs/features/LearningManagement/RuleContent/TierCard.js +1 -1
- package/dist/cjs/features/LearningManagement/RuleContent/VariantCard.js +1 -1
- package/dist/cjs/features/LearningManagement/Sidebar.js +1 -1
- package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js +1 -1
- package/dist/cjs/features/LearningManagement/components/ScopeTree/TreeNode.js +1 -1
- package/dist/cjs/features/LearningManagement/config.js +1 -1
- package/dist/cjs/features/LearningManagement/constants.js +2 -0
- package/dist/cjs/features/LearningManagement/constants.js.map +1 -0
- package/dist/cjs/features/LearningManagement/queries/useLMSConfigQuery.js +1 -1
- package/dist/cjs/features/LearningManagement/store/useLMSConfigStore.js +1 -1
- package/dist/cjs/plugins/ValueTypes/Default/DefaultTeachMeRenderer.js +1 -1
- package/dist/cjs/plugins/ValueTypes/Guidelines/GuidelinesTeachMeRenderer.js +1 -1
- package/dist/features/IL-OTJ/_components/MessageRendering/ClickableChatComponents.js +1 -1
- package/dist/features/LearningManagement/AuditLog/AuditLog.js +1 -1
- package/dist/features/LearningManagement/LearningManagement.js +1 -1
- package/dist/features/LearningManagement/RuleContent/AddScopeModal.js +1 -1
- package/dist/features/LearningManagement/RuleContent/ApprovalLearningDialog.js +1 -1
- package/dist/features/LearningManagement/RuleContent/RuleAccordionHeader.js +1 -1
- package/dist/features/LearningManagement/RuleContent/RuleContent.js +1 -1
- package/dist/features/LearningManagement/RuleContent/TierCard.js +1 -1
- package/dist/features/LearningManagement/RuleContent/VariantCard.js +1 -1
- package/dist/features/LearningManagement/Sidebar.js +1 -1
- package/dist/features/LearningManagement/components/InstantLearningModal.js +1 -1
- package/dist/features/LearningManagement/components/ScopeTree/TreeNode.js +1 -1
- package/dist/features/LearningManagement/config.js +1 -1
- package/dist/features/LearningManagement/constants.js +2 -0
- package/dist/features/LearningManagement/constants.js.map +1 -0
- package/dist/features/LearningManagement/queries/useLMSConfigQuery.js +1 -1
- package/dist/features/LearningManagement/store/useLMSConfigStore.js +1 -1
- package/dist/plugins/ValueTypes/Default/DefaultTeachMeRenderer.js +1 -1
- package/dist/plugins/ValueTypes/Guidelines/GuidelinesTeachMeRenderer.js +1 -1
- package/dist/types/src/features/IL-OTJ/_components/MessageRendering/ClickableChatComponents.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/AuditLog/AuditLog.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/LearningManagement.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/RuleContent/AddScopeModal.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/RuleContent/ApprovalLearningDialog.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/RuleContent/RuleAccordionHeader.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/RuleContent/RuleContent.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/RuleContent/TierCard.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/RuleContent/VariantCard.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/Sidebar.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/components/ScopeTree/TreeNode.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/constants.d.ts +8 -0
- package/dist/types/src/features/LearningManagement/constants.d.ts.map +1 -0
- package/dist/types/src/features/LearningManagement/queries/useLMSConfigQuery.d.ts +1 -1
- package/dist/types/src/features/LearningManagement/queries/useLMSConfigQuery.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/store/useLMSConfigStore.d.ts +16 -0
- package/dist/types/src/features/LearningManagement/store/useLMSConfigStore.d.ts.map +1 -1
- package/dist/types/src/plugins/ValueTypes/Default/DefaultTeachMeRenderer.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,67 +3,186 @@
|
|
|
3
3
|
|
|
4
4
|
## Changelog
|
|
5
5
|
|
|
6
|
-
### 1.3.0-alpha.
|
|
7
|
-
**
|
|
8
|
-
|
|
6
|
+
### 1.3.0-alpha.20 - 2026, June 8th
|
|
7
|
+
**TeachMe Popup — LHS Customisation via `dtt()`**
|
|
8
|
+
|
|
9
|
+
- **Chat Title**: Configurable for both Add and Edit modes via `teachMe.chatTitle` and `teachMe.chatTitleEdit`. Both support `{scope}` placeholder which is replaced at runtime with the selected scope name.
|
|
10
|
+
- **Welcome Message**: Configurable greeting via `teachMe.welcomeMessage`. Subtitle via `teachMe.welcomeMessageSubtitle` with full **Markdown** support rendered via `ReactMarkdown`.
|
|
11
|
+
- **Action Buttons**: Configurable via `teachMe.actions` array — each entry has a `label` (button text) and `value` (message sent to agent on click).
|
|
12
|
+
- **Textarea Placeholder**: Configurable via `teachMe.textareaPlaceholder`.
|
|
13
|
+
- **Backward Compatibility**: TeachMe popup customisation is supported with `backwardCompatibility` flag.
|
|
14
|
+
|
|
15
|
+
Keys added in this version:
|
|
16
|
+
|
|
17
|
+
| JSON Key | Default |
|
|
18
|
+
|---|---|
|
|
19
|
+
| `teachMe.chatTitle` | `"Teach Me OTJ - {scope} - Add Learning"` |
|
|
20
|
+
| `teachMe.chatTitleEdit` | `"Teach Me OTJ - {scope} - Edit Learning"` |
|
|
21
|
+
| `teachMe.welcomeMessageSubtitle` | `"How would you like to get started?..."` |
|
|
22
|
+
| `teachMe.actions` | Array of `{ label, value }` — see sample JSON in v17 |
|
|
23
|
+
| `teachMe.textareaPlaceholder` | `"Tell me more about this learning.."` |
|
|
9
24
|
|
|
10
|
-
-
|
|
11
|
-
**
|
|
25
|
+
### 1.3.0-alpha.19 - 2026, June 6th
|
|
26
|
+
- **Cognitive Compare UI**: Updated comparison UI with visual changes
|
|
27
|
+
- **GraphQL Params**: `userDetails` object is now passed through as a GraphQL parameter
|
|
28
|
+
|
|
29
|
+
### 1.3.0-alpha.18 - 2026, June 6th
|
|
30
|
+
Patch Fix: Removal of underscore for all labels
|
|
31
|
+
|
|
32
|
+
### 1.3.0-alpha.17 - 2026, June 6th
|
|
33
|
+
**Without BackwardCompatibiltity Support**
|
|
34
|
+
- **TeachMe Renderer**: Added valuetype json support to render teachMe popup and create rule from the same.
|
|
35
|
+
|
|
36
|
+
**Configurable UI via `dtt()`** — all LHS labels in the TeachMe popup are driven by `value_type_config.teachMe` JSON loaded per `appIntegrationId` and resolved at runtime through the `dtt()` helper.
|
|
37
|
+
|
|
38
|
+
**Supported keys:**
|
|
39
|
+
|
|
40
|
+
| JSON Key | Default |
|
|
41
|
+
|---|---|
|
|
42
|
+
| `teachMe.welcomeMessage` | `"Hi! 👋 I'm your Instant Learning Concierge."` |
|
|
43
|
+
| `teachMe.formTitle` | `"Rule setup"` |
|
|
44
|
+
| `teachMe.setupLabel` | `"Configure your IL"` |
|
|
45
|
+
| `teachMe.ruleTitle` | `"Main Rule Name"` |
|
|
46
|
+
| `teachMe.scopeLabel` | `"Define Scope"` |
|
|
47
|
+
| `teachMe.tierLabel` | `"Select Tiers"` |
|
|
48
|
+
| `teachMe.ruleDescriptionTitle` | `"Learning Explanation"` |
|
|
49
|
+
| `teachMe.whenToApplyTitle` | `"Trigger Events (When to Apply)"` |
|
|
50
|
+
| `teachMe.addWhenToApplyBtnLabel` | `"Add WTA"` |
|
|
51
|
+
| `teachMe.whenNotToApplyTitle` | `"Exclusion Events (When NOT to Apply)"` |
|
|
52
|
+
| `teachMe.addWhenNotToApplyBtnLabel` | `"Add WNTA"` |
|
|
53
|
+
| `teachMe.configTitle` | `"Advanced Settings"` |
|
|
54
|
+
| `teachMe.saveBtnLabel` | `"Save Rule"` |
|
|
55
|
+
| `teachMe.saveBtnLoadingLabel` | `"Saving Rule..."` |
|
|
56
|
+
| `teachMe.showConfiguration` | `false` |
|
|
57
|
+
| `teachMe.showScope` | `false` |
|
|
58
|
+
|
|
59
|
+
**Full sample `value_type_config` JSON:**
|
|
60
|
+
|
|
61
|
+
```json
|
|
62
|
+
{
|
|
63
|
+
"template": "Default",
|
|
64
|
+
"teachMe": {
|
|
65
|
+
"welcomeMessage": "Hi! 👋 I'm your Instant Learning Concierge.",
|
|
66
|
+
"welcomeMessageSubtitle": "How would you like to get started?\nYou can select an option below or **describe the rule** you'd like to create.",
|
|
67
|
+
"actions": [
|
|
68
|
+
{ "label": "Separation rule", "value": "I would want to add a separation rule" },
|
|
69
|
+
{ "label": "Max priority rule", "value": "I would want to set a max priority rule" },
|
|
70
|
+
{ "label": "Break code matching", "value": "I would want to add a break code matching rule" },
|
|
71
|
+
{ "label": "Inventory code matching", "value": "I would want to add a inventory window matching rule" },
|
|
72
|
+
{ "label": "Enter a rule description", "value": "I want to add a rule description" },
|
|
73
|
+
{ "label": "Tester Genie", "value": "Loading prompt..." }
|
|
74
|
+
],
|
|
75
|
+
"chatTitle": "Teach Me OTJ - {scope} - Add Learning",
|
|
76
|
+
"chatTitleEdit": "Teach Me OTJ - {scope} - Edit Learning",
|
|
77
|
+
"formTitle": "Rule Setup",
|
|
78
|
+
"setupLabel": "Configure your IL",
|
|
79
|
+
"ruleTitle": "Main Rule Name",
|
|
80
|
+
"scopeLabel": "Define Scope",
|
|
81
|
+
"tierLabel": "Select Tiers",
|
|
82
|
+
"ruleDescriptionTitle": "Learning Explanation",
|
|
83
|
+
"whenToApplyTitle": "Trigger Events (When to Apply)",
|
|
84
|
+
"addWhenToApplyBtnLabel": "Add WTA",
|
|
85
|
+
"whenNotToApplyTitle": "Exclusion Events (When NOT to Apply)",
|
|
86
|
+
"addWhenNotToApplyBtnLabel": "Add WNTA",
|
|
87
|
+
"configTitle": "Advanced Settings",
|
|
88
|
+
"saveBtnLabel": "Save Rule",
|
|
89
|
+
"saveBtnLoadingLabel": "Saving Rule...",
|
|
90
|
+
"textareaPlaceholder": "Tell me more about this learning..",
|
|
91
|
+
"showConfiguration": false,
|
|
92
|
+
"showScope": false
|
|
93
|
+
},
|
|
94
|
+
"learningManagement": {}
|
|
95
|
+
}
|
|
96
|
+
```
|
|
12
97
|
|
|
13
|
-
|
|
14
|
-
|
|
98
|
+
> ⚠️ **Important**: The `template` key at the root of `value_type_config` **must** be provided for any JSON customisation to take effect. Without it, the system falls back to resolving the renderer via `value_type_name` from the API, and config values may not be applied.
|
|
99
|
+
>
|
|
100
|
+
> ```json
|
|
101
|
+
> {
|
|
102
|
+
> "template": "Default"
|
|
103
|
+
> }
|
|
104
|
+
> ```
|
|
105
|
+
>
|
|
106
|
+
> The value must exactly match a key registered in `TemplateRegistry`:
|
|
107
|
+
>
|
|
108
|
+
> | `template` value | Renderer |
|
|
109
|
+
> |---|---|
|
|
110
|
+
> | `"Default"` | `DefaultTeachMeRenderer` |
|
|
111
|
+
> | `"Radio Traffic Learning"` | `RadioTrafficLearningRenderer` |
|
|
112
|
+
> | `"Guidelines"` | `GuidelinesTeachMeRenderer` |
|
|
113
|
+
>
|
|
114
|
+
> For custom plugins, use the exact key you registered in `TemplateRegistry` in `TeachMePlugin.tsx`:
|
|
115
|
+
>
|
|
116
|
+
> ```ts
|
|
117
|
+
> export const TemplateRegistry: Record<string, React.FC<TeachMeWrapperProps>> = {
|
|
118
|
+
> "Default": DefaultTeachMeRenderer,
|
|
119
|
+
> "Radio Traffic Learning": RadioTrafficLearningRenderer,
|
|
120
|
+
> "Guidelines": GuidelinesTeachMeRenderer,
|
|
121
|
+
> "Your Template Name": YourCustomRenderer, // ← use this exact string in "template"
|
|
122
|
+
> };
|
|
123
|
+
> ```
|
|
124
|
+
>
|
|
125
|
+
> If the provided `template` value is not found in `TemplateRegistry`, the system automatically falls back to `"Default"`.
|
|
126
|
+
|
|
127
|
+
- **Learning Management Renderer**: Added valuetype json support to render Learning Management Screen and create rule from the same.
|
|
128
|
+
|
|
129
|
+
**Configurable UI via `dt()`**
|
|
130
|
+
|
|
131
|
+
The LMS UI is driven by a remote JSON config loaded per `appIntegrationId`. Every label, button text, and dialog copy is resolved at runtime through the `dt()` helper instead of being hardcoded.
|
|
132
|
+
|
|
133
|
+
`dt()` — read a config value anywhere
|
|
15
134
|
|
|
16
135
|
```ts
|
|
17
|
-
function dt(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
): string
|
|
136
|
+
function dt(
|
|
137
|
+
path: string, // dot-notation key into LMSConfig
|
|
138
|
+
fallback?: string, // returned when key is missing
|
|
139
|
+
params?: Record<string, string | number> // fills {placeholder} tokens in the value
|
|
140
|
+
): string
|
|
22
141
|
```
|
|
23
142
|
|
|
24
|
-
- Reads directly from the Zustand store (no hook — works outside React components).
|
|
25
|
-
- Returns `fallback ?? path` when the key is not found or config is not loaded.
|
|
143
|
+
- Reads directly from the Zustand store (no hook — works outside React components).
|
|
144
|
+
- Returns `fallback ?? path` when the key is not found or config is not loaded.
|
|
26
145
|
|
|
27
|
-
**Examples:**
|
|
146
|
+
**Examples:**
|
|
28
147
|
|
|
29
148
|
```ts
|
|
30
|
-
dt('pageTitle')
|
|
31
|
-
// → value of lmsConfig.pageTitle
|
|
149
|
+
dt('pageTitle')
|
|
150
|
+
// → value of lmsConfig.pageTitle
|
|
32
151
|
|
|
33
|
-
dt('middleDrawer.addScope', 'Add Scope')
|
|
34
|
-
// → config value or fallback 'Add Scope'
|
|
152
|
+
dt('middleDrawer.addScope', 'Add Scope')
|
|
153
|
+
// → config value or fallback 'Add Scope'
|
|
35
154
|
|
|
36
|
-
dt('learnings.tier.deleteDialog.title', 'Delete {N} learnings', { N: 3 })
|
|
37
|
-
// → "Delete 3 learnings" (placeholder replaced)
|
|
155
|
+
dt('learnings.tier.deleteDialog.title', 'Delete {N} learnings', { N: 3 })
|
|
156
|
+
// → "Delete 3 learnings" (placeholder replaced)
|
|
38
157
|
|
|
39
|
-
dt('learnings.tier.learning.approveDialog.desc', undefined, { variant_name: 'Rule A' })
|
|
40
|
-
// → config string with {variant_name} replaced by "Rule A"
|
|
158
|
+
dt('learnings.tier.learning.approveDialog.desc', undefined, { variant_name: 'Rule A' })
|
|
159
|
+
// → config string with {variant_name} replaced by "Rule A"
|
|
41
160
|
```
|
|
42
161
|
|
|
43
|
-
### 1.3.0-alpha.16 -2026, June 5th
|
|
162
|
+
### 1.3.0-alpha.16 - 2026, June 5th
|
|
44
163
|
- **Scope Management**: Added appIntegrationId support to scope creation and deletion flows in AddScopeModal and related API endpoints
|
|
45
164
|
- **Override History**: Included appIntegrationId when fetching override history to ensure correct integration context
|
|
46
165
|
- **Rule Retrieval**: Added appIntegrationId support when fetching rules by ruleId
|
|
47
166
|
- **Scope Deletion**: Fixed deletion logic for station scopes so that associated stations are correctly removed when type = station
|
|
48
167
|
|
|
49
|
-
### 1.3.0-alpha.15 -2026, June 5th
|
|
168
|
+
### 1.3.0-alpha.15 - 2026, June 5th
|
|
50
169
|
- **Teach Me Renderer**: Modified default Teach Me renderer — switched from generic renderer to Radio Traffic value type renderer to support rule creation flow
|
|
51
170
|
|
|
52
|
-
### 1.3.0-alpha.14 -2026, June 5th
|
|
171
|
+
### 1.3.0-alpha.14 - 2026, June 5th
|
|
53
172
|
- **IL Mode - Scope Creation**: `parentScopeId` now correctly receives the parent scope's ID (global ID) when creating a new scope from a child node, instead of always being `null`
|
|
54
173
|
- **Auth Fallback**: Added optional chaining (`?.`) on `userDetails.accessToken` to prevent crashes on reload
|
|
55
174
|
- **Access Section**: Fixed logic that was hiding the Access section — it is now always visible regardless of `backwardCompatibility` flag
|
|
56
175
|
|
|
57
176
|
---
|
|
58
177
|
|
|
59
|
-
## Alpha Release Commands
|
|
178
|
+
## Alpha Release Commands
|
|
60
179
|
|
|
61
|
-
1. npm version prerelease --preid=alpha
|
|
180
|
+
1. npm version prerelease --preid=alpha
|
|
62
181
|
|
|
63
182
|
becomes 0.0.0-alpha.0
|
|
64
183
|
|
|
65
|
-
2. run this again to bump it
|
|
184
|
+
2. run this again to bump it: npm version prerelease --preid=alpha
|
|
66
185
|
|
|
67
|
-
3. during publish
|
|
186
|
+
3. during publish: npm publish --tag alpha
|
|
68
187
|
|
|
69
|
-
4. installation
|
|
188
|
+
4. installation: npm install @e-llm-studio/instant-learning@0.1.0-alpha.1
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),n=require("react"),t=require("../../helpers/utils.js"),i=require("../_svg/TickIcon.js"),o=require("../ChatComponents/ChatComponent.js"),s=require("../_svg/SparkleIcon.js"),a=require("lucide-react"),l=function(n){var t=n.label,i=n.onToggle,o=n.isSelected,s=n.disabled;return r.jsxs("div",e.__assign({style:{display:"inline-flex",alignItems:"center",cursor:s?"not-allowed":"pointer",margin:"8px 24px 8px 0",userSelect:"none",fontFamily:"Plus Jakarta Sans, sans-serif",fontSize:"14px",color:s?"#9ca3af":"#000000de",verticalAlign:"middle",opacity:s&&!o?.6:1},onClick:function(){return!s&&i(t,!o)}},{children:[r.jsx("div",e.__assign({style:{width:"18px",height:"18px",borderRadius:"4px",border:o?"none":"2px solid ".concat(s?"#e5e7eb":"#cfd8dc"),backgroundColor:o?s?"#90caf9":"#2661eb":"transparent",display:"flex",alignItems:"center",justifyContent:"center",marginRight:"8px",transition:"all 0.2s ease",color:"white",flexShrink:0}},{children:o&&r.jsx("svg",e.__assign({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:r.jsx("path",{d:"M10 3L4.5 8.5L2 6",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}))})),r.jsx("span",{children:t})]}))};exports.ActionableButton=function(l){var d,c=l.node,u=l.className,g=l.children,p=l.handleStream,f=l.onAction,x=l.disabled,b=l.isStreamEnd,h=void 0===b||b,y=l.style;l.isLastMessage;var m=l.onTypeResponseClick,_=e.__rest(l,["node","className","children","handleStream","onAction","disabled","isStreamEnd","style","isLastMessage","onTypeResponseClick"]),v=t.extractTextFromChildren(g),C=n.useState(!1),k=C[0],j=C[1],F=n.useState(!1),w=F[0],T=F[1],S=n.useState(null),R=S[0],E=S[1],z=n.useState(!1),A=z[0],G=z[1],L=n.useState(""),W=L[0],M=L[1],I="typeYourAnswer"===((null===(d=null==c?void 0:c.properties)||void 0===d?void 0:d.id)||_.id)||"type your response"===v.toLowerCase().trim(),P=_["data-selected"],B="true"===P,D="true"===P||"false"===P,N=_["data-value"],q=n.useState(!1),J=q[0],H=q[1],K=B||I&&J;if(!1===h&&!x&&!D&&!I)return null;var U={padding:"0.3rem 0.8rem",borderRadius:"4px",fontSize:"0.9rem",fontWeight:"500",fontFamily:"Plus Jakarta Sans, sans-serif",display:"flex",alignItems:"center",gap:"6px",cursor:"pointer",transition:"all 0.2s ease",border:"1px solid"},O={display:"inline-block",width:"12px",height:"12px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",animation:"spin 0.6s linear infinite",flexShrink:0};if("clickable-button"===u){var Y=(null==_?void 0:_.isTesterGenie)&&(k||null!==R),$=x||D&&!B||Y,Q={background:(null==_?void 0:_.isTesterGenie)?"linear-gradient(135deg, #e0eaff, #ede9fe, #dbeafe, #e0eaff)":"#fff",color:(null==_?void 0:_.isTesterGenie)?"#6d28d9":"#272727ff",borderColor:(null==_?void 0:_.isTesterGenie)?"rgba(139, 92, 246, 0.35)":"#272727ff",cursor:"pointer",opacity:1};return D||I?Q=K?{background:"linear-gradient(to right, rgb(236, 253, 245), rgb(209, 250, 229))",color:"#047857",borderColor:"#55a78fff",cursor:I?"pointer":"default",opacity:1}:{background:"#f3f4f6",color:"#64676A",borderColor:"#a8a8a8ff",cursor:"default",opacity:.6}:(x||Y)&&(Q={background:"#f3f4f6",color:"#64676A",borderColor:"#C0C0C2",cursor:"not-allowed",opacity:1}),r.jsxs(r.Fragment,{children:[r.jsx("style",{children:"\n @keyframes spin { to { transform: rotate(360deg); } }\n @keyframes tgShimmer {\n 0%, 100% { background-position: 0% 50%; }\n 50% { background-position: 100% 50%; }\n }\n "}),r.jsx("button",e.__assign({className:u,onClick:function(r){return e.__awaiter(void 0,void 0,void 0,function(){var n,t,i,s;return e.__generator(this,function(e){switch(e.label){case 0:return r.preventDefault(),I?(H(!0),m&&m(),[2]):$?[2]:(n=N||v,f?(f(n),[3,8]):[3,1]);case 1:if(!(null==_?void 0:_.isTesterGenie))return[3,7];e.label=2;case 2:return e.trys.push([2,4,5,6]),j(!0),[4,o.autoGeneratePrompt(_.baseURL)];case 3:return t=e.sent(),E((null===(s=null==t?void 0:t.result)||void 0===s?void 0:s.Answer)||""),[3,6];case 4:return i=e.sent(),console.error("Error in TesterGenie click:",i),[3,6];case 5:return j(!1),[7];case 6:return[3,8];case 7:p(new KeyboardEvent("keydown",{key:"Enter"}),!1,n,j),e.label=8;case 8:return[2]}})})},disabled:$,style:(null==_?void 0:_.isTesterGenie)?e.__assign(e.__assign({padding:"0.3rem 0.8rem",margin:"10px 8px 8px 0",background:Q.background,backgroundSize:(null==_?void 0:_.isTesterGenie)?"250% 250%":void 0,animation:(null==_?void 0:_.isTesterGenie)&&!$?"tgShimmer 6s ease infinite":void 0,color:Q.color,border:"1.5px solid ".concat(Q.borderColor),borderRadius:"6px",cursor:Q.cursor,fontSize:"0.9rem",fontWeight:"500",transition:"color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease",fontFamily:"Plus Jakarta Sans, sans-serif",display:"flex",alignItems:"center",gap:"3px",pointerEvents:$?"none":"auto",opacity:Q.opacity,boxShadow:(null==_?void 0:_.isTesterGenie)?"0 1px 4px rgba(124, 58, 237, 0.1)":"none"},y),{marginLeft:"8px"}):e.__assign({display:"flex",alignItems:"center",padding:"5px 8px",background:K?"linear-gradient(to right, #EFF4FF)":"transparent",border:"1px solid ".concat(K?"#B2CCFF":"transparent"),borderRadius:"6px",cursor:$?"not-allowed":"pointer",textAlign:"left",fontFamily:"Plus Jakarta Sans, sans-serif",opacity:$?.6:1},y),onMouseEnter:function(e){$||(null==_?void 0:_.isTesterGenie)||K||(e.currentTarget.style.background="linear-gradient(to right, #EFF4FF)",e.currentTarget.style.borderColor="#B2CCFF")},onMouseLeave:function(e){$||(null==_?void 0:_.isTesterGenie)||K||(e.currentTarget.style.background="transparent",e.currentTarget.style.borderColor="transparent")}},_,{children:k&&(null==_?void 0:_.isTesterGenie)&&null===R?r.jsxs("span",e.__assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[r.jsx("span",{style:O}),"Finding an interesting usecase to test..."]})):r.jsx(r.Fragment,{children:(null==_?void 0:_.isTesterGenie)?g:r.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",width:"100%"}},{children:[r.jsx("div",e.__assign({style:{width:"28px",height:"28px",borderRadius:"50%",border:K?"1px solid #D0D5DD":"1px solid #B2CCFF",display:"flex",alignItems:"center",justifyContent:"center",marginRight:"12px",backgroundColor:K?"#D1E0FF":"#fff",flexShrink:0}},{children:r.jsx(a.ArrowRight,{color:K?"#004EEB":"#667085",size:20})})),r.jsx("span",e.__assign({style:{fontSize:"14px",color:"#344054",fontFamily:"Inter",fontWeight:"500"}},{children:g}))]}))})})),(null==_?void 0:_.isTesterGenie)&&null!==R&&r.jsxs("div",e.__assign({style:{marginTop:"6px",borderRadius:"8px",border:"1px solid #e5e7eb",background:"#f9fafb",padding:"14px 16px",maxWidth:"520px",fontFamily:"Plus Jakarta Sans, sans-serif"},onWheel:function(e){return e.stopPropagation()}},{children:[r.jsxs("p",e.__assign({style:{margin:"0 0 4px 0",fontSize:"1rem",color:"#111827"}},{children:[r.jsx("span",e.__assign({style:{height:"1.2em",width:"1.2em",marginRight:"4px"}},{children:r.jsx(s.default,{})})),"Your prompt is ready!"]})),r.jsx("p",e.__assign({style:{margin:"14px 0 14px 0",fontSize:"0.95rem",fontWeight:"600",color:"#111827",whiteSpace:"pre-wrap"}},{children:R})),r.jsx("p",e.__assign({style:{margin:"0 0 4px 0",fontSize:"1rem",color:"#111827",lineHeight:"1.55"}},{children:"Would you like to proceed with this prompt, or generate a new one?"})),r.jsxs("div",e.__assign({style:{display:"flex",gap:"6px",flexWrap:"wrap"}},{children:[r.jsxs("button",e.__assign({disabled:w||k,style:e.__assign(e.__assign({},U),{background:"linear-gradient(to right, rgb(237, 233, 254), rgb(221, 214, 254))",color:"#5b21b6",borderColor:"#7c3aed",opacity:w||k?.6:1,cursor:w||k?"not-allowed":"pointer"}),onMouseEnter:function(e){w||k||(e.currentTarget.style.background="linear-gradient(to right, rgb(221, 214, 254), rgb(196, 181, 253))")},onMouseLeave:function(e){w||k||(e.currentTarget.style.background="linear-gradient(to right, rgb(237, 233, 254), rgb(221, 214, 254))")},onClick:function(){p(new KeyboardEvent("keydown",{key:"Enter"}),!1,R,j),E(null),G(!1),M("")}},{children:[r.jsx(i.TickIcon,{color:"#5b21b6"})," Proceed"]})),r.jsx("button",e.__assign({disabled:w||k,style:e.__assign(e.__assign({},U),{background:w?"#f3f4f6":"#fff",color:w?"#64676A":"#272727",borderColor:w?"#C0C0C2":"#272727",cursor:w||k?"not-allowed":"pointer",opacity:w||k?.7:1}),onMouseEnter:function(e){w||k||(e.currentTarget.style.background="linear-gradient(to right, rgb(237, 233, 254), rgb(221, 214, 254))",e.currentTarget.style.borderColor="#7c3aed",e.currentTarget.style.color="#5b21b6")},onMouseLeave:function(e){w||k||(e.currentTarget.style.background="#fff",e.currentTarget.style.borderColor="#272727",e.currentTarget.style.color="#272727")},onClick:function(){return e.__awaiter(void 0,void 0,void 0,function(){var r,n,t;return e.__generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,3,4]),T(!0),[4,o.autoGeneratePrompt(_.baseUrl,W||void 0)];case 1:return r=e.sent(),E((null===(t=null==r?void 0:r.result)||void 0===t?void 0:t.Answer)||""),[3,4];case 2:return n=e.sent(),console.error("Error regenerating prompt:",n),[3,4];case 3:return T(!1),[7];case 4:return[2]}})})}},{children:w?r.jsxs(r.Fragment,{children:[r.jsx("span",{style:O})," Regenerating..."]}):r.jsxs(r.Fragment,{children:[r.jsxs("svg",e.__assign({width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0}},{children:[r.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),r.jsx("path",{d:"M3 3v5h5"})]})),"Regenerate"]})})),r.jsx("button",e.__assign({disabled:w||k,style:e.__assign(e.__assign({},U),{background:"#fff",color:A?"#5b21b6":"#64676A",borderColor:A?"#7c3aed":"#C0C0C2",cursor:w||k?"not-allowed":"pointer",opacity:w||k?.6:1}),onMouseEnter:function(e){w||k||(e.currentTarget.style.borderColor="#7c3aed",e.currentTarget.style.color="#5b21b6")},onMouseLeave:function(e){w||k||A||(e.currentTarget.style.borderColor="#C0C0C2",e.currentTarget.style.color="#64676A")},onClick:function(){return G(function(e){return!e})}},{children:A?"✕ Hide Inputs":" Give Inputs"}))]})),A&&r.jsxs("div",e.__assign({style:{marginTop:"12px",paddingTop:"12px",borderTop:"1px solid #e5e7eb"}},{children:[r.jsx("p",e.__assign({style:{margin:"0 0 6px 0",fontSize:"1rem",color:"#6b7280"}},{children:"Help us generate better prompt (optional)"})),r.jsx("textarea",{placeholder:"e.g. Provide usecases for seperation rules",value:W,onChange:function(e){return M(e.target.value)},rows:3,onKeyDown:function(e){e.stopPropagation()},onWheel:function(e){e.stopPropagation()},style:{width:"100%",minWidth:"420px",maxWidth:"100%",padding:"10px 12px",borderRadius:"6px",border:"1px solid #d1d5db",fontSize:"0.9rem",fontFamily:"Plus Jakarta Sans, sans-serif",color:"#111827",background:"#fff",resize:"vertical",outline:"none",boxSizing:"border-box",lineHeight:"1.5",transition:"border-color 0.2s ease"},onFocus:function(e){e.currentTarget.style.borderColor="#7c3aed"},onBlur:function(e){e.currentTarget.style.borderColor="#d1d5db"}}),r.jsxs("div",e.__assign({style:{display:"flex",gap:"8px",marginTop:"8px"}},{children:[r.jsx("button",e.__assign({disabled:k||!W.trim(),style:e.__assign(e.__assign({},U),{background:k||!W.trim()?"#f3f4f6":"linear-gradient(to right, rgb(237, 233, 254), rgb(221, 214, 254))",color:k||!W.trim()?"#64676A":"#5b21b6",borderColor:k||!W.trim()?"#C0C0C2":"#7c3aed",cursor:k||!W.trim()?"not-allowed":"pointer",opacity:k||!W.trim()?.7:1}),onMouseEnter:function(e){!k&&W.trim()&&(e.currentTarget.style.background="linear-gradient(to right, rgb(221, 214, 254), rgb(196, 181, 253))")},onMouseLeave:function(e){!k&&W.trim()&&(e.currentTarget.style.background="linear-gradient(to right, rgb(237, 233, 254), rgb(221, 214, 254))")},onClick:function(){return e.__awaiter(void 0,void 0,void 0,function(){var r,n,t;return e.__generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,3,4]),j(!0),[4,o.autoGeneratePrompt(_.baseUrl,W)];case 1:return r=e.sent(),E((null===(t=null==r?void 0:r.result)||void 0===t?void 0:t.Answer)||""),G(!1),[3,4];case 2:return n=e.sent(),console.error("Error generating with direction:",n),[3,4];case 3:return j(!1),[7];case 4:return[2]}})})}},{children:k?r.jsxs(r.Fragment,{children:[r.jsx("span",{style:O})," Generating..."]}):r.jsx(r.Fragment,{children:"✦ Generate"})})),r.jsx("button",e.__assign({disabled:k,style:e.__assign(e.__assign({},U),{background:"#fff",color:"#64676A",borderColor:"#C0C0C2",cursor:k?"not-allowed":"pointer",opacity:k?.5:1}),onMouseEnter:function(e){k||(e.currentTarget.style.borderColor="#272727",e.currentTarget.style.color="#272727")},onMouseLeave:function(e){k||(e.currentTarget.style.borderColor="#C0C0C2",e.currentTarget.style.color="#64676A")},onClick:function(){return M("")}},{children:"Clear"}))]}))]}))]}))]})}return r.jsx("button",e.__assign({className:u},_,{children:g}))},exports.ActionableCheckbox=function(n){n.node;var i=n.className,o=n.children,s=n.selectedItems,a=n.onToggle,d=n.isSubmitted,c=n.disabled;e.__rest(n,["node","className","children","selectedItems","onToggle","isSubmitted","disabled"]);var u=t.extractTextFromChildren(o),g=u.trim();return"clickable-box"===i?d?s.includes(g)?r.jsxs("div",e.__assign({style:{display:"inline-flex",alignItems:"center",margin:"4px 24px 4px 0",color:"#2661eb",fontWeight:600,fontFamily:"Plus Jakarta Sans, sans-serif"}},{children:[r.jsx("span",e.__assign({style:{marginRight:"6px",fontSize:"16px"}},{children:"✓"}))," ",u]})):null:r.jsx(l,{label:u,isSelected:s.includes(g),onToggle:a,disabled:c}):r.jsx("span",e.__assign({className:i},{children:o}))},exports.CheckboxSelector=l,exports.RuleDisplay=function(n){var t=n.content,i=function(e){var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp("<".concat(r,">([\\s\\S]*?)<\\/").concat(r,">"),"i"),i=t.match(n);return i?i[1].trim():"*No ".concat(e," tag found.*")},o=i("reasoning_new"),s=i("proposed_rule"),a=i("wta_new"),l=i("wnta_new");return r.jsxs("div",e.__assign({style:{padding:"16px 16px",maxWidth:"100%",border:"1px solid #A78BFA",borderRadius:"8px",backgroundColor:"#F6F4FF"}},{children:[r.jsx("div",e.__assign({style:{color:"#4B5563",fontSize:"1rem",lineHeight:"1.5rem",marginBottom:"1rem",fontFamily:"inherit",maxWidth:"90%"}},{children:o})),r.jsxs("div",e.__assign({style:{border:"1px solid #ddd",borderRadius:"8px",padding:"16px",backgroundColor:"#FFFFFF",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.05)"}},{children:[r.jsxs("div",e.__assign({style:{paddingLeft:"12px",marginBottom:"12px",fontFamily:"inherit"}},{children:[r.jsx("div",e.__assign({style:{fontSize:"14px",fontWeight:"400",color:"#666F8D",fontFamily:"inherit"}},{children:"Proposed Rule"})),r.jsx("div",e.__assign({style:{fontSize:"0.95rem",color:"#374151",fontFamily:"inherit"}},{children:s}))]})),r.jsxs("div",e.__assign({style:{marginBottom:"12px",paddingLeft:"12px",fontFamily:"inherit"}},{children:[r.jsx("div",e.__assign({style:{fontSize:"14px",fontWeight:"400",color:"#666F8D",fontFamily:"inherit"}},{children:"When to apply"})),r.jsx("div",e.__assign({style:{fontSize:"0.9rem",color:"#374151",fontFamily:"inherit"}},{children:a}))]})),r.jsxs("div",e.__assign({style:{paddingLeft:"12px",fontFamily:"inherit"}},{children:[r.jsx("div",e.__assign({style:{fontSize:"14px",fontWeight:"400",color:"#666F8D",fontFamily:"inherit"}},{children:"When NOT to apply"})),r.jsx("div",e.__assign({style:{fontSize:"0.9rem",color:"#374151",fontFamily:"inherit"}},{children:l}))]}))]}))]}))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),n=require("react"),t=require("../../helpers/utils.js"),i=require("../_svg/TickIcon.js"),o=require("../ChatComponents/ChatComponent.js"),s=require("../_svg/SparkleIcon.js"),a=require("lucide-react"),l=function(n){var t=n.label,i=n.onToggle,o=n.isSelected,s=n.disabled;return r.jsxs("div",e.__assign({style:{display:"inline-flex",alignItems:"center",cursor:s?"not-allowed":"pointer",margin:"8px 24px 8px 0",userSelect:"none",fontFamily:"Plus Jakarta Sans, sans-serif",fontSize:"14px",color:s?"#9ca3af":"#000000de",verticalAlign:"middle",opacity:s&&!o?.6:1},onClick:function(){return!s&&i(t,!o)}},{children:[r.jsx("div",e.__assign({style:{width:"18px",height:"18px",borderRadius:"4px",border:o?"none":"2px solid ".concat(s?"#e5e7eb":"#cfd8dc"),backgroundColor:o?s?"#90caf9":"#2661eb":"transparent",display:"flex",alignItems:"center",justifyContent:"center",marginRight:"8px",transition:"all 0.2s ease",color:"white",flexShrink:0}},{children:o&&r.jsx("svg",e.__assign({width:"12",height:"12",viewBox:"0 0 12 12",fill:"none",xmlns:"http://www.w3.org/2000/svg"},{children:r.jsx("path",{d:"M10 3L4.5 8.5L2 6",stroke:"white",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})}))})),r.jsx("span",{children:t})]}))};exports.ActionableButton=function(l){var d,c=l.node,u=l.className,g=l.children,p=l.handleStream,f=l.onAction,x=l.disabled,b=l.isStreamEnd,h=void 0===b||b,y=l.style;l.isLastMessage;var m=l.onTypeResponseClick,_=e.__rest(l,["node","className","children","handleStream","onAction","disabled","isStreamEnd","style","isLastMessage","onTypeResponseClick"]),v=t.extractTextFromChildren(g),C=n.useState(!1),k=C[0],j=C[1],w=n.useState(!1),F=w[0],T=w[1],S=n.useState(null),R=S[0],E=S[1],z=n.useState(!1),A=z[0],G=z[1],L=n.useState(""),W=L[0],M=L[1],I="typeYourAnswer"===((null===(d=null==c?void 0:c.properties)||void 0===d?void 0:d.id)||_.id)||"type your response"===v.toLowerCase().trim(),P=_["data-selected"],B="true"===P,D="true"===P||"false"===P,N=_["data-value"],q=n.useState(!1),J=q[0],H=q[1],K=B||I&&J;if(!1===h&&!x&&!D&&!I)return null;var U={padding:"0.3rem 0.8rem",borderRadius:"4px",fontSize:"0.9rem",fontWeight:"500",fontFamily:"Plus Jakarta Sans, sans-serif",display:"flex",alignItems:"center",gap:"6px",cursor:"pointer",transition:"all 0.2s ease",border:"1px solid"},O={display:"inline-block",width:"12px",height:"12px",border:"2px solid currentColor",borderTopColor:"transparent",borderRadius:"50%",animation:"spin 0.6s linear infinite",flexShrink:0};if("clickable-button"===u){var Y=(null==_?void 0:_.isTesterGenie)&&(k||null!==R),$=x||D&&!B||Y,Q={background:(null==_?void 0:_.isTesterGenie)?"linear-gradient(135deg, #e0eaff, #ede9fe, #dbeafe, #e0eaff)":"#fff",color:(null==_?void 0:_.isTesterGenie)?"#6d28d9":"#272727ff",borderColor:(null==_?void 0:_.isTesterGenie)?"rgba(139, 92, 246, 0.35)":"#272727ff",cursor:"pointer",opacity:1};return D||I?Q=K?{background:"linear-gradient(to right, rgb(236, 253, 245), rgb(209, 250, 229))",color:"#047857",borderColor:"#55a78fff",cursor:I?"pointer":"default",opacity:1}:{background:"#f3f4f6",color:"#64676A",borderColor:"#a8a8a8ff",cursor:"default",opacity:.6}:(x||Y)&&(Q={background:"#f3f4f6",color:"#64676A",borderColor:"#C0C0C2",cursor:"not-allowed",opacity:1}),r.jsxs(r.Fragment,{children:[r.jsx("style",{children:"\n @keyframes spin { to { transform: rotate(360deg); } }\n @keyframes tgShimmer {\n 0%, 100% { background-position: 0% 50%; }\n 50% { background-position: 100% 50%; }\n }\n "}),r.jsx("button",e.__assign({className:u,onClick:function(r){return e.__awaiter(void 0,void 0,void 0,function(){var n,t,i,s;return e.__generator(this,function(e){switch(e.label){case 0:return r.preventDefault(),I?(H(!0),m&&m(),[2]):$?[2]:(n=N||v,f?(f(n),[3,8]):[3,1]);case 1:if(!(null==_?void 0:_.isTesterGenie))return[3,7];e.label=2;case 2:return e.trys.push([2,4,5,6]),j(!0),[4,o.autoGeneratePrompt(_.baseURL)];case 3:return t=e.sent(),E((null===(s=null==t?void 0:t.result)||void 0===s?void 0:s.Answer)||""),[3,6];case 4:return i=e.sent(),console.error("Error in TesterGenie click:",i),[3,6];case 5:return j(!1),[7];case 6:return[3,8];case 7:p(new KeyboardEvent("keydown",{key:"Enter"}),!1,n,j),e.label=8;case 8:return[2]}})})},disabled:$,style:(null==_?void 0:_.isTesterGenie)?e.__assign(e.__assign({padding:"0.3rem 0.8rem",margin:"10px 8px 8px 0",background:Q.background,backgroundSize:(null==_?void 0:_.isTesterGenie)?"250% 250%":void 0,animation:(null==_?void 0:_.isTesterGenie)&&!$?"tgShimmer 6s ease infinite":void 0,color:Q.color,border:"1.5px solid ".concat(Q.borderColor),borderRadius:"6px",cursor:Q.cursor,fontSize:"0.9rem",fontWeight:"500",transition:"color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease",fontFamily:"Plus Jakarta Sans, sans-serif",display:"flex",alignItems:"center",gap:"3px",pointerEvents:$?"none":"auto",opacity:Q.opacity,boxShadow:(null==_?void 0:_.isTesterGenie)?"0 1px 4px rgba(124, 58, 237, 0.1)":"none"},y),{marginLeft:"8px",width:"fit-content"}):e.__assign({display:"flex",alignItems:"center",padding:"5px 8px",background:K?"linear-gradient(to right, #EFF4FF)":"transparent",border:"1px solid ".concat(K?"#B2CCFF":"transparent"),borderRadius:"6px",cursor:$?"not-allowed":"pointer",textAlign:"left",fontFamily:"Plus Jakarta Sans, sans-serif",opacity:$?.6:1},y),onMouseEnter:function(e){$||(null==_?void 0:_.isTesterGenie)||K||(e.currentTarget.style.background="linear-gradient(to right, #EFF4FF)",e.currentTarget.style.borderColor="#B2CCFF")},onMouseLeave:function(e){$||(null==_?void 0:_.isTesterGenie)||K||(e.currentTarget.style.background="transparent",e.currentTarget.style.borderColor="transparent")}},_,{children:k&&(null==_?void 0:_.isTesterGenie)&&null===R?r.jsxs("span",e.__assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[r.jsx("span",{style:O}),"Finding an interesting usecase to test..."]})):r.jsx(r.Fragment,{children:(null==_?void 0:_.isTesterGenie)?g:r.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",width:"100%"}},{children:[r.jsx("div",e.__assign({style:{width:"28px",height:"28px",borderRadius:"50%",border:K?"1px solid #D0D5DD":"1px solid #B2CCFF",display:"flex",alignItems:"center",justifyContent:"center",marginRight:"12px",backgroundColor:K?"#D1E0FF":"#fff",flexShrink:0}},{children:r.jsx(a.ArrowRight,{color:K?"#004EEB":"#667085",size:20})})),r.jsx("span",e.__assign({style:{fontSize:"14px",color:"#344054",fontFamily:"Inter",fontWeight:"500"}},{children:g}))]}))})})),(null==_?void 0:_.isTesterGenie)&&null!==R&&r.jsxs("div",e.__assign({style:{marginTop:"6px",borderRadius:"8px",border:"1px solid #e5e7eb",background:"#f9fafb",padding:"14px 16px",maxWidth:"520px",fontFamily:"Plus Jakarta Sans, sans-serif"},onWheel:function(e){return e.stopPropagation()}},{children:[r.jsxs("p",e.__assign({style:{margin:"0 0 4px 0",fontSize:"1rem",color:"#111827"}},{children:[r.jsx("span",e.__assign({style:{height:"1.2em",width:"1.2em",marginRight:"4px"}},{children:r.jsx(s.default,{})})),"Your prompt is ready!"]})),r.jsx("p",e.__assign({style:{margin:"14px 0 14px 0",fontSize:"0.95rem",fontWeight:"600",color:"#111827",whiteSpace:"pre-wrap"}},{children:R})),r.jsx("p",e.__assign({style:{margin:"0 0 4px 0",fontSize:"1rem",color:"#111827",lineHeight:"1.55"}},{children:"Would you like to proceed with this prompt, or generate a new one?"})),r.jsxs("div",e.__assign({style:{display:"flex",gap:"6px",flexWrap:"wrap"}},{children:[r.jsxs("button",e.__assign({disabled:F||k,style:e.__assign(e.__assign({},U),{background:"linear-gradient(to right, rgb(237, 233, 254), rgb(221, 214, 254))",color:"#5b21b6",borderColor:"#7c3aed",opacity:F||k?.6:1,cursor:F||k?"not-allowed":"pointer"}),onMouseEnter:function(e){F||k||(e.currentTarget.style.background="linear-gradient(to right, rgb(221, 214, 254), rgb(196, 181, 253))")},onMouseLeave:function(e){F||k||(e.currentTarget.style.background="linear-gradient(to right, rgb(237, 233, 254), rgb(221, 214, 254))")},onClick:function(){p(new KeyboardEvent("keydown",{key:"Enter"}),!1,R,j),E(null),G(!1),M("")}},{children:[r.jsx(i.TickIcon,{color:"#5b21b6"})," Proceed"]})),r.jsx("button",e.__assign({disabled:F||k,style:e.__assign(e.__assign({},U),{background:F?"#f3f4f6":"#fff",color:F?"#64676A":"#272727",borderColor:F?"#C0C0C2":"#272727",cursor:F||k?"not-allowed":"pointer",opacity:F||k?.7:1}),onMouseEnter:function(e){F||k||(e.currentTarget.style.background="linear-gradient(to right, rgb(237, 233, 254), rgb(221, 214, 254))",e.currentTarget.style.borderColor="#7c3aed",e.currentTarget.style.color="#5b21b6")},onMouseLeave:function(e){F||k||(e.currentTarget.style.background="#fff",e.currentTarget.style.borderColor="#272727",e.currentTarget.style.color="#272727")},onClick:function(){return e.__awaiter(void 0,void 0,void 0,function(){var r,n,t;return e.__generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,3,4]),T(!0),[4,o.autoGeneratePrompt(_.baseUrl,W||void 0)];case 1:return r=e.sent(),E((null===(t=null==r?void 0:r.result)||void 0===t?void 0:t.Answer)||""),[3,4];case 2:return n=e.sent(),console.error("Error regenerating prompt:",n),[3,4];case 3:return T(!1),[7];case 4:return[2]}})})}},{children:F?r.jsxs(r.Fragment,{children:[r.jsx("span",{style:O})," Regenerating..."]}):r.jsxs(r.Fragment,{children:[r.jsxs("svg",e.__assign({width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round",style:{flexShrink:0}},{children:[r.jsx("path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8"}),r.jsx("path",{d:"M3 3v5h5"})]})),"Regenerate"]})})),r.jsx("button",e.__assign({disabled:F||k,style:e.__assign(e.__assign({},U),{background:"#fff",color:A?"#5b21b6":"#64676A",borderColor:A?"#7c3aed":"#C0C0C2",cursor:F||k?"not-allowed":"pointer",opacity:F||k?.6:1}),onMouseEnter:function(e){F||k||(e.currentTarget.style.borderColor="#7c3aed",e.currentTarget.style.color="#5b21b6")},onMouseLeave:function(e){F||k||A||(e.currentTarget.style.borderColor="#C0C0C2",e.currentTarget.style.color="#64676A")},onClick:function(){return G(function(e){return!e})}},{children:A?"✕ Hide Inputs":" Give Inputs"}))]})),A&&r.jsxs("div",e.__assign({style:{marginTop:"12px",paddingTop:"12px",borderTop:"1px solid #e5e7eb"}},{children:[r.jsx("p",e.__assign({style:{margin:"0 0 6px 0",fontSize:"1rem",color:"#6b7280"}},{children:"Help us generate better prompt (optional)"})),r.jsx("textarea",{placeholder:"e.g. Provide usecases for seperation rules",value:W,onChange:function(e){return M(e.target.value)},rows:3,onKeyDown:function(e){e.stopPropagation()},onWheel:function(e){e.stopPropagation()},style:{width:"100%",minWidth:"420px",maxWidth:"100%",padding:"10px 12px",borderRadius:"6px",border:"1px solid #d1d5db",fontSize:"0.9rem",fontFamily:"Plus Jakarta Sans, sans-serif",color:"#111827",background:"#fff",resize:"vertical",outline:"none",boxSizing:"border-box",lineHeight:"1.5",transition:"border-color 0.2s ease"},onFocus:function(e){e.currentTarget.style.borderColor="#7c3aed"},onBlur:function(e){e.currentTarget.style.borderColor="#d1d5db"}}),r.jsxs("div",e.__assign({style:{display:"flex",gap:"8px",marginTop:"8px"}},{children:[r.jsx("button",e.__assign({disabled:k||!W.trim(),style:e.__assign(e.__assign({},U),{background:k||!W.trim()?"#f3f4f6":"linear-gradient(to right, rgb(237, 233, 254), rgb(221, 214, 254))",color:k||!W.trim()?"#64676A":"#5b21b6",borderColor:k||!W.trim()?"#C0C0C2":"#7c3aed",cursor:k||!W.trim()?"not-allowed":"pointer",opacity:k||!W.trim()?.7:1}),onMouseEnter:function(e){!k&&W.trim()&&(e.currentTarget.style.background="linear-gradient(to right, rgb(221, 214, 254), rgb(196, 181, 253))")},onMouseLeave:function(e){!k&&W.trim()&&(e.currentTarget.style.background="linear-gradient(to right, rgb(237, 233, 254), rgb(221, 214, 254))")},onClick:function(){return e.__awaiter(void 0,void 0,void 0,function(){var r,n,t;return e.__generator(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,3,4]),j(!0),[4,o.autoGeneratePrompt(_.baseUrl,W)];case 1:return r=e.sent(),E((null===(t=null==r?void 0:r.result)||void 0===t?void 0:t.Answer)||""),G(!1),[3,4];case 2:return n=e.sent(),console.error("Error generating with direction:",n),[3,4];case 3:return j(!1),[7];case 4:return[2]}})})}},{children:k?r.jsxs(r.Fragment,{children:[r.jsx("span",{style:O})," Generating..."]}):r.jsx(r.Fragment,{children:"✦ Generate"})})),r.jsx("button",e.__assign({disabled:k,style:e.__assign(e.__assign({},U),{background:"#fff",color:"#64676A",borderColor:"#C0C0C2",cursor:k?"not-allowed":"pointer",opacity:k?.5:1}),onMouseEnter:function(e){k||(e.currentTarget.style.borderColor="#272727",e.currentTarget.style.color="#272727")},onMouseLeave:function(e){k||(e.currentTarget.style.borderColor="#C0C0C2",e.currentTarget.style.color="#64676A")},onClick:function(){return M("")}},{children:"Clear"}))]}))]}))]}))]})}return r.jsx("button",e.__assign({className:u},_,{children:g}))},exports.ActionableCheckbox=function(n){n.node;var i=n.className,o=n.children,s=n.selectedItems,a=n.onToggle,d=n.isSubmitted,c=n.disabled;e.__rest(n,["node","className","children","selectedItems","onToggle","isSubmitted","disabled"]);var u=t.extractTextFromChildren(o),g=u.trim();return"clickable-box"===i?d?s.includes(g)?r.jsxs("div",e.__assign({style:{display:"inline-flex",alignItems:"center",margin:"4px 24px 4px 0",color:"#2661eb",fontWeight:600,fontFamily:"Plus Jakarta Sans, sans-serif"}},{children:[r.jsx("span",e.__assign({style:{marginRight:"6px",fontSize:"16px"}},{children:"✓"}))," ",u]})):null:r.jsx(l,{label:u,isSelected:s.includes(g),onToggle:a,disabled:c}):r.jsx("span",e.__assign({className:i},{children:o}))},exports.CheckboxSelector=l,exports.RuleDisplay=function(n){var t=n.content,i=function(e){var r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp("<".concat(r,">([\\s\\S]*?)<\\/").concat(r,">"),"i"),i=t.match(n);return i?i[1].trim():"*No ".concat(e," tag found.*")},o=i("reasoning_new"),s=i("proposed_rule"),a=i("wta_new"),l=i("wnta_new");return r.jsxs("div",e.__assign({style:{padding:"16px 16px",maxWidth:"100%",border:"1px solid #A78BFA",borderRadius:"8px",backgroundColor:"#F6F4FF"}},{children:[r.jsx("div",e.__assign({style:{color:"#4B5563",fontSize:"1rem",lineHeight:"1.5rem",marginBottom:"1rem",fontFamily:"inherit",maxWidth:"90%"}},{children:o})),r.jsxs("div",e.__assign({style:{border:"1px solid #ddd",borderRadius:"8px",padding:"16px",backgroundColor:"#FFFFFF",boxShadow:"0 4px 6px rgba(0, 0, 0, 0.05)"}},{children:[r.jsxs("div",e.__assign({style:{paddingLeft:"12px",marginBottom:"12px",fontFamily:"inherit"}},{children:[r.jsx("div",e.__assign({style:{fontSize:"14px",fontWeight:"400",color:"#666F8D",fontFamily:"inherit"}},{children:"Proposed Rule"})),r.jsx("div",e.__assign({style:{fontSize:"0.95rem",color:"#374151",fontFamily:"inherit"}},{children:s}))]})),r.jsxs("div",e.__assign({style:{marginBottom:"12px",paddingLeft:"12px",fontFamily:"inherit"}},{children:[r.jsx("div",e.__assign({style:{fontSize:"14px",fontWeight:"400",color:"#666F8D",fontFamily:"inherit"}},{children:"When to apply"})),r.jsx("div",e.__assign({style:{fontSize:"0.9rem",color:"#374151",fontFamily:"inherit"}},{children:a}))]})),r.jsxs("div",e.__assign({style:{paddingLeft:"12px",fontFamily:"inherit"}},{children:[r.jsx("div",e.__assign({style:{fontSize:"14px",fontWeight:"400",color:"#666F8D",fontFamily:"inherit"}},{children:"When NOT to apply"})),r.jsx("div",e.__assign({style:{fontSize:"0.9rem",color:"#374151",fontFamily:"inherit"}},{children:l}))]}))]}))]}))};
|
|
2
2
|
//# sourceMappingURL=ClickableChatComponents.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),i=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),i=require("react"),o=require("@e-llm-studio/audit-log");require("@e-llm-studio/audit-log/dist/styles.css");var n=require("lucide-react"),r=require("./ChangeLogDiff.js"),a=require("../store/useLMSConfigStore.js");exports.default=function(l){var s=l.configId,d=l.ruleData,c=l.scopeId,g=l.scopeName,h=(null==g?void 0:g.trim())||"Selected",u=i.useMemo(function(){var e=[];return c&&e.push(c),e},[d,c]);return i.useEffect(function(){console.log("Flattened External Resource IDs:",u)},[u]),t.jsxs("div",e.__assign({style:{padding:"24px",fontFamily:"Arial, sans-serif"}},{children:[t.jsxs("div",e.__assign({style:{marginBottom:"16px",paddingBottom:"4px"}},{children:[t.jsx("h1",e.__assign({style:{margin:0,color:"#334155",fontSize:"20px",fontWeight:700,lineHeight:1.25}},{children:a.dt("history.title","".concat(h," - Audit Log"),{scope_name:h})})),t.jsx("p",e.__assign({style:{margin:"8px 0 0",color:"#667085",fontSize:"16px",fontWeight:500,lineHeight:1}},{children:a.dt("history.subtitle","Track all learning updates and modifications with the ".concat(h," scope."),{scope_name:h})}))]})),t.jsx(o.AuditLog,{configId:s,getData:{baseUrl:"https://dev.appmod.ai",endpoint:"/changelog/audit-log/fetch"},distinctValuesApi:{baseUrl:"https://dev.appmod.ai",endpoint:"/changelog/audit-log/distinct-values"},query:{externalResourceId:u.length>0?u:[""],paginationLimit:10},sidebar:{config:{showAnalystFilter:!0,showDateFilter:!0,showChangeTitleFilter:!0,showImpactPercentage:!1},labels:{title:"Filters",multiSelectLabel:"Modified By",multiSelectHint:"Filter by the user who made the change",changeTitleLabel:"Change Action",changeTitleHint:"Filter by Actions"}},table:{tableProps:{scrollable:!0,scrollHeight:"80vh",showGridlines:!0,size:"small",rowClassName:function(){return"custom-compact-row"},pt:{bodyCell:{style:{paddingTop:"4px",paddingBottom:"4px"}}}},hiddenColumns:["actions","changeSummary","changeDateTime","logId"],extraColumns:[{key:"modifiedBy",header:"Modified By",body:function(i){return t.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[t.jsx(n.User,{size:16,color:"#64748b",style:{flexShrink:0}}),t.jsx("span",e.__assign({style:{fontWeight:500}},{children:i.modifiedBy}))]}))},style:{width:"15%",minWidth:"140px"}},{key:"changeAction",header:"Action",body:function(i){var o,n,r=(o=i.changeTitle,(n=(o||"").toUpperCase()).includes("CREATE")?{color:"#2e7d32",backgroundColor:"#edf7ed",borderColor:"#c8e6c9",boxShadow:"0 1px 2px rgba(46, 125, 50, 0.08)"}:n.includes("UPDATE")||n.includes("TOGGLE")?{color:"#1565c0",backgroundColor:"#e3f2fd",borderColor:"#bbdefb",boxShadow:"0 1px 2px rgba(21, 101, 192, 0.08)"}:n.includes("DELETE")?{color:"#c62828",backgroundColor:"#fdeeed",borderColor:"#ffcdd2",boxShadow:"0 1px 2px rgba(198, 40, 40, 0.08)"}:{color:"#475569",backgroundColor:"#f8fafc",borderColor:"#cbd5e1",boxShadow:"0 1px 2px rgba(15, 23, 42, 0.06)"}),a=i.changeTitle?i.changeTitle.replace(/_/g," "):"—";return t.jsx("span",e.__assign({style:{color:r.color,backgroundColor:r.backgroundColor,border:"1px solid ".concat(r.borderColor),boxShadow:r.boxShadow,padding:"6px 12px",borderRadius:"999px",fontSize:"12px",lineHeight:1,fontWeight:600,display:"inline-block",minWidth:"76px",textAlign:"center",textTransform:"capitalize"}},{children:a}))},style:{width:"15%",textAlign:"center"}},{key:"customChangeSummary",header:"Change Summary",body:function(e){var i;return t.jsx(r.default,{change:null!==(i=e.actionText)&&void 0!==i?i:"-"})},style:{width:"30%",minWidth:"200px"}},{key:"redirectLink",header:"Link",body:function(i){var o,r=(null===(o=i.metadata)||void 0===o?void 0:o.redirect_url)||i.redirect_url;return r?t.jsx("div",e.__assign({style:{display:"flex",justifyContent:"center",alignItems:"center"}},{children:t.jsxs("a",e.__assign({href:r,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"6px",color:"#2563eb",textDecoration:"none",fontWeight:500,fontSize:"13px"}},{children:["View ",t.jsx(n.ExternalLink,{size:14})]}))})):t.jsx("span",e.__assign({style:{color:"#94a3b8",display:"flex",justifyContent:"center"}},{children:"—"}))},style:{width:"10%",minWidth:"90px",textAlign:"center"}},{key:"customChangeDateTime",header:"Change Time and Date",body:function(i){if(!i.actionDate)return t.jsx("span",e.__assign({style:{color:"#94a3b8"}},{children:"—"}));var o=new Date(i.actionDate),n=o.toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"}),r=o.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"});return t.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",fontSize:"13px",color:"#475569"}},{children:[t.jsx("span",e.__assign({style:{fontWeight:500}},{children:n})),t.jsx("span",{children:r})]}))},style:{width:"15%",minWidth:"150px",textAlign:"center"}}]},filters:{config:{showFilterButton:!0,showSort:!0,showDate:!0,showSearch:!0,sortOptions:{latest:!0,oldest:!0,impactHighToLow:!1,impactLowToHigh:!1}}}})]}))};
|
|
2
2
|
//# sourceMappingURL=AuditLog.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),r=require("lucide-react"),s=require("./store/useLearningTemplateStore.js"),a=require("primereact/toast"),i=require("./styles/LearningTemplateManagement.module.css.js"),o=require("./LearningTemplateLayout.js"),l=require("./components/EmptyLearningState.js"),u=require("./store/useAuthStore.js"),c=require("./apis/scopeApis.js"),d=require("./hooks/useLearningTemplateQueryParams.js"),p=require("./components/ConfirmationModal.js"),g=require("./components/LearningTemplateManagementSkeleton.js"),f=require("./utils/treeUtils.js"),m=require("./store/useEnvStore.js"),S=require("./store/useConfigStore.js"),v=require("./components/ToolTip.js"),_=require("./components/CreateRuleSetLegacyModal.js"),h=require("./store/usePermissionsStore.js"),y=require("./store/useAppSecRolesStore.js"),T=require("./queries/useApprovalQueries.js"),b=require("./queries/useLMSConfigQuery.js"),C=require("./RuleContent/AddScopeModal.js"),L=require("./components/RuleContentSkeleton.js"),j=require("./components/ErrorStateDisplay.js"),E=require("react-router-dom"),w=require("./shared/SuccessToastContent.js"),R=require("./shared/ErrorToastContent.js"),A=require("./RuleContent/RenameScopeModal.js"),I=require("./store/useLMSConfigStore.js");console.log("learningstest",I.dt("middleDrawer.treeMenu.submenu.learnings")),exports.default=function(q){var O,D,x,M=this,N=q.userDetails,P=q.llmStudioUrl,k=q.audacyBackendUrl,U=q.ilLabels,B=q.config,G=q.rbacConfig,F=q.auditLogConfig,Q=q.app_integration_id,Y=q.backwardCompatibility,K=void 0!==Y&&Y,H=s.useLearningTemplateStore(function(e){return e.selectedRuleSetId}),z=s.useLearningTemplateStore(function(e){return e.setSelectedRuleSetId}),V=s.useLearningTemplateStore(function(e){return e.error}),W=s.useLearningTemplateStore(function(e){return e.setError}),J=s.useLearningTemplateStore(function(e){return e.setStations}),X=s.useLearningTemplateStore(function(e){return e.scopeTreeData}),Z=s.useLearningTemplateStore(function(e){return e.setScopeTreeData}),$=n.useState({isOpen:!1,type:"GLOBAL"}),ee=$[0],te=$[1],ne=n.useState(!1),re=ne[0],se=ne[1],ae=n.useState(!1),ie=ae[0],oe=ae[1],le=n.useState("learnings"),ue=le[0],ce=le[1],de=n.useState(null),pe=de[0],ge=de[1],fe=n.useState(null),me=fe[0],Se=fe[1],ve=n.useRef(null),_e=n.useRef(null),he=n.useRef(!1),ye=n.useRef(null),Te=u.default();Te.user;var be=Te.setUser,Ce=S.useConfigStore(),Le=Ce.setConfig,je=Ce.setIlLabels;console.log("testing",I.dt("middleDrawer.contextMenu.addSubscope",""));var Ee=function(){try{return E.useLocation()}catch(e){return{search:""}}}();n.useEffect(function(){if(!he.current){var e=new URLSearchParams(window.location.search),t=e.get(d.QUERY_PARAM_KEYS.RULESET_ID),n=e.get(d.QUERY_PARAM_KEYS.SECTION),r=n&&Ye.has(n)?n:"learnings";(null==t?void 0:t.length)&&z&&ce&&(z(t),ce(r),he.current=!0)}},[null==Ee?void 0:Ee.search,ce,z]);var we=h.usePermissionsStore(function(e){return e.fetchPermissions}),Re=h.usePermissionsStore(function(e){return e.hasPermission}),Ae=y.useAppSecRolesStore(function(e){return e.setRoles}),Ie=m.default(function(e){return e.appsecRbacUrl})===G.appsecRbacUrl,qe=T.useGetAppSecRolesQuery(G.applicationId,Ie).data,Oe=b.useLMSConfigQuery(null!=Q?Q:""),De=Oe.isLoading,xe=Oe.isError,Me=Oe.refetch;Oe.isSuccess,n.useEffect(function(){qe&&Ae(qe.map(function(e){return{_id:e._id,name:e.name}}))},[qe,Ae]),n.useEffect(function(){var e;console.log("userDetails",N),be(N),console.log("llmStudioUrl",P),console.log("audacyBackendUrl",k),m.default.getState().setLlmStudioUrl(P),m.default.getState().setAudacyBackendUrl(k),m.default.getState().setRbacConfig(G),m.default.getState().setAuditLogConfig(F),Le(B),je(U),s.useLearningTemplateStore.getState().setAppIntegrationId(null!=Q?Q:null),s.useLearningTemplateStore.getState().setBackwardCompatibility(K),s.useLearningTemplateStore.getState().setToken(null!==(e=null==N?void 0:N.accessToken)&&void 0!==e?e:null)},[N,be,P,k,G,F,B,Le,U,je,Q,K]),n.useEffect(function(){(null==N?void 0:N.accessToken)&&P&&c.fetchTiers()},[Q,null==N?void 0:N.accessToken,P]);var Ne=function(t){return void 0===t&&(t=!0),e.__awaiter(M,void 0,void 0,function(){var n,r,a,i,o,l;return e.__generator(this,function(u){switch(u.label){case 0:t&&se(!0),W(null),u.label=1;case 1:return u.trys.push([1,4,5,6]),[4,we(G.applicationId)];case 2:return u.sent(),n=function(t){if(!h.usePermissionsStore.getState().hasPermission("ilotj.scope.view",t.id))return null;var r=t.children?t.children.map(function(e){return n(e)}).filter(function(e){return null!==e}):[];return e.__assign(e.__assign({},t),{children:r})},[4,c.fetchScopes(Q,N.accessToken)];case 3:return(r=u.sent())&&r.data&&r.data.data&&(a=r.data.data,Array.isArray(a)&&(a=a.length>0?a[0]:null),a?(i=n(a))?(ge(null),Z({data:i}),_e.current?(z(_e.current),ce("learnings"),_e.current=null):s.useLearningTemplateStore.getState().selectedRuleSetId||z(i.id)):(ge(null!==(l=a.id)&&void 0!==l?l:null),Z(null)):(ge(null),Z(null))),[3,6];case 4:return o=u.sent(),console.error("Failed to fetch rule sets or permissions",o),W("Failed to load data. Please try again later."),[3,6];case 5:return se(!1),[7];case 6:return[2]}})})};n.useEffect(function(){var e;(null===(e=null==N?void 0:N.accessToken)||void 0===e?void 0:e.length)&&Ie?Ne(!0):console.warn("Error: Trying to fetch rules without access token",N)},[null==N?void 0:N.accessToken,W,J,G.applicationId,Ie]);var Pe=function(t,n,r){return e.__awaiter(M,void 0,void 0,function(){var n,r,a,i,o,l,u,d;return e.__generator(this,function(p){switch(p.label){case 0:oe(!0),p.label=1;case 1:return p.trys.push([1,4,5,6]),[4,c.deleteRuleSet(t,N.accessToken)];case 2:return p.sent(),s.useLearningTemplateStore.getState().selectedRuleSetId===t&&(n=s.useLearningTemplateStore.getState().scopeTreeData,(r=f.findNodePathById((null==n?void 0:n.data)||null,t))&&r.length>1&&(a=r[r.length-2],z(a),ce("learnings"))),[4,Ne(!0)];case 3:return p.sent(),te(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),null===(o=ye.current)||void 0===o||o.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,6];case 4:return i=p.sent(),console.error("An error occurred during scope deletion.",i),null===(l=ye.current)||void 0===l||l.show({severity:"error",summary:"Delete Failed",detail:(null===(d=null===(u=null==i?void 0:i.response)||void 0===u?void 0:u.data)||void 0===d?void 0:d.message)||"There was an error deleting the scope. Please try again."}),[3,6];case 5:return oe(!1),[7];case 6:return[2]}})})},ke=X,Ue=me?{data:{id:me.stationId,name:me.stationName,type:"STATION",metrics:{learningsCount:me.learningsCount,stationsCount:0},children:[]}}:ke,Be=!!(null==Ue?void 0:Ue.data);null===(O=null==Ue?void 0:Ue.data)||void 0===O||O.type;var Ge=h.usePermissionsStore(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",G.applicationResourceId||"");if(De)return t.jsx("div",e.__assign({className:i.default.learningManagementContainer},{children:t.jsx(L.default,{})}));if(xe)return t.jsx("div",e.__assign({className:i.default.learningManagementContainer},{children:t.jsx(j.default,{errorMessage:"Failed to load configuration. Please try again.",onRetry:function(){return Me()},title:"Error Loading Configuration"})}));var Fe=e.__spreadArray([{type:"GLOBAL",label:"Global",addChildLabel:"".concat(I.dt("middleDrawer.addScope","Add Scope")),addChildType:"SCOPE"},e.__assign({type:"SCOPE",label:I.dt("middleDrawer.scope","Scope")},!K&&{addChildLabel:I.dt("middleDrawer.treeMenu.contextMenu.addSubscope","Add Subscope"),addChildType:"SUBSCOPE"})],K?[]:[{type:"SUBSCOPE",label:I.dt("middleDrawer.subScope","Subscope")}],!0),Qe=[{id:"learnings",label:I.dt("middleDrawer.treeMenu.submenu.learnings","Learnings"),icon:r.BookOpen,badgeKey:"learningsCount"},{id:"access",label:I.dt("middleDrawer.treeMenu.submenu.access","Access"),icon:r.Users},{id:"history",label:I.dt("middleDrawer.treeMenu.submenu.changeHistory","Change History"),icon:r.History}],Ye=new Set(Qe.map(function(e){return e.id})),Ke=me?Qe.filter(function(e){return"stations"!==e.id}):Qe;return t.jsx(v.TooltipProvider,{children:t.jsxs("div",e.__assign({className:i.default.learningManagementContainer},{children:[t.jsx("div",e.__assign({className:i.default.mainWrapper},{children:re?t.jsx(g.default,{}):V?t.jsxs("div",e.__assign({className:i.default.errorContainer},{children:[t.jsx("div",e.__assign({className:i.default.errorTitle},{children:"Error Loading Data"})),t.jsx("p",e.__assign({className:i.default.errorDesc},{children:V})),t.jsx("button",e.__assign({onClick:function(){return Ne(!0)},className:i.default.tryAgainBtn},{children:"Try Again"}))]})):Be?t.jsx(o.default,{onOpenCreateModal:function(){return te({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return te({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return te({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(t,n,r){return e.__awaiter(M,void 0,void 0,function(){var a,i,o;return e.__generator(this,function(e){switch(e.label){case 0:return a=s.useLearningTemplateStore.getState().scopeTreeData,i=f.findNodePathById((null==a?void 0:a.data)||null,t),o=!!i&&3===i.length,0!==r?[3,2]:[4,Pe(t)];case 1:return e.sent(),[3,3];case 2:te({isOpen:!0,type:"DELETE",scopeId:t,initialName:n,isSubscope:o}),e.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return Re("ilotj.scope.delete",e)},canEditScope:function(e){return Re("ilotj.scope.edit",e)},canCreateScope:function(e){return Re("ilotj.scope.create",e)},onSectionSelect:function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),d.setQueryParams(((n={})[d.QUERY_PARAM_KEYS.SECTION]="learnings"===t?null:t,n[d.QUERY_PARAM_KEYS.RULESET_ID]=e,n)),ce(t),z(e)},activeSectionId:ue,scopeTreeData:Ue,sectionsConfig:Ke,onViewStation:function(e){ve.current=H,Se(e),ce("learnings"),z(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(_e.current=t),Ne(e)},nodeTypesConfig:Fe,app_integration_id:Q,token:N.accessToken}):t.jsx(l.default,{onCreate:function(){return te({isOpen:!0,type:"GLOBAL"})},title:"No Global Scope has been added!",desc:"Start by creating a Global scope to define base learnings that apply across all stations.",button:"Create Global Scope",canCreateRule:Ge,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return e.__awaiter(M,void 0,void 0,function(){var n,r,a,o,l,u,d,p,g;return e.__generator(this,function(e){switch(e.label){case 0:if(!(n=(null===(o=null===(a=s.useLearningTemplateStore.getState().scopeTreeData)||void 0===a?void 0:a.data)||void 0===o?void 0:o.id)||pe))return null===(l=ye.current)||void 0===l||l.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(R.default,{message:"Unable to identify the global scope for this access request."})}),[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.requestAccess(n)];case 2:return e.sent(),null===(u=ye.current)||void 0===u||u.show({severity:"success",sticky:!1,life:3e3,className:i.default.successToast,content:t.jsx(w.default,{message:"Access request submitted successfully!"})}),[3,4];case 3:return r=e.sent(),null===(d=ye.current)||void 0===d||d.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(R.default,{message:(null===(g=null===(p=null==r?void 0:r.response)||void 0===p?void 0:p.data)||void 0===g?void 0:g.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),t.jsx(a.Toast,{ref:ye,pt:{root:{style:{zIndex:9999}}}}),K&&ee.isOpen&&"DELETE"!==ee.type&&"RENAME"!==ee.type?t.jsx(_.default,{isOpen:!0,onClose:function(){return te(e.__assign(e.__assign({},ee),{isOpen:!1}))},onSubmit:function(t){return e.__awaiter(M,void 0,void 0,function(){var n,r,a,i,o,l,u,d,p,g,f,m,S,v,_,h,y,T,b,C;return e.__generator(this,function(L){switch(L.label){case 0:oe(!0),n=s.useLearningTemplateStore.getState().backwardCompatibility,L.label=1;case 1:return L.trys.push([1,12,13,14]),r=void 0,n&&"object"==typeof t?r=t:(a=t,i="SCOPE"===ee.type&&ee.parentId,o=i?"genreRuleSet":ee.type,r={topic:o,scope_reference_id:null,scopeDescription:"demo",parentScopeId:ee.parentId||null,scopeName:a,scopeReferenceMetadata:{},applicationMappingId:Q}),[4,c.createRuleSet(r,N.accessToken)];case 2:if(l=L.sent(),!(u=null===(v=null==l?void 0:l.data)||void 0===v?void 0:v.scopeId))return[3,10];if(_e.current=u,d=n&&(null===(_=r.topic)||void 0===_?void 0:_.toLowerCase().includes("genre")),p=!n&&"GLOBAL"!==ee.type&&ee.parentId,!d&&!p)return[3,10];if(!(g=n?null===(y=null===(h=s.useLearningTemplateStore.getState().scopeTreeData)||void 0===h?void 0:h.data)||void 0===y?void 0:y.id:ee.parentId))return[3,10];if(!K)return[3,7];L.label=3;case 3:return L.trys.push([3,5,,6]),[4,c.inheritScopeBackwardCompatible({source_scope_id:g,target_scope_id:u})];case 4:return L.sent(),[3,6];case 5:return f=L.sent(),console.error("Failed to inherit rules for the new scope:",f),[3,6];case 6:return[3,10];case 7:return L.trys.push([7,9,,10]),[4,c.inheritScope({source_scope_id:g,target_scope_id:u,application_mapping_id:Q||"",is_copy_parent_variant_id:!1})];case 8:return L.sent(),[3,10];case 9:return m=L.sent(),console.error("Failed to inherit rules for the new scope:",m),[3,10];case 10:return[4,Ne(!0)];case 11:return L.sent(),te(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),[3,14];case 12:throw S=L.sent(),console.error("An error occurred during scope creation.",S),null===(T=ye.current)||void 0===T||T.show({severity:"error",summary:"Creation Failed",detail:(null===(C=null===(b=null==S?void 0:S.response)||void 0===b?void 0:b.data)||void 0===C?void 0:C.message)||"There was an error creating the scope. Please try again."}),S;case 13:return oe(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:Be,canCreateGlobal:Ge,globalScopeId:null!==(x=null===(D=null==X?void 0:X.data)||void 0===D?void 0:D.id)&&void 0!==x?x:null}):t.jsxs(t.Fragment,{children:[t.jsx(C.default,{isOpen:ee.isOpen&&"DELETE"!==ee.type&&"RENAME"!==ee.type,onClose:function(){return te(e.__assign(e.__assign({},ee),{isOpen:!1}))},onCreate:function(e){e&&(_e.current=e),Ne(!0)},hasGlobalRuleSet:Be,parentId:ee.parentId}),t.jsx(A.default,{isOpen:ee.isOpen&&"RENAME"===ee.type,onClose:function(){return te(e.__assign(e.__assign({},ee),{isOpen:!1}))},onSave:function(n){return e.__awaiter(M,void 0,void 0,function(){var r,s,a,o;return e.__generator(this,function(l){switch(l.label){case 0:oe(!0),l.label=1;case 1:return l.trys.push([1,4,5,6]),ee.scopeId?[4,c.renameScope({scope_id:ee.scopeId,scope_name:n})]:[2];case 2:return l.sent(),[4,Ne(!0)];case 3:return l.sent(),te(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),[3,6];case 4:throw r=l.sent(),console.error("An error occurred during scope rename.",r),null===(s=ye.current)||void 0===s||s.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(R.default,{message:(null===(o=null===(a=null==r?void 0:r.response)||void 0===a?void 0:a.data)||void 0===o?void 0:o.message)||"There was an error renaming the scope. Please try again."})}),r;case 5:return oe(!1),[7];case 6:return[2]}})})},initialName:ee.initialName})]}),t.jsx(p.default,{isOpen:ee.isOpen&&"DELETE"===ee.type,onCancel:function(){return te(e.__assign(e.__assign({},ee),{isOpen:!1}))},onConfirm:function(){return Pe(ee.scopeId,ee.initialName,ee.isSubscope)},title:"Delete Scope",description:t.jsxs(t.Fragment,{children:["Deleting ",t.jsx("span",e.__assign({className:i.default.highlight},{children:ee.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:ie})]}))})};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),t=require("react/jsx-runtime"),n=require("react"),r=require("lucide-react"),s=require("./store/useLearningTemplateStore.js"),a=require("primereact/toast"),i=require("./styles/LearningTemplateManagement.module.css.js"),o=require("./LearningTemplateLayout.js"),l=require("./components/EmptyLearningState.js"),u=require("./store/useAuthStore.js"),c=require("./apis/scopeApis.js"),d=require("./hooks/useLearningTemplateQueryParams.js"),p=require("./components/ConfirmationModal.js"),g=require("./components/LearningTemplateManagementSkeleton.js"),f=require("./utils/treeUtils.js"),_=require("./store/useEnvStore.js"),S=require("./store/useConfigStore.js"),m=require("./components/ToolTip.js"),v=require("./components/CreateRuleSetLegacyModal.js"),h=require("./store/usePermissionsStore.js"),y=require("./store/useAppSecRolesStore.js"),T=require("./queries/useApprovalQueries.js"),E=require("./queries/useLMSConfigQuery.js"),b=require("./RuleContent/AddScopeModal.js"),L=require("./components/RuleContentSkeleton.js"),C=require("./components/ErrorStateDisplay.js"),R=require("react-router-dom"),A=require("./shared/SuccessToastContent.js"),j=require("./shared/ErrorToastContent.js"),D=require("./RuleContent/RenameScopeModal.js"),I=require("./store/useLMSConfigStore.js"),w=require("./constants.js");exports.default=function(q){var O,P,M,N=this,x=q.userDetails,k=q.llmStudioUrl,U=q.audacyBackendUrl,B=q.ilLabels,G=q.config,F=q.rbacConfig,H=q.auditLogConfig,Q=q.app_integration_id,Y=q.backwardCompatibility,W=void 0!==Y&&Y,K=s.useLearningTemplateStore(function(e){return e.selectedRuleSetId}),z=s.useLearningTemplateStore(function(e){return e.setSelectedRuleSetId}),V=s.useLearningTemplateStore(function(e){return e.error}),X=s.useLearningTemplateStore(function(e){return e.setError}),J=s.useLearningTemplateStore(function(e){return e.setStations}),Z=s.useLearningTemplateStore(function(e){return e.scopeTreeData}),$=s.useLearningTemplateStore(function(e){return e.setScopeTreeData}),ee=n.useState({isOpen:!1,type:"GLOBAL"}),te=ee[0],ne=ee[1],re=n.useState(!1),se=re[0],ae=re[1],ie=n.useState(!1),oe=ie[0],le=ie[1],ue=n.useState("learnings"),ce=ue[0],de=ue[1],pe=n.useState(null),ge=pe[0],fe=pe[1],_e=n.useState(null),Se=_e[0],me=_e[1],ve=n.useRef(null),he=n.useRef(null),ye=n.useRef(!1),Te=n.useRef(null),Ee=u.default();Ee.user;var be=Ee.setUser,Le=S.useConfigStore(),Ce=Le.setConfig,Re=Le.setIlLabels,Ae=function(){try{return R.useLocation()}catch(e){return{search:""}}}();n.useEffect(function(){if(!ye.current){var e=new URLSearchParams(window.location.search),t=e.get(d.QUERY_PARAM_KEYS.RULESET_ID),n=e.get(d.QUERY_PARAM_KEYS.SECTION),r=n&&Ye.has(n)?n:"learnings";(null==t?void 0:t.length)&&z&&de&&(z(t),de(r),ye.current=!0)}},[null==Ae?void 0:Ae.search,de,z]);var je=h.usePermissionsStore(function(e){return e.fetchPermissions}),De=h.usePermissionsStore(function(e){return e.hasPermission}),Ie=y.useAppSecRolesStore(function(e){return e.setRoles}),we=_.default(function(e){return e.appsecRbacUrl})===F.appsecRbacUrl,qe=T.useGetAppSecRolesQuery(F.applicationId,we).data,Oe=E.useLMSConfigQuery(null!=Q?Q:"",W),Pe=Oe.isLoading,Me=Oe.isError,Ne=Oe.refetch;Oe.isSuccess,n.useEffect(function(){qe&&Ie(qe.map(function(e){return{_id:e._id,name:e.name}}))},[qe,Ie]),n.useEffect(function(){var e;console.log("userDetails",x),be(x),console.log("llmStudioUrl",k),console.log("audacyBackendUrl",U),_.default.getState().setLlmStudioUrl(k),_.default.getState().setAudacyBackendUrl(U),_.default.getState().setRbacConfig(F),_.default.getState().setAuditLogConfig(H),Ce(G),Re(B),s.useLearningTemplateStore.getState().setAppIntegrationId(null!=Q?Q:null),s.useLearningTemplateStore.getState().setBackwardCompatibility(W),s.useLearningTemplateStore.getState().setToken(null!==(e=null==x?void 0:x.accessToken)&&void 0!==e?e:null)},[x,be,k,U,F,H,G,Ce,B,Re,Q,W]),n.useEffect(function(){(null==x?void 0:x.accessToken)&&k&&c.fetchTiers()},[Q,null==x?void 0:x.accessToken,k]);var xe=function(t){return void 0===t&&(t=!0),e.__awaiter(N,void 0,void 0,function(){var n,r,a,i,o,l;return e.__generator(this,function(u){switch(u.label){case 0:t&&ae(!0),X(null),u.label=1;case 1:return u.trys.push([1,4,5,6]),[4,je(F.applicationId)];case 2:return u.sent(),n=function(t){if(!h.usePermissionsStore.getState().hasPermission("ilotj.scope.view",t.id))return null;var r=t.children?t.children.map(function(e){return n(e)}).filter(function(e){return null!==e}):[];return e.__assign(e.__assign({},t),{children:r})},[4,c.fetchScopes(Q,x.accessToken)];case 3:return(r=u.sent())&&r.data&&r.data.data&&(a=r.data.data,Array.isArray(a)&&(a=a.length>0?a[0]:null),a?(i=n(a))?(fe(null),$({data:i}),he.current?(z(he.current),de("learnings"),he.current=null):s.useLearningTemplateStore.getState().selectedRuleSetId||z(i.id)):(fe(null!==(l=a.id)&&void 0!==l?l:null),$(null)):(fe(null),$(null))),[3,6];case 4:return o=u.sent(),console.error("Failed to fetch rule sets or permissions",o),X("Failed to load data. Please try again later."),[3,6];case 5:return ae(!1),[7];case 6:return[2]}})})};n.useEffect(function(){var e;(null===(e=null==x?void 0:x.accessToken)||void 0===e?void 0:e.length)&&we?xe(!0):console.warn("Error: Trying to fetch rules without access token",x)},[null==x?void 0:x.accessToken,X,J,F.applicationId,we]);var ke=function(t,n,r){return e.__awaiter(N,void 0,void 0,function(){var n,r,a,i,o,l,u,d;return e.__generator(this,function(p){switch(p.label){case 0:le(!0),p.label=1;case 1:return p.trys.push([1,4,5,6]),[4,c.deleteRuleSet(t,x.accessToken)];case 2:return p.sent(),s.useLearningTemplateStore.getState().selectedRuleSetId===t&&(n=s.useLearningTemplateStore.getState().scopeTreeData,(r=f.findNodePathById((null==n?void 0:n.data)||null,t))&&r.length>1&&(a=r[r.length-2],z(a),de("learnings"))),[4,xe(!0)];case 3:return p.sent(),ne(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),null===(o=Te.current)||void 0===o||o.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,6];case 4:return i=p.sent(),console.error("An error occurred during scope deletion.",i),null===(l=Te.current)||void 0===l||l.show({severity:"error",summary:"Delete Failed",detail:(null===(d=null===(u=null==i?void 0:i.response)||void 0===u?void 0:u.data)||void 0===d?void 0:d.message)||"There was an error deleting the scope. Please try again."}),[3,6];case 5:return le(!1),[7];case 6:return[2]}})})},Ue=Z,Be=Se?{data:{id:Se.stationId,name:Se.stationName,type:"STATION",metrics:{learningsCount:Se.learningsCount,stationsCount:0},children:[]}}:Ue,Ge=!!(null==Be?void 0:Be.data);null===(O=null==Be?void 0:Be.data)||void 0===O||O.type;var Fe=h.usePermissionsStore(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",F.applicationResourceId||"");if(Pe)return t.jsx("div",e.__assign({className:i.default.learningManagementContainer},{children:t.jsx(L.default,{})}));if(Me)return t.jsx("div",e.__assign({className:i.default.learningManagementContainer},{children:t.jsx(C.default,{errorMessage:"Failed to load configuration. Please try again.",onRetry:function(){return Ne()},title:"Error Loading Configuration"})}));var He=e.__spreadArray([{type:"GLOBAL",label:"Global",addChildLabel:"".concat(I.dt("".concat(w.MIDDLE_DRAWER_DT_PATH,".addScope"),"Add Scope")),addChildType:"SCOPE"},e.__assign({type:"SCOPE",label:I.dt("".concat(w.MIDDLE_DRAWER_DT_PATH,".scope"),"Scope")},!W&&{addChildLabel:I.dt("".concat(w.MIDDLE_DRAWER_CONTEXT_MENU_DT_PATH,".addSubScope"),"Add Subscope"),addChildType:"SUBSCOPE"})],W?[]:[{type:"SUBSCOPE",label:I.dt("".concat(w.MIDDLE_DRAWER_DT_PATH,".subScope"),"Subscope")}],!0),Qe=[{id:"learnings",label:I.dt("".concat(w.MIDDLE_DRAWER_DT_PATH,".treeMenu.submenu.learnings"),"Learnings"),icon:r.BookOpen,badgeKey:"learningsCount"},{id:"access",label:I.dt("".concat(w.MIDDLE_DRAWER_DT_PATH,".treeMenu.submenu.access"),"Access"),icon:r.Users},{id:"history",label:I.dt("".concat(w.MIDDLE_DRAWER_DT_PATH,".treeMenu.submenu.changeHistory"),"Change History"),icon:r.History}],Ye=new Set(Qe.map(function(e){return e.id})),We=Se?Qe.filter(function(e){return"stations"!==e.id}):Qe;return t.jsx(m.TooltipProvider,{children:t.jsxs("div",e.__assign({className:i.default.learningManagementContainer},{children:[t.jsx("div",e.__assign({className:i.default.mainWrapper},{children:se?t.jsx(g.default,{}):V?t.jsxs("div",e.__assign({className:i.default.errorContainer},{children:[t.jsx("div",e.__assign({className:i.default.errorTitle},{children:"Error Loading Data"})),t.jsx("p",e.__assign({className:i.default.errorDesc},{children:V})),t.jsx("button",e.__assign({onClick:function(){return xe(!0)},className:i.default.tryAgainBtn},{children:"Try Again"}))]})):Ge?t.jsx(o.default,{onOpenCreateModal:function(){return ne({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return ne({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return ne({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(t,n,r){return e.__awaiter(N,void 0,void 0,function(){var a,i,o;return e.__generator(this,function(e){switch(e.label){case 0:return a=s.useLearningTemplateStore.getState().scopeTreeData,i=f.findNodePathById((null==a?void 0:a.data)||null,t),o=!!i&&3===i.length,0!==r?[3,2]:[4,ke(t)];case 1:return e.sent(),[3,3];case 2:ne({isOpen:!0,type:"DELETE",scopeId:t,initialName:n,isSubscope:o}),e.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return De("ilotj.scope.delete",e)},canEditScope:function(e){return De("ilotj.scope.edit",e)},canCreateScope:function(e){return De("ilotj.scope.create",e)},onSectionSelect:function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),d.setQueryParams(((n={})[d.QUERY_PARAM_KEYS.SECTION]="learnings"===t?null:t,n[d.QUERY_PARAM_KEYS.RULESET_ID]=e,n)),de(t),z(e)},activeSectionId:ce,scopeTreeData:Be,sectionsConfig:We,onViewStation:function(e){ve.current=K,me(e),de("learnings"),z(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(he.current=t),xe(e)},nodeTypesConfig:He,app_integration_id:Q,token:x.accessToken}):t.jsx(l.default,{onCreate:function(){return ne({isOpen:!0,type:"GLOBAL"})},title:"No Global Scope has been added!",desc:"Start by creating a Global scope to define base learnings that apply across all stations.",button:"Create Global Scope",canCreateRule:Fe,noAccessTitle:"Access Restricted",noAccessDesc:"You do not have access to create a Global scope for this application.",onRequestAccess:function(){return e.__awaiter(N,void 0,void 0,function(){var n,r,a,o,l,u,d,p,g;return e.__generator(this,function(e){switch(e.label){case 0:if(!(n=(null===(o=null===(a=s.useLearningTemplateStore.getState().scopeTreeData)||void 0===a?void 0:a.data)||void 0===o?void 0:o.id)||ge))return null===(l=Te.current)||void 0===l||l.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(j.default,{message:"Unable to identify the global scope for this access request."})}),[2];e.label=1;case 1:return e.trys.push([1,3,,4]),[4,c.requestAccess(n)];case 2:return e.sent(),null===(u=Te.current)||void 0===u||u.show({severity:"success",sticky:!1,life:3e3,className:i.default.successToast,content:t.jsx(A.default,{message:"Access request submitted successfully!"})}),[3,4];case 3:return r=e.sent(),null===(d=Te.current)||void 0===d||d.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(j.default,{message:(null===(g=null===(p=null==r?void 0:r.response)||void 0===p?void 0:p.data)||void 0===g?void 0:g.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),t.jsx(a.Toast,{ref:Te,pt:{root:{style:{zIndex:9999}}}}),W&&te.isOpen&&"DELETE"!==te.type&&"RENAME"!==te.type?t.jsx(v.default,{isOpen:!0,onClose:function(){return ne(e.__assign(e.__assign({},te),{isOpen:!1}))},onSubmit:function(t){return e.__awaiter(N,void 0,void 0,function(){var n,r,a,i,o,l,u,d,p,g,f,_,S,m,v,h,y,T,E,b;return e.__generator(this,function(L){switch(L.label){case 0:le(!0),n=s.useLearningTemplateStore.getState().backwardCompatibility,L.label=1;case 1:return L.trys.push([1,12,13,14]),r=void 0,n&&"object"==typeof t?r=t:(a=t,i="SCOPE"===te.type&&te.parentId,o=i?"genreRuleSet":te.type,r={topic:o,scope_reference_id:null,scopeDescription:"demo",parentScopeId:te.parentId||null,scopeName:a,scopeReferenceMetadata:{},applicationMappingId:Q}),[4,c.createRuleSet(r,x.accessToken)];case 2:if(l=L.sent(),!(u=null===(m=null==l?void 0:l.data)||void 0===m?void 0:m.scopeId))return[3,10];if(he.current=u,d=n&&(null===(v=r.topic)||void 0===v?void 0:v.toLowerCase().includes("genre")),p=!n&&"GLOBAL"!==te.type&&te.parentId,!d&&!p)return[3,10];if(!(g=n?null===(y=null===(h=s.useLearningTemplateStore.getState().scopeTreeData)||void 0===h?void 0:h.data)||void 0===y?void 0:y.id:te.parentId))return[3,10];if(!W)return[3,7];L.label=3;case 3:return L.trys.push([3,5,,6]),[4,c.inheritScopeBackwardCompatible({source_scope_id:g,target_scope_id:u})];case 4:return L.sent(),[3,6];case 5:return f=L.sent(),console.error("Failed to inherit rules for the new scope:",f),[3,6];case 6:return[3,10];case 7:return L.trys.push([7,9,,10]),[4,c.inheritScope({source_scope_id:g,target_scope_id:u,application_mapping_id:Q||"",is_copy_parent_variant_id:!1})];case 8:return L.sent(),[3,10];case 9:return _=L.sent(),console.error("Failed to inherit rules for the new scope:",_),[3,10];case 10:return[4,xe(!0)];case 11:return L.sent(),ne(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),[3,14];case 12:throw S=L.sent(),console.error("An error occurred during scope creation.",S),null===(T=Te.current)||void 0===T||T.show({severity:"error",summary:"Creation Failed",detail:(null===(b=null===(E=null==S?void 0:S.response)||void 0===E?void 0:E.data)||void 0===b?void 0:b.message)||"There was an error creating the scope. Please try again."}),S;case 13:return le(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:Ge,canCreateGlobal:Fe,globalScopeId:null!==(M=null===(P=null==Z?void 0:Z.data)||void 0===P?void 0:P.id)&&void 0!==M?M:null}):t.jsxs(t.Fragment,{children:[t.jsx(b.default,{isOpen:te.isOpen&&"DELETE"!==te.type&&"RENAME"!==te.type,onClose:function(){return ne(e.__assign(e.__assign({},te),{isOpen:!1}))},onCreate:function(e){e&&(he.current=e),xe(!0)},hasGlobalRuleSet:Ge,parentId:te.parentId}),t.jsx(D.default,{isOpen:te.isOpen&&"RENAME"===te.type,onClose:function(){return ne(e.__assign(e.__assign({},te),{isOpen:!1}))},onSave:function(n){return e.__awaiter(N,void 0,void 0,function(){var r,s,a,o;return e.__generator(this,function(l){switch(l.label){case 0:le(!0),l.label=1;case 1:return l.trys.push([1,4,5,6]),te.scopeId?[4,c.renameScope({scope_id:te.scopeId,scope_name:n})]:[2];case 2:return l.sent(),[4,xe(!0)];case 3:return l.sent(),ne(function(t){return e.__assign(e.__assign({},t),{isOpen:!1})}),[3,6];case 4:throw r=l.sent(),console.error("An error occurred during scope rename.",r),null===(s=Te.current)||void 0===s||s.show({severity:"error",sticky:!1,className:i.default.errorToast,content:t.jsx(j.default,{message:(null===(o=null===(a=null==r?void 0:r.response)||void 0===a?void 0:a.data)||void 0===o?void 0:o.message)||"There was an error renaming the scope. Please try again."})}),r;case 5:return le(!1),[7];case 6:return[2]}})})},initialName:te.initialName})]}),t.jsx(p.default,{isOpen:te.isOpen&&"DELETE"===te.type,onCancel:function(){return ne(e.__assign(e.__assign({},te),{isOpen:!1}))},onConfirm:function(){return ke(te.scopeId,te.initialName,te.isSubscope)},title:"Delete Scope",description:t.jsxs(t.Fragment,{children:["Deleting ",t.jsx("span",e.__assign({className:i.default.highlight},{children:te.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:oe})]}))})};
|
|
2
2
|
//# sourceMappingURL=LearningManagement.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),i=require("react/jsx-runtime"),r=require("react"),n=require("@tanstack/react-query"),t=require("lucide-react"),o=require("primereact/toast"),a=require("uuid"),s=require("../components/StationOnboarding/StationAutocomplete.js"),l=require("./AddScopeApprovalSearchComponent.js"),d=require("../components/ScopeSkeletonLoader.js"),u=require("@mui/material"),c=require("../store/useAuthStore.js"),p=require("../store/useAppSecRolesStore.js"),g=require("../store/useEnvStore.js"),_=require("../apis/scopeApis.js"),h=require("../store/useLearningTemplateStore.js"),f=require("../config.js"),m=require("../store/useLMSConfigStore.js");exports.default=function(v){var S=v.isOpen,x=v.onClose,y=v.onCreate,b=v.hasGlobalRuleSet,j=v.parentId,C=r.useState(""),w=C[0],D=C[1],q=r.useState(""),A=q[0],R=q[1],k=r.useState({}),I=k[0],F=k[1],L=r.useRef(null),z=c.default().user,E=p.useAppSecRolesStore(function(e){return e.roles}),N=g.default(function(e){return e.rbacConfig}),B=r.useState(null),W=B[0],T=B[1],G=r.useState("approval_required"),O=G[0],M=G[1],P=r.useState([]),K=P[0],U=P[1],X=r.useState([]),H=X[0],J=X[1],Q=r.useState(""),V=Q[0],Y=Q[1],Z=n.useMutation({mutationFn:function(i){return e.__awaiter(void 0,void 0,void 0,function(){var r;return e.__generator(this,function(e){switch(e.label){case 0:return[4,_.createRuleSet(i,null!==(r=null==z?void 0:z.accessToken)&&void 0!==r?r:"")];case 1:return[2,e.sent()]}})})},onSuccess:function(i){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){return console.log("Rule Set Created Successfully",i),[2]})})}});Z.data;var $=Z.isPending,ee=Z.mutateAsync;return r.useEffect(function(){S&&(D(""),R(""),F({}),T(null),M("approval_required"),U([]),J([]),Y(""))},[S]),S?$?i.jsx(d.default,{isLoading:$}):i.jsxs("div",e.__assign({style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"}},{children:[i.jsx(o.Toast,{ref:L}),i.jsxs("div",e.__assign({style:{position:"relative",width:600,borderRadius:12,backgroundColor:"white",padding:24,boxShadow:"0 25px 50px -12px rgba(0,0,0,0.25)"}},{children:[i.jsxs("div",e.__assign({style:{marginBottom:24,display:"flex",alignItems:"flex-start",justifyContent:"space-between"}},{children:[i.jsxs("div",{children:[i.jsx("h2",e.__assign({style:{margin:0,fontSize:18,fontWeight:500,color:"#19213D"}},{children:m.dt("middleDrawer.addScopeDialog.title","Add Scope")})),i.jsx("p",e.__assign({style:{margin:"4px 0 0 0",fontSize:14,fontWeight:400,color:"#666F8D"}},{children:m.dt("middleDrawer.addScopeDialog.subtitle","This scope will be created under Global and will inherit its Learnings by default.",{parent:"Global"})}))]}),i.jsx("button",e.__assign({onClick:x,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"#9CA3AF"}},{children:i.jsx(t.X,{size:24})}))]})),i.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:20}},{children:[i.jsxs("div",e.__assign({style:{position:"relative",display:"flex",flexDirection:"column",gap:6}},{children:[i.jsxs("label",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[i.jsx("span",e.__assign({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),m.dt("middleDrawer.addScopeDialog.scopeName","Scope Name")]})),"Custom"===w?i.jsx(s.default,{value:A,onChange:function(i){if(i.length>50)return R(i.slice(0,50)),void F(function(i){return e.__assign(e.__assign({},i),{name:"Scope Name must be 50 characters or fewer"})});R(i),F(function(i){return e.__assign(e.__assign({},i),{name:void 0})})},onStationSelect:function(e){T(e)},style:{border:I.name?"1px solid #8F2C23":void 0}}):i.jsx(u.Input,{value:A,onChange:function(i){var r=i.target.value;if(r.length>50)return R(r.slice(0,50)),void F(function(i){return e.__assign(e.__assign({},i),{name:"Scope Name must be 50 characters or fewer"})});R(r),F(function(i){return e.__assign(e.__assign({},i),{name:void 0})})},style:{border:"1px solid ".concat(I.name?"#8F2C23":"#F0F2F5")},placeholder:"e.g. Global Learnings"}),I.name&&i.jsx("p",e.__assign({style:{margin:"4px 0 0 0",fontSize:12,color:"#8F2C23"}},{children:I.name}))]})),i.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:12}},{children:[i.jsxs("label",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[i.jsx("span",e.__assign({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),m.dt("middleDrawer.addScopeDialog.learningApprovalSettings.title","Learning Approval Settings")]})),i.jsxs("div",e.__assign({role:"radio","aria-checked":"approval_required"===O,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){return M("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||M("approval_required")}},{children:[i.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:8}},{children:[i.jsx("div",e.__assign({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===O?"#2563EB":"#CBD5E1")}},{children:"approval_required"===O&&i.jsx("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),i.jsx("span",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:m.dt("middleDrawer.addScopeDialog.learningApprovalSettings.approvalRequired.title","Approval Required Before Publishing")}))]})),i.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:m.dt("middleDrawer.addScopeDialog.learningApprovalSettings.approvalRequired.subtitle","Learnings require approval before publishing.")}))]})),"approval_required"===O&&i.jsx(l.default,{selectedApprovers:K,selectedGroupOfApprovers:H,onApproversChange:U,onGroupsChange:J}),V&&i.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#8F2C23"}},{children:V})),i.jsxs("div",e.__assign({role:"radio","aria-checked":"publish_without"===O,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){M("publish_without"),Y("")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(M("publish_without"),Y(""))}},{children:[i.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:8}},{children:[i.jsx("div",e.__assign({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===O?"#2563EB":"#CBD5E1")}},{children:"publish_without"===O&&i.jsx("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),i.jsx("span",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:m.dt("middleDrawer.addScopeDialog.learningApprovalSettings.publishWithoutApproval.title","Publish Without Approval")}))]})),i.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:m.dt("middleDrawer.addScopeDialog.learningApprovalSettings.publishWithoutApproval.subtitle","Learnings can be published directly.")}))]}))]})),i.jsxs("div",e.__assign({style:{marginTop:32,display:"flex",justifyContent:"flex-end",gap:12}},{children:[i.jsx("button",e.__assign({onClick:x,style:{borderRadius:6,border:"1px solid #E2E8F0",padding:"8px 16px",fontSize:14,fontWeight:500,color:"#64748B",backgroundColor:"white",cursor:"pointer",opacity:$?.5:1},disabled:$},{children:m.dt("middleDrawer.addScopeDialog.cancel","Cancel")})),i.jsx("button",e.__assign({onClick:function(){return e.__awaiter(void 0,void 0,void 0,function(){var i,r,n,t,o,s,l,d,u,c,p,g,_,m;return e.__generator(this,function(v){switch(v.label){case 0:if(i={},A.trim()?A.length>50&&(i.name="Scope Name must be 50 characters or fewer"):i.name="Scope Name is required","approval_required"===O&&0===K.length&&0===H.length&&Y("Please select at least one approver or approver group."),i.name)return F(i),[2];if("approval_required"===O&&0===K.length&&0===H.length)return[2];Y(""),v.label=1;case 1:return v.trys.push([1,3,,4]),r="approval_required"===O,n=h.useLearningTemplateStore.getState().backwardCompatibility,t=n?{topic:b?"genreRuleSet":"globalRuleSet",customScopeGroupName:f.IL_CONFIG_CONSTANTS.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:A,parentScopeId:null,customScopeName:A,customScopeId:a.v4(),createByName:(null==z?void 0:z.firstname)||"System",createdBy:(null==z?void 0:z.email)||"system@audacy.com",approvalRequired:r,appsecData:{application:null==N?void 0:N.applicationId,module:null==N?void 0:N.moduleId,roles:e.__spreadArray(e.__spreadArray([],r?[{users:K.map(function(e){return e.email}),groups:H.map(function(e){return e._id}),role:null!==(d=null===(l=E.find(function(e){return"Learning Manager"===e.name}))||void 0===l?void 0:l._id)&&void 0!==d?d:""}]:[],!0),[{users:[null==z?void 0:z.email],groups:[],role:null!==(c=null===(u=E.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===u?void 0:u._id)&&void 0!==c?c:""}],!1)}}:{topic:b?"genreRuleSet":"globalRuleSet",scope_reference_id:null,scopeDescription:A,parentScopeId:null!=j?j:null,scopeName:A,scopeReferenceMetadata:{},scopeType:"Custom",applicationMappingId:h.useLearningTemplateStore.getState().app_integration_id},console.log("Add Scope payload:",t),[4,ee(t)];case 2:return o=v.sent(),y(null===(p=null==o?void 0:o.data)||void 0===p?void 0:p.scopeId),x(),[3,4];case 3:return s=v.sent(),console.error("An error occurred during scope creation.",s),null===(g=L.current)||void 0===g||g.show({severity:"error",summary:"Adding Scope Failed",detail:(null===(m=null===(_=null==s?void 0:s.response)||void 0===_?void 0:_.data)||void 0===m?void 0:m.message)||"There was an error creating the scope. Please try again."}),[3,4];case 4:return[2]}})})},style:{display:"flex",alignItems:"center",borderRadius:6,backgroundColor:"#2563EB",padding:"8px 16px",fontSize:14,fontWeight:500,color:"white",border:"none",cursor:"pointer",opacity:$||"Custom"===w&&!W?.5:1},disabled:$||"Custom"===w&&!W},{children:$?i.jsxs(i.Fragment,{children:[i.jsx(t.Loader2,{className:"animate-spin",style:{marginRight:8,height:16,width:16,color:"white"}}),"Creating..."]}):m.dt("middleDrawer.addScopeDialog.submitButton","Create Scope")}))]}))]}))]}))]})):null};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),t=require("react"),r=require("@tanstack/react-query"),i=require("lucide-react"),o=require("primereact/toast"),s=require("uuid"),a=require("../components/StationOnboarding/StationAutocomplete.js"),l=require("./AddScopeApprovalSearchComponent.js"),u=require("../components/ScopeSkeletonLoader.js"),c=require("@mui/material"),d=require("../store/useAuthStore.js"),p=require("../store/useAppSecRolesStore.js"),_=require("../store/useEnvStore.js"),g=require("../apis/scopeApis.js"),h=require("../store/useLearningTemplateStore.js"),f=require("../config.js"),m=require("../store/useLMSConfigStore.js"),v=require("../constants.js");exports.default=function(S){var x=S.isOpen,y=S.onClose,b=S.onCreate,D=S.hasGlobalRuleSet,A=S.parentId,j=t.useState(""),C=j[0],R=j[1],E=t.useState(""),T=E[0],q=E[1],I=t.useState({}),L=I[0],P=I[1],w=t.useRef(null),k=d.default().user,W=p.useAppSecRolesStore(function(e){return e.roles}),N=_.default(function(e){return e.rbacConfig}),O=t.useState(null),F=O[0],M=O[1],z=t.useState("approval_required"),G=z[0],B=z[1],H=t.useState([]),V=H[0],K=H[1],U=t.useState([]),X=U[0],J=U[1],Q=t.useState(""),Y=Q[0],Z=Q[1],$=r.useMutation({mutationFn:function(n){return e.__awaiter(void 0,void 0,void 0,function(){var t;return e.__generator(this,function(e){switch(e.label){case 0:return[4,g.createRuleSet(n,null!==(t=null==k?void 0:k.accessToken)&&void 0!==t?t:"")];case 1:return[2,e.sent()]}})})},onSuccess:function(n){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){return console.log("Rule Set Created Successfully",n),[2]})})}});$.data;var ee=$.isPending,ne=$.mutateAsync;return t.useEffect(function(){x&&(R(""),q(""),P({}),M(null),B("approval_required"),K([]),J([]),Z(""))},[x]),x?ee?n.jsx(u.default,{isLoading:ee}):n.jsxs("div",e.__assign({style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"}},{children:[n.jsx(o.Toast,{ref:w}),n.jsxs("div",e.__assign({style:{position:"relative",width:600,borderRadius:12,backgroundColor:"white",padding:24,boxShadow:"0 25px 50px -12px rgba(0,0,0,0.25)"}},{children:[n.jsxs("div",e.__assign({style:{marginBottom:24,display:"flex",alignItems:"flex-start",justifyContent:"space-between"}},{children:[n.jsxs("div",{children:[n.jsx("h2",e.__assign({style:{margin:0,fontSize:18,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".title"),"Add Scope")})),n.jsx("p",e.__assign({style:{margin:"4px 0 0 0",fontSize:14,fontWeight:400,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".subtitle"),"This scope will be created under Global and will inherit its Learnings by default.",{parent:"Global"})}))]}),n.jsx("button",e.__assign({onClick:y,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"#9CA3AF"}},{children:n.jsx(i.X,{size:24})}))]})),n.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:20}},{children:[n.jsxs("div",e.__assign({style:{position:"relative",display:"flex",flexDirection:"column",gap:6}},{children:[n.jsxs("label",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[n.jsx("span",e.__assign({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".scopeName"),"Scope Name")]})),"Custom"===C?n.jsx(a.default,{value:T,onChange:function(n){if(n.length>50)return q(n.slice(0,50)),void P(function(n){return e.__assign(e.__assign({},n),{name:"Scope Name must be 50 characters or fewer"})});q(n),P(function(n){return e.__assign(e.__assign({},n),{name:void 0})})},onStationSelect:function(e){M(e)},style:{border:L.name?"1px solid #8F2C23":void 0}}):n.jsx(c.Input,{value:T,onChange:function(n){var t=n.target.value;if(t.length>50)return q(t.slice(0,50)),void P(function(n){return e.__assign(e.__assign({},n),{name:"Scope Name must be 50 characters or fewer"})});q(t),P(function(n){return e.__assign(e.__assign({},n),{name:void 0})})},style:{border:"1px solid ".concat(L.name?"#8F2C23":"#F0F2F5")},placeholder:"e.g. Global Learnings"}),L.name&&n.jsx("p",e.__assign({style:{margin:"4px 0 0 0",fontSize:12,color:"#8F2C23"}},{children:L.name}))]})),n.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:12}},{children:[n.jsxs("label",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[n.jsx("span",e.__assign({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".title"),"Learning Approval Settings")]})),n.jsxs("div",e.__assign({role:"radio","aria-checked":"approval_required"===G,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){return B("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||B("approval_required")}},{children:[n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:8}},{children:[n.jsx("div",e.__assign({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===G?"#2563EB":"#CBD5E1")}},{children:"approval_required"===G&&n.jsx("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),n.jsx("span",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".approvalRequired.title"),"Approval Required Before Publishing")}))]})),n.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".approvalRequired.subtitle"),"Learnings require approval before publishing.")}))]})),"approval_required"===G&&n.jsx(l.default,{selectedApprovers:V,selectedGroupOfApprovers:X,onApproversChange:K,onGroupsChange:J}),Y&&n.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#8F2C23"}},{children:Y})),n.jsxs("div",e.__assign({role:"radio","aria-checked":"publish_without"===G,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){B("publish_without"),Z("")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(B("publish_without"),Z(""))}},{children:[n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:8}},{children:[n.jsx("div",e.__assign({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===G?"#2563EB":"#CBD5E1")}},{children:"publish_without"===G&&n.jsx("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),n.jsx("span",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".publishWithoutApproval.title"),"Publish Without Approval")}))]})),n.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".publishWithoutApproval.subtitle"),"Learnings can be published directly.")}))]}))]})),n.jsxs("div",e.__assign({style:{marginTop:32,display:"flex",justifyContent:"flex-end",gap:12}},{children:[n.jsx("button",e.__assign({onClick:y,style:{borderRadius:6,border:"1px solid #E2E8F0",padding:"8px 16px",fontSize:14,fontWeight:500,color:"#64748B",backgroundColor:"white",cursor:"pointer",opacity:ee?.5:1},disabled:ee},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".cancel"),"Cancel")})),n.jsx("button",e.__assign({onClick:function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,t,r,i,o,a,l,u,c,d,p,_,g,m;return e.__generator(this,function(v){switch(v.label){case 0:if(n={},T.trim()?T.length>50&&(n.name="Scope Name must be 50 characters or fewer"):n.name="Scope Name is required","approval_required"===G&&0===V.length&&0===X.length&&Z("Please select at least one approver or approver group."),n.name)return P(n),[2];if("approval_required"===G&&0===V.length&&0===X.length)return[2];Z(""),v.label=1;case 1:return v.trys.push([1,3,,4]),t="approval_required"===G,r=h.useLearningTemplateStore.getState().backwardCompatibility,i=r?{topic:D?"genreRuleSet":"globalRuleSet",customScopeGroupName:f.IL_CONFIG_CONSTANTS.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:T,parentScopeId:null,customScopeName:T,customScopeId:s.v4(),createByName:(null==k?void 0:k.firstname)||"System",createdBy:(null==k?void 0:k.email)||"system@audacy.com",approvalRequired:t,appsecData:{application:null==N?void 0:N.applicationId,module:null==N?void 0:N.moduleId,roles:e.__spreadArray(e.__spreadArray([],t?[{users:V.map(function(e){return e.email}),groups:X.map(function(e){return e._id}),role:null!==(u=null===(l=W.find(function(e){return"Learning Manager"===e.name}))||void 0===l?void 0:l._id)&&void 0!==u?u:""}]:[],!0),[{users:[null==k?void 0:k.email],groups:[],role:null!==(d=null===(c=W.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===c?void 0:c._id)&&void 0!==d?d:""}],!1)}}:{topic:D?"genreRuleSet":"globalRuleSet",scope_reference_id:null,scopeDescription:T,parentScopeId:null!=A?A:null,scopeName:T,scopeReferenceMetadata:{},scopeType:"Custom",applicationMappingId:h.useLearningTemplateStore.getState().app_integration_id},console.log("Add Scope payload:",i),[4,ne(i)];case 2:return o=v.sent(),b(null===(p=null==o?void 0:o.data)||void 0===p?void 0:p.scopeId),y(),[3,4];case 3:return a=v.sent(),console.error("An error occurred during scope creation.",a),null===(_=w.current)||void 0===_||_.show({severity:"error",summary:"Adding Scope Failed",detail:(null===(m=null===(g=null==a?void 0:a.response)||void 0===g?void 0:g.data)||void 0===m?void 0:m.message)||"There was an error creating the scope. Please try again."}),[3,4];case 4:return[2]}})})},style:{display:"flex",alignItems:"center",borderRadius:6,backgroundColor:"#2563EB",padding:"8px 16px",fontSize:14,fontWeight:500,color:"white",border:"none",cursor:"pointer",opacity:ee||"Custom"===C&&!F?.5:1},disabled:ee||"Custom"===C&&!F},{children:ee?n.jsxs(n.Fragment,{children:[n.jsx(i.Loader2,{className:"animate-spin",style:{marginRight:8,height:16,width:16,color:"white"}}),"Creating..."]}):m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".submitButton"),"Create Scope")}))]}))]}))]}))]})):null};
|
|
2
2
|
//# sourceMappingURL=AddScopeModal.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),o=require("react"),t=require("@mui/material"),i=require("@mui/icons-material/Check"),r=require("@mui/icons-material/CloseRounded"),a=require("lucide-react"),s=require("../store/useLMSConfigStore.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),o=require("react"),t=require("@mui/material"),i=require("@mui/icons-material/Check"),r=require("@mui/icons-material/CloseRounded"),a=require("lucide-react"),s=require("../store/useLMSConfigStore.js"),c=require("../constants.js");function l(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var d=l(i),u=l(r),p={header:{padding:"16px 16px 0",display:"flex",justifyContent:"space-between",alignItems:"center"},title:{color:"#334155",fontSize:"1rem"},closeButton:{border:"none",background:"transparent",padding:0,color:"#9CA3AF",cursor:"pointer",outline:"none",transition:"color 150ms ease-in-out"},dialogContent:{padding:"8px 16px"},description:{color:"#475569",fontSize:"0.875rem",lineHeight:1.625},descriptionStrong:{fontWeight:700,color:"#1E293B"},secondaryDescription:{color:"#475569",fontSize:"0.875rem",marginTop:"8px"},rejectSection:{marginTop:"20px"},feedbackLabel:{display:"block",fontSize:"0.875rem",fontWeight:600,color:"#334155",marginBottom:"6px"},textarea:{width:"100%",fontSize:"0.875rem",color:"#1E293B",padding:"10px",border:"1px solid #E2E8F0",borderRadius:"0.5rem",outline:"none",resize:"none",transition:"border-color 150ms ease-in-out, box-shadow 150ms ease-in-out",boxSizing:"border-box",fontFamily:"inherit"},checkboxLabel:{display:"flex",justifyContent:"flex-end",alignItems:"center",gap:"8px",cursor:"pointer",userSelect:"none",marginTop:"16px"},checkbox:{margin:0,height:"1.125rem",width:"1.125rem",borderRadius:"0.25rem",border:"1px solid #CBD5E1",accentColor:"#DC2626",cursor:"pointer"},checkboxTextWrap:{display:"flex",alignItems:"center"},checkboxText:{fontSize:"0.875rem",fontWeight:500,color:"#1E293B",transition:"color 150ms ease-in-out"},actions:{padding:"24px",gap:"8px"},secondaryButton:{padding:"8px 20px",fontSize:"0.875rem",fontWeight:500,color:"#475569",border:"1px solid #E2E8F0",borderRadius:"0.5rem",backgroundColor:"#FFFFFF",transition:"background-color 150ms ease-in-out, border-color 150ms ease-in-out",cursor:"pointer"},primaryButton:{display:"inline-flex",alignItems:"center",gap:"0.375rem",padding:"8px 20px",fontSize:"0.875rem",fontWeight:500,color:"#FFFFFF",border:"none",borderRadius:"0.5rem",transition:"background-color 150ms ease-in-out",boxShadow:"none",cursor:"pointer"},actionIcon:{width:"1rem",height:"1rem",fontSize:"1rem"},variantCard:{backgroundColor:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:"10px",padding:"16px 20px",marginTop:"12px"},variantCardTitle:{fontSize:"0.9375rem",fontWeight:700,color:"#111111",marginBottom:"4px"},variantCardDescription:{fontSize:"0.8125rem",color:"#374151",marginBottom:"12px",lineHeight:1.5},variantCardMono:{fontSize:"0.75rem",color:"#4b5563",fontFamily:"ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace",lineHeight:1.6}};exports.default=function(i){var r=i.open,l=i.mode,g=i.onClose,x=i.onSubmit,_=i.variantInformation,b=i.ruleTitle,h=i.pendingVariants,f=void 0===h?[]:h,m=i.isPending,j=void 0!==m&&m,y=o.useState(""),T=y[0],v=y[1],C=o.useState(!0),A=C[0],D=C[1],k=o.useState(!1),E=k[0],F=k[1],L=o.useState(!1),S=L[0],N=L[1],I=o.useState(!1),R=I[0],w=I[1],B=o.useState(!1),M=B[0],z=B[1],P=o.useState(!1),H=P[0],G=P[1],W="undefined"!=typeof document?document.getElementById("rule-template-layout-content"):null,q="reject"===l,V=function(){x(q?{feedback:T,deleteLearning:A}:{}),v(""),D(!1)},O=function(){v(""),D(!1),g()};return n.jsxs(t.Dialog,e.__assign({open:r,onClose:O,container:W,maxWidth:!1,fullWidth:!0,sx:{position:"absolute",inset:0,zIndex:999,"& .MuiBackdrop-root":{position:"absolute"},"& .MuiDialog-container":{alignItems:"center",justifyContent:"center",padding:"24px 16px"},"& .MuiDialog-paper":{width:"100%",maxWidth:"640px",margin:0,borderRadius:"16px"}}},{children:[n.jsxs("div",e.__assign({style:p.header},{children:[n.jsx("div",e.__assign({style:p.title},{children:"".concat(q?s.dt("".concat(c.LEARNING_DT_PATH,".rejectDialog.title"),"Reject Learning"):s.dt("".concat(c.LEARNING_DT_PATH,".approveDialog.title"),"Approve Learning"))})),n.jsx("button",e.__assign({onClick:g,onMouseEnter:function(){return F(!0)},onMouseLeave:function(){return F(!1)},style:e.__assign(e.__assign({},p.closeButton),{color:E?"#4B5563":"#9CA3AF"})},{children:n.jsx(a.X,{size:24})}))]})),n.jsxs(t.DialogContent,e.__assign({sx:p.dialogContent},{children:[n.jsxs(t.DialogContentText,e.__assign({sx:p.description},{children:[n.jsx("span",e.__assign({style:p.descriptionStrong},{children:_}))," ","".concat(q?s.dt("".concat(c.LEARNING_DT_PATH,".rejectDialog.desc"),"will not be published or applied within the selected scope. You can provide feedback before rejecting"):s.dt("".concat(c.LEARNING_DT_PATH,".approveDialog.desc"),"will be published and become active within the selected scope after approval."))]})),f.length>0&&n.jsx("div",{children:f.map(function(o,t){return n.jsxs("div",e.__assign({style:p.variantCard},{children:[n.jsxs("div",e.__assign({style:p.variantCardTitle},{children:[b,f.length>1?" — Variant ".concat(t+1):""]})),o.description&&n.jsx("div",e.__assign({style:p.variantCardDescription},{children:o.description})),n.jsxs("div",e.__assign({style:p.variantCardMono},{children:[o.whenToApply&&n.jsxs("div",{children:["WTA — ",o.whenToApply]}),o.whenNotToApply&&n.jsxs("div",{children:["WNTA — ",o.whenNotToApply]})]}))]}),o.variantId)})}),n.jsx(t.DialogContentText,e.__assign({sx:p.secondaryDescription},{children:q?"":s.dt("".concat(c.LEARNING_DT_PATH,".approveDialog.footer"),"Take a moment to check the configuration before moving forward.")})),q&&n.jsxs("div",e.__assign({style:p.rejectSection},{children:[n.jsxs("div",{children:[n.jsx("label",e.__assign({htmlFor:"feedback",style:p.feedbackLabel},{children:s.dt("".concat(c.LEARNING_DT_PATH,".rejectDialog.feedbackTitle"),"Feedback")})),n.jsx("textarea",{id:"feedback",rows:4,value:T,onChange:function(e){return v(e.target.value)},onFocus:function(){return N(!0)},onBlur:function(){return N(!1)},placeholder:"".concat(s.dt("".concat(c.LEARNING_DT_PATH,".rejectDialog.feedbackPlaceholder"),"Add feedback or reason for rejection")),style:e.__assign(e.__assign({},p.textarea),{borderColor:S?"#EF4444":"#E2E8F0",boxShadow:S?"0 0 0 2px rgba(239, 68, 68, 0.2)":"none"})})]}),n.jsxs("label",e.__assign({style:p.checkboxLabel,onMouseEnter:function(){return w(!0)},onMouseLeave:function(){return w(!1)}},{children:[n.jsx("input",{type:"checkbox",checked:A,disabled:!1,onChange:function(e){return D(e.target.checked)},style:p.checkbox}),n.jsx("div",e.__assign({style:p.checkboxTextWrap},{children:n.jsx("span",e.__assign({style:e.__assign(e.__assign({},p.checkboxText),{color:R?"#0F172A":"#1E293B"})},{children:s.dt("".concat(c.LEARNING_DT_PATH,".rejectDialog.deleteCheckboxLabel"),"Also delete this learning")}))}))]}))]}))]})),n.jsxs(t.DialogActions,e.__assign({sx:p.actions},{children:[n.jsx("button",e.__assign({onClick:O,type:"button",disabled:j,onMouseEnter:function(){return z(!0)},onMouseLeave:function(){return z(!1)},style:e.__assign(e.__assign({},p.secondaryButton),{backgroundColor:M&&!j?"#F8FAFC":"#FFFFFF",borderColor:M&&!j?"#CBD5E1":"#E2E8F0",opacity:j?.5:1,cursor:j?"not-allowed":"pointer"})},{children:s.dt("".concat(c.LEARNING_DT_PATH,".approveDialog.cancel"),"Cancel")})),q?n.jsxs("button",e.__assign({onClick:V,type:"button",disabled:j,onMouseEnter:function(){return G(!0)},onMouseLeave:function(){return G(!1)},style:e.__assign(e.__assign({},p.primaryButton),{backgroundColor:j?"#EF4444":H?"#DC2626":"#EF4444",opacity:j?.7:1,cursor:j?"not-allowed":"pointer"})},{children:[j?n.jsx(a.Loader2,{size:16,style:{animation:"spin 1s linear infinite"}}):n.jsx(u.default,{sx:p.actionIcon}),j?s.dt("".concat(c.LEARNING_DT_PATH,".rejectDialog.loadingText"),"Processing..."):s.dt("".concat(c.LEARNING_DT_PATH,".rejectDialog.rejectLearning"),"Reject Learning")]})):n.jsxs("button",e.__assign({onClick:V,type:"button",disabled:j,onMouseEnter:function(){return G(!0)},onMouseLeave:function(){return G(!1)},style:e.__assign(e.__assign({},p.primaryButton),{backgroundColor:j?"#22C55E":H?"#16A34A":"#22C55E",opacity:j?.7:1,cursor:j?"not-allowed":"pointer"})},{children:[j?n.jsx(a.Loader2,{size:16,style:{animation:"spin 1s linear infinite"}}):n.jsx(d.default,{sx:p.actionIcon}),j?s.dt("".concat(c.LEARNING_DT_PATH,".approveDialog.loadingText"),"Processing..."):s.dt("".concat(c.LEARNING_DT_PATH,".approveDialog.approveLearning"),"Approve Learning")]}))]})),n.jsx("style",{children:"@keyframes spin { to { transform: rotate(360deg); } }"})]}))};
|
|
2
2
|
//# sourceMappingURL=ApprovalLearningDialog.js.map
|