@e-llm-studio/instant-learning 1.3.0-alpha.37 → 1.3.0-alpha.38
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/LearningManagement/RuleContent/AddScopeApprovalSearchComponent.js +1 -1
- package/dist/cjs/features/LearningManagement/RuleContent/AddScopeModal.js +1 -1
- package/dist/cjs/features/LearningManagement/components/InstantLearningModal.js +1 -1
- package/dist/features/LearningManagement/RuleContent/AddScopeApprovalSearchComponent.js +1 -1
- package/dist/features/LearningManagement/RuleContent/AddScopeModal.js +1 -1
- package/dist/features/LearningManagement/components/InstantLearningModal.js +1 -1
- package/dist/types/src/features/LearningManagement/RuleContent/AddScopeModal.d.ts.map +1 -1
- package/dist/types/src/features/LearningManagement/components/InstantLearningModal.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),r=require("react"),t=require("lucide-react"),i=require("../queries/useApprovalQueries.js"),o={root:{marginLeft:"1.5rem"},sectionLabel:{fontSize:"0.875rem",fontWeight:500,color:"#19213D"},requiredMark:{marginRight:"0.25rem",fontSize:"1rem",fontWeight:600,color:"#8F2C23"},dropdownWrapper:{position:"relative",marginTop:"0.375rem"},inputShell:{display:"flex",minHeight:"38px",width:"100%",cursor:"text",flexWrap:"wrap",alignItems:"center",gap:"0.375rem",borderRadius:"0.375rem",border:"1px solid #E2E8F0",padding:"0.375rem 0.5rem",boxSizing:"border-box",transition:"border-color 150ms ease-in-out, box-shadow 150ms ease-in-out"},searchIcon:{flexShrink:0,color:"#9CA3AF"},chip:{display:"flex",alignItems:"center",gap:"0.25rem",borderRadius:"9999px",backgroundColor:"#EFF6FF",padding:"0.125rem 0.625rem",fontSize:"0.75rem",fontWeight:500,color:"#1D4ED8"},chipRemoveButton:{marginLeft:"0.125rem",border:"none",borderRadius:"9999px",background:"transparent",padding:0,cursor:"pointer",outline:"none"},input:{minWidth:"120px",flex:1,border:"none",backgroundColor:"transparent",fontSize:"0.875rem",color:"#19213D",outline:"none"},dropdown:{position:"absolute",zIndex:50,marginTop:"0.25rem",maxHeight:"12rem",width:"100%",overflowY:"auto",borderRadius:"0.375rem",border:"1px solid #E2E8F0",backgroundColor:"#FFFFFF",padding:"0.25rem 0",listStyle:"none",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",boxSizing:"border-box"},skeletonItem:{padding:"0.5rem 0.75rem"},skeletonLinePrimary:{height:"1rem",width:"75%",borderRadius:"0.25rem",backgroundColor:"#E5E7EB"},skeletonLineSecondary:{height:"0.75rem",width:"50%",borderRadius:"0.25rem",backgroundColor:"#E5E7EB",marginTop:"0.375rem"},checkboxOption:{display:"flex",alignItems:"center",gap:"0.625rem",width:"100%",padding:"0.5rem 0.75rem",cursor:"pointer",boxSizing:"border-box"},checkboxInput:{width:"14px",height:"14px",flexShrink:0,cursor:"pointer",accentColor:"#2563EB",margin:0},optionTitle:{fontSize:"0.875rem",fontWeight:500,color:"#19213D",margin:0},optionSubtitle:{fontSize:"0.75rem",color:"#666F8D",margin:0}};exports.default=function(s){var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),r=require("react"),t=require("lucide-react"),i=require("../queries/useApprovalQueries.js"),o={root:{marginLeft:"1.5rem"},sectionLabel:{fontSize:"0.875rem",fontWeight:500,color:"#19213D"},requiredMark:{marginRight:"0.25rem",fontSize:"1rem",fontWeight:600,color:"#8F2C23"},dropdownWrapper:{position:"relative",marginTop:"0.375rem"},inputShell:{display:"flex",minHeight:"38px",width:"100%",cursor:"text",flexWrap:"wrap",alignItems:"center",gap:"0.375rem",borderRadius:"0.375rem",border:"1px solid #E2E8F0",padding:"0.375rem 0.5rem",boxSizing:"border-box",transition:"border-color 150ms ease-in-out, box-shadow 150ms ease-in-out"},searchIcon:{flexShrink:0,color:"#9CA3AF"},chip:{display:"flex",alignItems:"center",gap:"0.25rem",borderRadius:"9999px",backgroundColor:"#EFF6FF",padding:"0.125rem 0.625rem",fontSize:"0.75rem",fontWeight:500,color:"#1D4ED8"},chipRemoveButton:{marginLeft:"0.125rem",border:"none",borderRadius:"9999px",background:"transparent",padding:0,cursor:"pointer",outline:"none"},input:{minWidth:"120px",flex:1,border:"none",backgroundColor:"transparent",fontSize:"0.875rem",color:"#19213D",outline:"none"},dropdown:{position:"absolute",zIndex:50,marginTop:"0.25rem",maxHeight:"12rem",width:"100%",overflowY:"auto",borderRadius:"0.375rem",border:"1px solid #E2E8F0",backgroundColor:"#FFFFFF",padding:"0.25rem 0",listStyle:"none",boxShadow:"0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1)",boxSizing:"border-box"},skeletonItem:{padding:"0.5rem 0.75rem"},skeletonLinePrimary:{height:"1rem",width:"75%",borderRadius:"0.25rem",backgroundColor:"#E5E7EB"},skeletonLineSecondary:{height:"0.75rem",width:"50%",borderRadius:"0.25rem",backgroundColor:"#E5E7EB",marginTop:"0.375rem"},checkboxOption:{display:"flex",alignItems:"center",gap:"0.625rem",width:"100%",padding:"0.5rem 0.75rem",cursor:"pointer",boxSizing:"border-box"},checkboxInput:{width:"14px",height:"14px",flexShrink:0,cursor:"pointer",accentColor:"#2563EB",margin:0},optionTitle:{fontSize:"0.875rem",fontWeight:500,color:"#19213D",margin:0},optionSubtitle:{fontSize:"0.75rem",color:"#666F8D",margin:0}};exports.default=function(s){var a=s.selectedApprovers,u=s.selectedGroupOfApprovers,l=s.onApproversChange,c=s.onGroupsChange,d=r.useState(""),p=d[0],h=d[1],g=r.useState(""),f=g[0],m=g[1],_=r.useState(!1),x=_[0],b=_[1],v=r.useRef(null),y=r.useRef(null),S=r.useState(""),j=S[0],E=S[1],k=r.useState(""),F=k[0],w=k[1],C=r.useState(!1),L=C[0],D=C[1],M=r.useRef(null),z=r.useRef(null),B=r.useState(!1),R=B[0],A=B[1],I=r.useState(!1),T=I[0],q=I[1],W=r.useState(null),O=W[0],P=W[1],G=r.useState(null),Q=G[0],H=G[1],X=r.useState(null),Y=X[0],J=X[1],K=r.useState(null),N=K[0],U=K[1];r.useEffect(function(){if(!p.trim())return m(""),void b(!1);var e=setTimeout(function(){return m(p)},500);return function(){return clearTimeout(e)}},[p]),r.useEffect(function(){var e=setTimeout(function(){return w(j)},300);return function(){return clearTimeout(e)}},[j]);var V=i.useApproverSearchQuery(f),Z=V.data,$=V.isFetching,ee=(Z||[]).filter(function(e){return!a.some(function(n){return n.id===e._id})}).slice(0,10).map(function(e){var n,r,t,i;return{id:e._id,email:null!==(n=e.email)&&void 0!==n?n:"",name:(null===(r=e.firstname)||void 0===r?void 0:r.trim())?"".concat(e.firstname," ").concat(null!==(t=e.lastname)&&void 0!==t?t:"").trim():null!==(i=e.email)&&void 0!==i?i:""}});r.useEffect(function(){f.trim()&&($||ee.length>0)&&b(!0)},[$,ee.length,f]);var ne=i.useGroupSearchQuery(F),re=ne.data,te=ne.isFetching,ie=(re||[]).filter(function(e){return!u.some(function(n){return n._id===e._id})}).slice(0,10);r.useEffect(function(){T&&(te||ie.length>0)&&D(!0)},[te,ie.length,T]),r.useEffect(function(){var e=function(e){v.current&&!v.current.contains(e.target)&&b(!1),M.current&&!M.current.contains(e.target)&&D(!1)};return document.addEventListener("mousedown",e),function(){return document.removeEventListener("mousedown",e)}},[]);return n.jsxs("div",e.__assign({style:o.root},{children:[n.jsxs("label",e.__assign({htmlFor:"approver-search-input",style:o.sectionLabel},{children:[n.jsx("span",e.__assign({style:o.requiredMark},{children:"*"})),"Select who can approve"]})),n.jsxs("div",e.__assign({ref:v,style:o.dropdownWrapper},{children:[n.jsxs("label",e.__assign({htmlFor:"approver-search-input",style:e.__assign(e.__assign({},o.inputShell),{borderColor:R?"#2563EB":"#E2E8F0",boxShadow:R?"0 0 0 1px #2563EB":"none"})},{children:[n.jsx(t.Search,{size:14,style:o.searchIcon}),a.map(function(r){return n.jsxs("span",e.__assign({style:o.chip},{children:[r.email,n.jsx("button",e.__assign({type:"button",onMouseDown:function(e){var n;e.preventDefault(),n=r.id,l(a.filter(function(e){return e.id!==n}))},onMouseEnter:function(){return J(r.id)},onMouseLeave:function(){return J(null)},style:e.__assign(e.__assign({},o.chipRemoveButton),{backgroundColor:Y===r.id?"#DBEAFE":"transparent"})},{children:n.jsx(t.X,{size:12})}))]}),r.id)}),n.jsx("input",{ref:y,id:"approver-search-input",type:"text",value:p,onChange:function(e){return h(e.target.value)},onFocus:function(){A(!0),(ee.length>0||$)&&b(!0)},onBlur:function(){return A(!1)},placeholder:0===a.length?"Search by name or email...":"",style:o.input})]})),x&&($||ee.length>0)&&n.jsx("ul",e.__assign({style:o.dropdown},{children:$?[1,2,3,4].map(function(r){return n.jsxs("li",e.__assign({style:o.skeletonItem},{children:[n.jsx("div",{style:o.skeletonLinePrimary}),n.jsx("div",{style:o.skeletonLineSecondary})]}),r)}):ee.map(function(r){return n.jsx("li",{children:n.jsxs("div",e.__assign({onMouseDown:function(n){n.preventDefault(),function(n){var r;l(e.__spreadArray(e.__spreadArray([],a,!0),[n],!1)),h(""),b(!1),null===(r=y.current)||void 0===r||r.focus()}(r)},onMouseEnter:function(){return P(r.id)},onMouseLeave:function(){return P(null)},style:e.__assign(e.__assign({},o.checkboxOption),{backgroundColor:O===r.id?"#F1F5F9":"transparent"})},{children:[n.jsx("input",{type:"checkbox",checked:!1,onChange:function(){},style:o.checkboxInput}),n.jsxs("div",{children:[n.jsx("p",e.__assign({style:o.optionTitle},{children:r.name})),n.jsx("p",e.__assign({style:o.optionSubtitle},{children:r.email}))]})]}))},r.id)})}))]})),n.jsxs("label",e.__assign({htmlFor:"group-search-input",style:e.__assign(e.__assign({},o.sectionLabel),{display:"inline-block",marginTop:"0.375rem"})},{children:[n.jsx("span",e.__assign({style:o.requiredMark},{children:"*"})),"Select user group who can approve"]})),n.jsxs("div",e.__assign({ref:M,style:o.dropdownWrapper},{children:[n.jsxs("label",e.__assign({htmlFor:"group-search-input",style:e.__assign(e.__assign({},o.inputShell),{borderColor:T?"#2563EB":"#E2E8F0",boxShadow:T?"0 0 0 1px #2563EB":"none"})},{children:[n.jsx(t.Search,{size:14,style:o.searchIcon}),u.map(function(r){return n.jsxs("span",e.__assign({style:o.chip},{children:[r.name,n.jsx("button",e.__assign({type:"button",onMouseDown:function(e){var n;e.preventDefault(),n=r._id,c(u.filter(function(e){return e._id!==n}))},onMouseEnter:function(){return U(r._id)},onMouseLeave:function(){return U(null)},style:e.__assign(e.__assign({},o.chipRemoveButton),{backgroundColor:N===r._id?"#DBEAFE":"transparent"})},{children:n.jsx(t.X,{size:12})}))]}),r._id)}),n.jsx("input",{ref:z,id:"group-search-input",type:"text",value:j,onChange:function(e){return E(e.target.value)},onFocus:function(){q(!0)},onBlur:function(){return q(!1)},placeholder:0===u.length?"Search by group name...":"",style:o.input})]})),L&&(te||ie.length>0)&&n.jsx("ul",e.__assign({style:o.dropdown},{children:te?[1,2,3,4].map(function(r){return n.jsxs("li",e.__assign({style:o.skeletonItem},{children:[n.jsx("div",{style:o.skeletonLinePrimary}),n.jsx("div",{style:o.skeletonLineSecondary})]}),r)}):ie.map(function(r){return n.jsx("li",{children:n.jsxs("div",e.__assign({onMouseDown:function(n){n.preventDefault(),function(n){var r;c(e.__spreadArray(e.__spreadArray([],u,!0),[n],!1)),E(""),D(!1),null===(r=z.current)||void 0===r||r.focus()}(r)},onMouseEnter:function(){return H(r._id)},onMouseLeave:function(){return H(null)},style:e.__assign(e.__assign({},o.checkboxOption),{backgroundColor:Q===r._id?"#F1F5F9":"transparent"})},{children:[n.jsx("input",{type:"checkbox",checked:!1,onChange:function(){},style:o.checkboxInput}),n.jsxs("div",{children:[n.jsx("p",e.__assign({style:o.optionTitle},{children:r.name})),n.jsx("p",e.__assign({style:o.optionSubtitle},{children:r.description}))]})]}))},r._id)})}))]}))]}))};
|
|
2
2
|
//# sourceMappingURL=AddScopeApprovalSearchComponent.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),r=require("react"),i=require("@tanstack/react-query"),t=require("lucide-react"),o=require("primereact/toast"),s=require("uuid"),a=require("../components/StationOnboarding/StationAutocomplete.js"),l=require("./AddScopeApprovalSearchComponent.js"),u=require("../components/ScopeSkeletonLoader.js"),d=require("@mui/material"),c=require("../store/useAuthStore.js"),p=require("../store/useAppSecRolesStore.js"),_=require("../store/useEnvStore.js"),g=require("../apis/scopeApis.js"),f=require("../store/useLearningTemplateStore.js"),h=require("../config.js"),m=require("../store/useLMSConfigStore.js"),v=require("../constants.js");exports.default=function(S){var y=S.isOpen,x=S.onClose,b=S.onCreate,D=S.hasGlobalRuleSet,A=S.parentId,j=r.useState(""),C=j[0],R=j[1],E=r.useState(""),T=E[0],I=E[1],q=r.useState({}),L=q[0],w=q[1],P=r.useRef(null),k=c.default().user,W=p.useAppSecRolesStore(function(e){return e.roles}),N=_.default(function(e){return e.rbacConfig}),F=r.useState(null),M=F[0],O=F[1],z=r.useState("approval_required"),G=z[0],B=z[1],H=r.useState([]),V=H[0],K=H[1],U=r.useState([]),X=U[0],J=U[1],Q=r.useState(""),Y=Q[0],Z=Q[1],$=i.useMutation({mutationFn:function(n){return e.__awaiter(void 0,void 0,void 0,function(){var r;return e.__generator(this,function(e){switch(e.label){case 0:return[4,g.createRuleSet(n,null!==(r=null==k?void 0:k.accessToken)&&void 0!==r?r:"")];case 1:return[2,e.sent()]}})})},onSuccess:function(n){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){return console.log("Rule Set Created Successfully",n),[2]})})}});$.data;var ee=$.isPending,ne=$.mutateAsync;return r.useEffect(function(){y&&(R(""),I(""),w({}),O(null),B("approval_required"),K([]),J([]),Z(""))},[y]),y?ee?n.jsx(u.default,{isLoading:ee}):n.jsxs("div",e.__assign({style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"}},{children:[n.jsx(o.Toast,{ref:P}),n.jsxs("div",e.__assign({style:{position:"relative",width:600,borderRadius:12,backgroundColor:"white",padding:24,boxShadow:"0 25px 50px -12px rgba(0,0,0,0.25)"}},{children:[n.jsxs("div",e.__assign({style:{marginBottom:24,display:"flex",alignItems:"flex-start",justifyContent:"space-between"}},{children:[n.jsxs("div",{children:[n.jsx("h2",e.__assign({style:{margin:0,fontSize:18,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".title"),"Add Scope")})),n.jsx("p",e.__assign({style:{margin:"4px 0 0 0",fontSize:14,fontWeight:400,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".subtitle"),"This scope will be created under Global and will inherit its Learnings by default.",{parent:"Global"})}))]}),n.jsx("button",e.__assign({onClick:x,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"#9CA3AF"}},{children:n.jsx(t.X,{size:24})}))]})),n.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:20}},{children:[n.jsxs("div",e.__assign({style:{position:"relative",display:"flex",flexDirection:"column",gap:6}},{children:[n.jsxs("label",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[n.jsx("span",e.__assign({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".scopeName"),"Scope Name")]})),"Custom"===C?n.jsx(a.default,{value:T,onChange:function(n){if(n.length>50)return I(n.slice(0,50)),void w(function(n){return e.__assign(e.__assign({},n),{name:"Scope Name must be 50 characters or fewer"})});I(n),w(function(n){return e.__assign(e.__assign({},n),{name:void 0})})},onStationSelect:function(e){O(e)},style:{border:L.name?"1px solid #8F2C23":void 0}}):n.jsx(d.Input,{value:T,onChange:function(n){var r=n.target.value;if(r.length>50)return I(r.slice(0,50)),void w(function(n){return e.__assign(e.__assign({},n),{name:"Scope Name must be 50 characters or fewer"})});I(r),w(function(n){return e.__assign(e.__assign({},n),{name:void 0})})},style:{border:"1px solid ".concat(L.name?"#8F2C23":"#F0F2F5")},placeholder:"e.g. Global Learnings"}),L.name&&n.jsx("p",e.__assign({style:{margin:"4px 0 0 0",fontSize:12,color:"#8F2C23"}},{children:L.name}))]})),n.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:12}},{children:[n.jsxs("label",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[n.jsx("span",e.__assign({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".title"),"Learning Approval Settings")]})),n.jsxs("div",e.__assign({role:"radio","aria-checked":"approval_required"===G,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){return B("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||B("approval_required")}},{children:[n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:8}},{children:[n.jsx("div",e.__assign({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===G?"#2563EB":"#CBD5E1")}},{children:"approval_required"===G&&n.jsx("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),n.jsx("span",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".approvalRequired.title"),"Approval Required Before Publishing")}))]})),n.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".approvalRequired.subtitle"),"Learnings require approval before publishing.")}))]})),"approval_required"===G&&n.jsx(l.default,{selectedApprovers:V,selectedGroupOfApprovers:X,onApproversChange:K,onGroupsChange:J}),Y&&n.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#8F2C23"}},{children:Y})),n.jsxs("div",e.__assign({role:"radio","aria-checked":"publish_without"===G,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){B("publish_without"),Z("")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(B("publish_without"),Z(""))}},{children:[n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:8}},{children:[n.jsx("div",e.__assign({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===G?"#2563EB":"#CBD5E1")}},{children:"publish_without"===G&&n.jsx("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),n.jsx("span",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".publishWithoutApproval.title"),"Publish Without Approval")}))]})),n.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".publishWithoutApproval.subtitle"),"Learnings can be published directly.")}))]}))]})),n.jsxs("div",e.__assign({style:{marginTop:32,display:"flex",justifyContent:"flex-end",gap:12}},{children:[n.jsx("button",e.__assign({onClick:x,style:{borderRadius:6,border:"1px solid #E2E8F0",padding:"8px 16px",fontSize:14,fontWeight:500,color:"#64748B",backgroundColor:"white",cursor:"pointer",opacity:ee?.5:1},disabled:ee},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".cancel"),"Cancel")})),n.jsx("button",e.__assign({onClick:function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,r,i,t,o,a,l,u,d,c,p,_,m,v,S,y,j,C,R,E;return e.__generator(this,function(I){switch(I.label){case 0:if(n={},T.trim()?T.length>50&&(n.name="Scope Name must be 50 characters or fewer"):n.name="Scope Name is required","approval_required"===G&&0===V.length&&0===X.length&&Z("Please select at least one approver or approver group."),n.name)return w(n),[2];if("approval_required"===G&&0===V.length&&0===X.length)return[2];Z(""),I.label=1;case 1:return I.trys.push([1,7,,8]),r="approval_required"===G,i=f.useLearningTemplateStore.getState().backwardCompatibility,t=i?{topic:D?"genreRuleSet":"globalRuleSet",customScopeGroupName:h.IL_CONFIG_CONSTANTS.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:T,parentScopeId:null,customScopeName:T,customScopeId:s.v4(),createByName:(null==k?void 0:k.firstname)||"System",createdBy:(null==k?void 0:k.email)||"system@audacy.com",approvalRequired:r,appsecData:{application:null==N?void 0:N.applicationId,module:null==N?void 0:N.moduleId,roles:e.__spreadArray(e.__spreadArray([],r?[{users:V.map(function(e){return e.email}),groups:X.map(function(e){return e._id}),role:null!==(c=null===(d=W.find(function(e){return"Learning Manager"===e.name}))||void 0===d?void 0:d._id)&&void 0!==c?c:""}]:[],!0),[{users:[null==k?void 0:k.email],groups:[],role:null!==(_=null===(p=W.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===p?void 0:p._id)&&void 0!==_?_:""}],!1)}}:{topic:D?"genreRuleSet":"globalRuleSet",scope_reference_id:null,scopeDescription:T,parentScopeId:null!=A?A:null,scopeName:T,scopeReferenceMetadata:{},scopeType:"Custom",applicationMappingId:f.useLearningTemplateStore.getState().app_integration_id,appsecData:{application:null==N?void 0:N.applicationId,module:null==N?void 0:N.moduleId,roles:e.__spreadArray(e.__spreadArray([],r?[{users:V.map(function(e){return e.email}),groups:X.map(function(e){return e._id}),role:null!==(v=null===(m=W.find(function(e){return"Learning Manager"===e.name}))||void 0===m?void 0:m._id)&&void 0!==v?v:""}]:[],!0),[{users:[null==k?void 0:k.email],groups:[],role:null!==(y=null===(S=W.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===S?void 0:S._id)&&void 0!==y?y:""}],!1)}},console.log("Add Scope payload:",t),[4,ne(t)];case 2:if(o=I.sent(),a=null===(j=null==o?void 0:o.data)||void 0===j?void 0:j.scopeId,i||!a||!A)return[3,6];I.label=3;case 3:return I.trys.push([3,5,,6]),[4,g.inheritScope({source_scope_id:A,target_scope_id:a,application_mapping_id:f.useLearningTemplateStore.getState().app_integration_id||"",is_copy_parent_variant_id:!1})];case 4:return I.sent(),[3,6];case 5:return l=I.sent(),console.error("Failed to inherit rules for the new scope:",l),[3,6];case 6:return b(a),x(),[3,8];case 7:return u=I.sent(),console.error("An error occurred during scope creation.",u),null===(C=P.current)||void 0===C||C.show({severity:"error",summary:"Adding Scope Failed",detail:(null===(E=null===(R=null==u?void 0:u.response)||void 0===R?void 0:R.data)||void 0===E?void 0:E.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:ee||"Custom"===C&&!M?.5:1},disabled:ee||"Custom"===C&&!M},{children:ee?n.jsxs(n.Fragment,{children:[n.jsx(t.Loader2,{className:"animate-spin",style:{marginRight:8,height:16,width:16,color:"white"}}),"Creating..."]}):m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".submitButton"),"Create Scope")}))]}))]}))]}))]})):null};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),n=require("react/jsx-runtime"),r=require("react"),i=require("@tanstack/react-query"),t=require("lucide-react"),o=require("primereact/toast"),a=require("uuid"),s=require("../components/StationOnboarding/StationAutocomplete.js"),l=require("./AddScopeApprovalSearchComponent.js"),u=require("../components/ScopeSkeletonLoader.js"),d=require("@mui/material"),c=require("../store/useAuthStore.js"),p=require("../store/useAppSecRolesStore.js"),_=require("../store/useEnvStore.js"),g=require("../apis/scopeApis.js"),f=require("../store/useLearningTemplateStore.js"),h=require("../config.js"),m=require("../store/useLMSConfigStore.js"),v=require("../constants.js");exports.default=function(S){var y=S.isOpen,x=S.onClose,b=S.onCreate,D=S.hasGlobalRuleSet,A=S.parentId,j=r.useState(""),C=j[0],R=j[1],E=r.useState(""),T=E[0],I=E[1],q=r.useState({}),L=q[0],w=q[1],P=r.useRef(null),k=c.default().user,W=p.useAppSecRolesStore(function(e){return e.roles}),N=_.default(function(e){return e.rbacConfig}),F=r.useState(null),M=F[0],O=F[1],z=r.useState("approval_required"),G=z[0],B=z[1],H=r.useState([]),V=H[0],K=H[1],U=r.useState([]),X=U[0],J=U[1],Q=r.useState(""),Y=Q[0],Z=Q[1],$=i.useMutation({mutationFn:function(n){return e.__awaiter(void 0,void 0,void 0,function(){var r;return e.__generator(this,function(e){switch(e.label){case 0:return[4,g.createRuleSet(n,null!==(r=null==k?void 0:k.accessToken)&&void 0!==r?r:"")];case 1:return[2,e.sent()]}})})},onSuccess:function(n){return e.__awaiter(void 0,void 0,void 0,function(){return e.__generator(this,function(e){return console.log("Rule Set Created Successfully",n),[2]})})}});$.data;var ee=$.isPending,ne=$.mutateAsync;return r.useEffect(function(){y&&(R(""),I(""),w({}),O(null),B("approval_required"),K([]),J([]),Z(""))},[y]),y?ee?n.jsx(u.default,{isLoading:ee}):n.jsxs("div",e.__assign({style:{position:"absolute",inset:0,zIndex:50,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.3)"}},{children:[n.jsx(o.Toast,{ref:P}),n.jsxs("div",e.__assign({style:{position:"relative",width:600,borderRadius:12,backgroundColor:"white",padding:24,boxShadow:"0 25px 50px -12px rgba(0,0,0,0.25)"}},{children:[n.jsxs("div",e.__assign({style:{marginBottom:24,display:"flex",alignItems:"flex-start",justifyContent:"space-between"}},{children:[n.jsxs("div",{children:[n.jsx("h2",e.__assign({style:{margin:0,fontSize:18,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".title"),"Add Scope")})),n.jsx("p",e.__assign({style:{margin:"4px 0 0 0",fontSize:14,fontWeight:400,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".subtitle"),"This scope will be created under Global scope and will inherit its learnings by default.",{parent:"Global"})}))]}),n.jsx("button",e.__assign({onClick:x,style:{background:"none",border:"none",padding:0,cursor:"pointer",color:"#9CA3AF"}},{children:n.jsx(t.X,{size:24})}))]})),n.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:20}},{children:[n.jsxs("div",e.__assign({style:{position:"relative",display:"flex",flexDirection:"column",gap:6}},{children:[n.jsxs("label",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[n.jsx("span",e.__assign({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".scopeName"),"Scope Name")]})),"Custom"===C?n.jsx(s.default,{value:T,onChange:function(n){if(n.length>50)return I(n.slice(0,50)),void w(function(n){return e.__assign(e.__assign({},n),{name:"Scope Name must be 50 characters or fewer"})});I(n),w(function(n){return e.__assign(e.__assign({},n),{name:void 0})})},onStationSelect:function(e){O(e)},style:{border:L.name?"1px solid #8F2C23":void 0}}):n.jsx(d.Input,{value:T,onChange:function(n){var r=n.target.value;if(r.length>50)return I(r.slice(0,50)),void w(function(n){return e.__assign(e.__assign({},n),{name:"Scope Name must be 50 characters or fewer"})});I(r),w(function(n){return e.__assign(e.__assign({},n),{name:void 0})})},style:{border:"1px solid ".concat(L.name?"#8F2C23":"#F0F2F5")},placeholder:"e.g. Global Learnings"}),L.name&&n.jsx("p",e.__assign({style:{margin:"4px 0 0 0",fontSize:12,color:"#8F2C23"}},{children:L.name}))]})),n.jsxs("div",e.__assign({style:{display:"flex",flexDirection:"column",gap:12}},{children:[n.jsxs("label",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:[n.jsx("span",e.__assign({style:{marginRight:4,fontSize:16,fontWeight:600,color:"#8F2C23"}},{children:"*"})),m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".title"),"Learning Approval Settings")]})),n.jsxs("div",e.__assign({role:"radio","aria-checked":"approval_required"===G,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){return B("approval_required")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||B("approval_required")}},{children:[n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:8}},{children:[n.jsx("div",e.__assign({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("approval_required"===G?"#2563EB":"#CBD5E1")}},{children:"approval_required"===G&&n.jsx("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),n.jsx("span",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".approvalRequired.title"),"Approval Required Before Publishing")}))]})),n.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".approvalRequired.subtitle"),"Learnings require approval before publishing.")}))]})),"approval_required"===G&&n.jsx(l.default,{selectedApprovers:V,selectedGroupOfApprovers:X,onApproversChange:K,onGroupsChange:J}),Y&&n.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#8F2C23"}},{children:Y})),n.jsxs("div",e.__assign({role:"radio","aria-checked":"publish_without"===G,tabIndex:0,style:{cursor:"pointer",display:"flex",flexDirection:"column",gap:4},onClick:function(){B("publish_without"),Z("")},onKeyDown:function(e){"Enter"!==e.key&&" "!==e.key||(B("publish_without"),Z(""))}},{children:[n.jsxs("div",e.__assign({style:{display:"flex",alignItems:"center",gap:8}},{children:[n.jsx("div",e.__assign({style:{display:"flex",height:16,width:16,flexShrink:0,alignItems:"center",justifyContent:"center",borderRadius:"50%",border:"2px solid ".concat("publish_without"===G?"#2563EB":"#CBD5E1")}},{children:"publish_without"===G&&n.jsx("div",{style:{height:8,width:8,borderRadius:"50%",backgroundColor:"#2563EB"}})})),n.jsx("span",e.__assign({style:{fontSize:14,fontWeight:500,color:"#19213D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".publishWithoutApproval.title"),"Publish Without Approval")}))]})),n.jsx("p",e.__assign({style:{margin:0,marginLeft:24,fontSize:12,color:"#666F8D"}},{children:m.dt("".concat(v.MIDDLE_DRAWER_APPROVAL_SETTINGS_DT_PATH,".publishWithoutApproval.subtitle"),"Learnings can be published directly.")}))]}))]})),n.jsxs("div",e.__assign({style:{marginTop:32,display:"flex",justifyContent:"flex-end",gap:12}},{children:[n.jsx("button",e.__assign({onClick:x,style:{borderRadius:6,border:"1px solid #E2E8F0",padding:"8px 16px",fontSize:14,fontWeight:500,color:"#64748B",backgroundColor:"white",cursor:"pointer",opacity:ee?.5:1},disabled:ee},{children:m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".cancel"),"Cancel")})),n.jsx("button",e.__assign({onClick:function(){return e.__awaiter(void 0,void 0,void 0,function(){var n,r,i,t,o,s,l,u,d,c,p,_,m,v,S,y,j,C,R,E;return e.__generator(this,function(I){switch(I.label){case 0:if(n={},T.trim()?T.length>50&&(n.name="Scope Name must be 50 characters or fewer"):n.name="Scope Name is required","approval_required"===G&&0===V.length&&0===X.length&&Z("Please select at least one approver or approver group."),n.name)return w(n),[2];if("approval_required"===G&&0===V.length&&0===X.length)return[2];Z(""),I.label=1;case 1:return I.trys.push([1,7,,8]),r="approval_required"===G,i=f.useLearningTemplateStore.getState().backwardCompatibility,t=i?{topic:D?"genreRuleSet":"globalRuleSet",customScopeGroupName:h.IL_CONFIG_CONSTANTS.CUSTOM_SCOPE_GROUP_NAME,scopeDescription:T,parentScopeId:null,customScopeName:T,customScopeId:a.v4(),createByName:(null==k?void 0:k.firstname)||"System",createdBy:(null==k?void 0:k.email)||"system@audacy.com",approvalRequired:r,appsecData:{application:null==N?void 0:N.applicationId,module:null==N?void 0:N.moduleId,roles:e.__spreadArray(e.__spreadArray([],r?[{users:V.map(function(e){return e.email}),groups:X.map(function(e){return e._id}),role:null!==(c=null===(d=W.find(function(e){return"Learning Manager"===e.name}))||void 0===d?void 0:d._id)&&void 0!==c?c:""}]:[],!0),[{users:[null==k?void 0:k.email],groups:[],role:null!==(_=null===(p=W.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===p?void 0:p._id)&&void 0!==_?_:""}],!1)}}:{topic:D?"genreRuleSet":"globalRuleSet",scope_reference_id:null,scopeDescription:T,parentScopeId:null!=A?A:null,scopeName:T,scopeReferenceMetadata:{},scopeType:"Custom",applicationMappingId:f.useLearningTemplateStore.getState().app_integration_id,approvalRequired:r,appsecData:{application:null==N?void 0:N.applicationId,module:null==N?void 0:N.moduleId,roles:e.__spreadArray(e.__spreadArray([],r?[{users:V.map(function(e){return e.email}),groups:X.map(function(e){return e._id}),role:null!==(v=null===(m=W.find(function(e){return"Learning Manager"===e.name}))||void 0===m?void 0:m._id)&&void 0!==v?v:""}]:[],!0),[{users:[null==k?void 0:k.email],groups:[],role:null!==(y=null===(S=W.find(function(e){return"Instant Learning Admin"===e.name}))||void 0===S?void 0:S._id)&&void 0!==y?y:""}],!1)}},console.log("Add Scope payload:",t),[4,ne(t)];case 2:if(o=I.sent(),s=null===(j=null==o?void 0:o.data)||void 0===j?void 0:j.scopeId,i||!s||!A)return[3,6];I.label=3;case 3:return I.trys.push([3,5,,6]),[4,g.inheritScope({source_scope_id:A,target_scope_id:s,application_mapping_id:f.useLearningTemplateStore.getState().app_integration_id||"",is_copy_parent_variant_id:!1})];case 4:return I.sent(),[3,6];case 5:return l=I.sent(),console.error("Failed to inherit rules for the new scope:",l),[3,6];case 6:return b(s),x(),[3,8];case 7:return u=I.sent(),console.error("An error occurred during scope creation.",u),null===(C=P.current)||void 0===C||C.show({severity:"error",summary:"Adding Scope Failed",detail:(null===(E=null===(R=null==u?void 0:u.response)||void 0===R?void 0:R.data)||void 0===E?void 0:E.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:ee||"Custom"===C&&!M?.5:1},disabled:ee||"Custom"===C&&!M},{children:ee?n.jsxs(n.Fragment,{children:[n.jsx(t.Loader2,{className:"animate-spin",style:{marginRight:8,height:16,width:16,color:"white"}}),"Creating..."]}):m.dt("".concat(v.MIDDLE_DRAWER_ADD_SCOPE_DT_PATH,".submitButton"),"Create Scope")}))]}))]}))]}))]})):null};
|
|
2
2
|
//# sourceMappingURL=AddScopeModal.js.map
|