slice-machine-ui 1.23.1-beta.2 → 1.23.1-beta.3
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/components/CustomTypeTable/changesPage.tsx +1 -0
- package/components/DeleteDocumentsDrawer/HardDeleteDocumentsDrawer.tsx +11 -23
- package/components/DeleteDocumentsDrawer/SoftDeleteDocumentsDrawer.tsx +11 -23
- package/components/DeleteDocumentsDrawer/index.tsx +0 -1
- package/components/SliceMachineDrawer/index.tsx +4 -6
- package/out/404.html +1 -1
- package/out/_next/static/{8aiH3LjdI_Vj38RRmPnNx → c66ozmNEqPsp5qxNPQX7V}/_buildManifest.js +1 -1
- package/out/_next/static/chunks/25-37d6fa7f064be04b.js +1 -0
- package/out/_next/static/chunks/{727-15cf3f2fea9a37e5.js → 727-2016e98f80ea6a62.js} +1 -1
- package/out/_next/static/chunks/{904-ccd8ca3368ce29fc.js → 904-4c4d0a2183ae9a27.js} +1 -1
- package/out/_next/static/chunks/pages/{_app-46cdcb7304fa805f.js → _app-d528dd2b96dccb97.js} +2 -2
- package/out/_next/static/chunks/pages/{changelog-68d115a14f1423d7.js → changelog-afd18276fe018b24.js} +1 -1
- package/out/_next/static/chunks/pages/changes-898f58035cfafe03.js +1 -0
- package/out/_next/static/chunks/pages/{labs-526bb7d60a1b90f4.js → labs-ee206005948f8e87.js} +1 -1
- package/out/_next/static/chunks/pages/slices/[lib]/[sliceName]/{[variation]-73dd999915509965.js → [variation]-b2a9d773ce5d7739.js} +1 -1
- package/out/_next/static/chunks/pages/{slices-7b09cb5130c63bb3.js → slices-e9c70c082ca3e3f9.js} +1 -1
- package/out/changelog.html +1 -1
- package/out/changes.html +1 -1
- package/out/custom-types/[customTypeId].html +1 -1
- package/out/custom-types.html +1 -1
- package/out/index.html +1 -1
- package/out/labs.html +1 -1
- package/out/page-types/[pageTypeId].html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation]/simulator.html +1 -1
- package/out/slices/[lib]/[sliceName]/[variation].html +1 -1
- package/out/slices.html +1 -1
- package/package.json +3 -3
- package/pages/changes.tsx +67 -28
- package/src/features/changes/actions/pushChanges.ts +66 -0
- package/src/{modules/pushChangesSaga → features/changes/actions}/trackPushChangesSuccess.ts +16 -12
- package/src/modules/loading/types.ts +0 -1
- package/src/modules/modal/types.ts +0 -3
- package/src/modules/useSliceMachineActions.ts +3 -18
- package/src/modules/userContext/index.ts +6 -3
- package/src/redux/reducer.ts +0 -2
- package/src/redux/saga.ts +0 -2
- package/src/redux/type.ts +0 -2
- package/components/DeleteDocumentsDrawer/ReferencesErrorDrawer.tsx +0 -92
- package/lib/models/common/TransactionalPush.ts +0 -10
- package/out/_next/static/chunks/25-8fedd33ad9b6de5b.js +0 -1
- package/out/_next/static/chunks/pages/changes-6a24f50da1a00688.js +0 -1
- package/src/modules/pushChangesSaga/index.ts +0 -191
- package/test/src/modules/pushChangesSaga.test.ts +0 -261
- /package/out/_next/static/{8aiH3LjdI_Vj38RRmPnNx → c66ozmNEqPsp5qxNPQX7V}/_ssgManifest.js +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[849],{21985:function(e,n,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/changes",function(){return t(4920)}])},56577:function(e,n,t){"use strict";t.d(n,{z:function(){return u}});var s=t(62230),i=t(85244),r=t(98240),a=t(52322),o=t(2784),c=t(75289),l=function(e,n){return e?"".concat(e,"-").concat(n):""},d=function(e){switch(e){case"white":case"secondaryMedium":case"secondarySmall":case"secondary":return"#1A1523";default:return"grey01"}},u=(0,o.forwardRef)(function(e,n){var t=e.label,o=e.Icon,u=e.type,h=e.form,x=e.isLoading,m=void 0!==x&&x,f=e.disabled,p=e.onClick,g=e.sx,j=e.iconSize,v=void 0===j?16:j,y=e.iconFill,b=e.variant,_=void 0===b?"primary":b,C=(0,r.Z)(e,["label","Icon","type","form","isLoading","disabled","onClick","sx","iconSize","iconFill","variant"]);return(0,a.jsx)(c.zx,(0,i.Z)((0,s.Z)({ref:n,sx:(0,s.Z)((0,i.Z)((0,s.Z)({},void 0===g?{}:g),{display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"}),m?{cursor:"wait !important"}:{}),type:u,form:h,disabled:void 0!==f&&f||m,onClick:m?void 0:p,variant:_},C),{children:m?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.$j,{size:v,color:d(_),"data-cy":l(C["data-cy"],"spinner")}),o&&t]}):(0,a.jsxs)(a.Fragment,{children:[o&&(0,a.jsx)(o,{size:v,fill:y,"data-cy":l(C["data-cy"],"icon")}),t]})}))})},59469:function(e,n,t){"use strict";var s=t(62230),i=t(52322),r=t(75289);n.Z=function(e){var n=e.elems,t=e.renderElem,a=e.defineElementKey,o=e.gridTemplateMinPx,c=e.gridGap,l=e.sx;return(0,i.jsx)(r.xu,{as:"section",sx:(0,s.Z)({display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(".concat(void 0===o?"320px":o,", 1fr))"),gridGap:void 0===c?"16px":c,pt:2},l),children:n.map(function(e,n){return e?(0,i.jsx)("span",{children:t(e,n)},"".concat(a(e),"-").concat(n+1)):null})})}},4920:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return ed}});var s=t(52322),i=t(22715),r=t(2784),a=t(97729),o=t.n(a),c=t(65077),l=t(56580),d=t(22337),u=t(75289),h=t(951),x=function(e){var n=e.children;return(0,s.jsx)(u.kC,{sx:{alignItems:"center",justifyContent:"space-between",mt:"8px",bg:"grey02",borderRadius:4,padding:"12px 16px"},children:n})},m=t(39097),f=t.n(m),p=t(7819),g=t(34728),j=t(67445),v=function(e){var n=e.ct,t=e.status,i=e.authStatus,r=e.isOnline;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(u.xu,{as:"td",style:{width:"40%"},children:(0,s.jsx)(u.xv,{sx:{fontWeight:500},children:n.label})}),(0,s.jsx)(u.xu,{as:"td",style:{width:"40%"},children:n.id}),(0,s.jsx)(u.xu,{as:"td",style:{width:"20%"},children:(0,s.jsx)(g.O,{authStatus:i,isOnline:r,modelStatus:t,modelType:"CustomType"})})]})},y=function(e){var n=e.customTypes,t=e.modelsStatuses,i=e.authStatus,r=e.isOnline;return(0,s.jsxs)(u.xu,{as:"table","data-legacy-component":!0,children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"transparent small",children:[(0,s.jsx)(u.xu,{as:"th",sx:{width:"40%",fontWeight:600},children:"Name"}),(0,s.jsx)(u.xu,{as:"th",sx:{width:"40%",fontWeight:600},children:"API ID"}),(0,s.jsx)(u.xu,{as:"th",sx:{width:"20%",fontWeight:600},children:"Status"})]})}),(0,s.jsx)("tbody",{children:n.map(function(e){return(0,p.TG)(e)?(0,s.jsx)(f(),{passHref:!0,href:j.cd[e.local.format].getBuilderPagePathname(e.local.id),legacyBehavior:!0,children:(0,s.jsx)("tr",{tabIndex:0,"data-cy":"custom-type-".concat(e.local.id),children:(0,s.jsx)(v,{ct:e.local,status:t.customTypes[e.local.id],authStatus:i,isOnline:r,modelsStatuses:t},e.local.id)})},e.local.id):(0,s.jsx)("tr",{tabIndex:0,className:"disabled","data-cy":"custom-type-".concat(e.remote.id),children:(0,s.jsx)(v,{ct:e.remote,status:t.customTypes[e.remote.id],authStatus:i,isOnline:r,modelsStatuses:t},e.remote.id)})})})]})},b=t(59469),_=t(15836),C=t(5479),S=t(47731),D=t(32681),T=t(71749),k=function(e){var n=e.unSyncedCustomTypes,t=e.unSyncedSlices,i=e.modelsStatuses,r=e.authStatus,a=e.isOnline,o=(0,S.H)(),c=o.modalPayload,l=o.onOpenModal,d=c.sliceFilterFn,m=c.defaultVariationSelector,f=t.filter(function(e){return i.slices[e.model.id]!==D.G.Deleted});return(0,s.jsxs)(s.Fragment,{children:[n.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(x,{children:(0,s.jsxs)(u.xu,{children:[(0,s.jsx)(u.xv,{variant:"heading",children:"Types"}),(0,s.jsx)(u.xv,{variant:"grey",sx:{ml:"8px"},children:n.length})]})}),(0,s.jsx)(y,{customTypes:n,modelsStatuses:i,authStatus:r,isOnline:a})]}),t.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(u.xu,{sx:{mb:"8px"},children:(0,s.jsxs)(x,{children:[(0,s.jsxs)(u.xu,{children:[(0,s.jsx)(u.xv,{variant:"heading",children:"Slices"}),(0,s.jsx)(u.xv,{variant:"grey",sx:{ml:"8px"},children:t.length})]}),(0,s.jsxs)(u.xu,{children:[t.some(function(e){return(0,C.cx)(e)>0&&i.slices[e.model.id]!==D.G.Deleted})&&(0,s.jsxs)(u.xv,{sx:{mr:3,color:"warning02",fontSize:"12px",lineHeight:"16px",fontWeight:600},children:[(0,s.jsx)(h.sQg,{size:16,style:{marginRight:"4px",position:"relative",top:"3px"}}),"Missing Screenshots"]}),(0,s.jsxs)(u.zx,{variant:"darkSmall",onClick:function(){return l({sliceFilterFn:function(e){return e}})},children:[(0,s.jsx)(h.hOO,{style:{color:"#FFF",fontSize:"15px",position:"relative",top:"3px",marginRight:"4px"}})," ","Update all screenshots"]})]})]})}),(0,s.jsx)(b.Z,{gridGap:"32px 16px",elems:t,gridTemplateMinPx:"305px",defineElementKey:function(e){return e.model.name},renderElem:function(e){var n=i.slices[e.model.id];return(0,s.jsx)(T.b,{action:{type:"status",authStatus:r,isOnline:a,modelStatus:n},isDeleted:n===D.G.Deleted,mode:"navigation",onUpdateScreenshot:function(){l({sliceFilterFn:function(n){return n.filter(function(n){return n.model.id===e.model.id})}})},slice:e,variant:"solid"})}}),(0,s.jsx)(_.Z,{slices:d(f),defaultVariationSelector:m})]})]})},z=t(91914),O=function(){return(0,s.jsx)(u.kC,{sx:{justifyContent:"center",alignItems:"center",flex:1},children:(0,s.jsxs)(u.kC,{sx:{flexDirection:"column",alignItems:"center",transform:"translateY(-50%)"},children:[(0,s.jsx)(z.wQ1,{size:48}),(0,s.jsx)(u.xv,{sx:{fontWeight:600,fontSize:"24px",lineHeight:"32px",mb:"8px",mt:"2px",textAlign:"center"},children:"No internet connection"}),(0,s.jsx)(u.xv,{sx:{fontSize:"13px",lineHeight:"24px",textAlign:"center"},children:"You need a stable internet connection to review and push changes"})]})})},w=t(90374),Z=t(79096),R=function(e){var n=e.authStatus,t=(0,w.Z)().openLoginModal;return(0,s.jsxs)(i.xu,{flexDirection:"column",height:"100%",alignItems:"center",justifyContent:"center",gap:8,children:[n===Z.t.FORBIDDEN?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.xv,{variant:"h3",align:"center",children:"It seems like you are logged out"}),(0,s.jsx)(i.xv,{align:"center",children:"Log in to connect to your repository."})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(i.xv,{variant:"h3",align:"center",children:"It seems like you don't have access to this repository"}),(0,s.jsx)(i.xv,{align:"center",children:"Check that the repository name is correct, then contact your repository administrator."})]}),(0,s.jsxs)(i.xv,{align:"center",children:["If that doesn't work, it's possible that Slice Machine is having trouble accessing Prismic's servers."," ",(0,s.jsx)(i.hh,{href:"https://community.prismic.io/",children:"Contact our support team"}),"."]}),n===Z.t.FORBIDDEN&&(0,s.jsx)(i.zx,{onClick:function(){return t()},children:"Log in to Prismic"})]})},E=t(5632),N=t.n(E),F=t(2754),I=t(34543),M=t(62230),P=t(85244),H=t(98240),W=t(6277);t(25977);var A={primary:"_1ecs97dbc8 _1ecs97dbjl _1ecs97dbc2 _1ecs97dbjf _1ecs97dbca _1ecs97dbjn",secondary:"_1ecs97daji _1ecs97dah3 _1ecs97dajc _1ecs97dagx _1ecs97dajk _1ecs97dah5"},B={normal:"ovkapw1",smallBold:"ovkapw2",inherit:"ovkapw3 _1ecs97df47"},G=function(e){var n=e.children,t=e.color,a=e.endIcon,o=e.href,c=e.textVariant,l=void 0===c?"smallBold":c,d=(0,H.Z)(e,["children","color","endIcon","href","textVariant"]);return(0,s.jsxs)("a",(0,P.Z)((0,M.Z)({href:o,target:"_blank",rel:"noreferrer"},d),{className:(0,W.Z)("ovkapw0 _1ecs97dez0 _1ecs97df41 _1ecs97dez2 _1ecs97dez8",A[void 0===t?"primary":t]),children:[(0,s.jsx)(i.xv,{component:"span",color:"inherit",variant:l,children:n}),(0,r.isValidElement)(a)?(0,r.cloneElement)(a,{className:(0,W.Z)(a.props.className,"_1ecs97dfhw",B[l])}):null]}))},L=t(39092),U=function(){var e,n=(e=(0,l.v9)(function(e){return{repoName:(0,L.MY)(e)}}).repoName,"https://".concat(e,".prismic.io/documents/working"));return(0,s.jsxs)(F.R$,{style:{alignSelf:"center",marginTop:i.TV.size[72]},children:[(0,s.jsx)(F.u2,{children:(0,s.jsx)(i.Ee,{src:"/blank-slate-changes-uptodate.png",sizing:"cover"})}),(0,s.jsxs)(F.T9,{children:[(0,s.jsx)(F._T,{children:"Everything up-to-date"}),(0,s.jsx)(F.nf,{children:"You have no changes staged. Your changes appear here after you have saved them, while they're waiting to be pushed to the Page Builder. Ready to get going?"}),(0,s.jsxs)(F.Qj,{children:[(0,s.jsx)(i.zx,{onClick:function(){N().push("/")},children:"Create a page type"}),(0,s.jsx)(G,{endIcon:(0,s.jsx)(I.AlO,{}),textVariant:"normal",href:n,children:"Create content"})]})]})]})},V=t(67764),Y=t(32665),X=t(3098),q=t(56577),Q=t(24340),$=t(77174),J=t(49471),K=t(40432),ee=t(78656),en=function(e){var n=e.ctName,t=e.numberOfDocuments,i=e.link,r=e.isOverLimit;return(0,s.jsxs)(u.Zb,{sx:{mb:12},variant:"drawerCard","data-cy":"AssociatedDocumentsCard-".concat(n),children:[(0,s.jsxs)(u.kC,{sx:{flexDirection:"column"},children:[(0,s.jsx)(u.xv,{children:n}),(0,s.jsxs)(u.xv,{sx:{color:"textClear",fontSize:"12px",lineHeight:"16px"},children:[t," documents"]})]}),(0,s.jsx)(u.rU,{href:i,target:"_blank",variant:"cardSmall",sx:{color:void 0!==r&&r?"danger":"purple08"},children:"View documents"})]})},et=function(e){var n=e.format,t=e.id,i=e.name;return(0,s.jsxs)(u.Zb,{sx:{mb:12},variant:"drawerCard","data-cy":"CustomTypesReferencesCard-".concat(i),children:[(0,s.jsxs)(u.kC,{sx:{flexDirection:"column"},children:[(0,s.jsx)(u.xv,{children:i}),(0,s.jsx)(u.xv,{sx:{color:"textClear",fontSize:"12px",lineHeight:"16px"},children:"Missing Slices"})]}),(0,s.jsxs)(u.rU,{href:j.cd[n].getBuilderPagePathname(t),target:"_blank",variant:"cardSmall",children:["View ",ee.$[n].name({start:!1,plural:!1})]},t)]})},es=t(79797),ei=t(54132),er=function(e){var n=e.isOpen,t=e.title,i=e.footer,r=e.explanations,a=(0,w.Z)().closeModals;return(0,s.jsx)(es.Z,{placement:"right",open:n,level:null,onClose:a,width:496,children:(0,s.jsx)(ei.Z,{radius:"0px",bodySx:{bg:"white",padding:24,flex:1,display:"flex",flexDirection:"column",overflow:"scroll"},footerSx:{p:0},sx:{flexDirection:"column",display:"flex",height:"100%",border:"none"},borderFooter:!0,Header:function(){return(0,s.jsxs)(u.kC,{sx:{p:"16px",alignItems:"center",justifyContent:"space-between",borderBottom:function(e){var n;return"1px solid ".concat(String(null===(n=e.colors)||void 0===n?void 0:n.borders))}},children:[(0,s.jsx)(u.kC,{sx:{alignItems:"center"},children:(0,s.jsx)(u.X6,{sx:{fontSize:"14px",fontWeight:"bold",ml:1},children:t})}),(0,s.jsx)(u.x8,{type:"button",onClick:function(){return a()}})]})},Footer:function(){return(0,s.jsx)(u.kC,{sx:{flexDirection:"column",justifyContent:"center",alignItems:"center",paddingRight:16,borderTop:function(e){var n;return"1px solid ".concat(String(null===(n=e.colors)||void 0===n?void 0:n.darkBorders))},backgroundColor:"white",padding:20},children:i})},children:r})})},ea=function(e){var n=e.onToggle,t=e.isConfirmed,i=e.sx;return(0,s.jsxs)(u.kC,{sx:(0,M.Z)({borderRadius:6,flexDirection:"column",backgroundColor:"grey03",padding:12,width:"100%"},i),children:[(0,s.jsx)(u.xv,{sx:{fontWeight:"bold",mb:2},children:"Are you sure to proceed?"}),(0,s.jsxs)(u.__,{sx:{mt:"4px",py:1},variant:"large",children:[(0,s.jsx)(u.XZ,{defaultChecked:t,onChange:n,variant:"forms.checkbox.dark"}),"Delete these Documents"]})]})},eo=function(e){var n=e.pushChanges,t=(0,r.useState)(!1),i=t[0],a=t[1],o=(0,l.v9)(function(e){return{isDeleteDocumentsDrawerOpen:(0,$.gP)(e,Q.q.SOFT_DELETE_DOCUMENTS_DRAWER),remoteOnlyCustomTypes:(0,J.Ch)(e).filter(p.yp),modalData:e.pushChanges}}),c=o.isDeleteDocumentsDrawerOpen,d=o.remoteOnlyCustomTypes,h=o.modalData,x=(0,w.Z)(),m=x.closeModals,f=x.openToaster;if(!c)return null;if((null==h?void 0:h.type)!=="SOFT")return f("No change data",K.Jf.ERROR),null;var g=h.details.customTypes.map(function(e){var n,t=d.find(function(n){return(0,p.n5)(n)===e.id});return void 0===t?null:(0,s.jsx)(en,{isOverLimit:!0,ctName:null!==(n=t.remote.label)&&void 0!==n?n:t.remote.id,link:e.url,numberOfDocuments:e.numberOfDocuments},e.id)});return(0,s.jsx)(er,{isOpen:c,title:"Confirm deletion",footer:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ea,{onToggle:function(){a(!i)},isConfirmed:i,sx:{mb:10}}),(0,s.jsx)(q.z,{label:"Push changes",variant:"primary",onClick:function(){m(),n(i)},disabled:!i,sx:{fontWeight:"bold",color:"white",borderRadius:6,width:"100%"}})]}),explanations:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(u.xv,{sx:{fontWeight:"bold",mb:1,lineHeight:"24px"},children:"This action will also delete Documents."}),(0,s.jsxs)(u.xv,{sx:{mb:24},children:[h.details.customTypes.length>1?"These types have":"This type has"," ","associated Documents, which will also be deleted. This might create broken links in your repository."]}),g]})})},ec=function(e){var n=e.pushChanges,t=(0,l.v9)(function(e){return{isDeleteDocumentsDrawerOpen:(0,$.gP)(e,Q.q.HARD_DELETE_DOCUMENTS_DRAWER),remoteOnlyCustomTypes:(0,J.Ch)(e).filter(p.yp),modalData:e.pushChanges}}),i=t.isDeleteDocumentsDrawerOpen,r=t.remoteOnlyCustomTypes,a=t.modalData,o=(0,w.Z)(),c=o.closeModals,d=o.openToaster;if(!i)return null;if((null==a?void 0:a.type)!=="HARD")return d("No change data",K.Jf.ERROR),null;var h=a.details.customTypes.map(function(e){var n,t=r.find(function(n){return(0,p.n5)(n)===e.id});return void 0===t?null:(0,s.jsx)(en,{isOverLimit:!0,ctName:null!==(n=t.remote.label)&&void 0!==n?n:t.remote.id,link:e.url,numberOfDocuments:e.numberOfDocuments},e.id)});return(0,s.jsx)(er,{isOpen:i,title:"Manual action required",footer:(0,s.jsx)(q.z,{label:"Try again",variant:"primary",onClick:function(){c(),n(!1)},sx:{fontWeight:"bold",color:"white",borderRadius:6,width:"100%"}}),explanations:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(u.xv,{sx:{fontWeight:"bold",mb:1,lineHeight:"24px"},children:["Your type",a.details.customTypes.length>1&&"s"," cannot be deleted."]}),(0,s.jsxs)(u.xv,{sx:{mb:24},children:[a.details.customTypes.length>1?"These types have":"This type has"," ","too many associated Documents. Archive and delete these Documents manually and then try deleting the types again."]}),h]})})},el=function(e){var n=e.pushChanges,t=(0,l.v9)(function(e){return{isOpen:(0,$.gP)(e,Q.q.REFERENCES_MISSING_DRAWER),localCustomTypes:(0,J.Ch)(e).filter(p.TG),modalData:e.pushChanges}}),i=t.isOpen,r=t.modalData,a=t.localCustomTypes,o=(0,w.Z)(),c=o.closeModals,d=o.openToaster;if(!i)return null;if((null==r?void 0:r.details)===void 0)return d("No change data",K.Jf.ERROR),null;var h=(null==r?void 0:r.details.customTypes.length)>1,x=r.details.customTypes.map(function(e){var n,t=a.find(function(n){return(0,p.n5)(n)===e.id});return void 0===t?null:(0,s.jsx)(et,{format:t.local.format,id:t.local.id,name:null!==(n=t.local.label)&&void 0!==n?n:t.local.id})});return(0,s.jsx)(er,{isOpen:i,title:"Missing Slices",footer:(0,s.jsx)(s.Fragment,{children:(0,s.jsx)(q.z,{label:"Try again",variant:"primary",onClick:function(){c(),n(!1)},sx:{fontWeight:"bold",color:"white",borderRadius:6,width:"100%"}})}),explanations:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)(u.xv,{sx:{fontWeight:"bold",mb:1,lineHeight:"24px"},children:["You have",h?"":" a"," type",h?"s":""," that reference"," ",h?"":"s"," one or more missing Slices"]}),(0,s.jsxs)(u.xv,{sx:{mb:24},children:["Before pushing, remove references to any missing Slices by opening"," ","the affected type",h?"s":""," and clicking the"," ",(0,s.jsx)("b",{children:"Save"})," button."]}),x]})})},ed=function(){var e=(0,V.X)(),n=e.unSyncedSlices,t=e.unSyncedCustomTypes,a=e.modelsStatuses,u=e.authStatus,h=e.isOnline,x=(0,r.useMemo)(function(){var e;return{changedSlices:n.map(function(e){return{slice:e,status:a.slices[e.model.id]}}).filter(function(e){return V.O.includes(e.status)}),changedCustomTypes:t.map(function(e){return(0,p.TG)(e)?e.local:e.remote}).map(function(e){return{customType:e,status:a.customTypes[e.id]}}).filter(function(e){return V.O.includes(e.status)})}},[n,t,a]),m=x.changedSlices,f=x.changedCustomTypes,g=(0,w.Z)(),j=g.pushChanges,v=g.closeModals,y=(0,l.v9)(function(e){return{isSyncing:(0,Y.hg)(e,X.z.CHANGES_PUSH)}}).isSyncing;(0,r.useEffect)(function(){return function(){v()}},[]);var b=n.length+t.length,_=function(e){return j({confirmDeleteDocuments:e,changedSlices:m,changedCustomTypes:f})},C=(0,r.useMemo)(function(){return h?u===Z.t.UNAUTHORIZED||u===Z.t.FORBIDDEN?(0,s.jsx)(R,{authStatus:u}):0===b?(0,s.jsx)(U,{}):(0,s.jsx)(k,{unSyncedSlices:n,unSyncedCustomTypes:t,modelsStatuses:a,authStatus:u,isOnline:h}):(0,s.jsx)(O,{})},[h,u,b,n,t,a,]);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(o(),{children:(0,s.jsx)("title",{children:"Changes - Slice Machine"})}),(0,s.jsxs)(d.LN,{children:[(0,s.jsxs)(d.wd,{children:[(0,s.jsx)(d.Cx,{folder:"Changes"}),(0,s.jsx)(d.K2,{children:(0,s.jsx)(i.zx,{onClick:function(){return _(!1)},loading:y,disabled:0===b||!h||u===Z.t.UNAUTHORIZED||u===Z.t.FORBIDDEN||y,"data-cy":"push-changes",children:"Push Changes"})})]}),(0,s.jsx)(d.RN,{children:(0,s.jsxs)(c.xR,{sx:{display:"flex",flexDirection:"column"},children:[C,(0,s.jsx)(eo,{pushChanges:_}),(0,s.jsx)(ec,{pushChanges:_}),(0,s.jsx)(el,{pushChanges:_})]})})]})]})}},2754:function(e,n,t){"use strict";t.d(n,{R$:function(){return d},Qj:function(){return f},T9:function(){return h},nf:function(){return m},u2:function(){return u},_T:function(){return x}});var s=t(67557),i=t(62230),r=t(85244),a=t(98240),o=t(52322),c=t(6277),l=t(22715);t(69143);var d=function(e){var n=e.backgroundImage,t=e.style,l=(0,a.Z)(e,["backgroundImage","style"]),d=void 0!==n;return(0,o.jsx)("article",(0,r.Z)((0,i.Z)({},l),{className:(0,c.Z)("_18bjhbz0 _1ecs97dez0 _1ecs97dez1 _1ecs97dez2 _1ecs97dezb _1ecs97dfiv _1ecs97dfix _1ecs97dfiz _1ecs97d3fg _1ecs97d3mt _1ecs97df0r _1ecs97df23 _1ecs97df2h _1ecs97dezp",(0,s.Z)({},"_18bjhbz1 _1ecs97dezx _1ecs97df4v",d)),style:(0,i.Z)({backgroundImage:d?"url(".concat(n,")"):void 0},t)}))},u=function(e){return(0,o.jsx)("div",(0,r.Z)((0,i.Z)({},e),{className:"_1ecs97dez0 _1ecs97dez1 _1ecs97dez2 _1ecs97dezb _1ecs97d6r8 _1ecs97d6yl _1ecs97df29 _1ecs97df2l _1ecs97dezp"}))},h=function(e){return(0,o.jsx)("div",(0,r.Z)((0,i.Z)({},e),{className:"_18bjhbz3 _1ecs97dez0 _1ecs97dez1 _1ecs97dez2 _1ecs97dezb _1ecs97dffv"}))},x=function(e){return(0,o.jsx)(l.xv,(0,r.Z)((0,i.Z)({},e),{className:"_18bjhbz4"}))},m=function(e){return(0,o.jsx)(l.xv,(0,r.Z)((0,i.Z)({},e),{className:"_18bjhbz5",color:"grey11"}))},f=function(e){return(0,o.jsx)("div",(0,r.Z)((0,i.Z)({},e),{className:"_18bjhbz6 _1ecs97dez0 _1ecs97dez8 _1ecs97dez1 _1ecs97dez2 _1ecs97df95 _1ecs97dfdl",color:"grey"}))}},69143:function(){},25977:function(){}},function(e){e.O(0,[898,789,123,543,918,25,286,774,888,179],function(){return e(e.s=21985)}),_N_E=e.O()}]);
|
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { getState, pushChanges, telemetry } from "../../apiClient";
|
|
2
|
-
import {
|
|
3
|
-
call,
|
|
4
|
-
fork,
|
|
5
|
-
put,
|
|
6
|
-
SagaReturnType,
|
|
7
|
-
takeLatest,
|
|
8
|
-
} from "redux-saga/effects";
|
|
9
|
-
import {
|
|
10
|
-
ActionType,
|
|
11
|
-
createAsyncAction,
|
|
12
|
-
getType,
|
|
13
|
-
Reducer,
|
|
14
|
-
} from "typesafe-actions";
|
|
15
|
-
import { withLoader } from "../loading";
|
|
16
|
-
import { openToasterCreator, ToasterType } from "../toaster";
|
|
17
|
-
import { modalOpenCreator } from "../modal";
|
|
18
|
-
import { ModalKeysEnum } from "../modal/types";
|
|
19
|
-
import { LoadingKeysEnum } from "../loading/types";
|
|
20
|
-
import { refreshStateCreator } from "../environment";
|
|
21
|
-
import {
|
|
22
|
-
InvalidCustomTypeResponse,
|
|
23
|
-
PushChangesPayload,
|
|
24
|
-
} from "@lib/models/common/TransactionalPush";
|
|
25
|
-
import { trackPushChangesSuccess } from "./trackPushChangesSuccess";
|
|
26
|
-
import {
|
|
27
|
-
isUnauthenticatedError,
|
|
28
|
-
isUnauthorizedError,
|
|
29
|
-
SliceMachineManagerClient,
|
|
30
|
-
} from "@slicemachine/manager/client";
|
|
31
|
-
import {
|
|
32
|
-
ChangedCustomType,
|
|
33
|
-
ChangedSlice,
|
|
34
|
-
} from "@lib/models/common/ModelStatus";
|
|
35
|
-
|
|
36
|
-
export type ChangesPushSagaPayload = PushChangesPayload & {
|
|
37
|
-
changedSlices: ReadonlyArray<ChangedSlice>;
|
|
38
|
-
changedCustomTypes: ReadonlyArray<ChangedCustomType>;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
type Limit = NonNullable<
|
|
42
|
-
Awaited<
|
|
43
|
-
ReturnType<SliceMachineManagerClient["prismicRepository"]["pushChanges"]>
|
|
44
|
-
>
|
|
45
|
-
>;
|
|
46
|
-
|
|
47
|
-
export const changesPushCreator = createAsyncAction(
|
|
48
|
-
"PUSH_CHANGES.REQUEST",
|
|
49
|
-
"PUSH_CHANGES.RESPONSE",
|
|
50
|
-
"PUSH_CHANGES.FAILURE",
|
|
51
|
-
)<ChangesPushSagaPayload, undefined, Limit | InvalidCustomTypeResponse>();
|
|
52
|
-
|
|
53
|
-
export const sortDocumentLimits = (limit: Readonly<Limit>) => ({
|
|
54
|
-
...limit,
|
|
55
|
-
details: {
|
|
56
|
-
...limit.details,
|
|
57
|
-
customTypes: [...limit.details.customTypes].sort(
|
|
58
|
-
(doc1, doc2) => doc2.numberOfDocuments - doc1.numberOfDocuments,
|
|
59
|
-
),
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const MODAL_KEY_MAP = {
|
|
64
|
-
["INVALID_CUSTOM_TYPES"]: ModalKeysEnum.REFERENCES_MISSING_DRAWER,
|
|
65
|
-
["SOFT"]: ModalKeysEnum.SOFT_DELETE_DOCUMENTS_DRAWER,
|
|
66
|
-
["HARD"]: ModalKeysEnum.HARD_DELETE_DOCUMENTS_DRAWER,
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export function* changesPushSaga({
|
|
70
|
-
payload,
|
|
71
|
-
}: ReturnType<typeof changesPushCreator.request>): Generator {
|
|
72
|
-
const startTime = Date.now();
|
|
73
|
-
const { changedSlices, changedCustomTypes } = payload;
|
|
74
|
-
|
|
75
|
-
const sliceChanges = changedSlices.map((sliceChange) => ({
|
|
76
|
-
id: sliceChange.slice.model.id,
|
|
77
|
-
type: "Slice" as const,
|
|
78
|
-
libraryID: sliceChange.slice.from,
|
|
79
|
-
status: sliceChange.status,
|
|
80
|
-
}));
|
|
81
|
-
const customTypeChanges = changedCustomTypes.map((customTypeChange) => ({
|
|
82
|
-
id: customTypeChange.customType.id,
|
|
83
|
-
type: "CustomType" as const,
|
|
84
|
-
status: customTypeChange.status,
|
|
85
|
-
}));
|
|
86
|
-
|
|
87
|
-
// Creating a new payload with the correct format
|
|
88
|
-
const pushPayload = {
|
|
89
|
-
confirmDeleteDocuments: payload.confirmDeleteDocuments,
|
|
90
|
-
changes: [...sliceChanges, ...customTypeChanges],
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
try {
|
|
94
|
-
const response = (yield call(pushChanges, pushPayload)) as SagaReturnType<
|
|
95
|
-
typeof pushChanges
|
|
96
|
-
>;
|
|
97
|
-
|
|
98
|
-
if (response) {
|
|
99
|
-
// sending failure event
|
|
100
|
-
yield put(changesPushCreator.failure(sortDocumentLimits(response)));
|
|
101
|
-
// Tracking when a limit has been reached
|
|
102
|
-
void telemetry.track({
|
|
103
|
-
event: "changes:limit-reach",
|
|
104
|
-
limitType: response.type,
|
|
105
|
-
});
|
|
106
|
-
// Open the corresponding drawer
|
|
107
|
-
yield put(
|
|
108
|
-
modalOpenCreator({
|
|
109
|
-
modalKey: MODAL_KEY_MAP[response.type],
|
|
110
|
-
}),
|
|
111
|
-
);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const serverState = (yield call(getState)) as SagaReturnType<
|
|
116
|
-
typeof getState
|
|
117
|
-
>;
|
|
118
|
-
yield put(
|
|
119
|
-
refreshStateCreator({
|
|
120
|
-
env: serverState.env,
|
|
121
|
-
remoteCustomTypes: serverState.remoteCustomTypes,
|
|
122
|
-
localCustomTypes: serverState.customTypes,
|
|
123
|
-
libraries: serverState.libraries,
|
|
124
|
-
remoteSlices: serverState.remoteSlices,
|
|
125
|
-
clientError: serverState.clientError,
|
|
126
|
-
}),
|
|
127
|
-
);
|
|
128
|
-
|
|
129
|
-
// Tracking the success of the push
|
|
130
|
-
void trackPushChangesSuccess({ ...payload, startTime });
|
|
131
|
-
|
|
132
|
-
// Send global success event
|
|
133
|
-
yield put(changesPushCreator.success());
|
|
134
|
-
|
|
135
|
-
// Display success toaster
|
|
136
|
-
yield put(
|
|
137
|
-
openToasterCreator({
|
|
138
|
-
content: "All slices and types have been pushed",
|
|
139
|
-
type: ToasterType.SUCCESS,
|
|
140
|
-
}),
|
|
141
|
-
);
|
|
142
|
-
} catch (error) {
|
|
143
|
-
if (isUnauthenticatedError(error) || isUnauthorizedError(error)) {
|
|
144
|
-
yield put(modalOpenCreator({ modalKey: ModalKeysEnum.LOGIN }));
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
// TODO: handle auth errors
|
|
148
|
-
yield put(
|
|
149
|
-
openToasterCreator({
|
|
150
|
-
content:
|
|
151
|
-
"Something went wrong when pushing your changes. Check your terminal logs.",
|
|
152
|
-
type: ToasterType.ERROR,
|
|
153
|
-
}),
|
|
154
|
-
);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
function* watchChangesPush() {
|
|
159
|
-
yield takeLatest(
|
|
160
|
-
getType(changesPushCreator.request),
|
|
161
|
-
withLoader(changesPushSaga, LoadingKeysEnum.CHANGES_PUSH),
|
|
162
|
-
);
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
// Saga Exports
|
|
166
|
-
export function* watchChangesPushSagas() {
|
|
167
|
-
yield fork(watchChangesPush);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
// Reducer
|
|
171
|
-
export type PushChangesStoreType = Readonly<
|
|
172
|
-
Limit | InvalidCustomTypeResponse | null
|
|
173
|
-
>;
|
|
174
|
-
type PushChangesActions = ActionType<typeof changesPushCreator>;
|
|
175
|
-
|
|
176
|
-
export const pushChangesReducer: Reducer<
|
|
177
|
-
PushChangesStoreType,
|
|
178
|
-
PushChangesActions
|
|
179
|
-
> = (state = null, action) => {
|
|
180
|
-
switch (action.type) {
|
|
181
|
-
case getType(changesPushCreator.request):
|
|
182
|
-
case getType(changesPushCreator.success):
|
|
183
|
-
return null;
|
|
184
|
-
|
|
185
|
-
case getType(changesPushCreator.failure): {
|
|
186
|
-
return action.payload;
|
|
187
|
-
}
|
|
188
|
-
default:
|
|
189
|
-
return state;
|
|
190
|
-
}
|
|
191
|
-
};
|
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import { describe, test } from "vitest";
|
|
2
|
-
import { Analytics } from "@segment/analytics-node";
|
|
3
|
-
import "@testing-library/jest-dom";
|
|
4
|
-
import { TestApi, testSaga } from "redux-saga-test-plan";
|
|
5
|
-
import {
|
|
6
|
-
ChangesPushSagaPayload,
|
|
7
|
-
changesPushCreator,
|
|
8
|
-
changesPushSaga,
|
|
9
|
-
} from "../../../src/modules/pushChangesSaga";
|
|
10
|
-
|
|
11
|
-
import { refreshStateCreator } from "@src/modules/environment";
|
|
12
|
-
import { setupServer } from "msw/node";
|
|
13
|
-
import { getState, pushChanges } from "../../../src/apiClient";
|
|
14
|
-
import { modalOpenCreator } from "../../../src/modules/modal";
|
|
15
|
-
import { ModalKeysEnum } from "../../../src/modules/modal/types";
|
|
16
|
-
import { openToasterCreator, ToasterType } from "../../../src/modules/toaster";
|
|
17
|
-
import { dummyServerState } from "./__fixtures__/serverState";
|
|
18
|
-
import { ModelStatus } from "@lib/models/common/ModelStatus";
|
|
19
|
-
import { ComponentUI } from "@lib/models/common/ComponentUI";
|
|
20
|
-
import { CustomTypeSM } from "@lib/models/common/CustomType";
|
|
21
|
-
|
|
22
|
-
enum LimitType {
|
|
23
|
-
SOFT = "SOFT",
|
|
24
|
-
HARD = "HARD",
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
class CustomAxiosError extends Error {
|
|
28
|
-
isAxiosError: boolean;
|
|
29
|
-
response?: {
|
|
30
|
-
data: any;
|
|
31
|
-
status: number;
|
|
32
|
-
statusText?: string;
|
|
33
|
-
headers?: any;
|
|
34
|
-
config?: any;
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
constructor(status: number) {
|
|
38
|
-
super();
|
|
39
|
-
this.isAxiosError = true;
|
|
40
|
-
this.response = { data: {}, status };
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const server = setupServer();
|
|
45
|
-
beforeAll(() => server.listen());
|
|
46
|
-
afterEach(() => server.resetHandlers());
|
|
47
|
-
afterAll(() => server.close());
|
|
48
|
-
|
|
49
|
-
const changesPayload: ChangesPushSagaPayload = {
|
|
50
|
-
confirmDeleteDocuments: false,
|
|
51
|
-
changedSlices: [
|
|
52
|
-
{
|
|
53
|
-
slice: {
|
|
54
|
-
model: { id: "slice1", variations: [{ id: "var1" }] },
|
|
55
|
-
screenshots: { var1: { hash: "__HASH__" } },
|
|
56
|
-
from: "library1",
|
|
57
|
-
} as unknown as ComponentUI,
|
|
58
|
-
status: ModelStatus.New,
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
changedCustomTypes: [
|
|
62
|
-
{
|
|
63
|
-
customType: { id: "customType1" } as CustomTypeSM,
|
|
64
|
-
status: ModelStatus.Modified,
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const pushChangesApiPayload = {
|
|
70
|
-
confirmDeleteDocuments: false,
|
|
71
|
-
changes: [
|
|
72
|
-
{
|
|
73
|
-
id: "slice1",
|
|
74
|
-
status: ModelStatus.New,
|
|
75
|
-
libraryID: "library1",
|
|
76
|
-
type: "Slice",
|
|
77
|
-
},
|
|
78
|
-
{
|
|
79
|
-
id: "customType1",
|
|
80
|
-
status: ModelStatus.Modified,
|
|
81
|
-
type: "CustomType",
|
|
82
|
-
},
|
|
83
|
-
],
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
describe("[pushChanges module]", () => {
|
|
87
|
-
describe("[changesPushSaga]", () => {
|
|
88
|
-
let saga: TestApi;
|
|
89
|
-
|
|
90
|
-
beforeEach(() => {
|
|
91
|
-
saga = testSaga(
|
|
92
|
-
changesPushSaga,
|
|
93
|
-
changesPushCreator.request(changesPayload),
|
|
94
|
-
);
|
|
95
|
-
});
|
|
96
|
-
test("Pushes changes when API response is OK display success toaster", async () => {
|
|
97
|
-
saga.next().call(pushChanges, pushChangesApiPayload);
|
|
98
|
-
|
|
99
|
-
saga.next(null).call(getState);
|
|
100
|
-
|
|
101
|
-
saga.next(dummyServerState).put(
|
|
102
|
-
refreshStateCreator({
|
|
103
|
-
env: dummyServerState.env,
|
|
104
|
-
remoteCustomTypes: dummyServerState.remoteCustomTypes,
|
|
105
|
-
localCustomTypes: dummyServerState.customTypes,
|
|
106
|
-
libraries: dummyServerState.libraries,
|
|
107
|
-
remoteSlices: [],
|
|
108
|
-
clientError: undefined,
|
|
109
|
-
}),
|
|
110
|
-
);
|
|
111
|
-
|
|
112
|
-
saga.next().put(changesPushCreator.success());
|
|
113
|
-
|
|
114
|
-
saga.next().put(
|
|
115
|
-
openToasterCreator({
|
|
116
|
-
content: "All slices and types have been pushed",
|
|
117
|
-
type: ToasterType.SUCCESS,
|
|
118
|
-
}),
|
|
119
|
-
);
|
|
120
|
-
|
|
121
|
-
saga.next().isDone();
|
|
122
|
-
|
|
123
|
-
// Wait for network request to be performed
|
|
124
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
125
|
-
expect(Analytics.prototype.track).toHaveBeenCalledOnce();
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
test.each([
|
|
129
|
-
[LimitType.HARD, ModalKeysEnum.HARD_DELETE_DOCUMENTS_DRAWER],
|
|
130
|
-
[LimitType.SOFT, ModalKeysEnum.SOFT_DELETE_DOCUMENTS_DRAWER],
|
|
131
|
-
])(
|
|
132
|
-
"Displays delete limit modal when there is a %s limit response",
|
|
133
|
-
async (limitType, expectedModalKey) => {
|
|
134
|
-
saga.next().call(pushChanges, pushChangesApiPayload);
|
|
135
|
-
|
|
136
|
-
// This test will also verify that the details are sorted in descending order.
|
|
137
|
-
saga
|
|
138
|
-
.next({
|
|
139
|
-
type: limitType,
|
|
140
|
-
details: {
|
|
141
|
-
customTypes: [
|
|
142
|
-
{
|
|
143
|
-
id: "CT1",
|
|
144
|
-
numberOfDocuments: 2000,
|
|
145
|
-
url: "url",
|
|
146
|
-
},
|
|
147
|
-
{
|
|
148
|
-
id: "CT2",
|
|
149
|
-
numberOfDocuments: 3000,
|
|
150
|
-
url: "url",
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
},
|
|
154
|
-
})
|
|
155
|
-
.put(
|
|
156
|
-
changesPushCreator.failure({
|
|
157
|
-
type: limitType,
|
|
158
|
-
details: {
|
|
159
|
-
customTypes: [
|
|
160
|
-
{
|
|
161
|
-
id: "CT2",
|
|
162
|
-
numberOfDocuments: 3000,
|
|
163
|
-
url: "url",
|
|
164
|
-
},
|
|
165
|
-
{
|
|
166
|
-
id: "CT1",
|
|
167
|
-
numberOfDocuments: 2000,
|
|
168
|
-
url: "url",
|
|
169
|
-
},
|
|
170
|
-
],
|
|
171
|
-
},
|
|
172
|
-
}),
|
|
173
|
-
);
|
|
174
|
-
|
|
175
|
-
saga.next().put(
|
|
176
|
-
modalOpenCreator({
|
|
177
|
-
modalKey: expectedModalKey,
|
|
178
|
-
}),
|
|
179
|
-
);
|
|
180
|
-
|
|
181
|
-
saga.next().isDone();
|
|
182
|
-
|
|
183
|
-
// Wait for network request to be performed
|
|
184
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
185
|
-
expect(Analytics.prototype.track).toHaveBeenCalledOnce();
|
|
186
|
-
},
|
|
187
|
-
);
|
|
188
|
-
|
|
189
|
-
test("Displays an error toaster when there is an API error on push", () => {
|
|
190
|
-
saga.next().call(pushChanges, pushChangesApiPayload);
|
|
191
|
-
|
|
192
|
-
saga.throw(new Error()).put(
|
|
193
|
-
openToasterCreator({
|
|
194
|
-
content:
|
|
195
|
-
"Something went wrong when pushing your changes. Check your terminal logs.",
|
|
196
|
-
type: ToasterType.ERROR,
|
|
197
|
-
}),
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
saga.next().isDone();
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
// TODO: unskip when auth error is handled
|
|
204
|
-
test.skip.each([[401], [403]])(
|
|
205
|
-
"when there's a %s error while pushing a slice it should stop and open the login model",
|
|
206
|
-
(errorCode) => {
|
|
207
|
-
saga.next().call(pushChanges, pushChangesApiPayload);
|
|
208
|
-
|
|
209
|
-
const customError = new CustomAxiosError(errorCode);
|
|
210
|
-
|
|
211
|
-
saga
|
|
212
|
-
.throw(customError)
|
|
213
|
-
.put(modalOpenCreator({ modalKey: ModalKeysEnum.LOGIN }));
|
|
214
|
-
|
|
215
|
-
saga.next().isDone();
|
|
216
|
-
},
|
|
217
|
-
);
|
|
218
|
-
|
|
219
|
-
// TODO: unskip when invalid references are handled
|
|
220
|
-
test.skip("when there's INVALID_CUSTOM_TYPES response, open the references drawer", () => {
|
|
221
|
-
saga.next().call(pushChanges, {
|
|
222
|
-
confirmDeleteDocuments: false,
|
|
223
|
-
changes: [
|
|
224
|
-
{ id: "slice1", status: ModelStatus.New, type: "Slice" },
|
|
225
|
-
{
|
|
226
|
-
id: "customType1",
|
|
227
|
-
status: ModelStatus.Modified,
|
|
228
|
-
type: "CustomType",
|
|
229
|
-
},
|
|
230
|
-
],
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
saga
|
|
234
|
-
.next({
|
|
235
|
-
status: 200,
|
|
236
|
-
data: {
|
|
237
|
-
type: "INVALID_CUSTOM_TYPES",
|
|
238
|
-
details: {
|
|
239
|
-
customTypes: [{ id: "CT1" }, { id: "CT2" }],
|
|
240
|
-
},
|
|
241
|
-
},
|
|
242
|
-
})
|
|
243
|
-
.put(
|
|
244
|
-
changesPushCreator.failure({
|
|
245
|
-
type: "INVALID_CUSTOM_TYPES",
|
|
246
|
-
details: {
|
|
247
|
-
customTypes: [{ id: "CT1" }, { id: "CT2" }],
|
|
248
|
-
},
|
|
249
|
-
}),
|
|
250
|
-
);
|
|
251
|
-
|
|
252
|
-
saga.next().put(
|
|
253
|
-
modalOpenCreator({
|
|
254
|
-
modalKey: ModalKeysEnum.REFERENCES_MISSING_DRAWER,
|
|
255
|
-
}),
|
|
256
|
-
);
|
|
257
|
-
|
|
258
|
-
saga.next().isDone();
|
|
259
|
-
});
|
|
260
|
-
});
|
|
261
|
-
});
|
|
File without changes
|