@e-llm-studio/instant-learning 1.3.0-alpha.44 → 1.3.0-alpha.46
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js +1 -1
- package/dist/cjs/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.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/RuleContent.js +1 -1
- package/dist/cjs/features/LearningManagement/RuleContent/VariantCard.js +1 -1
- package/dist/cjs/features/LearningManagement/apis/apiConfig.js +1 -1
- package/dist/cjs/features/LearningManagement/apis/scopeApis.js +1 -1
- package/dist/cjs/features/LearningManagement/components/EmptyLearningState.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/store/useLMSConfigStore.js +1 -1
- package/dist/cjs/plugins/ValueTypes/Guidelines/GuidelinesTeachMeRenderer.js +1 -1
- package/dist/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.js +1 -1
- package/dist/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.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/RuleContent.js +1 -1
- package/dist/features/LearningManagement/RuleContent/VariantCard.js +1 -1
- package/dist/features/LearningManagement/apis/apiConfig.js +1 -1
- package/dist/features/LearningManagement/apis/scopeApis.js +1 -1
- package/dist/features/LearningManagement/components/EmptyLearningState.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/store/useLMSConfigStore.js +1 -1
- package/dist/plugins/ValueTypes/Guidelines/GuidelinesTeachMeRenderer.js +1 -1
- package/dist/types/src/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.d.ts +1 -0
- package/dist/types/src/features/IL-OTJ/ValueTypeWrappers/TeachMePlugin.d.ts.map +1 -1
- package/dist/types/src/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.d.ts +1 -0
- package/dist/types/src/features/IL-OTJ/ValueTypeWrappers/TeachMeWrapper.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/RuleContent.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/apis/apiConfig.d.ts +2 -0
- package/dist/types/src/features/LearningManagement/apis/apiConfig.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/apis/scopeApis.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/components/EmptyLearningState.d.ts +6 -0
- package/dist/types/src/features/LearningManagement/components/EmptyLearningState.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/store/useLMSConfigStore.d.ts +1 -0
- package/dist/types/src/features/LearningManagement/store/useLMSConfigStore.d.ts.map +1 -1
- package/dist/types/src/plugins/ValueTypes/Category/CategoryTeachMeRenderer.d.ts +1 -0
- package/dist/types/src/plugins/ValueTypes/Category/CategoryTeachMeRenderer.d.ts.map +1 -1
- package/dist/types/src/plugins/ValueTypes/Guidelines/GuidelinesTeachMeRenderer.d.ts +1 -0
- package/dist/types/src/plugins/ValueTypes/Guidelines/GuidelinesTeachMeRenderer.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/features/LearningManagement/assets/Search-result(add new).svg.js +0 -2
- package/dist/cjs/features/LearningManagement/assets/Search-result(add new).svg.js.map +0 -1
- package/dist/cjs/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js +0 -2
- package/dist/cjs/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js.map +0 -1
- package/dist/features/LearningManagement/assets/Search-result(add new).svg.js +0 -2
- package/dist/features/LearningManagement/assets/Search-result(add new).svg.js.map +0 -1
- package/dist/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js +0 -2
- package/dist/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.js.map +0 -1
- package/dist/types/src/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.d.ts +0 -12
- package/dist/types/src/features/LearningManagement/components/StationOnboarding/BackwardStationOnboardModal.d.ts.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),o=require("react/jsx-runtime"),n=require("lucide-react"),i=require("../../styles/ScopeTree.module.css.js"),d=require("./TreeNodeHeader.js"),t=require("./TreeSectionItem.js"),r=require("./TreeAddAction.js"),l=require("../../store/useLMSConfigStore.js"),a=require("../../constants.js"),c=function(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),o=require("react/jsx-runtime"),n=require("lucide-react"),i=require("../../styles/ScopeTree.module.css.js"),d=require("./TreeNodeHeader.js"),t=require("./TreeSectionItem.js"),r=require("./TreeAddAction.js"),l=require("../../store/useLMSConfigStore.js"),a=require("../../constants.js"),s=require("../../store/useLearningTemplateStore.js"),c=function(u){var p,h,v,C,m=u.node,T=u.depth,g=void 0===T?0:T,b=u.nodePath,f=void 0===b?[]:b,_=u.expandedNodeIds,S=u.activeSelection,y=u.onToggleExpand,A=u.onSectionSelect,D=u.onNodeOptionsClick,x=u.onAddChild,E=u.onRenameChild,j=u.onDeleteChild,L=u.canDeleteScope,N=u.canEditScope,P=u.canCreateScope,q=u.searchQuery,R=u.sectionsConfig,k=void 0===R?[]:R,I=u.nodeTypesConfig,w=void 0===I?[]:I,M=u.forceVisible,O=void 0!==M&&M,H=e.__spreadArray(e.__spreadArray([],f,!0),[m.id],!1),W=_.has(m.id),V=s.useLearningTemplateStore.getState().backwardCompatibility,Q=l.dt("".concat(a.MIDDLE_DRAWER_DT_PATH,".scope")),Y=!!S&&S.nodePath[S.nodePath.length-1]===m.id,K=!!S&&(S.nodePath.includes(m.id)&&!Y),U=function(e,o){if(!o)return!0;var n=o.toLowerCase();return!!e.name.toLowerCase().includes(n)||!!e.children&&e.children.some(function(e){return U(e,o)})};if(!O&&!U(m,q||""))return null;var X=g>=w.length-1?w[w.length-1]:w[g],z=!!(null==X?void 0:X.addChildType),B=!L||L(m.id),F=!N||N(m.id),G=!P||P(m.id),J=m.children&&m.children.length>0,Z=!B||J,$=B?J?"This scope cannot be deleted because other scopes inherit learnings from it.":void 0:"You do not have permission to delete this scope.",ee=G?void 0:"You do not have permission to add a scope here.",oe=!q||m.name.toLowerCase().includes(q.toLowerCase());return o.jsxs("div",e.__assign({className:i.default.nodeWrapper,style:{"--tree-depth":g}},{children:[o.jsx(d.TreeNodeHeader,{nodeType:m.type,name:m.name,isExpanded:W,isSelected:Y,isAncestor:K,childrenCount:null===(p=m.children)||void 0===p?void 0:p.length,onToggleExpand:function(e){e.stopPropagation(),y(m.id)},onClick:function(){A(H,"learnings")},searchQuery:q,menuOptions:e.__spreadArray(e.__spreadArray([],z?[{label:X.addChildLabel||"Add Child",icon:n.Plus,onClick:function(){return null==x?void 0:x(m.id,X.addChildType,m.name)},disabled:!G,tooltip:ee}]:[],!0),[{label:"".concat(l.dt("".concat(a.MIDDLE_DRAWER_CONTEXT_MENU_DT_PATH,".rename"),"Rename")),icon:n.Pencil,onClick:function(){return null==E?void 0:E(m.id,m.name)},disabled:!F||"station"===(null===(h=null==m?void 0:m.type)||void 0===h?void 0:h.toLocaleLowerCase()),tooltip:F?void 0:"You do not have permission to rename this scope."},{label:"station"===(null===(v=null==m?void 0:m.type)||void 0===v?void 0:v.toLowerCase())?"Delete Station":V?"Delete Scope":"".concat(l.dt("".concat(a.MIDDLE_DRAWER_CONTEXT_MENU_DT_PATH,".delete"),"Delete ".concat((null==X?void 0:X.label)||"Node"),{scope:Q})),icon:n.Trash2,onClick:function(){var e;return null==j?void 0:j(m.id,m.name,(null===(e=m.metrics)||void 0===e?void 0:e.learningsCount)||0)},disabled:Z,tooltip:$,className:"text-red-500 hover:text-red-600 hover:bg-red-50"}],!1)}),W&&o.jsxs("div",e.__assign({className:i.default.childrenWrapper},{children:[k.filter(function(e){return!e.isVisible||e.isVisible(m,g)}).map(function(e){var n;return o.jsx(t.TreeSectionItem,{icon:e.icon,label:e.label,badgeCount:e.badgeKey?null===(n=m.metrics)||void 0===n?void 0:n[e.badgeKey]:void 0,isActive:Y&&(null==S?void 0:S.sectionId)===e.id,onClick:function(){return A(H,e.id)}},"".concat(m.id,"-").concat(e.id))}),null===(C=m.children)||void 0===C?void 0:C.map(function(e){return o.jsx(c,{node:e,depth:g+1,nodePath:H,expandedNodeIds:_,activeSelection:S,onToggleExpand:y,onSectionSelect:A,onNodeOptionsClick:D,onAddChild:x,onRenameChild:E,onDeleteChild:j,canDeleteScope:L,canEditScope:N,canCreateScope:P,searchQuery:q,forceVisible:oe,sectionsConfig:k,nodeTypesConfig:w},e.id)}),z&&o.jsx(r.TreeAddAction,{label:X.addChildLabel||"Add Child",onAdd:function(){return null==x?void 0:x(m.id,X.addChildType,m.name)},disabled:!G,tooltip:ee})]}))]}))};exports.TreeNode=c;
|
|
2
2
|
//# sourceMappingURL=TreeNode.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("zustand"),t=require("./useLearningTemplateStore.js"),n={pageTitle:"",middleDrawer:{scope:"",addScope:"",addSubScope:"",addScopeDialog:{title:"",globalTitle:"",subtitle:"",globalSubtitle:"",scopeName:"",learningApprovalSettings:{title:"",approvalRequired:{title:"",subtitle:""},publishWithoutApproval:{title:"",subtitle:""}},submitButton:"",cancel:""},treeMenu:{search:"",submenu:{learnings:"",access:"",changeHistory:""},contextMenu:{addScope:"",rename:"",delete:"",addSubScope:""}}},learnings:{header:{title:"",exportButton:"",addNewLearningButton:""},tier:{showTierHeader:!0,tierHeader:"",subtitle:"",tierHeaderNoOfLearnings:"",deleteDialog:{title:"",description:"",cancel:"",submit:""},learning:{inheritance:"",actions:{disable:"",enable:"",approve:"",reject:"",delete:""},approveDialog:{title:"",desc:"",footer:"",cancel:"",approveLearning:""},rejectDialog:{title:"",desc:"",feedbackTitle:"",feedbackPlaceholder:"",deleteCheckboxLabel:"",cancel:"",rejectLearning:""},deleteDialog:{title:"",desc:"",warningText:"",cancelText:"",deleteText:""}}}},emptyStateLearning:{title:"",desc:"",createNewLearning:"",createGlobalScope:"",noAccessTitle:"",noAccessDesc:"",requestAccessButton:""},agents:{LearningTerm:""}},a={showScope:!1,showConfiguration:!1,welcomeMessage:"Hi! 👋 I'm your Instant Learning Concierge.",welcomeMessageSubtitle:"How would you like to get started? You can select an option below or describe the rule you'd like to create.",actions:[{label:"Separation rule",value:"I would want to add a separation rule"},{label:"Max priority rule",value:"I would want to set a max priority rule"},{label:"Break code matching",value:"I would want to add a break code matching rule"},{label:"Inventory code matching",value:"I would want to add a inventory window matching rule"},{label:"Enter a rule description",value:"I want to add a rule description"},{label:"Tester Genie",value:"Loading prompt..."}],chatTitle:"Teach Me OTJ - {scope} - Add Learning",chatTitleEdit:"Teach Me OTJ - {scope} - Edit Learning",formTitle:"Rule setup",setupLabel:"Configure your IL",ruleTitle:"Main Rule Name",scopeLabel:"Define Scope",tierLabel:"Select Tiers",ruleDescriptionTitle:"Learning Explanation",whenToApplyTitle:"Trigger Events (When to Apply)",addWhenToApplyBtnLabel:"Add WTA",whenNotToApplyTitle:"Exclusion Events (When NOT to Apply)",addWhenNotToApplyBtnLabel:"Add WNTA",configTitle:"Advanced Settings",saveBtnLabel:"Save Rule",saveBtnLoadingLabel:"Saving Rule...",chatTextareaPlaceholder:"Tell me more about this learning.."},l=e.create(function(e){return{lmsConfig:n,setLMSConfig:function(t){return e({lmsConfig:t})},clearLMSConfig:function(){return e({lmsConfig:n})}}});var i=e.create(function(e){return{teachMeConfig:null,setTeachMeConfig:function(t){return e({teachMeConfig:t})},clearTeachMeConfig:function(){return e({teachMeConfig:null})}}});exports.defaultLMSConfig=n,exports.defaultTeachMeConfig=a,exports.dt=function(e,n,a){if(t.useLearningTemplateStore.getState().backwardCompatibility)return null!=n?n:"";var i=l.getState().lmsConfig,o=e.split(".").reduce(function(e,t){return null==e?void 0:e[t]},i);return"string"!=typeof o||""===o?null!=n?n:e:o.replace(/\{(\w+)\}/g,function(e,t){var n;return String(null!==(n=null==a?void 0:a[t])&&void 0!==n?n:"{".concat(t,"}"))})},exports.dtt=function(e,t,n){var a=i.getState().teachMeConfig,l=e.split(".").reduce(function(e,t){return null==e?void 0:e[t]},a);return"string"!=typeof l?null!=t?t:e:l.replace(/\{(\w+)\}/g,function(e,t){var a;return String(null!==(a=null==n?void 0:n[t])&&void 0!==a?a:"{".concat(t,"}"))})},exports.dttWelcomeMessageParts=function(){var e,t,n=null!==(e=i.getState().teachMeConfig)&&void 0!==e?e:a;return{greeting:n.welcomeMessage||a.welcomeMessage,subtitle:n.welcomeMessageSubtitle||a.welcomeMessageSubtitle,actions:(null===(t=n.actions)||void 0===t?void 0:t.length)?n.actions:a.actions}},exports.useLMSConfigStore=l,exports.useTeachMeConfigStore=i;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("zustand"),t=require("./useLearningTemplateStore.js"),n={pageTitle:"",middleDrawer:{scope:"",addScope:"",addSubScope:"",addScopeDialog:{title:"",globalTitle:"",subtitle:"",globalSubtitle:"",scopeName:"",learningApprovalSettings:{title:"",approvalRequired:{title:"",subtitle:""},publishWithoutApproval:{title:"",subtitle:""}},submitButton:"",cancel:""},treeMenu:{search:"",submenu:{learnings:"",access:"",changeHistory:""},contextMenu:{addScope:"",rename:"",delete:"",addSubScope:""}}},learnings:{header:{title:"",exportButton:"",addNewLearningButton:""},tier:{showTierHeader:!0,tierHeader:"",subtitle:"",tierHeaderNoOfLearnings:"",deleteDialog:{title:"",description:"",cancel:"",submit:""},learning:{inheritance:"",actions:{disable:"",enable:"",approve:"",reject:"",delete:""},approveDialog:{title:"",desc:"",footer:"",cancel:"",approveLearning:""},rejectDialog:{title:"",desc:"",feedbackTitle:"",feedbackPlaceholder:"",deleteCheckboxLabel:"",cancel:"",rejectLearning:""},deleteDialog:{title:"",desc:"",warningText:"",cancelText:"",deleteText:""}}}},emptyStateLearning:{title:"",desc:"",createNewLearning:"",createGlobalScope:"",noAccessTitle:"",noAccessDesc:"",requestAccessButton:"",requestSentButton:""},agents:{LearningTerm:""}},a={showScope:!1,showConfiguration:!1,welcomeMessage:"Hi! 👋 I'm your Instant Learning Concierge.",welcomeMessageSubtitle:"How would you like to get started? You can select an option below or describe the rule you'd like to create.",actions:[{label:"Separation rule",value:"I would want to add a separation rule"},{label:"Max priority rule",value:"I would want to set a max priority rule"},{label:"Break code matching",value:"I would want to add a break code matching rule"},{label:"Inventory code matching",value:"I would want to add a inventory window matching rule"},{label:"Enter a rule description",value:"I want to add a rule description"},{label:"Tester Genie",value:"Loading prompt..."}],chatTitle:"Teach Me OTJ - {scope} - Add Learning",chatTitleEdit:"Teach Me OTJ - {scope} - Edit Learning",formTitle:"Rule setup",setupLabel:"Configure your IL",ruleTitle:"Main Rule Name",scopeLabel:"Define Scope",tierLabel:"Select Tiers",ruleDescriptionTitle:"Learning Explanation",whenToApplyTitle:"Trigger Events (When to Apply)",addWhenToApplyBtnLabel:"Add WTA",whenNotToApplyTitle:"Exclusion Events (When NOT to Apply)",addWhenNotToApplyBtnLabel:"Add WNTA",configTitle:"Advanced Settings",saveBtnLabel:"Save Rule",saveBtnLoadingLabel:"Saving Rule...",chatTextareaPlaceholder:"Tell me more about this learning.."},l=e.create(function(e){return{lmsConfig:n,setLMSConfig:function(t){return e({lmsConfig:t})},clearLMSConfig:function(){return e({lmsConfig:n})}}});var i=e.create(function(e){return{teachMeConfig:null,setTeachMeConfig:function(t){return e({teachMeConfig:t})},clearTeachMeConfig:function(){return e({teachMeConfig:null})}}});exports.defaultLMSConfig=n,exports.defaultTeachMeConfig=a,exports.dt=function(e,n,a){if(t.useLearningTemplateStore.getState().backwardCompatibility)return null!=n?n:"";var i=l.getState().lmsConfig,o=e.split(".").reduce(function(e,t){return null==e?void 0:e[t]},i);return"string"!=typeof o||""===o?null!=n?n:e:o.replace(/\{(\w+)\}/g,function(e,t){var n;return String(null!==(n=null==a?void 0:a[t])&&void 0!==n?n:"{".concat(t,"}"))})},exports.dtt=function(e,t,n){var a=i.getState().teachMeConfig,l=e.split(".").reduce(function(e,t){return null==e?void 0:e[t]},a);return"string"!=typeof l?null!=t?t:e:l.replace(/\{(\w+)\}/g,function(e,t){var a;return String(null!==(a=null==n?void 0:n[t])&&void 0!==a?a:"{".concat(t,"}"))})},exports.dttWelcomeMessageParts=function(){var e,t,n=null!==(e=i.getState().teachMeConfig)&&void 0!==e?e:a;return{greeting:n.welcomeMessage||a.welcomeMessage,subtitle:n.welcomeMessageSubtitle||a.welcomeMessageSubtitle,actions:(null===(t=n.actions)||void 0===t?void 0:t.length)?n.actions:a.actions}},exports.useLMSConfigStore=l,exports.useTeachMeConfigStore=i;
|
|
2
2
|
//# sourceMappingURL=useLMSConfigStore.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),t=require("react"),n=require("lucide-react");require("../../../features/IL-OTJ/_components/atoms/Textarea/Textarea.js"),require("../../../features/IL-OTJ/_components/InputDataReasoningCard.js"),require("../../../features/IL-OTJ/_components/TooltipComponent.js");var a=require("../../../features/IL-OTJ/_components/templates/TemplatesMap/templatesMap.js");require("../../../features/IL-OTJ/store/CitationsContext.js"),require("@mui/material"),require("uuid"),require("@mui/material/Tooltip"),require("react-markdown"),require("rehype-raw"),require("axios"),require("@e-llm-studio/streaming-response"),require("@e-llm-studio/watch-me-work"),require("../../../features/IL-OTJ/_components/ChatComponents/ChatHeader.js"),require("remark-gfm"),require("../../../features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js"),require("../../../features/IL-OTJ/_components/CitationLink.js"),require("@e-llm-studio/citation"),require("@viswa-test/test-citation"),require("../../../features/LearningManagement/store/useLearningTemplateStore.js"),require("primereact/toast"),require("../../../features/LearningManagement/apis/scopeApis.js"),require("../../../features/LearningManagement/store/usePermissionsStore.js"),require("../../../features/LearningManagement/store/useLMSConfigStore.js"),require("../../../features/LearningManagement/components/ToolTip.js"),require("../../../features/LearningManagement/store/useAuthStore.js"),require("@mui/icons-material/Check"),require("@mui/icons-material/CloseRounded"),require("@tanstack/react-query"),require("../../../features/LearningManagement/store/useEnvStore.js"),require("date-fns"),require("framer-motion"),require("@mui/icons-material/Close");var i=require("../../../features/IL-OTJ/ILOTJ.js");require("../../../features/LearningManagement/store/useConfigStore.js"),require("../../../features/LearningManagement/config.js"),require("react-dom/server");var o=require("../../../features/IL-OTJ/_components/AccordianSection.js");require("appsec-ui"),require("@radix-ui/react-tooltip"),require("../../../features/LearningManagement/components/StationOnboarding/InputField.js"),require("../../../features/LearningManagement/store/useAppSecRolesStore.js"),require("@e-llm-studio/audit-log"),require("@e-llm-studio/audit-log/dist/styles.css"),require("../../../features/LearningManagement/AuditLog/ChangeLogDiff.js"),require("react-router-dom");var s={order_rules:{enabled:!1,global_min_separation_seconds:0},advertiser_rules:{enabled:!1,global_min_separation_seconds:0},inventory_rules:{respect_inventory_code:!1},break_code_rules:{respect_break_code:!1},is_default_enabled:!1},u=[{label:"Global Scope",value:"global"},{label:"Genre Scope",value:"genre"},{label:"Custom Scope",value:"custom"}],l=["Tier 1"];exports.default=function(){var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("react/jsx-runtime"),t=require("react"),n=require("lucide-react");require("../../../features/IL-OTJ/_components/atoms/Textarea/Textarea.js"),require("../../../features/IL-OTJ/_components/InputDataReasoningCard.js"),require("../../../features/IL-OTJ/_components/TooltipComponent.js");var a=require("../../../features/IL-OTJ/_components/templates/TemplatesMap/templatesMap.js");require("../../../features/IL-OTJ/store/CitationsContext.js"),require("@mui/material"),require("uuid"),require("@mui/material/Tooltip"),require("react-markdown"),require("rehype-raw"),require("axios"),require("@e-llm-studio/streaming-response"),require("@e-llm-studio/watch-me-work"),require("../../../features/IL-OTJ/_components/ChatComponents/ChatHeader.js"),require("remark-gfm"),require("../../../features/IL-OTJ/_components/MarkdownComponents/MarkdownElements.js"),require("../../../features/IL-OTJ/_components/CitationLink.js"),require("@e-llm-studio/citation"),require("@viswa-test/test-citation"),require("../../../features/LearningManagement/store/useLearningTemplateStore.js"),require("primereact/toast"),require("../../../features/LearningManagement/apis/scopeApis.js"),require("../../../features/LearningManagement/store/usePermissionsStore.js"),require("../../../features/LearningManagement/store/useLMSConfigStore.js"),require("../../../features/LearningManagement/components/ToolTip.js"),require("../../../features/LearningManagement/store/useAuthStore.js"),require("@mui/icons-material/Check"),require("@mui/icons-material/CloseRounded"),require("@tanstack/react-query"),require("../../../features/LearningManagement/store/useEnvStore.js"),require("date-fns"),require("framer-motion"),require("@mui/icons-material/Close");var i=require("../../../features/IL-OTJ/ILOTJ.js");require("../../../features/LearningManagement/store/useConfigStore.js"),require("../../../features/LearningManagement/config.js"),require("react-dom/server");var o=require("../../../features/IL-OTJ/_components/AccordianSection.js");require("appsec-ui"),require("@radix-ui/react-tooltip"),require("../../../features/LearningManagement/components/StationOnboarding/InputField.js"),require("../../../features/LearningManagement/store/useAppSecRolesStore.js"),require("@e-llm-studio/audit-log"),require("@e-llm-studio/audit-log/dist/styles.css"),require("../../../features/LearningManagement/AuditLog/ChangeLogDiff.js"),require("react-router-dom");var s={order_rules:{enabled:!1,global_min_separation_seconds:0},advertiser_rules:{enabled:!1,global_min_separation_seconds:0},inventory_rules:{respect_inventory_code:!1},break_code_rules:{respect_break_code:!1},is_default_enabled:!1},u=[{label:"Global Scope",value:"global"},{label:"Genre Scope",value:"genre"},{label:"Custom Scope",value:"custom"}],l=["Tier 1"];exports.default=function(c){c.baseURL;var d=t.useState(!0),p=d[0],_=d[1],m=t.useState(""),g=m[0],f=m[1],b=t.useState(""),q=b[0],y=b[1],h=t.useState({station:"",tiers:["Tier 1"]}),v=h[0],T=h[1],L=t.useState([]),k=L[0],C=L[1],S=t.useState([]),j=S[0],w=S[1],A=t.useState(s),x=A[0],I=A[1],M=t.useCallback(function(r,t){T(function(n){var a;return e.__assign(e.__assign({},n),((a={})[r]=t,a))})},[]),O=t.useCallback(function(r,t){I(function(n){var a=e.__assign({},n);switch(r){case"order_rules":case"advertiser_rules":a[r]="boolean"==typeof t?e.__assign(e.__assign({},n[r]),{enabled:t}):{enabled:t.enabled,global_min_separation_seconds:t.global_min_separation_seconds};break;case"inventory_rules":a.inventory_rules={respect_inventory_code:"boolean"==typeof t?t:t.respect_inventory_code};break;case"break_code_rules":a.break_code_rules={respect_break_code:"boolean"==typeof t?t:t.respect_break_code};break;case"is_default_enabled":a.is_default_enabled="boolean"==typeof t?t:!!t}return a})},[]),G=function(r){r(function(r){return e.__spreadArray(e.__spreadArray([],r,!0),[{id:Date.now(),text:"",reasoning:""}],!1)})},J=function(e,r){e(function(e){return e.filter(function(e){return e.id!==r})})},N=function(r,t,n){r(function(r){return r.map(function(r){return String(r.id)===String(t)?e.__assign(e.__assign({},r),{text:n}):r})})},W=[e.__assign({key:"order_rules",label:"Order"},x.order_rules),e.__assign({key:"advertiser_rules",label:"Advertiser"},x.advertiser_rules)],D=[{key:"inventory_rules",label:"Inventory code",enabled:x.inventory_rules.respect_inventory_code},{key:"break_code_rules",label:"Break Code",enabled:x.break_code_rules.respect_break_code},{key:"is_default_enabled",label:"Default Variant",enabled:x.is_default_enabled}],R={"Add Guideline":"I would want to add a separation rule","Search Guideline":"I would want to set a max priority rule","Type your query":"I would want to add a break code matching rule"},B="<p><span>Hi! 👋 I'm your Instant Learning Concierge.</span>\n <span>How would you like to get started? You can select an option below or describe the Guideline you’d like to create.</span>\n ".concat(["Add Guideline","Search Guideline","Type your query"].map(function(e){return'<button class="clickable-button" data-value="'.concat(R[e],'">').concat(e,"</button>")}).join(""),"</p>");return r.jsx(i.default,{open:p,closeFunction:function(){return _(!1)},chatAssistantName:"defaultAssistant",organizationName:"techolution",baseUrl:"https://devllmstudio.creativeworkspace.ai",baseWebsocketUrl:"wss://devllmstudio.creativeworkspace.ai/graphql",ThinkingBulbIconComponent:r.jsx(n.Lightbulb,{}),customSections:r.jsx(r.Fragment,{}),isUseNormalChat:!0,chatTitle:"Create New Guideline",formTitle:"Guideline Details",initialChatMessage:B,template:a.TemplateList.BaseTemplate,templateProps:{state:{title:g,description:q,scopeData:v,whenToApplyConditions:k,whenNotToApplyConditions:j,configData:x,citations:[],citation:{}},handlers:{onTitleChange:function(e){var r,t;return f(null!==(t=null===(r=null==e?void 0:e.target)||void 0===r?void 0:r.value)&&void 0!==t?t:e)},onDescriptionChange:function(e){var r,t;return y(null!==(t=null===(r=null==e?void 0:e.target)||void 0===r?void 0:r.value)&&void 0!==t?t:e)},onAddWhenToApply:function(){return G(C)},onRemoveWhenToApply:function(e){return J(C,e)},onEditWhenToApply:function(e,r){return N(C,e,r)},onAddWhenNotToApply:function(){return G(w)},onRemoveWhenNotToApply:function(e){return J(w,e)},onEditWhenNotToApply:function(e,r){return N(w,e,r)},onScopeChange:M,onConfigChange:O},uiState:{showScope:!1,showConfiguration:!1,titleLabel:"Guideline Name",scopeLabel:"Define Scope",tierLabel:"Select Tier",descriptionLabel:"Guideline Description",whenToApplyLabel:"When to apply this Guideline (When to Apply)",whenNotToApplyLabel:"When not to apply this Guideline (When NOT to Apply)",configLabel:"Advanced Settings",stationOptions:u,tierOptions:l,separationItems:W,toggles:D},customNodes:{afterTitle:r.jsx(o.default,e.__assign({title:{type:"other",label:"Guideline"}},{children:r.jsx("p",e.__assign({style:{padding:"12px",fontSize:"14px",color:"#64748b"}},{children:"HealthCare"}))})),top:r.jsxs("div",e.__assign({style:{marginBottom:"12px",padding:"8px",backgroundColor:"#f0f4ff",borderRadius:"4px"}},{children:[r.jsx("strong",{children:"Guideline Template:"})," This is an ILOTJ TeachMe customized for Guideline Value Type"]}))}}})};
|
|
2
2
|
//# sourceMappingURL=GuidelinesTeachMeRenderer.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsx as i}from"react/jsx-runtime";import{useEffect as n}from"react";import r from"./TeachMeWrapper.js";import t from"../../../plugins/ValueTypes/Default/DefaultTeachMeRenderer.js";import o from"../../../plugins/ValueTypes/RadioTrafficLearning/RadioTrafficLearningRenderer.js";import a from"../../../plugins/ValueTypes/Guidelines/GuidelinesTeachMeRenderer.js";import{useTeachMeConfigStore as l}from"../../LearningManagement/store/useLMSConfigStore.js";import{useLearningTemplateStore as
|
|
1
|
+
import{__assign as e}from"tslib";import{jsx as i}from"react/jsx-runtime";import{useEffect as n}from"react";import r from"./TeachMeWrapper.js";import t from"../../../plugins/ValueTypes/Default/DefaultTeachMeRenderer.js";import o from"../../../plugins/ValueTypes/RadioTrafficLearning/RadioTrafficLearningRenderer.js";import a from"../../../plugins/ValueTypes/Guidelines/GuidelinesTeachMeRenderer.js";import{useTeachMeConfigStore as l}from"../../LearningManagement/store/useLMSConfigStore.js";import{useLearningTemplateStore as s}from"../../LearningManagement/store/useLearningTemplateStore.js";var u={Default:t,"Radio Traffic Learning":o,Guidelines:a},p=function(t){var o,a=t.app_integration_id,p=t.isOpen,f=t.onClose,m=t.pluginPayload,d=t.token,g=t.mode,c=t.baseURL,T=l(function(e){return e.setTeachMeConfig});return l(function(e){return e.clearTeachMeConfig}),n(function(){(null==m?void 0:m.teachMe)&&T(m.teachMe),(null==m?void 0:m.tiers)&&s.getState().setTiers(null==m?void 0:m.tiers)},[m]),i(r,{app_integration_id:a,isOpen:p,onClose:f,token:d,templateRegistry:u,baseURL:c,initialScope:null!==(o=null==m?void 0:m.initialScope)&&void 0!==o?o:"",ruleSet:null==m?void 0:m.ruleSet,pluginPayload:e(e({},m),{mode:g})})};export{u as TemplateRegistry,p as default};
|
|
2
2
|
//# sourceMappingURL=TeachMePlugin.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__awaiter as t,__generator as r}from"tslib";import{jsx as
|
|
1
|
+
import{__assign as e,__awaiter as t,__generator as r}from"tslib";import{jsx as n,jsxs as i}from"react/jsx-runtime";import{useState as a,useEffect as o}from"react";import{Box as s,CircularProgress as c,Dialog as l,DialogTitle as p,Typography as d,IconButton as u,DialogContent as f}from"@mui/material";import m from"@mui/icons-material/Close";import{useLearningTemplateStore as h}from"../../LearningManagement/store/useLearningTemplateStore.js";var g=function(){var t=a(!0),r=t[0],o=t[1];return i(l,e({open:r,onClose:function(){return o(!1)},fullWidth:!0,maxWidth:"lg",PaperProps:{sx:{borderRadius:"16px",minHeight:"70vh",overflow:"hidden"}}},{children:[i(p,e({sx:{display:"flex",alignItems:"center",justifyContent:"space-between",borderBottom:"1px solid #e0e0e0",px:3,py:2}},{children:[n(d,e({variant:"h6",fontWeight:600},{children:"Teach Me"})),n(u,e({onClick:function(){return o(!1)}},{children:n(m,{})}))]})),n(f,e({dividers:!0,sx:{p:3,backgroundColor:"#fafafa"}},{children:"There is some issue with the selected template. Kindly check steps to resolve."}))]}))},v=function(i){var l=i.templateRegistry,p=void 0===l?{}:l,d=h(function(e){return e.backwardCompatibility}),u=h(function(e){return i.app_integration_id?e.templateMap[i.app_integration_id]:void 0}),f=h(function(e){return e.setTemplateData}),m=d?"Radio Traffic Learning":u,v=a(!m),_=v[0],y=v[1],b=a(!1),x=b[0],w=b[1];if(o(function(){if(i.isOpen){if(!d&&!i.app_integration_id)return console.error("TeachMeWrapper requires an app_integration_id when backward compatibility is disabled."),w(!0),void y(!1);if(m)y(!1);else{t(void 0,void 0,void 0,function(){var e,n;return r(this,function(a){switch(a.label){case 0:return a.trys.push([0,2,3,4]),y(!0),w(!1),[4,(o=i.app_integration_id,s=i.token,t(void 0,void 0,void 0,function(){var e,t;return r(this,function(r){switch(r.label){case 0:return[4,fetch("".concat(i.baseURL,"/instant_learning/ilotj/application/getValueType/").concat(o),{headers:{Authorization:"Bearer ".concat(s)}})];case 1:if(!(e=r.sent()).ok)throw new Error("Failed to fetch value type");return[4,e.json()];case 2:return t=r.sent(),console.log("Fetched value type data:",t),!t||Array.isArray(t.data)&&0===t.data.length?[2,null]:[2,t.data[0].value_type_name||t.valueTypeName||t.templateName]}})}))];case 1:return e=a.sent(),f(i.app_integration_id,e),[3,4];case 2:return n=a.sent(),console.error(n),w(!0),i.app_integration_id&&f(i.app_integration_id,"ERROR"),[3,4];case 3:return y(!1),[7];case 4:return[2]}var o,s})})}}},[i.isOpen,i.app_integration_id,m,i.token,f,d]),_)return n(s,e({sx:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%"}},{children:n(c,{size:32})}));if(x||!m)return n(g,{});var k=p[m&&p[m]?m:"Default"];return k?n(k,e({},i)):(console.warn("No renderer found for template: ".concat(m)),n(g,{}))};export{v as default};
|
|
2
2
|
//# sourceMappingURL=TeachMeWrapper.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e}from"tslib";import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useState as i,useMemo as n,useEffect as a}from"react";import{AuditLog as r}from"@e-llm-studio/audit-log";import"@e-llm-studio/audit-log/dist/styles.css";import{User as l,ExternalLink as c}from"lucide-react";import s from"./ChangeLogDiff.js";import{dt as d}from"../store/useLMSConfigStore.js";import p from"../RBAC/AccessPanel.module.css.js";import{usePermissionsStore as h}from"../store/usePermissionsStore.js";import g from"../store/useEnvStore.js";var
|
|
1
|
+
import{__assign as e}from"tslib";import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useState as i,useMemo as n,useEffect as a}from"react";import{AuditLog as r}from"@e-llm-studio/audit-log";import"@e-llm-studio/audit-log/dist/styles.css";import{User as l,ExternalLink as c}from"lucide-react";import s from"./ChangeLogDiff.js";import{dt as d}from"../store/useLMSConfigStore.js";import p from"../RBAC/AccessPanel.module.css.js";import{usePermissionsStore as h}from"../store/usePermissionsStore.js";import g from"../store/useEnvStore.js";import{useConfigStore as u}from"../store/useConfigStore.js";var m=function(m){var f=m.configId,b=m.ruleData,y=m.scopeId,x=m.scopeName,v=(null==x?void 0:x.trim())||"Selected",S=i("scope"),w=S[0],C=S[1],A=u.getState().configuration,T=h(function(e){return e.hasPermission}),L=g(function(e){var t;return(null===(t=e.rbacConfig)||void 0===t?void 0:t.applicationResourceId)||""}),k=Boolean(y&&T("ilotj.scope.changeLog.view",y)),D=Boolean(L&&T("ilotj.application.changeLog.view",L)),B=n(function(){var e=[];return y&&e.push(y),e},[b,y]);a(function(){console.log("Flattened External Resource IDs:",B)},[B]);var I={configId:f,getData:{baseUrl:A.BASE_APPMOD_URL||"https://dev.appmod.ai",endpoint:"/changelog/audit-log/fetch"},distinctValuesApi:{baseUrl:A.BASE_APPMOD_URL||"https://dev.appmod.ai",endpoint:"/changelog/audit-log/distinct-values"},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("div",e({style:{display:"flex",alignItems:"center",gap:"8px"}},{children:[o(l,{size:16,color:"#64748b",style:{flexShrink:0}}),o("span",e({style:{fontWeight:500}},{children:i.modifiedBy}))]}))},style:{width:"15%",minWidth:"140px"}},{key:"changeAction",header:"Action",body:function(t){var i,n,a=(i=t.changeTitle,(n=(i||"").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)"}),r=t.changeTitle?t.changeTitle.replace(/_/g," "):"—";return o("span",e({style:{color:a.color,backgroundColor:a.backgroundColor,border:"1px solid ".concat(a.borderColor),boxShadow:a.boxShadow,padding:"6px 12px",borderRadius:"999px",fontSize:"12px",lineHeight:1,fontWeight:600,display:"inline-block",minWidth:"76px",textAlign:"center",textTransform:"capitalize"}},{children:r}))},style:{width:"15%",textAlign:"center"}},{key:"customChangeSummary",header:"Change Summary",body:function(e){var t;return o(s,{change:null!==(t=e.actionText)&&void 0!==t?t:"-"})},style:{width:"30%",minWidth:"200px"}},{key:"redirectLink",header:"Link",body:function(i){var n,a=(null===(n=i.metadata)||void 0===n?void 0:n.redirect_url)||i.redirect_url;return a?o("div",e({style:{display:"flex",justifyContent:"center",alignItems:"center"}},{children:t("a",e({href:a,target:"_blank",rel:"noopener noreferrer",style:{display:"flex",alignItems:"center",gap:"6px",color:"#2563eb",textDecoration:"none",fontWeight:500,fontSize:"13px"}},{children:["View ",o(c,{size:14})]}))})):o("span",e({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 o("span",e({style:{color:"#94a3b8"}},{children:"—"}));var n=new Date(i.actionDate),a=n.toLocaleDateString("en-US",{month:"short",day:"2-digit",year:"numeric"}),r=n.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"});return t("div",e({style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"4px",fontSize:"13px",color:"#475569"}},{children:[o("span",e({style:{fontWeight:500}},{children:a})),o("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}}}};return t("div",e({style:{padding:"24px",fontFamily:"Arial, sans-serif"}},{children:[t("div",e({style:{marginBottom:"16px",paddingBottom:"4px"}},{children:[o("h1",e({style:{margin:0,color:"#334155",fontSize:"20px",fontWeight:700,lineHeight:1.25}},{children:d("history.title","".concat(v," - Audit Log"),{scope_name:v})})),o("p",e({style:{margin:"8px 0 0",color:"#667085",fontSize:"16px",fontWeight:500,lineHeight:1}},{children:d("history.subtitle","Track all learning updates and modifications with the ".concat(v," scope."),{scope_name:v})}))]})),t("div",e({className:p.accessTabs,role:"tablist","aria-label":"Audit log level"},{children:[o("button",e({type:"button",role:"tab","aria-selected":"scope"===w,className:"".concat(p.accessTab," ").concat("scope"===w?p.accessTabActive:""),onClick:function(){return C("scope")},disabled:!k,title:k?"":"You do not have permission to view scope level change log"},{children:d("history.scopeLevel","Scope Level")})),o("button",e({type:"button",role:"tab","aria-selected":"application"===w,className:"".concat(p.accessTab," ").concat("application"===w?p.accessTabActive:""),onClick:function(){return C("application")},disabled:!D,title:D?"":"You do not have permission to view application level change log"},{children:d("history.applicationLevel","Application Level")}))]})),"scope"===w?o(r,e({},I,{query:{externalResourceId:B.length>0?B:[""],paginationLimit:10}}),"scope-audit-log"):o(r,e({},I,{query:{externalResourceId:[],paginationLimit:10}}),"application-audit-log")]}))};export{m as default};
|
|
2
2
|
//# sourceMappingURL=AuditLog.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__spreadArray as n,__awaiter as t,__generator as r}from"tslib";import{jsx as o,jsxs as s,Fragment as i}from"react/jsx-runtime";import{useState as a,useRef as c,useEffect as l}from"react";import{BookOpen as u,Users as d,History as p}from"lucide-react";import{useLearningTemplateStore as m}from"./store/useLearningTemplateStore.js";import{Toast as f}from"primereact/toast";import v from"./styles/LearningTemplateManagement.module.css.js";import g from"./LearningTemplateLayout.js";import h from"./components/EmptyLearningState.js";import y from"./store/useAuthStore.js";import{fetchTiers as S,getILInstance as b,fetchScopes as C,inheritScope as T,inheritScopeBackwardCompatible as L,createRuleSet as A,renameScope as E,deleteRuleSet as I,requestAccess as w}from"./apis/scopeApis.js";import{QUERY_PARAM_KEYS as O,setQueryParams as R}from"./hooks/useLearningTemplateQueryParams.js";import j from"./components/ConfirmationModal.js";import _ from"./components/LearningTemplateManagementSkeleton.js";import{findNodeById as N,findNodePathById as k}from"./utils/treeUtils.js";import D from"./store/useEnvStore.js";import{useConfigStore as M}from"./store/useConfigStore.js";import{TooltipProvider as P}from"./components/ToolTip.js";import U from"./components/CreateRuleSetLegacyModal.js";import{usePermissionsStore as B}from"./store/usePermissionsStore.js";import{useAppSecRolesStore as G}from"./store/useAppSecRolesStore.js";import{useGetAppSecRolesQuery as F}from"./queries/useApprovalQueries.js";import{useLMSConfigQuery as q}from"./queries/useLMSConfigQuery.js";import x from"./RuleContent/AddScopeModal.js";import H from"./components/RuleContentSkeleton.js";import Q from"./components/ErrorStateDisplay.js";import{useLocation as z}from"react-router-dom";import K from"./shared/SuccessToastContent.js";import V from"./shared/ErrorToastContent.js";import W from"./RuleContent/RenameScopeModal.js";import{dt as Y}from"./store/useLMSConfigStore.js";import{MIDDLE_DRAWER_DT_PATH as J,MIDDLE_DRAWER_CONTEXT_MENU_DT_PATH as X,EMPTY_STATE_DT_PATH as Z}from"./constants.js";function $($){var ee,ne,te,re=this,oe=$.userDetails,se=$.llmStudioUrl,ie=$.audacyBackendUrl,ae=$.ilLabels,ce=$.config,le=$.rbacConfig,ue=$.auditLogConfig,de=$.app_integration_id,pe=$.backwardCompatibility,me=void 0!==pe&&pe,fe=$.modeId,ve=m(function(e){return e.selectedRuleSetId}),ge=m(function(e){return e.setSelectedRuleSetId}),he=m(function(e){return e.error}),ye=m(function(e){return e.setError}),Se=m(function(e){return e.setStations}),be=m(function(e){return e.scopeTreeData}),Ce=m(function(e){return e.setScopeTreeData}),Te=a({isOpen:!1,type:"GLOBAL"}),Le=Te[0],Ae=Te[1],Ee=a(!1),Ie=Ee[0],we=Ee[1],Oe=a(!1),Re=Oe[0],je=Oe[1],_e=a("learnings"),Ne=_e[0],ke=_e[1],De=a(null),Me=De[0],Pe=De[1],Ue=a(null),Be=Ue[0],Ge=Ue[1],Fe=c(null),qe=c(null),xe=c(!1),He=c(null),Qe=y();Qe.user;var ze=Qe.setUser,Ke=M(),Ve=Ke.setConfig,We=Ke.setIlLabels,Ye=function(){try{return z()}catch(e){return{search:""}}}();l(function(){if(!xe.current){var e=new URLSearchParams(window.location.search),n=e.get(O.RULESET_ID),t=e.get(O.SECTION),r=t&&hn.has(t)?t:"learnings";(null==n?void 0:n.length)&&ge&&ke&&(ge(n),ke(r),xe.current=!0)}},[null==Ye?void 0:Ye.search,ke,ge]);var Je=B(function(e){return e.fetchPermissions}),Xe=B(function(e){return e.hasPermission}),Ze=G(function(e){return e.setRoles}),$e=D(function(e){return e.appsecRbacUrl})===le.appsecRbacUrl,en=F(le.applicationId,$e).data,nn=q(null!=de?de:"",me),tn=nn.isLoading,rn=nn.isError,on=nn.refetch;nn.isSuccess;var sn=a(0),an=sn[0],cn=sn[1];l(function(){if(!me&&de&&se){t(re,void 0,void 0,function(){var e,n,t,o,s,i;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,b(de)];case 1:return e=r.sent(),"number"==typeof(n=null===(i=null===(s=null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.learningManagement)||void 0===s?void 0:s.scopeAndHierarchy)||void 0===i?void 0:i.maxHierarchyLevels)&&n>0&&cn(n-1),[3,3];case 2:return t=r.sent(),console.error("Failed to fetch IL instance for hierarchy levels:",t),[3,3];case 3:return[2]}})})}},[de,se]),l(function(){en&&Ze(en.map(function(e){return{_id:e._id,name:e.name}}))},[en,Ze]),l(function(){var e;console.log("userDetails",oe),ze(oe),console.log("llmStudioUrl",se),console.log("audacyBackendUrl",ie),D.getState().setLlmStudioUrl(se),D.getState().setAudacyBackendUrl(ie),D.getState().setRbacConfig(le),D.getState().setAuditLogConfig(ue),Ve(ce),We(ae),m.getState().setAppIntegrationId(null!=de?de:null),m.getState().setBackwardCompatibility(me),m.getState().setToken(null!==(e=null==oe?void 0:oe.accessToken)&&void 0!==e?e:null)},[oe,ze,se,ie,le,ue,ce,Ve,ae,We,de,me]),l(function(){(null==oe?void 0:oe.accessToken)&&se&&S()},[de,null==oe?void 0:oe.accessToken,se]);var ln=function(n){return void 0===n&&(n=!0),t(re,void 0,void 0,function(){var t,o,s,i,a,c,l,u;return r(this,function(r){switch(r.label){case 0:n&&we(!0),ye(null),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,Je(le.applicationId)];case 2:return r.sent(),t=function(n){if(!B.getState().hasPermission("ilotj.scope.view",n.id))return null;var r=n.children?n.children.map(function(e){return t(e)}).filter(function(e){return null!==e}):[];return e(e({},n),{children:r})},[4,C(de,oe.accessToken)];case 3:return(o=r.sent())&&o.data&&o.data.data&&(s=o.data.data,Array.isArray(s)&&(s=s.length>0?s[0]:null),s?(i=t(s))?(Pe(null),Ce({data:i}),qe.current?(ge(qe.current),ke("learnings"),qe.current=null):(a=m.getState().selectedRuleSetId,c=a?N(i,a):null,a&&c||ge(i.id))):(Pe(null!==(u=s.id)&&void 0!==u?u:null),Ce(null)):(Pe(null),Ce(null))),[3,6];case 4:return l=r.sent(),console.error("Failed to fetch rule sets or permissions",l),ye("Failed to load data. Please try again later."),[3,6];case 5:return we(!1),[7];case 6:return[2]}})})};l(function(){var e;(null===(e=null==oe?void 0:oe.accessToken)||void 0===e?void 0:e.length)&&$e?ln(!0):console.warn("Error: Trying to fetch rules without access token",oe)},[null==oe?void 0:oe.accessToken,ye,Se,le.applicationId,$e]);var un=function(n,o,s){return t(re,void 0,void 0,function(){var t,o,s,i,a,c,l,u;return r(this,function(r){switch(r.label){case 0:je(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,I(n,oe.accessToken)];case 2:return r.sent(),m.getState().selectedRuleSetId===n&&(t=m.getState().scopeTreeData,(o=k((null==t?void 0:t.data)||null,n))&&o.length>1&&(s=o[o.length-2],ge(s),ke("learnings"))),[4,ln(!0)];case 3:return r.sent(),Ae(function(n){return e(e({},n),{isOpen:!1})}),null===(a=He.current)||void 0===a||a.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,6];case 4:return i=r.sent(),console.error("An error occurred during scope deletion.",i),null===(c=He.current)||void 0===c||c.show({severity:"error",summary:"Delete Failed",detail:(null===(u=null===(l=null==i?void 0:i.response)||void 0===l?void 0:l.data)||void 0===u?void 0:u.message)||"There was an error deleting the scope. Please try again."}),[3,6];case 5:return je(!1),[7];case 6:return[2]}})})},dn=be,pn=Be?{data:{id:Be.stationId,name:Be.stationName,type:"STATION",metrics:{learningsCount:Be.learningsCount,stationsCount:0},children:[]}}:dn,mn=!!(null==pn?void 0:pn.data);null===(ee=null==pn?void 0:pn.data)||void 0===ee||ee.type;var fn=B(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",le.applicationResourceId||"");if(tn)return o("div",e({className:v.learningManagementContainer},{children:o(H,{})}));if(rn)return o("div",e({className:v.learningManagementContainer},{children:o(Q,{errorMessage:"Failed to load configuration. Please try again.",onRetry:function(){return on()},title:"Error Loading Configuration"})}));var vn=n(n([{type:"GLOBAL",label:"Global",addChildLabel:"".concat(Y("".concat(J,".addScope"),"Add Scope")),addChildType:"SCOPE"}],Array.from({length:an},function(){return e({type:"SCOPE",label:Y("".concat(J,".scope"),"Scope")},!me&&{addChildLabel:Y("".concat(X,".addSubScope"),"Add Subscope"),addChildType:"SUBSCOPE"})}),!0),me?[]:[{type:"SUBSCOPE",label:Y("".concat(J,".subScope"),"Subscope")}],!0),gn=[{id:"learnings",label:Y("".concat(J,".treeMenu.submenu.learnings"),"Learnings"),icon:u,badgeKey:"learningsCount"},{id:"access",label:Y("".concat(J,".treeMenu.submenu.access"),"Access"),icon:d},{id:"history",label:Y("".concat(J,".treeMenu.submenu.changeHistory"),"Change History"),icon:p}],hn=new Set(gn.map(function(e){return e.id})),yn=Be?gn.filter(function(e){return"stations"!==e.id}):gn;return o(P,{children:s("div",e({className:v.learningManagementContainer},{children:[o("div",e({className:v.mainWrapper},{children:Ie?o(_,{}):he?s("div",e({className:v.errorContainer},{children:[o("div",e({className:v.errorTitle},{children:"Error Loading Data"})),o("p",e({className:v.errorDesc},{children:he})),o("button",e({onClick:function(){return ln(!0)},className:v.tryAgainBtn},{children:"Try Again"}))]})):mn?o(g,{onOpenCreateModal:function(){return Ae({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,n,t){return Ae({isOpen:!0,type:n,parentId:e,parentName:t})},onRenameChild:function(e,n){return Ae({isOpen:!0,type:"RENAME",scopeId:e,initialName:n})},onDeleteChild:function(e,n,o){return t(re,void 0,void 0,function(){var t,s,i;return r(this,function(r){switch(r.label){case 0:return t=m.getState().scopeTreeData,s=k((null==t?void 0:t.data)||null,e),i=!!s&&3===s.length,0!==o?[3,2]:[4,un(e)];case 1:return r.sent(),[3,3];case 2:Ae({isOpen:!0,type:"DELETE",scopeId:e,initialName:n,isSubscope:i}),r.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return Xe("ilotj.scope.delete",e)},canEditScope:function(e){return Xe("ilotj.scope.edit",e)},canCreateScope:function(e){return Xe("ilotj.scope.create",e)},onSectionSelect:function(e,n){var t;console.log("Section Selected:",{scopeId:e,sectionId:n}),R(((t={})[O.SECTION]="learnings"===n?null:n,t[O.RULESET_ID]=e,t)),ke(n),ge(e)},activeSectionId:Ne,scopeTreeData:pn,sectionsConfig:yn,onViewStation:function(e){Fe.current=ve,Ge(e),ke("learnings"),ge(e.stationId)},onRefreshRuleSets:function(e,n){void 0===e&&(e=!0),n&&(qe.current=n),ln(e)},nodeTypesConfig:vn,app_integration_id:de,token:oe.accessToken,modeId:fe}):o(h,{onCreate:function(){return Ae({isOpen:!0,type:"GLOBAL"})},title:Y("".concat(Z,".title"),"No Global Scope has been added!"),desc:Y("".concat(Z,".desc"),"Start by creating a Global scope to define base learnings that apply across all stations."),button:Y("".concat(Z,".createGlobalScope"),"Create Global Scope"),canCreateRule:fn,noAccessTitle:Y("".concat(Z,".noAccessTitle"),"Access Restricted"),noAccessDesc:Y("".concat(Z,".noAccessDesc"),"You do not have access for this application."),requestAccessButton:Y("".concat(Z,".requestAccessButton"),"Request Access"),onRequestAccess:function(){return t(re,void 0,void 0,function(){var e,n,t,s,i,a,c,l,u;return r(this,function(r){switch(r.label){case 0:if(!(e=(null===(s=null===(t=m.getState().scopeTreeData)||void 0===t?void 0:t.data)||void 0===s?void 0:s.id)||Me))return null===(i=He.current)||void 0===i||i.show({severity:"error",sticky:!1,className:v.errorToast,content:o(V,{message:"Unable to identify the global scope for this access request."})}),[2];r.label=1;case 1:return r.trys.push([1,3,,4]),[4,w(e)];case 2:return r.sent(),null===(a=He.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:v.successToast,content:o(K,{message:"Access request submitted successfully!"})}),[3,4];case 3:return n=r.sent(),null===(c=He.current)||void 0===c||c.show({severity:"error",sticky:!1,className:v.errorToast,content:o(V,{message:(null===(u=null===(l=null==n?void 0:n.response)||void 0===l?void 0:l.data)||void 0===u?void 0:u.detail)||"Failed to request access. Please try again."})}),[3,4];case 4:return[2]}})})}})})),o(f,{ref:He,pt:{root:{style:{zIndex:9999}}}}),me&&Le.isOpen&&"DELETE"!==Le.type&&"RENAME"!==Le.type?o(U,{isOpen:!0,onClose:function(){return Ae(e(e({},Le),{isOpen:!1}))},onSubmit:function(n){return t(re,void 0,void 0,function(){var t,o,s,i,a,c,l,u,d,p,f,v,g,h,y,S,b,C,E,I;return r(this,function(r){switch(r.label){case 0:je(!0),t=m.getState().backwardCompatibility,r.label=1;case 1:return r.trys.push([1,12,13,14]),o=void 0,t&&"object"==typeof n?o=n:(s=n,i="SCOPE"===Le.type&&Le.parentId,a=i?"genreRuleSet":Le.type,o={topic:a,scope_reference_id:null,scopeDescription:"demo",parentScopeId:Le.parentId||null,scopeName:s,scopeReferenceMetadata:{},applicationMappingId:de}),[4,A(o,oe.accessToken)];case 2:if(c=r.sent(),!(l=null===(h=null==c?void 0:c.data)||void 0===h?void 0:h.scopeId))return[3,10];if(qe.current=l,u=t&&(null===(y=o.topic)||void 0===y?void 0:y.toLowerCase().includes("genre")),d=!t&&"GLOBAL"!==Le.type&&Le.parentId,!u&&!d)return[3,10];if(!(p=t?null===(b=null===(S=m.getState().scopeTreeData)||void 0===S?void 0:S.data)||void 0===b?void 0:b.id:Le.parentId))return[3,10];if(!me)return[3,7];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,L({source_scope_id:p,target_scope_id:l})];case 4:return r.sent(),[3,6];case 5:return f=r.sent(),console.error("Failed to inherit rules for the new scope:",f),[3,6];case 6:return[3,10];case 7:return r.trys.push([7,9,,10]),[4,T({source_scope_id:p,target_scope_id:l,application_mapping_id:de||"",is_copy_parent_variant_id:!1})];case 8:return r.sent(),[3,10];case 9:return v=r.sent(),console.error("Failed to inherit rules for the new scope:",v),[3,10];case 10:return[4,ln(!0)];case 11:return r.sent(),Ae(function(n){return e(e({},n),{isOpen:!1})}),[3,14];case 12:throw g=r.sent(),console.error("An error occurred during scope creation.",g),null===(C=He.current)||void 0===C||C.show({severity:"error",summary:"Creation Failed",detail:(null===(I=null===(E=null==g?void 0:g.response)||void 0===E?void 0:E.data)||void 0===I?void 0:I.message)||"There was an error creating the scope. Please try again."}),g;case 13:return je(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:mn,canCreateGlobal:fn,globalScopeId:null!==(te=null===(ne=null==be?void 0:be.data)||void 0===ne?void 0:ne.id)&&void 0!==te?te:null}):s(i,{children:[o(x,{isOpen:Le.isOpen&&"DELETE"!==Le.type&&"RENAME"!==Le.type,onClose:function(){return Ae(e(e({},Le),{isOpen:!1}))},onCreate:function(e){e&&(qe.current=e),ln(!0)},hasGlobalRuleSet:mn,parentId:Le.parentId}),o(W,{isOpen:Le.isOpen&&"RENAME"===Le.type,onClose:function(){return Ae(e(e({},Le),{isOpen:!1}))},onSave:function(n){return t(re,void 0,void 0,function(){var t,s,i,a,c,l;return r(this,function(r){switch(r.label){case 0:je(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),Le.scopeId?(t=m.getState().backwardCompatibility,s=t?{scope_id:Le.scopeId,scope_name:n}:{scope_id:Le.scopeId,scope_type:"Custom",scope_name:n,description:"demo",application_mapping_id:de},[4,E(s,oe.accessToken)]):[2];case 2:return r.sent(),[4,ln(!0)];case 3:return r.sent(),Ae(function(n){return e(e({},n),{isOpen:!1})}),[3,6];case 4:throw i=r.sent(),console.error("An error occurred during scope rename.",i),null===(a=He.current)||void 0===a||a.show({severity:"error",sticky:!1,className:v.errorToast,content:o(V,{message:(null===(l=null===(c=null==i?void 0:i.response)||void 0===c?void 0:c.data)||void 0===l?void 0:l.message)||"There was an error renaming the scope. Please try again."})}),i;case 5:return je(!1),[7];case 6:return[2]}})})},initialName:Le.initialName})]}),o(j,{isOpen:Le.isOpen&&"DELETE"===Le.type,onCancel:function(){return Ae(e(e({},Le),{isOpen:!1}))},onConfirm:function(){return un(Le.scopeId,Le.initialName,Le.isSubscope)},title:"Delete Scope",description:s(i,{children:["Deleting ",o("span",e({className:v.highlight},{children:Le.initialName||"this scope"}))," will permanently remove all Learnings, Access rules, and Change History inside it. This cannot be undone."]}),confirmText:"Delete",confirmBgColor:"#EF4444",isLoading:Re})]}))})}export{$ as default};
|
|
1
|
+
import{__assign as e,__spreadArray as t,__awaiter as n,__generator as r}from"tslib";import{jsx as o,jsxs as s,Fragment as i}from"react/jsx-runtime";import{useState as a,useRef as c,useEffect as l}from"react";import{BookOpen as u,Users as d,History as p}from"lucide-react";import{useLearningTemplateStore as m}from"./store/useLearningTemplateStore.js";import{Toast as f}from"primereact/toast";import v from"./styles/LearningTemplateManagement.module.css.js";import g from"./LearningTemplateLayout.js";import h from"./components/EmptyLearningState.js";import S from"./store/useAuthStore.js";import{fetchTiers as y,getILInstance as b,fetchScopes as C,inheritScope as T,inheritScopeBackwardCompatible as A,createRuleSet as L,renameScope as E,deleteRuleSet as I,requestAccess as R}from"./apis/scopeApis.js";import{QUERY_PARAM_KEYS as w,setQueryParams as O}from"./hooks/useLearningTemplateQueryParams.js";import j from"./components/ConfirmationModal.js";import _ from"./components/LearningTemplateManagementSkeleton.js";import{findNodeById as N,findNodePathById as k}from"./utils/treeUtils.js";import D from"./store/useEnvStore.js";import{useConfigStore as M}from"./store/useConfigStore.js";import{TooltipProvider as P}from"./components/ToolTip.js";import B from"./components/CreateRuleSetLegacyModal.js";import{usePermissionsStore as U}from"./store/usePermissionsStore.js";import{useAppSecRolesStore as q}from"./store/useAppSecRolesStore.js";import{useGetAppSecRolesQuery as G}from"./queries/useApprovalQueries.js";import{useLMSConfigQuery as F}from"./queries/useLMSConfigQuery.js";import x from"./RuleContent/AddScopeModal.js";import H from"./components/RuleContentSkeleton.js";import Q from"./components/ErrorStateDisplay.js";import{useLocation as z}from"react-router-dom";import K from"./shared/SuccessToastContent.js";import V from"./shared/ErrorToastContent.js";import W from"./RuleContent/RenameScopeModal.js";import{dt as Y}from"./store/useLMSConfigStore.js";import{MIDDLE_DRAWER_DT_PATH as J,MIDDLE_DRAWER_CONTEXT_MENU_DT_PATH as X,EMPTY_STATE_DT_PATH as Z}from"./constants.js";function $($){var ee,te,ne,re=this,oe=$.userDetails,se=$.llmStudioUrl,ie=$.audacyBackendUrl,ae=$.ilLabels,ce=$.config,le=$.rbacConfig,ue=$.auditLogConfig,de=$.app_integration_id,pe=$.backwardCompatibility,me=void 0!==pe&&pe,fe=$.modeId,ve=m(function(e){return e.selectedRuleSetId}),ge=m(function(e){return e.setSelectedRuleSetId}),he=m(function(e){return e.error}),Se=m(function(e){return e.setError}),ye=m(function(e){return e.setStations}),be=m(function(e){return e.scopeTreeData}),Ce=m(function(e){return e.setScopeTreeData}),Te=a({isOpen:!1,type:"GLOBAL"}),Ae=Te[0],Le=Te[1],Ee=a(!1),Ie=Ee[0],Re=Ee[1],we=a(!1),Oe=we[0],je=we[1],_e=a("learnings"),Ne=_e[0],ke=_e[1],De=a(null),Me=De[0],Pe=De[1],Be=a(null),Ue=Be[0],qe=Be[1],Ge=a(!1),Fe=Ge[0],xe=Ge[1],He=a(!1),Qe=He[0],ze=He[1],Ke=c(null),Ve=c(null),We=c(!1),Ye=c(null),Je=S();Je.user;var Xe=Je.setUser,Ze=M(),$e=Ze.setConfig,et=Ze.setIlLabels,tt=function(){try{return z()}catch(e){return{search:""}}}();l(function(){if(!We.current){var e=new URLSearchParams(window.location.search),t=e.get(w.RULESET_ID),n=e.get(w.SECTION),r=n&&Tt.has(n)?n:"learnings";(null==t?void 0:t.length)&&ge&&ke&&(ge(t),ke(r),We.current=!0)}},[null==tt?void 0:tt.search,ke,ge]);var nt=U(function(e){return e.fetchPermissions}),rt=U(function(e){return e.hasPermission}),ot=q(function(e){return e.setRoles}),st=D(function(e){return e.appsecRbacUrl})===le.appsecRbacUrl,it=G(le.applicationId,st).data,at=F(null!=de?de:"",me),ct=at.isLoading,lt=at.isError,ut=at.refetch;at.isSuccess;var dt=a(0),pt=dt[0],mt=dt[1];l(function(){if(!me&&de&&se){n(re,void 0,void 0,function(){var e,t,n,o,s,i;return r(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,b(de)];case 1:return e=r.sent(),"number"==typeof(t=null===(i=null===(s=null===(o=null==e?void 0:e.data)||void 0===o?void 0:o.learningManagement)||void 0===s?void 0:s.scopeAndHierarchy)||void 0===i?void 0:i.maxHierarchyLevels)&&t>0&&mt(t-1),[3,3];case 2:return n=r.sent(),console.error("Failed to fetch IL instance for hierarchy levels:",n),[3,3];case 3:return[2]}})})}},[de,se]),l(function(){it&&ot(it.map(function(e){return{_id:e._id,name:e.name}}))},[it,ot]),l(function(){var e;console.log("userDetails",oe),Xe(oe),console.log("llmStudioUrl",se),console.log("audacyBackendUrl",ie),D.getState().setLlmStudioUrl(se),D.getState().setAudacyBackendUrl(ie),D.getState().setRbacConfig(le),D.getState().setAuditLogConfig(ue),$e(ce),et(ae),m.getState().setAppIntegrationId(null!=de?de:null),m.getState().setBackwardCompatibility(me),m.getState().setToken(null!==(e=null==oe?void 0:oe.accessToken)&&void 0!==e?e:null)},[oe,Xe,se,ie,le,ue,ce,$e,ae,et,de,me]),l(function(){(null==oe?void 0:oe.accessToken)&&se&&y()},[de,null==oe?void 0:oe.accessToken,se]);var ft=function(t){return void 0===t&&(t=!0),n(re,void 0,void 0,function(){var n,o,s,i,a,c,l,u;return r(this,function(r){switch(r.label){case 0:t&&Re(!0),Se(null),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,nt(le.applicationId)];case 2:return r.sent(),n=function(t){if(!U.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(e({},t),{children:r})},[4,C(de,oe.accessToken)];case 3:return(o=r.sent())&&o.data&&o.data.data&&(s=o.data.data,Array.isArray(s)&&(s=s.length>0?s[0]:null),s?(i=n(s))?(Pe(null),Ce({data:i}),Ve.current?(ge(Ve.current),ke("learnings"),Ve.current=null):(a=m.getState().selectedRuleSetId,c=a?N(i,a):null,a&&c||ge(i.id))):(Pe(null!==(u=s.id)&&void 0!==u?u:null),Ce(null)):(Pe(null),Ce(null))),[3,6];case 4:return l=r.sent(),console.error("Failed to fetch rule sets or permissions",l),Se("Failed to load data. Please try again later."),[3,6];case 5:return Re(!1),[7];case 6:return[2]}})})};l(function(){var e;(null===(e=null==oe?void 0:oe.accessToken)||void 0===e?void 0:e.length)&&st?ft(!0):console.warn("Error: Trying to fetch rules without access token",oe)},[null==oe?void 0:oe.accessToken,Se,ye,le.applicationId,st]);var vt=function(t,o,s){return n(re,void 0,void 0,function(){var n,o,s,i,a,c,l,u;return r(this,function(r){switch(r.label){case 0:je(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),[4,I(t,oe.accessToken)];case 2:return r.sent(),m.getState().selectedRuleSetId===t&&(n=m.getState().scopeTreeData,(o=k((null==n?void 0:n.data)||null,t))&&o.length>1&&(s=o[o.length-2],ge(s),ke("learnings"))),[4,ft(!0)];case 3:return r.sent(),Le(function(t){return e(e({},t),{isOpen:!1})}),null===(a=Ye.current)||void 0===a||a.show({severity:"success",summary:"Deleted Successfully",detail:"The scope was permanently removed."}),[3,6];case 4:return i=r.sent(),console.error("An error occurred during scope deletion.",i),null===(c=Ye.current)||void 0===c||c.show({severity:"error",summary:"Delete Failed",detail:(null===(u=null===(l=null==i?void 0:i.response)||void 0===l?void 0:l.data)||void 0===u?void 0:u.message)||"There was an error deleting the scope. Please try again."}),[3,6];case 5:return je(!1),[7];case 6:return[2]}})})},gt=be,ht=Ue?{data:{id:Ue.stationId,name:Ue.stationName,type:"STATION",metrics:{learningsCount:Ue.learningsCount,stationsCount:0},children:[]}}:gt,St=!!(null==ht?void 0:ht.data);null===(ee=null==ht?void 0:ht.data)||void 0===ee||ee.type;var yt=U(function(e){return e.hasGlobalPermission})("ilotj.scope.global.create",le.applicationResourceId||"");if(ct)return o("div",e({className:v.learningManagementContainer},{children:o(H,{})}));if(lt)return o("div",e({className:v.learningManagementContainer},{children:o(Q,{errorMessage:"Failed to load configuration. Please try again.",onRetry:function(){return ut()},title:"Error Loading Configuration"})}));var bt=t(t([{type:"GLOBAL",label:"Global",addChildLabel:"".concat(Y("".concat(J,".addScope"),"Add Scope")),addChildType:"SCOPE"}],Array.from({length:pt},function(){return e({type:"SCOPE",label:Y("".concat(J,".scope"),"Scope")},!me&&{addChildLabel:Y("".concat(X,".addSubScope"),"Add Subscope"),addChildType:"SUBSCOPE"})}),!0),me?[]:[{type:"SUBSCOPE",label:Y("".concat(J,".subScope"),"Subscope")}],!0),Ct=[{id:"learnings",label:Y("".concat(J,".treeMenu.submenu.learnings"),"Learnings"),icon:u,badgeKey:"learningsCount"},{id:"access",label:Y("".concat(J,".treeMenu.submenu.access"),"Access"),icon:d},{id:"history",label:Y("".concat(J,".treeMenu.submenu.changeHistory"),"Change History"),icon:p}],Tt=new Set(Ct.map(function(e){return e.id})),At=Ue?Ct.filter(function(e){return"stations"!==e.id}):Ct;return o(P,{children:s("div",e({className:v.learningManagementContainer},{children:[o("div",e({className:v.mainWrapper},{children:Ie?o(_,{}):he?s("div",e({className:v.errorContainer},{children:[o("div",e({className:v.errorTitle},{children:"Error Loading Data"})),o("p",e({className:v.errorDesc},{children:he})),o("button",e({onClick:function(){return ft(!0)},className:v.tryAgainBtn},{children:"Try Again"}))]})):St?o(g,{onOpenCreateModal:function(){return Le({isOpen:!0,type:"GLOBAL"})},onAddChild:function(e,t,n){return Le({isOpen:!0,type:t,parentId:e,parentName:n})},onRenameChild:function(e,t){return Le({isOpen:!0,type:"RENAME",scopeId:e,initialName:t})},onDeleteChild:function(e,t,o){return n(re,void 0,void 0,function(){var n,s,i;return r(this,function(r){switch(r.label){case 0:return n=m.getState().scopeTreeData,s=k((null==n?void 0:n.data)||null,e),i=!!s&&3===s.length,0!==o?[3,2]:[4,vt(e)];case 1:return r.sent(),[3,3];case 2:Le({isOpen:!0,type:"DELETE",scopeId:e,initialName:t,isSubscope:i}),r.label=3;case 3:return[2]}})})},canDeleteScope:function(e){return rt("ilotj.scope.delete",e)},canEditScope:function(e){return rt("ilotj.scope.edit",e)},canCreateScope:function(e){return rt("ilotj.scope.create",e)},onSectionSelect:function(e,t){var n;console.log("Section Selected:",{scopeId:e,sectionId:t}),O(((n={})[w.SECTION]="learnings"===t?null:t,n[w.RULESET_ID]=e,n)),ke(t),ge(e)},activeSectionId:Ne,scopeTreeData:ht,sectionsConfig:At,onViewStation:function(e){Ke.current=ve,qe(e),ke("learnings"),ge(e.stationId)},onRefreshRuleSets:function(e,t){void 0===e&&(e=!0),t&&(Ve.current=t),ft(e)},nodeTypesConfig:bt,app_integration_id:de,token:oe.accessToken,modeId:fe}):o(h,{onCreate:function(){return Le({isOpen:!0,type:"GLOBAL"})},title:Y("".concat(Z,".title"),"No Global Scope has been added!"),desc:Y("".concat(Z,".desc"),"Start by creating a Global scope to define base learnings that apply across all stations."),button:Y("".concat(Z,".createGlobalScope"),"Create Global Scope"),canCreateRule:yt,noAccessTitle:Y("".concat(Z,".noAccessTitle"),"Access Restricted"),noAccessDesc:Y("".concat(Z,".noAccessDesc"),"You do not have access for this application."),requestAccessButton:Y("".concat(Z,".requestAccessButton"),"Request Access"),requestSentButton:Y("".concat(Z,".requestSentButton"),"Request Sent"),onRequestAccess:function(){return n(re,void 0,void 0,function(){var e,t,n,s,i,a,c,l,u;return r(this,function(r){switch(r.label){case 0:if(!(e=(null===(s=null===(n=m.getState().scopeTreeData)||void 0===n?void 0:n.data)||void 0===s?void 0:s.id)||Me))return null===(i=Ye.current)||void 0===i||i.show({severity:"error",sticky:!1,className:v.errorToast,content:o(V,{message:"Unable to identify the global scope for this access request."})}),[2];xe(!0),r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,R(e)];case 2:return r.sent(),ze(!0),null===(a=Ye.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:v.successToast,content:o(K,{message:"Access request submitted successfully!"})}),[3,5];case 3:return t=r.sent(),null===(c=Ye.current)||void 0===c||c.show({severity:"error",sticky:!1,className:v.errorToast,content:o(V,{message:(null===(u=null===(l=null==t?void 0:t.response)||void 0===l?void 0:l.data)||void 0===u?void 0:u.detail)||"Failed to request access. Please try again."})}),[3,5];case 4:return xe(!1),[7];case 5:return[2]}})})},isRequestingAccess:Fe,isAccessRequested:Qe})})),o(f,{ref:Ye,pt:{root:{style:{zIndex:9999}}}}),me&&Ae.isOpen&&"DELETE"!==Ae.type&&"RENAME"!==Ae.type?o(B,{isOpen:!0,onClose:function(){return Le(e(e({},Ae),{isOpen:!1}))},onSubmit:function(t){return n(re,void 0,void 0,function(){var n,o,s,i,a,c,l,u,d,p,f,v,g,h,S,y,b,C,E,I;return r(this,function(r){switch(r.label){case 0:je(!0),n=m.getState().backwardCompatibility,r.label=1;case 1:return r.trys.push([1,12,13,14]),o=void 0,n&&"object"==typeof t?o=t:(s=t,i="SCOPE"===Ae.type&&Ae.parentId,a=i?"genreRuleSet":Ae.type,o={topic:a,scope_reference_id:null,scopeDescription:"demo",parentScopeId:Ae.parentId||null,scopeName:s,scopeReferenceMetadata:{},applicationMappingId:de}),[4,L(o,oe.accessToken)];case 2:if(c=r.sent(),!(l=null===(h=null==c?void 0:c.data)||void 0===h?void 0:h.scopeId))return[3,10];if(Ve.current=l,u=n&&(null===(S=o.topic)||void 0===S?void 0:S.toLowerCase().includes("genre")),d=!n&&"GLOBAL"!==Ae.type&&Ae.parentId,!u&&!d)return[3,10];if(!(p=n?null===(b=null===(y=m.getState().scopeTreeData)||void 0===y?void 0:y.data)||void 0===b?void 0:b.id:Ae.parentId))return[3,10];if(!me)return[3,7];r.label=3;case 3:return r.trys.push([3,5,,6]),[4,A({source_scope_id:p,target_scope_id:l})];case 4:return r.sent(),[3,6];case 5:return f=r.sent(),console.error("Failed to inherit rules for the new scope:",f),[3,6];case 6:return[3,10];case 7:return r.trys.push([7,9,,10]),[4,T({source_scope_id:p,target_scope_id:l,application_mapping_id:de||"",is_copy_parent_variant_id:!1})];case 8:return r.sent(),[3,10];case 9:return v=r.sent(),console.error("Failed to inherit rules for the new scope:",v),[3,10];case 10:return[4,ft(!0)];case 11:return r.sent(),Le(function(t){return e(e({},t),{isOpen:!1})}),[3,14];case 12:throw g=r.sent(),console.error("An error occurred during scope creation.",g),null===(C=Ye.current)||void 0===C||C.show({severity:"error",summary:"Creation Failed",detail:(null===(I=null===(E=null==g?void 0:g.response)||void 0===E?void 0:E.data)||void 0===I?void 0:I.message)||"There was an error creating the scope. Please try again."}),g;case 13:return je(!1),[7];case 14:return[2]}})})},hasGlobalRuleSet:St,canCreateGlobal:yt,globalScopeId:null!==(ne=null===(te=null==be?void 0:be.data)||void 0===te?void 0:te.id)&&void 0!==ne?ne:null}):s(i,{children:[o(x,{isOpen:Ae.isOpen&&"DELETE"!==Ae.type&&"RENAME"!==Ae.type,onClose:function(){return Le(e(e({},Ae),{isOpen:!1}))},onCreate:function(e){e&&(Ve.current=e),ft(!0)},hasGlobalRuleSet:St,parentId:Ae.parentId}),o(W,{isOpen:Ae.isOpen&&"RENAME"===Ae.type,onClose:function(){return Le(e(e({},Ae),{isOpen:!1}))},onSave:function(t){return n(re,void 0,void 0,function(){var n,s,i,a,c,l;return r(this,function(r){switch(r.label){case 0:je(!0),r.label=1;case 1:return r.trys.push([1,4,5,6]),Ae.scopeId?(n=m.getState().backwardCompatibility,s=n?{scope_id:Ae.scopeId,scope_name:t}:{scope_id:Ae.scopeId,scope_type:"Custom",scope_name:t,description:"demo",application_mapping_id:de},[4,E(s,oe.accessToken)]):[2];case 2:return r.sent(),[4,ft(!0)];case 3:return r.sent(),Le(function(t){return e(e({},t),{isOpen:!1})}),[3,6];case 4:throw i=r.sent(),console.error("An error occurred during scope rename.",i),null===(a=Ye.current)||void 0===a||a.show({severity:"error",sticky:!1,className:v.errorToast,content:o(V,{message:(null===(l=null===(c=null==i?void 0:i.response)||void 0===c?void 0:c.data)||void 0===l?void 0:l.message)||"There was an error renaming the scope. Please try again."})}),i;case 5:return je(!1),[7];case 6:return[2]}})})},initialName:Ae.initialName})]}),o(j,{isOpen:Ae.isOpen&&"DELETE"===Ae.type,onCancel:function(){return Le(e(e({},Ae),{isOpen:!1}))},onConfirm:function(){return vt(Ae.scopeId,Ae.initialName,Ae.isSubscope)},title:"Delete Scope",description:s(i,{children:["Deleting ",o("span",e({className:v.highlight},{children:Ae.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})]}))})}export{$ as default};
|
|
2
2
|
//# sourceMappingURL=LearningManagement.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as o,__assign as n,__spreadArray as t}from"tslib";import{jsx as r,jsxs as i,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as s,useEffect as c}from"react";import{useMutation as d}from"@tanstack/react-query";import{X as u,Loader2 as p}from"lucide-react";import{Toast as m}from"primereact/toast";import{v4 as f}from"uuid";import h from"../components/StationOnboarding/StationAutocomplete.js";import g from"./AddScopeApprovalSearchComponent.js";import v from"../components/ScopeSkeletonLoader.js";import{Input as b}from"@mui/material";import y from"../store/useAuthStore.js";import{useAppSecRolesStore as S}from"../store/useAppSecRolesStore.js";import C from"../store/useEnvStore.js";import{createRuleSet as x,inheritScope as _}from"../apis/scopeApis.js";import{useLearningTemplateStore as w}from"../store/useLearningTemplateStore.js";import{IL_CONFIG_CONSTANTS as k}from"../config.js";import{dt as A}from"../store/useLMSConfigStore.js";import{MIDDLE_DRAWER_ADD_SCOPE_DT_PATH as R,MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH as I}from"../constants.js";var D=function(D){var j=D.isOpen,q=D.onClose,F=D.onCreate,z=D.hasGlobalRuleSet,E=D.parentId,L=a(""),B=L[0],W=L[1],N=a(""),G=N[0],T=N[1],M=a({}),O=M[0],P=M[1],K=s(null),U=y().user,H=S(function(e){return e.roles}),J=C(function(e){return e.rbacConfig}),Q=a(null),V=Q[0],X=Q[1],Y=a("approval_required"),Z=Y[0],$=Y[1],ee=a([]),oe=ee[0],ne=ee[1],te=a([]),re=te[0],ie=te[1],le=d({mutationFn:function(n){return e(void 0,void 0,void 0,function(){var e;return o(this,function(o){switch(o.label){case 0:return[4,x(n,null!==(e=null==U?void 0:U.accessToken)&&void 0!==e?e:"")];case 1:return[2,o.sent()]}})})},onSuccess:function(n){return e(void 0,void 0,void 0,function(){return o(this,function(e){return console.log("Rule Set Created Successfully",n),[2]})})}});le.data;var ae=le.isPending,se=le.mutateAsync;return c(function(){j&&(W(""),T(""),P({}),X(null),$("approval_required"),ne([]),ie([]))},[j]),j?ae?r(v,{isLoading:ae}):i("div",n({style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"}},{children:[r(m,{ref:K}),i("div",n({style:{position:"relative",width:600,borderRadius:12,backgroundColor:"white",padding:24,boxShadow:"0 25px 50px -12px rgba(0,0,0,0.25)"}},{children:[i("div",n({style:{marginBottom:24,display:"flex",alignItems:"flex-start",justifyContent:"space-between"}},{children:[i("div",{children:[r("h2",n({style:{margin:0,fontSize:18,fontWeight:500,color:"#19213D"}},{children:z?A("".concat(R,".title"),"Add Scope"):A("".concat(R,".globalTitle"),"Create Global Scope")})),r("p",n({style:{margin:"4px 0 0 0",fontSize:14,fontWeight:400,color:"#666F8D"}},{children:z?A("".concat(R,".subtitle"),"This scope will be created under Global scope and will inherit its learnings by default.",{parent:"Global"}):A("".concat(R,".globalSubtitle"),"This will be your Global scope that defines the base learnings shared across all stations.")}))]}),r("button",n({onClick:q,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"#9CA3AF"}},{children:r(u,{size:24})}))]})),i("div",n({style:{display:"flex",flexDirection:"column",gap:20}},{children:[i("div",n({style:{position:"relative",display:"flex",flexDirection:"column",gap:6}},{children:[i("label",n({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[r("span",n({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),A("".concat(R,".scopeName"),"Scope Name")]})),"Custom"===B?r(h,{value:G,onChange:function(e){if(e.length>50)return T(e.slice(0,50)),void P(function(e){return n(n({},e),{name:"Scope Name must be 50 characters or fewer"})});T(e),P(function(e){return n(n({},e),{name:void 0})})},onStationSelect:function(e){X(e)},style:{border:O.name?"1px solid #8F2C23":void 0}}):r(b,{value:G,onChange:function(e){var o=e.target.value;if(o.length>50)return T(o.slice(0,50)),void P(function(e){return n(n({},e),{name:"Scope Name must be 50 characters or fewer"})});T(o),P(function(e){return n(n({},e),{name:void 0})})},style:{border:"1px solid ".concat(O.name?"#8F2C23":"#F0F2F5")},placeholder:"e.g. Global Learnings"}),O.name&&r("p",n({style:{margin:"4px 0 0 0",fontSize:12,color:"#8F2C23"}},{children:O.name}))]})),i("div",n({style:{display:"flex",flexDirection:"column",gap:12}},{children:[i("label",n({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[r("span",n({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),A("".concat(I,".title"),"Learning Approval Settings")]})),i("div",n({role:"radio","aria-checked":"approval_required"===Z,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){return $("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||$("approval_required")}},{children:[i("div",n({style:{display:"flex",alignItems:"center",gap:8}},{children:[r("div",n({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===Z?"#2563EB":"#CBD5E1")}},{children:"approval_required"===Z&&r("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),r("span",n({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:A("".concat(I,".approvalRequired.title"),"Approval Required Before Publishing")}))]})),r("p",n({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:A("".concat(I,".approvalRequired.subtitle"),"Learnings require approval before publishing.")}))]})),"approval_required"===Z&&r(g,{selectedApprovers:oe,selectedGroupOfApprovers:re,onApproversChange:ne,onGroupsChange:ie}),i("div",n({role:"radio","aria-checked":"publish_without"===Z,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){$("publish_without")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||$("publish_without")}},{children:[i("div",n({style:{display:"flex",alignItems:"center",gap:8}},{children:[r("div",n({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===Z?"#2563EB":"#CBD5E1")}},{children:"publish_without"===Z&&r("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),r("span",n({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:A("".concat(I,".publishWithoutApproval.title"),"Publish Without Approval")}))]})),r("p",n({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:A("".concat(I,".publishWithoutApproval.subtitle"),"Learnings can be published directly.")}))]}))]})),i("div",n({style:{marginTop:32,display:"flex",justifyContent:"flex-end",gap:12}},{children:[r("button",n({onClick:q,style:{borderRadius:6,border:"1px solid #E2E8F0",padding:"8px 16px",fontSize:14,fontWeight:500,color:"#64748B",backgroundColor:"white",cursor:"pointer",opacity:ae?.5:1},disabled:ae},{children:A("".concat(R,".cancel"),"Cancel")})),r("button",n({onClick:function(){return e(void 0,void 0,void 0,function(){var e,n,r,i,l,a,s,c,d,u,p,m,h,g,v,b,y,S,C,x,A;return o(this,function(o){switch(o.label){case 0:if(e={},G.trim()?G.length>50&&(e.name="Scope Name must be 50 characters or fewer"):e.name="Scope Name is required",e.name)return P(e),[2];o.label=1;case 1:return o.trys.push([1,7,,8]),n="approval_required"===Z,r=w.getState().backwardCompatibility,i=oe.length>0||re.length>0,l=r?{topic:z?"genreRuleSet":"globalRuleSet",customScopeGroupName:k.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:G,parentScopeId:null,customScopeName:G,customScopeId:f(),createByName:(null==U?void 0:U.firstname)||"System",createdBy:(null==U?void 0:U.email)||"system@audacy.com",approvalRequired:n,appsecData:{application:null==J?void 0:J.applicationId,module:null==J?void 0:J.moduleId,roles:t(t([],n&&i?[{users:oe.map(function(e){return e.email}),groups:re.map(function(e){return e._id}),role:null!==(p=null===(u=H.find(function(e){return"Learning Manager"===e.name}))||void 0===u?void 0:u._id)&&void 0!==p?p:""}]:[],!0),[{users:[null==U?void 0:U.email],groups:[],role:null!==(h=null===(m=H.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===m?void 0:m._id)&&void 0!==h?h:""}],!1)}}:{topic:z?"genreRuleSet":"globalRuleSet",scope_reference_id:null,scopeDescription:G,parentScopeId:null!=E?E:null,scopeName:G,scopeReferenceMetadata:{},scopeType:"Custom",applicationMappingId:w.getState().app_integration_id,approvalRequired:n,appsecData:{application:null==J?void 0:J.applicationId,module:null==J?void 0:J.moduleId,roles:t(t([],n&&i?[{users:oe.map(function(e){return e.email}),groups:re.map(function(e){return e._id}),role:null!==(v=null===(g=H.find(function(e){return"Learning Manager"===e.name}))||void 0===g?void 0:g._id)&&void 0!==v?v:""}]:[],!0),[{users:[null==U?void 0:U.email],groups:[],role:null!==(y=null===(b=H.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===b?void 0:b._id)&&void 0!==y?y:""}],!1)}},console.log("Add Scope payload:",l),[4,se(l)];case 2:if(a=o.sent(),s=null===(S=null==a?void 0:a.data)||void 0===S?void 0:S.scopeId,r||!s||!E)return[3,6];o.label=3;case 3:return o.trys.push([3,5,,6]),[4,_({source_scope_id:E,target_scope_id:s,application_mapping_id:w.getState().app_integration_id||"",is_copy_parent_variant_id:!1})];case 4:return o.sent(),[3,6];case 5:return c=o.sent(),console.error("Failed to inherit rules for the new scope:",c),[3,6];case 6:return F(s),q(),[3,8];case 7:return d=o.sent(),console.error("An error occurred during scope creation.",d),null===(C=K.current)||void 0===C||C.show({severity:"error",summary:"Adding Scope Failed",detail:(null===(A=null===(x=null==d?void 0:d.response)||void 0===x?void 0:x.data)||void 0===A?void 0:A.message)||"There was an error creating the scope. Please try again."}),[3,8];case 8: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:ae||"Custom"===B&&!V?.5:1},disabled:ae||"Custom"===B&&!V},{children:ae?i(l,{children:[r(p,{className:"animate-spin",style:{marginRight:8,height:16,width:16,color:"white"}}),"Creating..."]}):A("".concat(R,".submitButton"),"Create Scope")}))]}))]}))]}))]})):null};export{D as default};
|
|
1
|
+
import{__awaiter as e,__generator as o,__assign as r,__spreadArray as n}from"tslib";import{jsxs as i,jsx as t,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as s,useEffect as c}from"react";import{useMutation as d}from"@tanstack/react-query";import{X as u,Loader2 as p}from"lucide-react";import{Toast as m}from"primereact/toast";import{v4 as f}from"uuid";import h from"../components/StationOnboarding/StationAutocomplete.js";import g from"./AddScopeApprovalSearchComponent.js";import v from"../components/ScopeSkeletonLoader.js";import{Input as y}from"@mui/material";import b from"../store/useAuthStore.js";import{useAppSecRolesStore as S}from"../store/useAppSecRolesStore.js";import C from"../store/useEnvStore.js";import{createRuleSet as x,inheritScope as _}from"../apis/scopeApis.js";import{useLearningTemplateStore as w}from"../store/useLearningTemplateStore.js";import{IL_CONFIG_CONSTANTS as k}from"../config.js";import{dt as A}from"../store/useLMSConfigStore.js";import{MIDDLE_DRAWER_ADD_SCOPE_DT_PATH as R,MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH as I}from"../constants.js";var D=function(D){var j=D.isOpen,q=D.onClose,F=D.onCreate,z=D.hasGlobalRuleSet,E=D.parentId,L=a(""),B=L[0],W=L[1],N=a(""),G=N[0],T=N[1],M=a({}),P=M[0],O=M[1],K=s(null),U=b().user,H=S(function(e){return e.roles}),J=C(function(e){return e.rbacConfig}),Q=a(!1),V=Q[0],X=Q[1],Y=a(null),Z=Y[0],$=Y[1],ee=a("approval_required"),oe=ee[0],re=ee[1],ne=a([]),ie=ne[0],te=ne[1],le=a([]),ae=le[0],se=le[1],ce=a(!1);ce[0];var de=ce[1],ue=d({mutationFn:function(r){return e(void 0,void 0,void 0,function(){var e;return o(this,function(o){switch(o.label){case 0:return[4,x(r,null!==(e=null==U?void 0:U.accessToken)&&void 0!==e?e:"")];case 1:return[2,o.sent()]}})})},onSuccess:function(r){return e(void 0,void 0,void 0,function(){var e,n;return o(this,function(o){return console.log("Rule Set Created Successfully",r),null===(e=K.current)||void 0===e||e.show({severity:"success",summary:"Scope Created",detail:(null===(n=null==r?void 0:r.data)||void 0===n?void 0:n.message)||"Scope created successfully",life:3e3}),[2]})})},onError:function(e){var o,r,n;console.error("Create scope failed",e),null===(o=K.current)||void 0===o||o.show({severity:"error",summary:"Creation Failed",detail:(null===(n=null===(r=null==e?void 0:e.response)||void 0===r?void 0:r.data)||void 0===n?void 0:n.message)||"There was an error creating the scope. Please try again."})}});ue.data;var pe=ue.isPending,me=ue.mutateAsync;return c(function(){j&&(W(""),T(""),O({}),$(null),re("approval_required"),te([]),se([]))},[j]),j?i("div",r({style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"}},{children:[t(m,{ref:K}),pe||V?t(v,{isLoading:pe||V}):i("div",r({style:{position:"relative",width:600,borderRadius:12,backgroundColor:"white",padding:24,boxShadow:"0 25px 50px -12px rgba(0,0,0,0.25)"}},{children:[i("div",r({style:{marginBottom:24,display:"flex",alignItems:"flex-start",justifyContent:"space-between"}},{children:[i("div",{children:[t("h2",r({style:{margin:0,fontSize:18,fontWeight:500,color:"#19213D"}},{children:z?A("".concat(R,".title"),"Add Scope"):A("".concat(R,".globalTitle"),"Create Global Scope")})),t("p",r({style:{margin:"4px 0 0 0",fontSize:14,fontWeight:400,color:"#666F8D"}},{children:z?A("".concat(R,".subtitle"),"This scope will be created under Global scope and will inherit its learnings by default.",{parent:"Global"}):A("".concat(R,".globalSubtitle"),"This will be your Global scope that defines the base learnings shared across all stations.")}))]}),t("button",r({onClick:q,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"#9CA3AF"}},{children:t(u,{size:24})}))]})),i("div",r({style:{display:"flex",flexDirection:"column",gap:20}},{children:[i("div",r({style:{position:"relative",display:"flex",flexDirection:"column",gap:6}},{children:[i("label",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[t("span",r({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),A("".concat(R,".scopeName"),"Scope Name")]})),"Custom"===B?t(h,{value:G,onChange:function(e){if(e.length>50)return T(e.slice(0,50)),void O(function(e){return r(r({},e),{name:"Scope Name must be 50 characters or fewer"})});T(e),O(function(e){return r(r({},e),{name:void 0})})},onStationSelect:function(e){$(e)},style:{border:P.name?"1px solid #8F2C23":void 0}}):t(y,{value:G,onChange:function(e){var o=e.target.value;if(o.length>50)return T(o.slice(0,50)),void O(function(e){return r(r({},e),{name:"Scope Name must be 50 characters or fewer"})});T(o),O(function(e){return r(r({},e),{name:void 0})})},style:{border:"1px solid ".concat(P.name?"#8F2C23":"#F0F2F5")},placeholder:"e.g. Global Learnings"}),P.name&&t("p",r({style:{margin:"4px 0 0 0",fontSize:12,color:"#8F2C23"}},{children:P.name}))]})),i("div",r({style:{display:"flex",flexDirection:"column",gap:12}},{children:[i("label",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[t("span",r({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),A("".concat(I,".title"),"Learning Approval Settings")]})),i("div",r({role:"radio","aria-checked":"approval_required"===oe,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){return re("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||re("approval_required")}},{children:[i("div",r({style:{display:"flex",alignItems:"center",gap:8}},{children:[t("div",r({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===oe?"#2563EB":"#CBD5E1")}},{children:"approval_required"===oe&&t("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),t("span",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:A("".concat(I,".approvalRequired.title"),"Approval Required Before Publishing")}))]})),t("p",r({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:A("".concat(I,".approvalRequired.subtitle"),"Learnings require approval before publishing.")}))]})),"approval_required"===oe&&t(g,{selectedApprovers:ie,selectedGroupOfApprovers:ae,onApproversChange:te,onGroupsChange:se}),i("div",r({role:"radio","aria-checked":"publish_without"===oe,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){re("publish_without")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||re("publish_without")}},{children:[i("div",r({style:{display:"flex",alignItems:"center",gap:8}},{children:[t("div",r({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===oe?"#2563EB":"#CBD5E1")}},{children:"publish_without"===oe&&t("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),t("span",r({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:A("".concat(I,".publishWithoutApproval.title"),"Publish Without Approval")}))]})),t("p",r({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:A("".concat(I,".publishWithoutApproval.subtitle"),"Learnings can be published directly.")}))]}))]})),i("div",r({style:{marginTop:32,display:"flex",justifyContent:"flex-end",gap:12}},{children:[t("button",r({onClick:q,style:{borderRadius:6,border:"1px solid #E2E8F0",padding:"8px 16px",fontSize:14,fontWeight:500,color:"#64748B",backgroundColor:"white",cursor:"pointer",opacity:pe?.5:1},disabled:pe},{children:A("".concat(R,".cancel"),"Cancel")})),t("button",r({onClick:function(){return e(void 0,void 0,void 0,function(){var e,r,i,t,l,a,s,c,d,u,p,m,h,g,v,y,b,S,C,x,A;return o(this,function(o){switch(o.label){case 0:if(e={},G.trim()?G.length>50&&(e.name="Scope Name must be 50 characters or fewer"):e.name="Scope Name is required",e.name)return O(e),[2];o.label=1;case 1:return o.trys.push([1,8,9,10]),X(!0),r="approval_required"===oe,i=w.getState().backwardCompatibility,t=ie.length>0||ae.length>0,l=i?{topic:z?"genreRuleSet":"globalRuleSet",customScopeGroupName:k.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:G,parentScopeId:null,customScopeName:G,customScopeId:f(),createByName:(null==U?void 0:U.firstname)||"System",createdBy:(null==U?void 0:U.email)||"system@audacy.com",approvalRequired:r,appsecData:{application:null==J?void 0:J.applicationId,module:null==J?void 0:J.moduleId,roles:n(n([],r&&t?[{users:ie.map(function(e){return e.email}),groups:ae.map(function(e){return e._id}),role:null!==(p=null===(u=H.find(function(e){return"Learning Manager"===e.name}))||void 0===u?void 0:u._id)&&void 0!==p?p:""}]:[],!0),[{users:[null==U?void 0:U.email],groups:[],role:null!==(h=null===(m=H.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===m?void 0:m._id)&&void 0!==h?h:""}],!1)}}:{topic:z?"genreRuleSet":"globalRuleSet",scope_reference_id:null,scopeDescription:G,parentScopeId:null!=E?E:null,scopeName:G,scopeReferenceMetadata:{},scopeType:"Custom",applicationMappingId:w.getState().app_integration_id,approvalRequired:r,appsecData:{application:null==J?void 0:J.applicationId,module:null==J?void 0:J.moduleId,roles:n(n([],r&&t?[{users:ie.map(function(e){return e.email}),groups:ae.map(function(e){return e._id}),role:null!==(v=null===(g=H.find(function(e){return"Learning Manager"===e.name}))||void 0===g?void 0:g._id)&&void 0!==v?v:""}]:[],!0),[{users:[null==U?void 0:U.email],groups:[],role:null!==(b=null===(y=H.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===y?void 0:y._id)&&void 0!==b?b:""}],!1)}},console.log("Add Scope payload:",l),[4,me(l)];case 2:if(a=o.sent(),s=null===(S=null==a?void 0:a.data)||void 0===S?void 0:S.scopeId,i||!s||!E)return[3,7];de(!0),o.label=3;case 3:return o.trys.push([3,5,6,7]),[4,_({source_scope_id:E,target_scope_id:s,application_mapping_id:w.getState().app_integration_id||"",is_copy_parent_variant_id:!1})];case 4:return o.sent(),[3,7];case 5:return c=o.sent(),console.error("Failed to inherit rules for the new scope:",c),[3,7];case 6:return de(!1),[7];case 7:return F(s),q(),[3,10];case 8:return d=o.sent(),console.error("An error occurred during scope creation.",d),null===(C=K.current)||void 0===C||C.show({severity:"error",summary:"Adding Scope Failed",detail:(null===(A=null===(x=null==d?void 0:d.response)||void 0===x?void 0:x.data)||void 0===A?void 0:A.message)||"There was an error creating the scope. Please try again."}),[3,10];case 9:return X(!1),[7];case 10: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:pe||"Custom"===B&&!Z?.5:1},disabled:pe||"Custom"===B&&!Z},{children:pe?i(l,{children:[t(p,{className:"animate-spin",style:{marginRight:8,height:16,width:16,color:"white"}}),"Creating..."]}):A("".concat(R,".submitButton"),"Create Scope")}))]}))]}))]}))]})):null};export{D as default};
|
|
2
2
|
//# sourceMappingURL=AddScopeModal.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__awaiter as e,__generator as t,__spreadArray as n,__assign as r}from"tslib";import{jsx as o,jsxs as i,Fragment as l}from"react/jsx-runtime";import{useRef as a,useState as s,useEffect as u}from"react";import{useLearningTemplateStore as c}from"../store/useLearningTemplateStore.js";import d from"../components/EmptyLearningState.js";import{getRulesInRuleSetById as p,exportRuleSet as m,deleteRule as f,deleteQuestion as v,alterQuestionPriority as g}from"../apis/scopeApis.js";import h from"../components/RuleContentSkeleton.js";import{Toast as T}from"primereact/toast";import y from"./ContentLogic.js";import w from"../components/ErrorStateDisplay.js";import S from"../shared/SuccessToastContent.js";import C from"../shared/ErrorToastContent.js";import{findNodeById as j}from"../utils/treeUtils.js";import R from"../styles/LearningContent.module.css.js";import b from"../components/ConfirmationModal.js";import{dt as I}from"../store/useLMSConfigStore.js";import"../../IL-OTJ/_components/atoms/Textarea/Textarea.js";import"lucide-react";import"../../IL-OTJ/_components/InputDataReasoningCard.js";import"../../IL-OTJ/_components/TooltipComponent.js";import"../../IL-OTJ/_components/templates/TemplatesMap/templatesMap.js";import{CitationProvider as D}from"../../IL-OTJ/store/CitationsContext.js";import"@mui/material";import"uuid";import"@mui/material/Tooltip";import"react-markdown";import"rehype-raw";import"axios";import"@e-llm-studio/streaming-response";import"@e-llm-studio/watch-me-work";import"../../IL-OTJ/_components/ChatComponents/ChatHeader.js";import"remark-gfm";import"../../IL-OTJ/_components/MarkdownComponents/MarkdownElements.js";import"../../IL-OTJ/_components/CitationLink.js";import"@e-llm-studio/citation";import"@viswa-test/test-citation";import x from"../../IL-OTJ/ValueTypeWrappers/TeachMePlugin.js";import{LEARNING_DT_PATH as _,VARIANT_DT_PATH as L,TIER_DT_PATH as k}from"../constants.js";import"../store/usePermissionsStore.js";import"appsec-ui";import"../store/useAuthStore.js";import"../store/useEnvStore.js";import"@radix-ui/react-tooltip";import"../components/StationOnboarding/InputField.js";import"../store/useConfigStore.js";import"../config.js";import"../store/useAppSecRolesStore.js";import"@tanstack/react-query";import"@e-llm-studio/audit-log";import"@e-llm-studio/audit-log/dist/styles.css";import"../AuditLog/ChangeLogDiff.js";import"../components/ToolTip.js";import"react-router-dom";var O=function(O){var M,A=O.noRulesTitle,N=void 0===A?"No rules have been added !":A,E=O.noRulesDesc,V=void 0===E?"Start by adding rules that should apply across all stations.":E,F=O.noRulesButtonText,P=void 0===F?"Create New Rule":F,B=O.deleteRuleSuccessMessage,J=void 0===B?"Rule deleted successfully!":B,U=O.deleteVariantSuccessMessage,W=void 0===U?"Variant deleted successfully!":U,q=O.deleteRuleErrorMessage,G=void 0===q?"Failed to delete rule. Please try again.":q,H=O.deleteVariantErrorMessage,$=void 0===H?"Failed to delete variant. Please try again.":H,z=O.deleteModalTitle,K=void 0===z?"Delete":z,Q=O.deleteRuleModalWarning,X=void 0===Q?"This will permanently delete the rule configuration.":Q,Y=O.deleteVariantModalWarning,Z=void 0===Y?"This will permanently delete the variant configuration.":Y,ee=O.deleteConfirmText,te=void 0===ee?"Delete":ee,ne=O.onRefreshRuleSets,re=O.app_integration_id,oe=O.token,ie=O.modeId,le=c(function(e){return e.selectedRuleSetId}),ae=c(function(e){return e.scopeTreeData}),se=c(function(e){return e.sidebarTab}),ue=c(function(e){return e.setInitialRules}),ce=c(function(e){return e.currentRules}),de=c(function(e){return e.setRawAuditRuleData});c(function(e){return e.createdVariantInfo});var pe=c(function(e){return e.resetCreatedVariantInfo}),me=c(function(e){return e.isILModalTriggered}),fe=c(function(e){return e.setIsILModalTriggered}),ve=a(null),ge=s(!1),he=ge[0],Te=ge[1],ye=s(null),we=ye[0],Se=ye[1],Ce=s(null),je=Ce[0],Re=Ce[1],be=s(null),Ie=be[0],De=be[1],xe=s(null),_e=xe[0],Le=xe[1],ke=s(!1),Oe=ke[0],Me=ke[1],Ae=s(null),Ne=Ae[0],Ee=Ae[1],Ve=s(!1),Fe=Ve[0],Pe=Ve[1],Be=s(""),Je=Be[0],Ue=Be[1],We=s(null),qe=We[0],Ge=We[1],He=s(!1),$e=He[0],ze=He[1],Ke=s(!1),Qe=Ke[0],Xe=Ke[1],Ye=s("ruleDeletion"),Ze=Ye[0],et=Ye[1],tt=s(null),nt=tt[0],rt=tt[1],ot=s(!1),it=ot[0],lt=ot[1],at=s(!1),st=at[0],ut=at[1],ct=c.getState().tiers,dt=s(null),pt=dt[0],mt=dt[1],ft=s(null),vt=ft[0],gt=ft[1],ht=s(null),Tt=ht[0],yt=ht[1],wt=function(){Se(null),Re(null),Te(!0),Le(0)},St=function(){Te(!1),fe(!1),Se(null),Re(null),De(null),Le(null),Xe(!1),ut(!1),Ct(),mt(null),gt(null),yt(null),ne&&ne(!1,le||void 0)};u(function(){Ct()},[le,ue]),u(function(){me&&Te(!0)},[me]);var Ct=function(o){return void 0===o&&(o=!1),e(void 0,void 0,void 0,function(){var e,i,l,a,s,u,d,m,f,v,g,h,T,y,w,S,C,j,R;return t(this,function(t){switch(t.label){case 0:if(!le)return ue([]),[2];o||Me(!0),Ee(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,p(le,oe)];case 2:return e=t.sent(),console.log("response==",e),(null==e?void 0:e.data)&&0!==Object.keys(e.data).length?(de(e),i=e.data,console.log("rulesData==",i),l=new Set(["ruleSetName","ruleSetDesc","created_at","updated_at","created_by","updated_by"]),a=Array.isArray(i.tiers)?n([],i.tiers,!0).sort(function(e,t){var n,r;return(null!==(n=e.tier_priority)&&void 0!==n?n:0)-(null!==(r=t.tier_priority)&&void 0!==r?r:0)}).map(function(e){return[e.name,e.value]}):Object.entries(i).filter(function(e){var t=e[0],n=e[1];return!l.has(t)&&Array.isArray(n)}),s=a.map(function(e){var t=e[1];return new Set(t.flatMap(function(e){var t,n;return null!==(n=null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return e.link_id}).filter(Boolean))&&void 0!==n?n:[]}))}),u=s.flatMap(function(e){return Array.from(e)}),d=u.reduce(function(e,t){var n;return e[t]=(null!==(n=e[t])&&void 0!==n?n:0)+1,e},{}),m=new Set(Object.entries(d).filter(function(e){return e[1]>1}).map(function(e){return e[0]})),f=function(e){return e.map(function(e){var t;return r(r({},e),{variants:null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return r(r({},e),{isLinked:!!e.link_id&&m.has(e.link_id)})})})})},v=a.map(function(e,t){var n,r=e[0],o=e[1],i=ct.find(function(e){return e.tier_name===r}),l=r.replace(/tier(\d+)/i,"tier_$1");return{id:null!==(n=null==i?void 0:i.tier_id)&&void 0!==n?n:String(t+1),name:l.replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()}),ruleCount:o.length,description:0===t?"".concat(I("tier.subtitle","These are the system-wide learnings applied across all stations.")):"These learnings apply after higher-priority tiers and may refine or relax default behavior.",isOpen:0===t,rules:f(o)}}),(g=c.getState().createdVariantInfo)&&g.length>0?(h=Object.fromEntries(a.map(function(e,t){return[e[0],String(t+1)]})),T=new Set(g.map(function(e){return h[e.tierName]}).filter(Boolean)),y=v.map(function(e){return r(r({},e),{isOpen:e.isOpen||T.has(e.id)})}),ue(y),(w=null===(R=null===(j=null===(C=g[0])||void 0===C?void 0:C.variants)||void 0===j?void 0:j[0])||void 0===R?void 0:R.id)?setTimeout(function(){var e=document.querySelector('[data-variant-id="'.concat(w,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(function(){return pe()},1e4)},500):pe()):ue(v),[3,5]):(ue([]),[2]);case 3:return S=t.sent(),console.error("Failed to fetch rule details",S),404!==(null==S?void 0:S.status)&&Ee((null==S?void 0:S.message)||"Failed to load rules. Please try again."),ue([]),[3,5];case 4:return o||Me(!1),[7];case 5:return[2]}})})},jt=le?j((null==ae?void 0:ae.data)||null,le):null,Rt=jt?{ruleSetId:jt.id,ruleSetName:jt.name,ruleSetDesc:"",ruleCount:null===(M=null==jt?void 0:jt.metrics)||void 0===M?void 0:M.learningsCount}:void 0,bt=Boolean(null==ae?void 0:ae.data),It=Boolean(le&&!jt&&bt),Dt=function(){if("stations"===se)return"custom";if(!jt)return"global";switch(jt.type){case"GLOBAL":default:return"global";case"SCOPE":return"genre";case"SUBSCOPE":case"Custom":return"custom"}},xt=function(e){var t;if(!e)return o("p",{children:I("".concat(k,".deleteDialog.description"),"Are you sure you want to delete this rule? This action cannot be undone.")});var n=null==ce?void 0:ce.flatMap(function(e){var t;return null!==(t=e.rules)&&void 0!==t?t:[]}).find(function(t){return t.ruleId===e});return o("p",{children:I("".concat(k,".deleteDialog.description"),"Are you sure you want to delete ".concat(null==n?void 0:n.ruleTitle," rule? This action cannot be undone."),{rule_title:null!==(t=null==n?void 0:n.ruleTitle)&&void 0!==t?t:""})})},_t={editingRule:we,editingTier:je,editingVariants:Ie,focusedVariantIndex:_e,setFocusedVariantIndex:Le,triggerAddVariant:Qe,triggerFixGaps:st,copiedRule:pt,copiedSourceTier:vt,copiedTargetTier:Tt,initialDraftMessage:Je,app_integration_id:re,modeId:ie};return Rt?i(l,{children:[o(T,{ref:ve}),o("div",r({className:R.container},{children:Oe?o(h,{}):Ne?o(w,{errorMessage:Ne,onRetry:Ct}):o(y,{onAddRule:wt,onDeleteRule:function(e){Ge(e)},onEditRule:function(e,t){Se(e),Re(t||null),De(e.variants||null),Le(null),Xe(!0),Te(!0)},onEditVariant:function(e,t,n,r){var o,i,l,a,s=null!==(l=null===(i=null===(o=null==ce?void 0:ce.find(function(e){return e.name===n}))||void 0===o?void 0:o.rules)||void 0===i?void 0:i.find(function(e){return e.ruleId===t}))&&void 0!==l?l:null==ce?void 0:ce.flatMap(function(e){return e.rules}).find(function(e){return e.ruleId===t});if(s){var u=null===(a=s.variants)||void 0===a?void 0:a.findIndex(function(t){return t.variantId===e.variantId}),c=void 0!==u&&-1!==u?u:0;Se(s),Re(n||null),De(s.variants||null),Le(c),Te(!0),"resolve_gaps"===r&&ut(!0)}},onDeleteVariant:function(e,t){rt({variantId:e,ruleId:t})},onExportRule:function(){return e(void 0,void 0,void 0,function(){var e,n,r,i,l,a,s;return t(this,function(t){switch(t.label){case 0:if(!le)return[2];Pe(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,m(le)];case 2:return e=t.sent(),n=window.URL.createObjectURL(e),(r=document.createElement("a")).href=n,i=(null==Rt?void 0:Rt.ruleSetName)?"".concat(Rt.ruleSetName.replace(/\s+/g,"_"),"_rules.csv"):"ruleset_".concat(le,".csv"),r.download=i,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(n),null===(a=ve.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:R.successToast,content:o(S,{message:"Ruleset exported successfully!"})}),[3,5];case 3:return l=t.sent(),console.error("Export error:",l),null===(s=ve.current)||void 0===s||s.show({severity:"error",sticky:!1,className:R.errorToast,content:o(C,{message:l.message||"Failed to export ruleset. Please try again."})}),[3,5];case 4:return Pe(!1),[7];case 5:return[2]}})})},isExporting:Fe,onToggleSuccess:function(){return Ct(!0)},onReorderRules:function(n,r,i,l,a){return e(void 0,void 0,void 0,function(){var e,s,u;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,g(n,r,i,l,a)];case 1:return t.sent(),Ct(!0),null===(s=ve.current)||void 0===s||s.show({severity:"success",sticky:!1,life:3e3,className:R.successToast,content:o(S,{message:"Rule order changed successfully. Future rule applications will follow the updated order."})}),[3,3];case 2:return e=t.sent(),console.error("Failed to reorder rules:",e),Ct(!0),null===(u=ve.current)||void 0===u||u.show({severity:"error",sticky:!1,className:R.errorToast,content:o(C,{message:"Failed to update rule order. Please try again."})}),[3,3];case 3:return[2]}})})},onRefreshRuleSets:ne,setDeleteConfirmationUsedFor:et,onCopyToTier:function(e,t,n,r,o){var i,l,a=null===(l=null===(i=null==ce?void 0:ce.find(function(e){return e.name===r}))||void 0===i?void 0:i.rules)||void 0===l?void 0:l.find(function(e){return e.ruleId===t});if(a){var s=["Add a new learning with the following details:","- Rule Title: ".concat(n),"- Description: ".concat(e.description),"- When to apply: ".concat(e.whenToApply),"- When NOT to apply: ".concat(e.whenNotToApply),"- Tier information: ".concat(o)].join("\n");Ue(s),mt(a),gt(r),yt(o),Se(null),Re(null),De(null),Le(null),Te(!0)}}})})),he&&o(D,{children:o(x,{isOpen:he,onClose:St,app_integration_id:re,token:oe,mode:"ADD",pluginPayload:r(r({},_t),{initialScope:Dt(),ruleSet:Rt})})}),o(b,{isOpen:!!qe,title:I("".concat(_,".deleteDialog.title"),K),description:xt(qe),warning:I("".concat(_,".deleteDialog.warningText"),X),confirmText:I("".concat(_,".deleteDialog.deleteText"),te),cancelText:I("".concat(_,".deleteDialog.cancelText"),"Cancel"),loadingText:I("".concat(_,".deleteDialog.loadingText"),"Deleting..."),confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,n,r,i,l;return t(this,function(t){switch(t.label){case 0:if(!qe)return[2];ze(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,f(qe)];case 2:return t.sent(),Ge(null),null===(n=ve.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:R.successToast,content:o(S,{message:J})}),Ct(),ne&&ne(!1,le||void 0),[3,5];case 3:return e=t.sent(),console.error("Failed to delete rule",e),null===(r=ve.current)||void 0===r||r.show({severity:"error",sticky:!1,className:R.errorToast,content:o(C,{message:(null===(l=null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.data)||void 0===l?void 0:l.detail)||G})}),[3,5];case 4:return ze(!1),[7];case 5:return[2]}})})},onCancel:function(){return Ge(null)},isLoading:$e}),o(b,{isOpen:!!nt,title:I("".concat(L,".deleteVariant.title"),K),description:"variantDeletion"===Ze?o("span",{children:I("".concat(L,".deleteVariant.desc"),"Are you sure you want to delete this variant? This action cannot be undone.")}):xt((null==nt?void 0:nt.ruleId)||null),warning:I("".concat(L,".deleteVariant.warningText"),"ruleDeletion"===Ze?X:Z),confirmText:I("".concat(L,".deleteDialog.deleteText"),te),cancelText:I("".concat(L,".cancelText"),"Cancel"),loadingText:I("".concat(L,".loadingText"),"Deleting..."),confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,n,r,i,l;return t(this,function(t){switch(t.label){case 0:if(!nt)return[2];lt(!0),t.label=1;case 1:return t.trys.push([1,6,7,8]),"ruleDeletion"!==Ze?[3,3]:[4,v(nt.ruleId)];case 2:return t.sent(),[3,5];case 3:return[4,f(nt.variantId)];case 4:t.sent(),t.label=5;case 5:return rt(null),null===(n=ve.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:R.successToast,content:o(S,{message:"ruleDeletion"===Ze?J:W})}),Ct(),ne&&ne(!1,le||void 0),[3,8];case 6:return e=t.sent(),console.error("Failed to delete variant",e),null===(r=ve.current)||void 0===r||r.show({severity:"error",sticky:!1,className:R.errorToast,content:o(C,{message:(null===(l=null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.data)||void 0===l?void 0:l.detail)||("ruleDeletion"===Ze?G:$)})}),[3,8];case 7:return lt(!1),[7];case 8:return[2]}})})},onCancel:function(){return rt(null)},isLoading:it})]}):It?o(w,{title:"Scope Not Found",errorMessage:"The selected scope does not exist. Please refresh the page or choose a valid scope.",onRetry:function(){return null==ne?void 0:ne(!0)},retryButtonText:"Refresh"}):i(l,{children:[o(d,{onCreate:wt,title:N,desc:V,button:P}),he&&o(D,{children:o(x,{isOpen:he,onClose:St,app_integration_id:re,token:oe,mode:"ADD",pluginPayload:r(r({},_t),{initialScope:Dt(),ruleSet:Rt})})})]})};export{O as default};
|
|
1
|
+
import{__awaiter as e,__generator as t,__spreadArray as n,__assign as r}from"tslib";import{jsx as o,jsxs as i,Fragment as l}from"react/jsx-runtime";import{useRef as a,useState as s,useEffect as u}from"react";import{useLearningTemplateStore as c}from"../store/useLearningTemplateStore.js";import d from"../components/EmptyLearningState.js";import{getRulesInRuleSetById as p,exportRuleSet as m,deleteRule as f,deleteQuestion as v,alterQuestionPriority as g}from"../apis/scopeApis.js";import h from"../components/RuleContentSkeleton.js";import{Toast as T}from"primereact/toast";import y from"./ContentLogic.js";import w from"../components/ErrorStateDisplay.js";import S from"../shared/SuccessToastContent.js";import C from"../shared/ErrorToastContent.js";import{findNodeById as R}from"../utils/treeUtils.js";import b from"../styles/LearningContent.module.css.js";import j from"../components/ConfirmationModal.js";import{dt as I}from"../store/useLMSConfigStore.js";import"../../IL-OTJ/_components/atoms/Textarea/Textarea.js";import"lucide-react";import"../../IL-OTJ/_components/InputDataReasoningCard.js";import"../../IL-OTJ/_components/TooltipComponent.js";import"../../IL-OTJ/_components/templates/TemplatesMap/templatesMap.js";import{CitationProvider as D}from"../../IL-OTJ/store/CitationsContext.js";import"@mui/material";import"uuid";import"@mui/material/Tooltip";import"react-markdown";import"rehype-raw";import"axios";import"@e-llm-studio/streaming-response";import"@e-llm-studio/watch-me-work";import"../../IL-OTJ/_components/ChatComponents/ChatHeader.js";import"remark-gfm";import"../../IL-OTJ/_components/MarkdownComponents/MarkdownElements.js";import"../../IL-OTJ/_components/CitationLink.js";import"@e-llm-studio/citation";import"@viswa-test/test-citation";import x from"../../IL-OTJ/ValueTypeWrappers/TeachMePlugin.js";import{LEARNING_DT_PATH as _,VARIANT_DT_PATH as L,TIER_DT_PATH as k}from"../constants.js";import{useConfigStore as O}from"../store/useConfigStore.js";import"../store/usePermissionsStore.js";import"appsec-ui";import"../store/useAuthStore.js";import"../store/useEnvStore.js";import"@radix-ui/react-tooltip";import"../components/StationOnboarding/InputField.js";import"../config.js";import"../store/useAppSecRolesStore.js";import"@tanstack/react-query";import"@e-llm-studio/audit-log";import"@e-llm-studio/audit-log/dist/styles.css";import"../AuditLog/ChangeLogDiff.js";import"../components/ToolTip.js";import"react-router-dom";var A=function(A){var M,E=A.noRulesTitle,N=void 0===E?"No rules have been added !":E,V=A.noRulesDesc,F=void 0===V?"Start by adding rules that should apply across all stations.":V,B=A.noRulesButtonText,P=void 0===B?"Create New Rule":B,U=A.deleteRuleSuccessMessage,J=void 0===U?"Rule deleted successfully!":U,W=A.deleteVariantSuccessMessage,q=void 0===W?"Variant deleted successfully!":W,G=A.deleteRuleErrorMessage,H=void 0===G?"Failed to delete rule. Please try again.":G,$=A.deleteVariantErrorMessage,z=void 0===$?"Failed to delete variant. Please try again.":$,K=A.deleteModalTitle,Q=void 0===K?"Delete":K,X=A.deleteRuleModalWarning,Y=void 0===X?"This will permanently delete the rule configuration.":X,Z=A.deleteVariantModalWarning,ee=void 0===Z?"This will permanently delete the variant configuration.":Z,te=A.deleteConfirmText,ne=void 0===te?"Delete":te,re=A.onRefreshRuleSets,oe=A.app_integration_id,ie=A.token,le=A.modeId,ae=c(function(e){return e.selectedRuleSetId}),se=c(function(e){return e.scopeTreeData}),ue=c(function(e){return e.sidebarTab}),ce=c(function(e){return e.setInitialRules}),de=c(function(e){return e.currentRules}),pe=c(function(e){return e.setRawAuditRuleData});c(function(e){return e.createdVariantInfo});var me=c(function(e){return e.resetCreatedVariantInfo}),fe=c(function(e){return e.isILModalTriggered}),ve=c(function(e){return e.setIsILModalTriggered}),ge=a(null),he=O.getState().configuration,Te=s(!1),ye=Te[0],we=Te[1],Se=s(null),Ce=Se[0],Re=Se[1],be=s(null),je=be[0],Ie=be[1],De=s(null),xe=De[0],_e=De[1],Le=s(null),ke=Le[0],Oe=Le[1],Ae=s(!1),Me=Ae[0],Ee=Ae[1],Ne=s(null),Ve=Ne[0],Fe=Ne[1],Be=s(!1),Pe=Be[0],Ue=Be[1],Je=s(""),We=Je[0],qe=Je[1],Ge=s(null),He=Ge[0],$e=Ge[1],ze=s(!1),Ke=ze[0],Qe=ze[1],Xe=s(!1),Ye=Xe[0],Ze=Xe[1],et=s("ruleDeletion"),tt=et[0],nt=et[1],rt=s(null),ot=rt[0],it=rt[1],lt=s(!1),at=lt[0],st=lt[1],ut=s(!1),ct=ut[0],dt=ut[1],pt=c.getState().tiers,mt=s(null),ft=mt[0],vt=mt[1],gt=s(null),ht=gt[0],Tt=gt[1],yt=s(null),wt=yt[0],St=yt[1],Ct=function(){Re(null),Ie(null),we(!0),Oe(0)},Rt=function(){we(!1),ve(!1),Re(null),Ie(null),_e(null),Oe(null),Ze(!1),dt(!1),bt(),vt(null),Tt(null),St(null),re&&re(!1,ae||void 0)};u(function(){bt()},[ae,ce]),u(function(){fe&&we(!0)},[fe]);var bt=function(o){return void 0===o&&(o=!1),e(void 0,void 0,void 0,function(){var e,i,l,a,s,u,d,m,f,v,g,h,T,y,w,S,C,R,b;return t(this,function(t){switch(t.label){case 0:if(!ae)return ce([]),[2];o||Ee(!0),Fe(null),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,p(ae,ie)];case 2:return e=t.sent(),console.log("response==",e),(null==e?void 0:e.data)&&0!==Object.keys(e.data).length?(pe(e),i=e.data,console.log("rulesData==",i),l=new Set(["ruleSetName","ruleSetDesc","created_at","updated_at","created_by","updated_by"]),a=Array.isArray(i.tiers)?n([],i.tiers,!0).sort(function(e,t){var n,r;return(null!==(n=e.tier_priority)&&void 0!==n?n:0)-(null!==(r=t.tier_priority)&&void 0!==r?r:0)}).map(function(e){return[e.name,e.value]}):Object.entries(i).filter(function(e){var t=e[0],n=e[1];return!l.has(t)&&Array.isArray(n)}),s=a.map(function(e){var t=e[1];return new Set(t.flatMap(function(e){var t,n;return null!==(n=null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return e.link_id}).filter(Boolean))&&void 0!==n?n:[]}))}),u=s.flatMap(function(e){return Array.from(e)}),d=u.reduce(function(e,t){var n;return e[t]=(null!==(n=e[t])&&void 0!==n?n:0)+1,e},{}),m=new Set(Object.entries(d).filter(function(e){return e[1]>1}).map(function(e){return e[0]})),f=function(e){return e.map(function(e){var t;return r(r({},e),{variants:null===(t=e.variants)||void 0===t?void 0:t.map(function(e){return r(r({},e),{isLinked:!!e.link_id&&m.has(e.link_id)})})})})},v=a.map(function(e,t){var n,r=e[0],o=e[1],i=pt.find(function(e){return e.tier_name===r}),l=r.replace(/tier(\d+)/i,"tier_$1");return{id:null!==(n=null==i?void 0:i.tier_id)&&void 0!==n?n:String(t+1),name:l.replace(/_/g," ").replace(/\b\w/g,function(e){return e.toUpperCase()}),ruleCount:o.length,description:0===t?"".concat(I("tier.subtitle","These are the system-wide learnings applied across all stations.")):"These learnings apply after higher-priority tiers and may refine or relax default behavior.",isOpen:0===t,rules:f(o)}}),(g=c.getState().createdVariantInfo)&&g.length>0?(h=Object.fromEntries(a.map(function(e,t){return[e[0],String(t+1)]})),T=new Set(g.map(function(e){return h[e.tierName]}).filter(Boolean)),y=v.map(function(e){return r(r({},e),{isOpen:e.isOpen||T.has(e.id)})}),ce(y),(w=null===(b=null===(R=null===(C=g[0])||void 0===C?void 0:C.variants)||void 0===R?void 0:R[0])||void 0===b?void 0:b.id)?setTimeout(function(){var e=document.querySelector('[data-variant-id="'.concat(w,'"]'));e&&e.scrollIntoView({behavior:"smooth",block:"center"}),setTimeout(function(){return me()},1e4)},500):me()):ce(v),[3,5]):(ce([]),[2]);case 3:return S=t.sent(),console.error("Failed to fetch rule details",S),404!==(null==S?void 0:S.status)&&Fe((null==S?void 0:S.message)||"Failed to load rules. Please try again."),ce([]),[3,5];case 4:return o||Ee(!1),[7];case 5:return[2]}})})},jt=ae?R((null==se?void 0:se.data)||null,ae):null,It=jt?{ruleSetId:jt.id,ruleSetName:jt.name,ruleSetDesc:"",ruleCount:null===(M=null==jt?void 0:jt.metrics)||void 0===M?void 0:M.learningsCount}:void 0,Dt=Boolean(null==se?void 0:se.data),xt=Boolean(ae&&!jt&&Dt),_t=function(){if("stations"===ue)return"custom";if(!jt)return"global";switch(jt.type){case"GLOBAL":default:return"global";case"SCOPE":return"genre";case"SUBSCOPE":case"Custom":return"custom"}},Lt=function(e){var t;if(!e)return o("p",{children:I("".concat(k,".deleteDialog.description"),"Are you sure you want to delete this rule? This action cannot be undone.")});var n=null==de?void 0:de.flatMap(function(e){var t;return null!==(t=e.rules)&&void 0!==t?t:[]}).find(function(t){return t.ruleId===e});return o("p",{children:I("".concat(k,".deleteDialog.description"),"Are you sure you want to delete ".concat(null==n?void 0:n.ruleTitle," rule? This action cannot be undone."),{rule_title:null!==(t=null==n?void 0:n.ruleTitle)&&void 0!==t?t:""})})},kt={editingRule:Ce,editingTier:je,editingVariants:xe,focusedVariantIndex:ke,setFocusedVariantIndex:Oe,triggerAddVariant:Ye,triggerFixGaps:ct,copiedRule:ft,copiedSourceTier:ht,copiedTargetTier:wt,initialDraftMessage:We,app_integration_id:oe,modeId:le};return It?i(l,{children:[o(T,{ref:ge}),o("div",r({className:b.container},{children:Me?o(h,{}):Ve?o(w,{errorMessage:Ve,onRetry:bt}):o(y,{onAddRule:Ct,onDeleteRule:function(e){$e(e)},onEditRule:function(e,t){Re(e),Ie(t||null),_e(e.variants||null),Oe(null),Ze(!0),we(!0)},onEditVariant:function(e,t,n,r){var o,i,l,a,s=null!==(l=null===(i=null===(o=null==de?void 0:de.find(function(e){return e.name===n}))||void 0===o?void 0:o.rules)||void 0===i?void 0:i.find(function(e){return e.ruleId===t}))&&void 0!==l?l:null==de?void 0:de.flatMap(function(e){return e.rules}).find(function(e){return e.ruleId===t});if(s){var u=null===(a=s.variants)||void 0===a?void 0:a.findIndex(function(t){return t.variantId===e.variantId}),c=void 0!==u&&-1!==u?u:0;Re(s),Ie(n||null),_e(s.variants||null),Oe(c),we(!0),"resolve_gaps"===r&&dt(!0)}},onDeleteVariant:function(e,t){it({variantId:e,ruleId:t})},onExportRule:function(){return e(void 0,void 0,void 0,function(){var e,n,r,i,l,a,s;return t(this,function(t){switch(t.label){case 0:if(!ae)return[2];Ue(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,m(ae)];case 2:return e=t.sent(),n=window.URL.createObjectURL(e),(r=document.createElement("a")).href=n,i=(null==It?void 0:It.ruleSetName)?"".concat(It.ruleSetName.replace(/\s+/g,"_"),"_rules.csv"):"ruleset_".concat(ae,".csv"),r.download=i,document.body.appendChild(r),r.click(),document.body.removeChild(r),window.URL.revokeObjectURL(n),null===(a=ge.current)||void 0===a||a.show({severity:"success",sticky:!1,life:3e3,className:b.successToast,content:o(S,{message:"Ruleset exported successfully!"})}),[3,5];case 3:return l=t.sent(),console.error("Export error:",l),null===(s=ge.current)||void 0===s||s.show({severity:"error",sticky:!1,className:b.errorToast,content:o(C,{message:l.message||"Failed to export ruleset. Please try again."})}),[3,5];case 4:return Ue(!1),[7];case 5:return[2]}})})},isExporting:Pe,onToggleSuccess:function(){return bt(!0)},onReorderRules:function(n,r,i,l,a){return e(void 0,void 0,void 0,function(){var e,s,u;return t(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,g(n,r,i,l,a)];case 1:return t.sent(),bt(!0),null===(s=ge.current)||void 0===s||s.show({severity:"success",sticky:!1,life:3e3,className:b.successToast,content:o(S,{message:"Rule order changed successfully. Future rule applications will follow the updated order."})}),[3,3];case 2:return e=t.sent(),console.error("Failed to reorder rules:",e),bt(!0),null===(u=ge.current)||void 0===u||u.show({severity:"error",sticky:!1,className:b.errorToast,content:o(C,{message:"Failed to update rule order. Please try again."})}),[3,3];case 3:return[2]}})})},onRefreshRuleSets:re,setDeleteConfirmationUsedFor:nt,onCopyToTier:function(e,t,n,r,o){var i,l,a=null===(l=null===(i=null==de?void 0:de.find(function(e){return e.name===r}))||void 0===i?void 0:i.rules)||void 0===l?void 0:l.find(function(e){return e.ruleId===t});if(a){var s=["Add a new learning with the following details:","- Rule Title: ".concat(n),"- Description: ".concat(e.description),"- When to apply: ".concat(e.whenToApply),"- When NOT to apply: ".concat(e.whenNotToApply),"- Tier information: ".concat(o)].join("\n");qe(s),vt(a),Tt(r),St(o),Re(null),Ie(null),_e(null),Oe(null),we(!0)}}})})),ye&&o(D,{children:o(x,{isOpen:ye,onClose:Rt,app_integration_id:oe,token:ie,mode:"ADD",baseURL:null==he?void 0:he.BASE_URL,pluginPayload:r(r({},kt),{initialScope:_t(),ruleSet:It})})}),o(j,{isOpen:!!He,title:I("".concat(_,".deleteDialog.title"),Q),description:Lt(He),warning:I("".concat(_,".deleteDialog.warningText"),Y),confirmText:I("".concat(_,".deleteDialog.deleteText"),ne),cancelText:I("".concat(_,".deleteDialog.cancelText"),"Cancel"),loadingText:I("".concat(_,".deleteDialog.loadingText"),"Deleting..."),confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,n,r,i,l;return t(this,function(t){switch(t.label){case 0:if(!He)return[2];Qe(!0),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,f(He)];case 2:return t.sent(),$e(null),null===(n=ge.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:b.successToast,content:o(S,{message:J})}),bt(),re&&re(!1,ae||void 0),[3,5];case 3:return e=t.sent(),console.error("Failed to delete rule",e),null===(r=ge.current)||void 0===r||r.show({severity:"error",sticky:!1,className:b.errorToast,content:o(C,{message:(null===(l=null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.data)||void 0===l?void 0:l.detail)||H})}),[3,5];case 4:return Qe(!1),[7];case 5:return[2]}})})},onCancel:function(){return $e(null)},isLoading:Ke}),o(j,{isOpen:!!ot,title:I("".concat(L,".deleteVariant.title"),Q),description:"variantDeletion"===tt?o("span",{children:I("".concat(L,".deleteVariant.desc"),"Are you sure you want to delete this variant? This action cannot be undone.")}):Lt((null==ot?void 0:ot.ruleId)||null),warning:I("".concat(L,".deleteVariant.warningText"),"ruleDeletion"===tt?Y:ee),confirmText:I("".concat(L,".deleteDialog.deleteText"),ne),cancelText:I("".concat(L,".cancelText"),"Cancel"),loadingText:I("".concat(L,".loadingText"),"Deleting..."),confirmBgColor:"#EF4444",onConfirm:function(){return e(void 0,void 0,void 0,function(){var e,n,r,i,l;return t(this,function(t){switch(t.label){case 0:if(!ot)return[2];st(!0),t.label=1;case 1:return t.trys.push([1,6,7,8]),"ruleDeletion"!==tt?[3,3]:[4,v(ot.ruleId)];case 2:return t.sent(),[3,5];case 3:return[4,f(ot.variantId)];case 4:t.sent(),t.label=5;case 5:return it(null),null===(n=ge.current)||void 0===n||n.show({severity:"success",sticky:!1,life:3e3,className:b.successToast,content:o(S,{message:"ruleDeletion"===tt?J:q})}),bt(),re&&re(!1,ae||void 0),[3,8];case 6:return e=t.sent(),console.error("Failed to delete variant",e),null===(r=ge.current)||void 0===r||r.show({severity:"error",sticky:!1,className:b.errorToast,content:o(C,{message:(null===(l=null===(i=null==e?void 0:e.response)||void 0===i?void 0:i.data)||void 0===l?void 0:l.detail)||("ruleDeletion"===tt?H:z)})}),[3,8];case 7:return st(!1),[7];case 8:return[2]}})})},onCancel:function(){return it(null)},isLoading:at})]}):xt?o(w,{title:"Scope Not Found",errorMessage:"The selected scope does not exist. Please refresh the page or choose a valid scope.",onRetry:function(){return null==re?void 0:re(!0)},retryButtonText:"Refresh"}):i(l,{children:[o(d,{onCreate:Ct,title:N,desc:F,button:P}),ye&&o(D,{children:o(x,{isOpen:ye,onClose:Rt,app_integration_id:oe,token:ie,mode:"ADD",baseURL:null==he?void 0:he.BASE_URL,pluginPayload:r(r({},kt),{initialScope:_t(),ruleSet:It})})})]})};export{A as default};
|
|
2
2
|
//# sourceMappingURL=RuleContent.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__assign as e,__awaiter as n,__generator as t}from"tslib";import{jsxs as i,jsx as o,Fragment as r}from"react/jsx-runtime";import{useState as a,useRef as l,useEffect as s}from"react";import{parseISO as c,isValid as d,format as u}from"date-fns";import{MoreVertical as p,Pause as v,Play as m,Copy as h,Eye as f,Info as g,TriangleAlert as y}from"lucide-react";import{toggleVariant as b}from"../apis/scopeApis.js";import{HistorySkeleton as T}from"./HistorySkeleton.js";import A from"./InheritanceBreadcrumb.js";import N from"./RuleConditionBlock.js";import C from"../styles/VariantCard.module.css.js";import j from"../styles/CustomTooltip.module.css.js";import w from"../components/CustomTooltip.js";import I from"../components/ConfirmationModal.js";import x from"./OverrideTimeline.js";import D from"../store/useAuthStore.js";import{usePermissionsStore as L}from"../store/usePermissionsStore.js";import B from"./PendingApprovalChip.js";import S from"./ApprovalActionButton.js";import O from"./ApprovalLearningDialog.js";import{useApproveOrRejectVariantsMutation as k}from"../queries/useApprovalQueries.js";import F from"../store/useEnvStore.js";import{dt as E}from"../store/useLMSConfigStore.js";import{VARIANT_DT_PATH as H}from"../constants.js";import{useLearningTemplateStore as _}from"../store/useLearningTemplateStore.js";var M=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return e.filter(Boolean).join(" ")},P=function(P){var R,V,W,z,U,G,q,Z,K,Q=P.ruleTitle,Y=P.variant,$=P.variantIndex,J=P.totalVariants,X=P.ruleId;P.pendingApprovalCount;var ee=P.ruleSetId,ne=P.tierName,te=P.displayLabel,ie=P.onEdit,oe=P.onDelete,re=P.onFetchOverrideHistory,ae=P.editButtonLabel,le=void 0===ae?E("".concat(H,".actions.edit"),"Edit"):ae,se=P.deleteButtonLabel,ce=void 0===se?E("".concat(H,".actions.delete"),"Delete"):se,de=P.whenToApplyLabel,ue=void 0===de?E("".concat(H,".whenToApply"),"When to Apply"):de,pe=P.whenNotToApplyLabel,ve=void 0===pe?E("".concat(H,".whenNotToApply"),"When Not to Apply"):pe,me=P.noConditionsText,he=void 0===me?"No conditions":me,fe=P.viewOverrideLabel,ge=void 0===fe?"View Override History":fe,ye=P.hideOverrideLabel,be=void 0===ye?"Hide Override History":ye,Te=P.enableLearningVariantLabel,Ae=void 0===Te?E("".concat(H,".actions.enable"),"Enable"):Te,Ne=P.disableLearningVariantLabel,Ce=void 0===Ne?E("".concat(H,".actions.disable"),"Disable"):Ne,je=P.historyErrorMessage,we=void 0===je?"Failed to load override history.":je,Ie=P.resolveGapsLabel,xe=void 0===Ie?"This learning has some gaps":Ie,De=P.showActionsBar,Le=void 0===De||De,Be=P.showDescriptionBox,Se=void 0===Be||Be,Oe=P.showConditions,ke=void 0===Oe||Oe,Fe=P.showInheritance,Ee=void 0===Fe||Fe,He=P.defaultApplyOpen,_e=void 0===He||He,Me=P.defaultNotApplyOpen,Pe=void 0===Me||Me,Re=P.className,Ve=P.isHighlighted,We=void 0!==Ve&&Ve,ze=P.highlightAction,Ue=P.highlightedTierNames,Ge=P.highlightedVariantIds,qe=P.headerContent,Ze=P.footerContent,Ke=P.onToggleSuccess,Qe=P.setDeleteConfirmationUsedFor,Ye=P.onCopyToTier,$e=P.onSetInitialDraftMessage,Je=D.getState().user,Xe=_.getState().tiers,en=a(_e),nn=en[0],tn=en[1],on=a(Pe),rn=on[0],an=on[1],ln=a(!1),sn=ln[0],cn=ln[1],dn=a(!1),un=dn[0],pn=dn[1],vn=a(null),mn=vn[0],hn=vn[1],fn=a(null),gn=fn[0],yn=fn[1],bn=a(!1),Tn=bn[0],An=bn[1],Nn=a(!1),Cn=Nn[0],jn=Nn[1],wn=l(null),In=!1!==Y.is_enabled,xn=a(!1),Dn=xn[0],Ln=xn[1],Bn=l(null),Sn=a({isOpen:!1,mode:"approve"}),On=Sn[0],kn=Sn[1],Fn=k(),En=F(function(e){return e.rbacConfig}),Hn=En?{application:En.applicationId,scopeLevelModuleId:null!==(R=null==En?void 0:En.moduleId)&&void 0!==R?R:"",applicationLevelModuleId:null!==(V=null==En?void 0:En.applicationModuleId)&&void 0!==V?V:"",applicationLevelResourceId:null!==(W=null==En?void 0:En.applicationResourceId)&&void 0!==W?W:""}:void 0,_n=L(function(e){return e.hasPermission}),Mn=ee,Pn=Y.inheritance&&Y.inheritance.length>1,Rn=_n("ilotj.rule.variant.edit",Mn)||_n(Pn?"ilotj.rule.variant.inherited.edit":"ilotj.rule.variant.nonInherited.edit",Mn),Vn=_n("ilotj.rule.variant.enable",Mn)||_n(Pn?"ilotj.rule.variant.inherited.enable":"ilotj.rule.variant.nonInherited.enable",Mn),Wn=_n("ilotj.rule.variant.disable",Mn)||_n(Pn?"ilotj.rule.variant.inherited.disable":"ilotj.rule.variant.nonInherited.disable",Mn),zn=_n("ilotj.rule.variant.delete",Mn),Un=_n("ilotj.rule.selfApprove",Mn),Gn=_n("ilotj.rule.approve",Mn),qn=_n("ilotj.scope.approve",Mn),Zn=_n("ilotj.rule.pendingApproval.view",Mn),Kn=_n("ilotj.rule.variant.pendingApproval.edit",Mn),Qn=Un||Gn||qn||Kn,Yn=Zn||Qn,$n="pending_approval"===(null==Y?void 0:Y.approvalStatus),Jn="rejected"===(null==Y?void 0:Y.approvalStatus),Xn=Qn&&$n;s(function(){var e=function(e){wn.current&&!wn.current.contains(e.target)&&An(!1)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}},[]);var et=(null===(z=null==mn?void 0:mn.wta)||void 0===z?void 0:z.changeLog)||[],nt=(null===(U=null==mn?void 0:mn.wnta)||void 0===U?void 0:U.changeLog)||[],tt=We&&Ue&&ne?Ue.filter(function(e){return e!==ne}):[],it=tt.length>0&&ne?tt.every(function(e){return e>ne})?"↓":"↑":"↓",ot=function(){if(Ge)for(var e=Array.from(Ge),n=0;n<e.length;n++)if(e[n]!==Y.variantId){var t=document.querySelector('[data-variant-id="'.concat(e[n],'"]'));if(t){t.scrollIntoView({behavior:"smooth",block:"center"});break}}},rt=function(e,n){e.stopPropagation(),kn({isOpen:!0,mode:n})},at=function(e){if(!e)return"";try{var n=e.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(e)?e:"".concat(e,"Z"),t=c(n);return d(t)?u(t,"MMM d, yyyy 'at' h:mm a"):e}catch(n){return e}},lt=function(e){return e?e.includes("@")?e.split("@")[0].split(".").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join(" "):e:""};return i("div",e({className:M(C.variantCard,We&&C.variantHighlight,Re),"data-variant-id":Y.variantId},{children:[i("div",e({className:C.variantHeader,style:{alignItems:"flex-start",gap:"0.75rem"}},{children:[i("div",e({className:C.variantLabelSection,style:{display:"flex",flexWrap:"wrap"}},{children:[o("span",e({className:C.variantLabel},{children:"Default"===Y.variantType&&"Default"!==te?"Default | ".concat(te):te})),We&&ze&&o("span",e({className:M(C.actionChip,"new"===ze?C.actionChipNew:C.actionChipUpdated)},{children:"new"===ze?"Created":"Updated"})),(null==Y?void 0:Y.isOverridden)&&o(w,e({content:"Inherited from the ".concat((null===(G=Y.inheritance)||void 0===G?void 0:G[(null===(q=Y.inheritance)||void 0===q?void 0:q.length)-2])||"parent"," scope and overridden in this scope."),placement:"top",withArrow:!0,contentClassName:j.customTooltip,sideOffset:5},{children:o("span",e({className:C.overriddenTag},{children:"Overridden"}))})),Yn&&$n&&o(B,{}),Jn&&o("span",e({style:{backgroundColor:"#FEF2F2",color:"#EF4444",border:"1px solid #FECACA",padding:"2px 8px",borderRadius:"9999px",fontSize:"0.75rem",fontWeight:500,display:"inline-flex",alignItems:"center"}},{children:"Rejected"})),!In&&o("span",e({className:C.learningDisabledPill},{children:"Disabled"})),Ee&&1!==J&&0!==$&&o("div",e({className:C.inheritanceSection},{children:o(A,{inheritance:Y.inheritance||[]})}))]})),Le&&i("div",e({className:C.variantActions},{children:[Xn&&i(r,{children:[o(S,{variant:"approve",text:"Approve",onClick:function(e){return rt(e,"approve")}}),o(S,{variant:"reject",text:"Reject",onClick:function(e){return rt(e,"reject")}})]}),ie&&Rn&&o("button",e({className:C.editButton,onClick:function(){null==ie||ie(Y,X,ne,"edit")}},{children:le})),oe&&zn&&"Default"!==Y.variantType&&o("button",e({className:C.deleteButton,onClick:function(){null==Qe||Qe("variantDeletion"),null==oe||oe(Y.variantId,X)}},{children:ce})),i("div",e({className:C.menuWrapper,ref:wn},{children:[o("button",e({onClick:function(){return An(!Tn)},className:"".concat(C.menuTrigger," ").concat(Tn?C.menuTriggerActive:"")},{children:o(p,{size:16})})),Tn&&i("div",e({className:C.menuDropdown},{children:[(In&&Wn||!In&&Vn)&&i("button",e({onClick:function(){return n(void 0,void 0,void 0,function(){return t(this,function(e){return An(!1),Ln(!0),[2]})})},disabled:Cn,className:"".concat(C.menuItem," ").concat(Cn?C.menuItemDisabled:"")},{children:[o(In?v:m,{size:14}),In?Ce:Ae]})),ne&&1==Xe.length&&i("button",e({onClick:function(){var e="Tier 1"===ne?"Tier 2":"Tier 1",n="Add a new learning in ".concat(e," with the following details:\nLearning Title: ").concat(Q,"\nLearning Description: ").concat(Y.description,"\nWhen to apply: ").concat(Y.whenToApply,"\nWhen not to apply: ").concat(Y.whenNotToApply);null==$e||$e(n),An(!1),null==Ye||Ye(Y,X,Q||"",ne,e)},className:C.menuItem},{children:[o(h,{size:14}),"Copy to ","Tier 1"===ne?"Tier 2":"Tier 1"]})),re&&(null!==(K=null===(Z=Y.inheritance)||void 0===Z?void 0:Z.length)&&void 0!==K?K:0)>1&&i("button",e({onClick:function(){An(!1),n(void 0,void 0,void 0,function(){var e;return t(this,function(n){switch(n.label){case 0:if(sn)return cn(!1),[2];if(cn(!0),!re)return[2];pn(!0),yn(null),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,re(X,Y.variantId)];case 2:return e=n.sent(),hn(e),[3,5];case 3:return n.sent(),yn(we),[3,5];case 4:return pn(!1),[7];case 5:return[2]}})})},className:C.menuItem},{children:[o(f,{size:14}),sn?be:ge]}))]}))]}))]}))]})),qe,Se&&Y.description&&i("div",e({className:C.descriptionBox},{children:[o("p",e({className:C.descriptionText},{children:Y.description})),sn&&(un?o(T,{}):gn?o("p",e({className:C.errorText},{children:gn})):(null==mn?void 0:mn.ruleDescription)?o(x,{changeLog:mn.ruleDescription.changeLog}):o("p",e({className:C.noHistoryText},{children:"No override history found"})))]})),ke&&i("div",e({className:C.conditionsContainer},{children:[o(N,{type:"apply",conditions:Y.whenToApply||"",isOpen:nn,onToggle:function(){return tn(!nn)},labelText:ue,noConditionsText:he,showOverrideHistory:sn,isLoadingHistory:un,historyError:gn,overrideHistoryData:et}),o(N,{type:"notApply",conditions:Y.whenNotToApply||"",isOpen:rn,onToggle:function(){return an(!rn)},labelText:ve,noConditionsText:he,showOverrideHistory:sn,isLoadingHistory:un,historyError:gn,overrideHistoryData:nt})]})),We&&tt.length>0&&i("div",e({className:C.crossTierBanner},{children:[o(g,{className:C.crossTierBannerIcon}),i("span",e({className:C.crossTierBannerText},{children:["Also created in ",tt.join(", "),"."]})),i("span",e({className:C.crossTierBannerLink,onClick:ot,role:"button",tabIndex:0,onKeyDown:function(e){return"Enter"===e.key&&ot()}},{children:["Scroll to view ",it]}))]})),Ze,(Y.createdBy||Y.createdAt)&&i("div",e({className:C.variantFooter},{children:[!0===Y.is_user_accepted_risk&&i("div",e({className:C.resolveGaps},{children:[o(y,{size:14,color:"#EF4444"}),o("span",e({className:C.resolveGapsText},{children:xe})),Rn&&o("button",e({onClick:function(){null==ie||ie(Y,X,ne,"resolve_gaps")},className:C.resolveButton},{children:"Resolve"}))]})),o("div",e({className:C.variantFooterContent},{children:Y.updatedBy||Y.updatedAt?i(r,{children:[Y.updatedBy&&o(w,e({content:Y.createdBy?"Created by ".concat(lt(Y.createdBy)):"",contentClassName:j.customTooltip,sideOffset:5,placement:"top"},{children:i("span",e({className:C.variantFooterItem},{children:["Updated by ",lt(Y.updatedBy)]}))})),Y.updatedBy&&Y.updatedAt&&o("span",e({className:C.variantFooterSeparator},{children:"•"})),Y.updatedAt&&o(w,e({content:Y.createdAt?"Created at ".concat(at(Y.createdAt)):"",contentClassName:j.customTooltip,sideOffset:5,placement:"top"},{children:o("span",e({className:C.variantFooterItem},{children:at(Y.updatedAt)}))}))]}):i(r,{children:[Y.createdBy&&i("span",e({className:C.variantFooterItem},{children:["Created by ",lt(Y.createdBy)]})),Y.createdBy&&Y.createdAt&&o("span",e({className:C.variantFooterSeparator},{children:"•"})),Y.createdAt&&o("span",e({className:C.variantFooterItem},{children:at(Y.createdAt)}))]})}))]})),o(I,{isOpen:Dn,title:In?E("".concat(H,".disableDialog.title"),"Disable Learning?"):E("".concat(H,".enableDialog.title"),"Enable Learning?"),description:In?E("".concat(H,".disableDialog.desc"),"Are you sure you want to disable learning for this variant in {rule_title}?",{rule_title:null!=Q?Q:""}):E("".concat(H,".enableDialog.desc"),"Are you sure you want to enable learning for this variant in {rule_title}?",{rule_title:null!=Q?Q:""}),warning:In?E("".concat(H,".disableDialog.warningText"),"This learning will no longer influence upcoming schedules. You can enable it again anytime."):E("".concat(H,".enableDialog.warningText"),"This learning will start influencing upcoming schedules again."),confirmText:In?E("".concat(H,".disableDialog.deleteText"),"Disable"):E("".concat(H,".enableDialog.deleteText"),"Enable"),cancelText:E("".concat(H,In?".disableDialog.cancelText":".enableDialog.cancelText"),"Cancel"),loadingText:E("".concat(H,In?".disableDialog.loadingText":".enableDialog.loadingText"),"Processing..."),confirmBgColor:In?"#DC2626":"#16A34A",onConfirm:function(){return n(void 0,void 0,void 0,function(){var e;return t(this,function(n){switch(n.label){case 0:jn(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),null==Je?void 0:Je.email,[4,b([Y.variantId],!In)];case 2:return n.sent(),null==Ke||Ke(),[3,5];case 3:return e=n.sent(),console.error("Failed to toggle variant",e),[3,5];case 4:return jn(!1),An(!1),Ln(!1),[7];case 5:return[2]}})})},onCancel:function(){return Ln(!1)},isLoading:Cn,position:"fixed"}),o(O,{open:On.isOpen,mode:On.mode,onClose:function(){return kn(function(n){return e(e({},n),{isOpen:!1})})},onSubmit:function(n){ee&&Fn.mutate({variantIds:[Y.variantId],status:"approve"===On.mode?"approved":"rejected",feedback:n.feedback,is_deleted:n.deleteLearning,scopeId:ee,appsecData:Hn},{onSuccess:function(){var n;kn(function(n){return e(e({},n),{isOpen:!1})}),null==Ke||Ke(),null===(n=Bn.current)||void 0===n||n.show({severity:"success",summary:"".concat("approve"===On.mode?"Approved":"Rejected"," Successfully"),detail:"Learning ".concat("approve"===On.mode?"approved":"rejected"," successfully.")})},onError:function(e){var n;console.error("An error occurred.",e),null===(n=Bn.current)||void 0===n||n.show({severity:"error",summary:"Action Failed",detail:"There was an error processing the learning. Please try again."})}})},variantInformation:"".concat(Q," — ").concat(te),ruleTitle:Q,pendingVariants:[Y],isPending:Fn.isPending})]}))};export{P as default};
|
|
1
|
+
import{__assign as e,__awaiter as n,__generator as t}from"tslib";import{jsxs as i,jsx as o,Fragment as r}from"react/jsx-runtime";import{useState as a,useRef as l,useEffect as s}from"react";import{parseISO as c,isValid as d,format as u}from"date-fns";import{MoreVertical as p,Pause as v,Play as m,Copy as h,Eye as f,Info as g,TriangleAlert as y}from"lucide-react";import{toggleVariant as b}from"../apis/scopeApis.js";import{HistorySkeleton as T}from"./HistorySkeleton.js";import A from"./InheritanceBreadcrumb.js";import N from"./RuleConditionBlock.js";import C from"../styles/VariantCard.module.css.js";import j from"../styles/CustomTooltip.module.css.js";import w from"../components/CustomTooltip.js";import I from"../components/ConfirmationModal.js";import x from"./OverrideTimeline.js";import D from"../store/useAuthStore.js";import{usePermissionsStore as L}from"../store/usePermissionsStore.js";import B from"./PendingApprovalChip.js";import S from"./ApprovalActionButton.js";import O from"./ApprovalLearningDialog.js";import{useApproveOrRejectVariantsMutation as k}from"../queries/useApprovalQueries.js";import F from"../store/useEnvStore.js";import{dt as E}from"../store/useLMSConfigStore.js";import{VARIANT_DT_PATH as H}from"../constants.js";import{useLearningTemplateStore as _}from"../store/useLearningTemplateStore.js";var M=function(){for(var e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];return e.filter(Boolean).join(" ")},P=function(P){var R,V,W,z,U,G,q,Z,K,Q=P.ruleTitle,Y=P.variant,$=P.variantIndex,J=P.totalVariants,X=P.ruleId;P.pendingApprovalCount;var ee=P.ruleSetId,ne=P.tierName,te=P.displayLabel,ie=P.onEdit,oe=P.onDelete,re=P.onFetchOverrideHistory,ae=P.editButtonLabel,le=void 0===ae?E("".concat(H,".actions.edit"),"Edit"):ae,se=P.deleteButtonLabel,ce=void 0===se?E("".concat(H,".actions.delete"),"Delete"):se,de=P.whenToApplyLabel,ue=void 0===de?E("".concat(H,".whenToApply"),"When to Apply"):de,pe=P.whenNotToApplyLabel,ve=void 0===pe?E("".concat(H,".whenNotToApply"),"When Not to Apply"):pe,me=P.noConditionsText,he=void 0===me?"No conditions":me,fe=P.viewOverrideLabel,ge=void 0===fe?"View Override History":fe,ye=P.hideOverrideLabel,be=void 0===ye?"Hide Override History":ye,Te=P.enableLearningVariantLabel,Ae=void 0===Te?E("".concat(H,".actions.enable"),"Enable"):Te,Ne=P.disableLearningVariantLabel,Ce=void 0===Ne?E("".concat(H,".actions.disable"),"Disable"):Ne,je=P.historyErrorMessage,we=void 0===je?"Failed to load override history.":je,Ie=P.resolveGapsLabel,xe=void 0===Ie?"This learning has some gaps":Ie,De=P.showActionsBar,Le=void 0===De||De,Be=P.showDescriptionBox,Se=void 0===Be||Be,Oe=P.showConditions,ke=void 0===Oe||Oe,Fe=P.showInheritance,Ee=void 0===Fe||Fe,He=P.defaultApplyOpen,_e=void 0===He||He,Me=P.defaultNotApplyOpen,Pe=void 0===Me||Me,Re=P.className,Ve=P.isHighlighted,We=void 0!==Ve&&Ve,ze=P.highlightAction,Ue=P.highlightedTierNames,Ge=P.highlightedVariantIds,qe=P.headerContent,Ze=P.footerContent,Ke=P.onToggleSuccess,Qe=P.setDeleteConfirmationUsedFor,Ye=P.onCopyToTier,$e=P.onSetInitialDraftMessage,Je=D.getState().user,Xe=_.getState().tiers,en=a(_e),nn=en[0],tn=en[1],on=a(Pe),rn=on[0],an=on[1],ln=a(!1),sn=ln[0],cn=ln[1],dn=a(!1),un=dn[0],pn=dn[1],vn=a(null),mn=vn[0],hn=vn[1],fn=a(null),gn=fn[0],yn=fn[1],bn=a(!1),Tn=bn[0],An=bn[1],Nn=a(!1),Cn=Nn[0],jn=Nn[1],wn=l(null),In=!1!==Y.is_enabled,xn=a(!1),Dn=xn[0],Ln=xn[1],Bn=l(null),Sn=a({isOpen:!1,mode:"approve"}),On=Sn[0],kn=Sn[1],Fn=k(),En=F(function(e){return e.rbacConfig}),Hn=En?{application:En.applicationId,scopeLevelModuleId:null!==(R=null==En?void 0:En.moduleId)&&void 0!==R?R:"",applicationLevelModuleId:null!==(V=null==En?void 0:En.applicationModuleId)&&void 0!==V?V:"",applicationLevelResourceId:null!==(W=null==En?void 0:En.applicationResourceId)&&void 0!==W?W:""}:void 0,_n=L(function(e){return e.hasPermission}),Mn=ee,Pn=Y.inheritance&&Y.inheritance.length>1,Rn=_n("ilotj.rule.variant.edit",Mn)||_n(Pn?"ilotj.rule.variant.inherited.edit":"ilotj.rule.variant.nonInherited.edit",Mn),Vn=_n("ilotj.rule.variant.enable",Mn)||_n(Pn?"ilotj.rule.variant.inherited.enable":"ilotj.rule.variant.nonInherited.enable",Mn),Wn=_n("ilotj.rule.variant.disable",Mn)||_n(Pn?"ilotj.rule.variant.inherited.disable":"ilotj.rule.variant.nonInherited.disable",Mn),zn=_n("ilotj.rule.variant.delete",Mn),Un=_n("ilotj.rule.selfApprove",Mn),Gn=_n("ilotj.rule.approve",Mn),qn=_n("ilotj.scope.approve",Mn),Zn=_n("ilotj.rule.pendingApproval.view",Mn),Kn=_n("ilotj.rule.variant.pendingApproval.edit",Mn),Qn=Un||Gn||qn||Kn,Yn=Zn||Qn,$n="pending_approval"===(null==Y?void 0:Y.approvalStatus),Jn="rejected"===(null==Y?void 0:Y.approvalStatus),Xn=Qn&&$n;s(function(){var e=function(e){wn.current&&!wn.current.contains(e.target)&&An(!1)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}},[]);var et=(null===(z=null==mn?void 0:mn.wta)||void 0===z?void 0:z.changeLog)||[],nt=(null===(U=null==mn?void 0:mn.wnta)||void 0===U?void 0:U.changeLog)||[],tt=We&&Ue&&ne?Ue.filter(function(e){return e!==ne}):[],it=tt.length>0&&ne?tt.every(function(e){return e>ne})?"↓":"↑":"↓",ot=function(){if(Ge)for(var e=Array.from(Ge),n=0;n<e.length;n++)if(e[n]!==Y.variantId){var t=document.querySelector('[data-variant-id="'.concat(e[n],'"]'));if(t){t.scrollIntoView({behavior:"smooth",block:"center"});break}}},rt=function(e,n){e.stopPropagation(),kn({isOpen:!0,mode:n})},at=function(e){if(!e)return"";try{var n=e.endsWith("Z")||/[+-]\d{2}:\d{2}$/.test(e)?e:"".concat(e,"Z"),t=c(n);return d(t)?u(t,"MMM d, yyyy 'at' h:mm a"):e}catch(n){return e}},lt=function(e){return e?e.includes("@")?e.split("@")[0].split(".").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join(" "):e:""};return i("div",e({className:M(C.variantCard,We&&C.variantHighlight,Re),"data-variant-id":Y.variantId},{children:[i("div",e({className:C.variantHeader,style:{alignItems:"flex-start",gap:"0.75rem"}},{children:[i("div",e({className:C.variantLabelSection,style:{display:"flex",flexWrap:"wrap"}},{children:[o("span",e({className:C.variantLabel},{children:"Default"===Y.variantType&&"Default"!==te?"Default | ".concat(te):te})),We&&ze&&o("span",e({className:M(C.actionChip,"new"===ze?C.actionChipNew:C.actionChipUpdated)},{children:"new"===ze?"Created":"Updated"})),(null==Y?void 0:Y.isOverridden)&&o(w,e({content:"Inherited from the ".concat((null===(G=Y.inheritance)||void 0===G?void 0:G[(null===(q=Y.inheritance)||void 0===q?void 0:q.length)-2])||"parent"," scope and overridden in this scope."),placement:"top",withArrow:!0,contentClassName:j.customTooltip,sideOffset:5},{children:o("span",e({className:C.overriddenTag},{children:"Overridden"}))})),Yn&&$n&&o(B,{}),Jn&&o("span",e({style:{backgroundColor:"#FEF2F2",color:"#EF4444",border:"1px solid #FECACA",padding:"2px 8px",borderRadius:"9999px",fontSize:"0.75rem",fontWeight:500,display:"inline-flex",alignItems:"center"}},{children:"Rejected"})),!In&&o("span",e({className:C.learningDisabledPill},{children:"Disabled"})),Ee&&1!==J&&0!==$&&o("div",e({className:C.inheritanceSection},{children:o(A,{inheritance:Y.inheritance||[]})}))]})),Le&&i("div",e({className:C.variantActions},{children:[Xn&&i(r,{children:[o(S,{variant:"approve",text:"Approve",onClick:function(e){return rt(e,"approve")}}),o(S,{variant:"reject",text:"Reject",onClick:function(e){return rt(e,"reject")}})]}),ie&&Rn&&o("button",e({className:C.editButton,onClick:function(){null==ie||ie(Y,X,ne,"edit")}},{children:le})),oe&&zn&&"Default"!==Y.variantType&&o("button",e({className:C.deleteButton,onClick:function(){null==Qe||Qe("variantDeletion"),null==oe||oe(Y.variantId,X)}},{children:ce})),i("div",e({className:C.menuWrapper,ref:wn},{children:[o("button",e({onClick:function(){return An(!Tn)},className:"".concat(C.menuTrigger," ").concat(Tn?C.menuTriggerActive:"")},{children:o(p,{size:16})})),Tn&&i("div",e({className:C.menuDropdown},{children:[(In&&Wn||!In&&Vn)&&i("button",e({onClick:function(){return n(void 0,void 0,void 0,function(){return t(this,function(e){return An(!1),Ln(!0),[2]})})},disabled:Cn,className:"".concat(C.menuItem," ").concat(Cn?C.menuItemDisabled:"")},{children:[o(In?v:m,{size:14}),In?Ce:Ae]})),ne&&Xe.length>1&&i("button",e({onClick:function(){var e="Tier 1"===ne?"Tier 2":"Tier 1",n="Add a new learning in ".concat(e," with the following details:\nLearning Title: ").concat(Q,"\nLearning Description: ").concat(Y.description,"\nWhen to apply: ").concat(Y.whenToApply,"\nWhen not to apply: ").concat(Y.whenNotToApply);null==$e||$e(n),An(!1),null==Ye||Ye(Y,X,Q||"",ne,e)},className:C.menuItem},{children:[o(h,{size:14}),"Copy to ","Tier 1"===ne?"Tier 2":"Tier 1"]})),re&&(null!==(K=null===(Z=Y.inheritance)||void 0===Z?void 0:Z.length)&&void 0!==K?K:0)>1&&i("button",e({onClick:function(){An(!1),n(void 0,void 0,void 0,function(){var e;return t(this,function(n){switch(n.label){case 0:if(sn)return cn(!1),[2];if(cn(!0),!re)return[2];pn(!0),yn(null),n.label=1;case 1:return n.trys.push([1,3,4,5]),[4,re(X,Y.variantId)];case 2:return e=n.sent(),hn(e),[3,5];case 3:return n.sent(),yn(we),[3,5];case 4:return pn(!1),[7];case 5:return[2]}})})},className:C.menuItem},{children:[o(f,{size:14}),sn?be:ge]}))]}))]}))]}))]})),qe,Se&&Y.description&&i("div",e({className:C.descriptionBox},{children:[o("p",e({className:C.descriptionText},{children:Y.description})),sn&&(un?o(T,{}):gn?o("p",e({className:C.errorText},{children:gn})):(null==mn?void 0:mn.ruleDescription)?o(x,{changeLog:mn.ruleDescription.changeLog}):o("p",e({className:C.noHistoryText},{children:"No override history found"})))]})),ke&&i("div",e({className:C.conditionsContainer},{children:[o(N,{type:"apply",conditions:Y.whenToApply||"",isOpen:nn,onToggle:function(){return tn(!nn)},labelText:ue,noConditionsText:he,showOverrideHistory:sn,isLoadingHistory:un,historyError:gn,overrideHistoryData:et}),o(N,{type:"notApply",conditions:Y.whenNotToApply||"",isOpen:rn,onToggle:function(){return an(!rn)},labelText:ve,noConditionsText:he,showOverrideHistory:sn,isLoadingHistory:un,historyError:gn,overrideHistoryData:nt})]})),We&&tt.length>0&&i("div",e({className:C.crossTierBanner},{children:[o(g,{className:C.crossTierBannerIcon}),i("span",e({className:C.crossTierBannerText},{children:["Also created in ",tt.join(", "),"."]})),i("span",e({className:C.crossTierBannerLink,onClick:ot,role:"button",tabIndex:0,onKeyDown:function(e){return"Enter"===e.key&&ot()}},{children:["Scroll to view ",it]}))]})),Ze,(Y.createdBy||Y.createdAt)&&i("div",e({className:C.variantFooter},{children:[!0===Y.is_user_accepted_risk&&i("div",e({className:C.resolveGaps},{children:[o(y,{size:14,color:"#EF4444"}),o("span",e({className:C.resolveGapsText},{children:xe})),Rn&&o("button",e({onClick:function(){null==ie||ie(Y,X,ne,"resolve_gaps")},className:C.resolveButton},{children:"Resolve"}))]})),o("div",e({className:C.variantFooterContent},{children:Y.updatedBy||Y.updatedAt?i(r,{children:[Y.updatedBy&&o(w,e({content:Y.createdBy?"Created by ".concat(lt(Y.createdBy)):"",contentClassName:j.customTooltip,sideOffset:5,placement:"top"},{children:i("span",e({className:C.variantFooterItem},{children:["Updated by ",lt(Y.updatedBy)]}))})),Y.updatedBy&&Y.updatedAt&&o("span",e({className:C.variantFooterSeparator},{children:"•"})),Y.updatedAt&&o(w,e({content:Y.createdAt?"Created at ".concat(at(Y.createdAt)):"",contentClassName:j.customTooltip,sideOffset:5,placement:"top"},{children:o("span",e({className:C.variantFooterItem},{children:at(Y.updatedAt)}))}))]}):i(r,{children:[Y.createdBy&&i("span",e({className:C.variantFooterItem},{children:["Created by ",lt(Y.createdBy)]})),Y.createdBy&&Y.createdAt&&o("span",e({className:C.variantFooterSeparator},{children:"•"})),Y.createdAt&&o("span",e({className:C.variantFooterItem},{children:at(Y.createdAt)}))]})}))]})),o(I,{isOpen:Dn,title:In?E("".concat(H,".disableDialog.title"),"Disable Learning?"):E("".concat(H,".enableDialog.title"),"Enable Learning?"),description:In?E("".concat(H,".disableDialog.desc"),"Are you sure you want to disable learning for this variant in {rule_title}?",{rule_title:null!=Q?Q:""}):E("".concat(H,".enableDialog.desc"),"Are you sure you want to enable learning for this variant in {rule_title}?",{rule_title:null!=Q?Q:""}),warning:In?E("".concat(H,".disableDialog.warningText"),"This learning will no longer influence upcoming schedules. You can enable it again anytime."):E("".concat(H,".enableDialog.warningText"),"This learning will start influencing upcoming schedules again."),confirmText:In?E("".concat(H,".disableDialog.deleteText"),"Disable"):E("".concat(H,".enableDialog.deleteText"),"Enable"),cancelText:E("".concat(H,In?".disableDialog.cancelText":".enableDialog.cancelText"),"Cancel"),loadingText:E("".concat(H,In?".disableDialog.loadingText":".enableDialog.loadingText"),"Processing..."),confirmBgColor:In?"#DC2626":"#16A34A",onConfirm:function(){return n(void 0,void 0,void 0,function(){var e;return t(this,function(n){switch(n.label){case 0:jn(!0),n.label=1;case 1:return n.trys.push([1,3,4,5]),null==Je?void 0:Je.email,[4,b([Y.variantId],!In)];case 2:return n.sent(),null==Ke||Ke(),[3,5];case 3:return e=n.sent(),console.error("Failed to toggle variant",e),[3,5];case 4:return jn(!1),An(!1),Ln(!1),[7];case 5:return[2]}})})},onCancel:function(){return Ln(!1)},isLoading:Cn,position:"fixed"}),o(O,{open:On.isOpen,mode:On.mode,onClose:function(){return kn(function(n){return e(e({},n),{isOpen:!1})})},onSubmit:function(n){ee&&Fn.mutate({variantIds:[Y.variantId],status:"approve"===On.mode?"approved":"rejected",feedback:n.feedback,is_deleted:n.deleteLearning,scopeId:ee,appsecData:Hn},{onSuccess:function(){var n;kn(function(n){return e(e({},n),{isOpen:!1})}),null==Ke||Ke(),null===(n=Bn.current)||void 0===n||n.show({severity:"success",summary:"".concat("approve"===On.mode?"Approved":"Rejected"," Successfully"),detail:"Learning ".concat("approve"===On.mode?"approved":"rejected"," successfully.")})},onError:function(e){var n;console.error("An error occurred.",e),null===(n=Bn.current)||void 0===n||n.show({severity:"error",summary:"Action Failed",detail:"There was an error processing the learning. Please try again."})}})},variantInformation:"".concat(Q," — ").concat(te),ruleTitle:Q,pendingVariants:[Y],isPending:Fn.isPending})]}))};export{P as default};
|
|
2
2
|
//# sourceMappingURL=VariantCard.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e={publishFeedback:"/instant_learning/ilotj/variants",submitChatFeedback:"/instant_learning/ilotj/feedback/teachme_otj",saveInstantLearningQuestion:"/instant_learning/getLearningQuestionId",fetchScopes:"/instant_learning/ilotj/scope",renameScope:"/instant_learning/ilotj/scope",getRulesInRuleSetById:"/instant_learning/ilotj/rules/scope",createRuleSet:"/instant_learning/ilotj/scope",fetchStationsByKeyword:"/backend/traffic-manager/station/search/{keyword}",saveRuleSet:"/backend/traffic-manager/station/ruleset",getRuleOverrideHistory:"/instant_learning/learnings/inheritance/change_log",deleteRuleSet:"/instant_learning/ilotj/scope/{ruleSetId}/{appIntegrationId}",deleteRule:"/instant_learning/ilotj/variant/{ruleId}/{appIntegrationId}",deleteQuestion:"/instant_learning/ilotj/question/{questionId}/{appIntegrationId}",deleteTier:"/instant_learning/ilotj/scope/{scopeId}/tier/{tierId}/{appIntegrationId}",updateVariant:"/instant_learning/v2/update/rule",inheritScope:"/instant_learning/ilotj/inherit-scope",updateStation:"/backend/traffic-manager/station/update",exportRuleSet:"/instant_learning/export-ruleset",toggleVariant:"/instant_learning/ilotj/toggle_variant",alterRulePriority:"/instant_learning/ilotj/alter-priority",fetchRulesByQuestionId:"/instant_learning/ilotj/rules/fetch_by_rule_id/{questionId}/{scopeId}/{appIntegrationId}?include_config=False",retrieveGenreScopes:"/instant_learning/learnings/retrieve_genre_scopes",searchScopes:"/instant_learning/learnings/search_scopes",sessionValidation:"/instant_learning/session-validation",getTiers:"/instant_learning/ilotj/tier/{appIntegrationId}",requestAccess:"/instant_learning/ilotj/request-access",getILInstance:"/instant_learning/ilotj/getData/"},n={submitChatFeedback:"/instant_learning/feedback/teachme_otj",fetchScopes:"/instant_learning/learning/fetch_by_scope/v2?custom_scope_group_name=Audacy-Traffic-Manager",createRuleSet:"/instant_learning/create-scope",deleteRuleSet:"/instant_learning/scope/{ruleSetId}/delete",getRulesInRuleSetById:"/instant_learning/learnings/rules/fetch_by_scope",publishFeedback:"/instant_learning/save",inheritScope:"/instant_learning/learnings/rules/inherit-scope",toggleVariant:"/instant_learning/toggle_variant",getTiers:"/instant_learning/retrieve_tiers",requestAccess:"/instant_learning/request-access",deleteQuestion:"/instant_learning/question/{questionId}",deleteRule:"/instant_learning/learning/{ruleId}/delete",deleteTier:"instant_learning/scopes/{scopeId}/tiers/{tierId}",fetchRulesByQuestionId:"/instant_learning/learnings/rules/fetch_by_rule_id/{questionId}/{scopeId}?include_config=True",renameScope:"/instant_learning/scope",alterRulePriority:"/instant_learning/v2/alterPriority"};export{e as API_ENDPOINTS,n as LEGACY_API_ENDPOINTS};
|
|
1
|
+
var e={publishFeedback:"/instant_learning/ilotj/variants",submitChatFeedback:"/instant_learning/ilotj/feedback/teachme_otj",saveInstantLearningQuestion:"/instant_learning/getLearningQuestionId",fetchScopes:"/instant_learning/ilotj/scope",renameScope:"/instant_learning/ilotj/scope",getRulesInRuleSetById:"/instant_learning/ilotj/rules/scope",createRuleSet:"/instant_learning/ilotj/scope",fetchStationsByKeyword:"/backend/traffic-manager/station/search/{keyword}",saveRuleSet:"/backend/traffic-manager/station/ruleset",getRuleOverrideHistory:"/instant_learning/learnings/inheritance/change_log",deleteRuleSet:"/instant_learning/ilotj/scope/{ruleSetId}/{appIntegrationId}",deleteRule:"/instant_learning/ilotj/variant/{ruleId}/{appIntegrationId}",deleteQuestion:"/instant_learning/ilotj/question/{questionId}/{appIntegrationId}",deleteTier:"/instant_learning/ilotj/scope/{scopeId}/tier/{tierId}/{appIntegrationId}",updateVariant:"/instant_learning/v2/update/rule",inheritScope:"/instant_learning/ilotj/inherit-scope",updateStation:"/backend/traffic-manager/station/update",exportRuleSet:"/instant_learning/export-ruleset",toggleVariant:"/instant_learning/ilotj/toggle_variant",alterRulePriority:"/instant_learning/ilotj/alter-priority",fetchRulesByQuestionId:"/instant_learning/ilotj/rules/fetch_by_rule_id/{questionId}/{scopeId}/{appIntegrationId}?include_config=False",retrieveGenreScopes:"/instant_learning/learnings/retrieve_genre_scopes",searchScopes:"/instant_learning/learnings/search_scopes",sessionValidation:"/instant_learning/session-validation",getTiers:"/instant_learning/ilotj/tier/{appIntegrationId}",requestAccess:"/instant_learning/ilotj/request-access",getILInstance:"/instant_learning/ilotj/getData/",updateVariantStatus:"/instant_learning/scopes/{scopeId}/variants/update_variant_status"},n={submitChatFeedback:"/instant_learning/feedback/teachme_otj",fetchScopes:"/instant_learning/learning/fetch_by_scope/v2?custom_scope_group_name=Audacy-Traffic-Manager",createRuleSet:"/instant_learning/create-scope",deleteRuleSet:"/instant_learning/scope/{ruleSetId}/delete",getRulesInRuleSetById:"/instant_learning/learnings/rules/fetch_by_scope",publishFeedback:"/instant_learning/save",inheritScope:"/instant_learning/learnings/rules/inherit-scope",toggleVariant:"/instant_learning/toggle_variant",getTiers:"/instant_learning/retrieve_tiers",requestAccess:"/instant_learning/request-access",deleteQuestion:"/instant_learning/question/{questionId}",deleteRule:"/instant_learning/learning/{ruleId}/delete",deleteTier:"instant_learning/scopes/{scopeId}/tiers/{tierId}",fetchRulesByQuestionId:"/instant_learning/learnings/rules/fetch_by_rule_id/{questionId}/{scopeId}?include_config=True",renameScope:"/instant_learning/scope",alterRulePriority:"/instant_learning/v2/alterPriority",updateVariantStatus:"/instant_learning/ilotj/variants/update_variant_status"};export{e as API_ENDPOINTS,n as LEGACY_API_ENDPOINTS};
|
|
2
2
|
//# sourceMappingURL=apiConfig.js.map
|