@strapi/admin 4.10.1 → 4.10.2-alpha.0
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/admin/src/components/AuthenticatedApp/index.js +19 -24
- package/admin/src/components/DragLayer/DragLayer.js +53 -0
- package/admin/src/components/DragLayer/index.js +1 -0
- package/admin/src/components/LeftMenu/index.js +2 -2
- package/admin/src/components/Providers/index.js +11 -7
- package/admin/src/content-manager/contexts/index.js +0 -1
- package/admin/src/content-manager/hooks/index.js +0 -1
- package/admin/src/content-manager/hooks/useLazyComponents/index.js +7 -3
- package/admin/src/content-manager/hooks/useRelation/useRelation.js +1 -3
- package/admin/src/content-manager/pages/{ListSettingsView/components/CardPreview.js → App/components/CardDragPreview.js} +28 -28
- package/admin/src/content-manager/pages/App/components/ComponentDragPreview.js +75 -0
- package/admin/src/content-manager/{components/DragLayer → pages/App/components}/RelationDragPreview.js +7 -4
- package/admin/src/content-manager/pages/App/index.js +39 -2
- package/admin/src/content-manager/pages/EditSettingsView/components/ComponentFieldList.js +1 -1
- package/admin/src/content-manager/pages/EditSettingsView/components/DisplayedFieldButton.js +1 -1
- package/admin/src/content-manager/pages/EditSettingsView/components/DynamicZoneList.js +1 -1
- package/admin/src/content-manager/pages/EditSettingsView/components/FormModal.js +1 -1
- package/admin/src/content-manager/{components → pages/EditSettingsView/components}/LayoutDndProvider/index.js +3 -4
- package/admin/src/content-manager/pages/EditSettingsView/components/LinkToCTB.js +1 -1
- package/admin/src/content-manager/pages/EditSettingsView/components/ModalForm.js +1 -1
- package/admin/src/content-manager/pages/EditSettingsView/components/RowItemsLayout.js +1 -1
- package/admin/src/content-manager/pages/EditSettingsView/hooks/useLayoutDnd.js +6 -0
- package/admin/src/content-manager/pages/EditSettingsView/index.js +1 -1
- package/admin/src/content-manager/pages/ListSettingsView/components/DraggableCard.js +6 -6
- package/admin/src/hooks/useMenu/index.js +2 -2
- package/admin/src/hooks/useReleaseNotification/index.js +2 -2
- package/admin/src/hooks/useSettingsMenu/index.js +2 -2
- package/admin/src/pages/Admin/Onboarding/index.js +2 -2
- package/admin/src/pages/App/index.js +2 -2
- package/admin/src/pages/HomePage/SocialLinks.js +2 -2
- package/admin/src/pages/MarketplacePage/index.js +2 -2
- package/admin/src/pages/ProfilePage/index.js +2 -2
- package/admin/src/pages/SettingsPage/pages/ApplicationInfosPage/index.js +2 -2
- package/admin/src/pages/SettingsPage/pages/Roles/EditPage/components/Permissions/utils/updateValues.js +3 -3
- package/admin/src/pages/SettingsPage/pages/Users/EditPage/index.js +2 -2
- package/admin/src/translations/fr.json +1 -1
- package/build/{5563.905daa13.chunk.js → 5563.986609ed.chunk.js} +2 -2
- package/build/{7259.b7d00cea.chunk.js → 7259.7a48aa2f.chunk.js} +1 -1
- package/build/7725.f717acdd.chunk.js +213 -0
- package/build/Admin-authenticatedApp.2fab70e4.chunk.js +79 -0
- package/build/{Admin_InternalErrorPage.15c6bf07.chunk.js → Admin_InternalErrorPage.96ceaae1.chunk.js} +1 -1
- package/build/{Admin_homePage.f9309c6d.chunk.js → Admin_homePage.9f7c0bb1.chunk.js} +5 -5
- package/build/{Admin_marketplace.56bc1008.chunk.js → Admin_marketplace.a60cde15.chunk.js} +5 -5
- package/build/{Admin_pluginsPage.f6b52ee9.chunk.js → Admin_pluginsPage.9e6fa51c.chunk.js} +1 -1
- package/build/{Admin_profilePage.9112cffc.chunk.js → Admin_profilePage.1b337b73.chunk.js} +2 -2
- package/build/{Admin_settingsPage.4604a16c.chunk.js → Admin_settingsPage.56e9641c.chunk.js} +2 -2
- package/build/{Upload_ConfigureTheView.eaaec495.chunk.js → Upload_ConfigureTheView.4fc648b5.chunk.js} +1 -1
- package/build/admin-app.9bfe4ec7.chunk.js +63 -0
- package/build/{admin-edit-roles-page.8a4063f7.chunk.js → admin-edit-roles-page.d0c9497b.chunk.js} +24 -24
- package/build/{admin-edit-users.7e14d85f.chunk.js → admin-edit-users.ba27c532.chunk.js} +2 -2
- package/build/{admin-roles-list.329c1f63.chunk.js → admin-roles-list.c759daa3.chunk.js} +1 -1
- package/build/{admin-users.d02de059.chunk.js → admin-users.ad5dd832.chunk.js} +2 -2
- package/build/{api-tokens-create-page.97595e12.chunk.js → api-tokens-create-page.973d2816.chunk.js} +1 -1
- package/build/{api-tokens-edit-page.cd36e30e.chunk.js → api-tokens-edit-page.29725c5e.chunk.js} +1 -1
- package/build/{api-tokens-list-page.6757c7b9.chunk.js → api-tokens-list-page.66c4fbdd.chunk.js} +2 -2
- package/build/{audit-logs-settings-page.19d90bda.chunk.js → audit-logs-settings-page.45cb4fb5.chunk.js} +1 -1
- package/build/content-manager.a0ff6cad.chunk.js +1111 -0
- package/build/{content-type-builder-list-view.9c2c020c.chunk.js → content-type-builder-list-view.5ff685ec.chunk.js} +1 -1
- package/build/{content-type-builder.68af11d2.chunk.js → content-type-builder.4737a30c.chunk.js} +3 -3
- package/build/{email-settings-page.1095e1ab.chunk.js → email-settings-page.dc07d518.chunk.js} +1 -1
- package/build/{fr-json.5947cf63.chunk.js → fr-json.73494bf5.chunk.js} +1 -1
- package/build/{i18n-settings-page.d95b32df.chunk.js → i18n-settings-page.8219dd99.chunk.js} +1 -1
- package/build/index.html +1 -1
- package/build/main.964e7203.js +2597 -0
- package/build/{review-workflows-settings.f7890c40.chunk.js → review-workflows-settings.089d7ec5.chunk.js} +1 -1
- package/build/{runtime~main.d4c8d6a2.js → runtime~main.c9593d59.js} +1 -1
- package/build/{sso-settings-page.1dd4886e.chunk.js → sso-settings-page.f44d95d8.chunk.js} +1 -1
- package/build/{transfer-tokens-create-page.ec2ca215.chunk.js → transfer-tokens-create-page.170acee6.chunk.js} +1 -1
- package/build/{transfer-tokens-edit-page.22bf28e5.chunk.js → transfer-tokens-edit-page.6cf23295.chunk.js} +1 -1
- package/build/{transfer-tokens-list-page.cf8c77f2.chunk.js → transfer-tokens-list-page.c3fec4c1.chunk.js} +2 -2
- package/build/{upload-settings.945fdcfa.chunk.js → upload-settings.dd2d987c.chunk.js} +1 -1
- package/build/{upload.a86b1054.chunk.js → upload.c8479232.chunk.js} +1 -1
- package/build/{users-advanced-settings-page.5b5a9baa.chunk.js → users-advanced-settings-page.c36cfd59.chunk.js} +1 -1
- package/build/{users-email-settings-page.e5506eb4.chunk.js → users-email-settings-page.2716ce8e.chunk.js} +5 -5
- package/build/{users-providers-settings-page.e32089c2.chunk.js → users-providers-settings-page.0d6304a5.chunk.js} +1 -1
- package/build/{users-roles-settings-page.20656f92.chunk.js → users-roles-settings-page.eeb3a339.chunk.js} +1 -1
- package/build/{webhook-edit-page.a3b62049.chunk.js → webhook-edit-page.f4db86f3.chunk.js} +2 -2
- package/build/{webhook-list-page.ca38eeef.chunk.js → webhook-list-page.30d73114.chunk.js} +1 -1
- package/ee/server/services/review-workflows/review-workflows.js +1 -1
- package/ee/server/utils/persisted-tables.js +3 -0
- package/jest.config.front.js +1 -0
- package/package.json +9 -9
- package/admin/src/components/AutoReloadOverlayBlockerProvider/Blocker.js +0 -95
- package/admin/src/components/AutoReloadOverlayBlockerProvider/Overlay.js +0 -42
- package/admin/src/components/AutoReloadOverlayBlockerProvider/index.js +0 -99
- package/admin/src/components/Notifications/Notification/index.js +0 -159
- package/admin/src/components/Notifications/index.js +0 -46
- package/admin/src/components/Notifications/reducer.js +0 -47
- package/admin/src/components/OverlayBlocker/index.js +0 -67
- package/admin/src/content-manager/components/DragLayer/ComponentDragPreview.js +0 -83
- package/admin/src/content-manager/components/DragLayer/index.js +0 -85
- package/admin/src/content-manager/contexts/LayoutDnd.js +0 -5
- package/admin/src/content-manager/hooks/useCallbackRef.js +0 -23
- package/admin/src/content-manager/hooks/useLayoutDnd.js +0 -6
- package/admin/src/content-manager/pages/ListSettingsView/utils/ellipsisCardTitle.js +0 -7
- package/build/8694.6522968d.chunk.js +0 -247
- package/build/Admin-authenticatedApp.5562aedc.chunk.js +0 -79
- package/build/admin-app.014adc27.chunk.js +0 -110
- package/build/content-manager.84f81966.chunk.js +0 -1130
- package/build/main.841e0dcb.js +0 -2280
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_strapi_admin=self.webpackChunk_strapi_admin||[]).push([[5162],{47272:function(ne,S,t){t.d(S,{Z:function(){return Se}});var e=t(32735),d=t(
|
|
1
|
+
"use strict";(self.webpackChunk_strapi_admin=self.webpackChunk_strapi_admin||[]).push([[5162],{47272:function(ne,S,t){t.d(S,{Z:function(){return Se}});var e=t(32735),d=t(24989),L=t(27649),o=t(20108),O=t(53038),D=t(67927),J=t(60216),s=t.n(J),g=t(2438),m=t(66456),N=t(29439),Oe=t(82055),b=t(87933),he=t(41415),ke=t(17e3),ae=t(72850),le=t(15335),V=t(5803),ie=t(10369),Z=t(92802),j=t(67879),Ee=t(28847),W=t(49372),de=t(8471),ve=t(8284),Le=t(44426),Q=t(23940),ce=t.n(Q);const i=({disabledEvents:n,name:r,events:a,inputValue:l,handleChange:p,handleChangeAll:I})=>{const u=a.filter(E=>!n.includes(E)),f=l.length===u.length,C=l.length>0,y=({target:{name:E}})=>{I({target:{name:E,value:!f}})};return e.createElement("tr",null,e.createElement("td",null,e.createElement(ve.X,{indeterminate:C&&!f,"aria-label":"Select all entries",name:r,onChange:y,value:f},ce()(r))),a.map(E=>e.createElement("td",{key:E},e.createElement(Le.C,{disabled:n.includes(E),"aria-label":E,name:E,value:l.includes(E),onValueChange:M=>p({target:{name:E,value:M}})}))))};i.defaultProps={disabledEvents:[],events:[],inputValue:[],handleChange(){},handleChangeAll(){}},i.propTypes={disabledEvents:s().array,events:s().array,inputValue:s().array,handleChange:s().func,handleChangeAll:s().func,name:s().string.isRequired};var A=i,X=n=>n.reduce((r,a)=>{const l=a.split(".")[0];return r[l]||(r[l]=[]),r[l].push(a),r},{});const R=de.ZP.table`
|
|
2
2
|
td {
|
|
3
3
|
height: ${52/16}rem;
|
|
4
4
|
width: 10%;
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
path {
|
|
21
21
|
fill: ${n.colors[r]};
|
|
22
22
|
}
|
|
23
|
-
`),B=({isPending:n,statusCode:r})=>{const{formatMessage:a}=(0,j.Z)();return n?e.createElement(b.k,{gap:2,alignItems:"center"},e.createElement(q,{as:Ae.Z}),e.createElement(W.Z,null,a({id:"Settings.webhooks.trigger.pending",defaultMessage:"pending"}))):r>=200&&r<300?e.createElement(b.k,{gap:2,alignItems:"center"},e.createElement(q,{as:m.Z,color:"success700"}),e.createElement(W.Z,null,a({id:"Settings.webhooks.trigger.success",defaultMessage:"success"}))):r>=300?e.createElement(b.k,{gap:2,alignItems:"center"},e.createElement(q,{as:Pe.Z,color:"danger700"}),e.createElement(W.Z,null,a({id:"Settings.error",defaultMessage:"error"})," ",r)):null};B.propTypes={isPending:s().bool.isRequired,statusCode:s().number},B.defaultProps={statusCode:void 0};const me=({statusCode:n,message:r})=>{const{formatMessage:a}=(0,j.Z)();return n>=200&&n<300?e.createElement(b.k,{justifyContent:"flex-end"},e.createElement(W.Z,{textColor:"neutral600",ellipsis:!0},a({id:"Settings.webhooks.trigger.success.label",defaultMessage:"Trigger succeeded"}))):n>=300?e.createElement(b.k,{justifyContent:"flex-end"},e.createElement(b.k,{maxWidth:(0,d.Q1)(250),justifyContent:"flex-end",title:r},e.createElement(W.Z,{ellipsis:!0,textColor:"neutral600"},r))):null};me.propTypes={statusCode:s().number,message:s().string},me.defaultProps={statusCode:void 0,message:void 0};const xe=({onCancel:n})=>{const{formatMessage:r}=(0,j.Z)();return e.createElement(b.k,{justifyContent:"flex-end"},e.createElement("button",{onClick:n,type:"button"},e.createElement(b.k,{gap:2,alignItems:"center"},e.createElement(W.Z,{textColor:"neutral400"},r({id:"Settings.webhooks.trigger.cancel",defaultMessage:"cancel"})),e.createElement(q,{as:Pe.Z,color:"neutral400"}))))};xe.propTypes={onCancel:s().func.isRequired};const x=({isPending:n,onCancel:r,response:a})=>{const{statusCode:l,message:p}=a,{formatMessage:I}=(0,j.Z)();return e.createElement(ae.x,{background:"neutral0",padding:5,shadow:"filterShadow",hasRadius:!0},e.createElement(le.r,{gap:4,style:{alignItems:"center"}},e.createElement(V.P,{col:3},e.createElement(W.Z,null,I({id:"Settings.webhooks.trigger.test",defaultMessage:"Test-trigger"}))),e.createElement(V.P,{col:3},e.createElement(B,{isPending:n,statusCode:l})),e.createElement(V.P,{col:6},n?e.createElement(xe,{onCancel:r}):e.createElement(me,{statusCode:l,message:p}))))};x.defaultProps={isPending:!1,onCancel(){},response:{}},x.propTypes={isPending:s().bool,onCancel:s().func,response:s().object};var Ie=x,w=t(24346);const De=/(^$)|(^[A-Za-z][_0-9A-Za-z ]*$)/,U=/(^$)|((https?:\/\/.*)(d*)\/?(.*))/;var z=w.Ry().shape({name:w.Z_(d.I0.string).required(d.I0.required).matches(De,d.I0.regex),url:w.Z_(d.I0.string).required(d.I0.required).matches(U,d.I0.regex),headers:w.Vo(n=>{let r=w.IX();if(n.length===1){const{key:a,value:l}=n[0];if(!a&&!l)return r}return r.of(w.Ry().shape({key:w.Z_().required(d.I0.required),value:w.Z_().required(d.I0.required)}))}),events:w.IX()});const pe=({handleSubmit:n,data:r,triggerWebhook:a,isCreating:l,isTriggering:p,triggerResponse:I,isDraftAndPublishEvents:u})=>{const{formatMessage:f}=(0,j.Z)(),[C,y]=(0,e.useState)(!1);return e.createElement(Z.J9,{onSubmit:n,initialValues:{name:r?.name||"",url:r?.url||"",headers:Object.keys(r?.headers||[]).length?Object.entries(r.headers).map(([E,M])=>({key:E,value:M})):[{key:"",value:""}],events:r?.events||[]},validationSchema:z,validateOnChange:!1,validateOnBlur:!1},({handleSubmit:E,errors:M})=>e.createElement(d.l0,{noValidate:!0},e.createElement(Oe.T,{primaryAction:e.createElement(b.k,{gap:2},e.createElement(he.z,{onClick:()=>{a(),y(!0)},variant:"tertiary",startIcon:e.createElement(g.Z,null),disabled:l||p,size:"L"},f({id:"Settings.webhooks.trigger",defaultMessage:"Trigger"})),e.createElement(he.z,{startIcon:e.createElement(m.Z,null),onClick:E,type:"submit",size:"L"},f({id:"global.save",defaultMessage:"Save"}))),title:l?f({id:"Settings.webhooks.create",defaultMessage:"Create a webhook"}):r?.name,navigationAction:e.createElement(d.rU,{startIcon:e.createElement(N.Z,null),to:"/settings/webhooks"},f({id:"global.back",defaultMessage:"Back"}))}),e.createElement(ke.D,null,e.createElement(b.k,{direction:"column",alignItems:"stretch",gap:4},C&&e.createElement("div",{className:"trigger-wrapper"},e.createElement(Ie,{isPending:p,response:I,onCancel:()=>y(!1)})),e.createElement(ae.x,{background:"neutral0",padding:8,shadow:"filterShadow",hasRadius:!0},e.createElement(b.k,{direction:"column",alignItems:"stretch",gap:6},e.createElement(le.r,{gap:6},e.createElement(V.P,{col:6},e.createElement(Z.gN,{as:ie.o,name:"name",error:M.name&&f({id:M.name}),label:f({id:"global.name",defaultMessage:"Name"}),required:!0})),e.createElement(V.P,{col:12},e.createElement(Z.gN,{as:ie.o,name:"url",error:M.url&&f({id:M.url}),label:f({id:"Settings.roles.form.input.url",defaultMessage:"Url"}),required:!0}))),e.createElement(Me,null),e.createElement(ue,{isDraftAndPublish:u})))))))};pe.propTypes={data:s().object,handleSubmit:s().func.isRequired,triggerWebhook:s().func.isRequired,isCreating:s().bool.isRequired,isDraftAndPublishEvents:s().bool.isRequired,isTriggering:s().bool.isRequired,triggerResponse:s().object},pe.defaultProps={data:void 0,triggerResponse:void 0};var k=pe;const oe=n=>({...n,headers:_(n.headers)}),_=n=>n.reduce((r,a)=>{const{key:l,value:p}=a;return l!==""?{...r,[l]:p}:r},{});var ee=oe,Se=()=>{const{params:{id:n}}=(0,O.$B)("/settings/webhooks/:id"),{replace:r}=(0,O.k6)(),{lockApp:a,unlockApp:l}=(0,d.o1)(),p=(0,d.lm)(),I=(0,o.useQueryClient)(),{isLoading:u,collectionTypes:f}=(0,D.bP)(),{put:C,get:y,post:E}=(0,d.kY)(),M=n==="create",{isLoading:h,data:T}=(0,o.useQuery)(["get-webhook",n],async()=>{try{const{data:{data:P}}=await y(`/admin/webhooks/${n}`);return P}catch{return p({type:"warning",message:{id:"notification.error"}}),null}},{enabled:!M}),{isLoading:F,data:G,isIdle:$e,mutate:Be}=(0,o.useMutation)(()=>E(`/admin/webhooks/${n}/trigger`)),Ue=()=>Be(null,{onError(){p({type:"warning",message:{id:"notification.error"}})}}),fe=(0,o.useMutation)(P=>E("/admin/webhooks",P)),c=(0,o.useMutation)(({id:P,body:te})=>C(`/admin/webhooks/${P}`,te)),v=async P=>{M?(a(),fe.mutate(ee(P),{onSuccess({data:te}){p({type:"success",message:{id:"Settings.webhooks.created"}}),r(`/settings/webhooks/${te.data.id}`),l()},onError(te){p({type:"warning",message:{id:"notification.error"}}),console.log(te),l()}})):(a(),c.mutate({id:n,body:ee(P)},{onSuccess(){I.invalidateQueries(["get-webhook",n]),p({type:"success",message:{id:"notification.form.success.fields"}}),l()},onError(te){p({type:"warning",message:{id:"notification.error"}}),console.log(te),l()}}))},K=e.useMemo(()=>f.some(P=>P.options.draftAndPublish===!0),[f]);return h||u?e.createElement(d.dO,null):e.createElement(L.o,null,e.createElement(d.SL,{name:"Webhooks"}),e.createElement(k,{handleSubmit:v,data:T,triggerWebhook:Ue,isCreating:M,isTriggering:F,isTriggerIdle:$e,triggerResponse:G?.data.data,isDraftAndPublishEvents:K}))}},33238:function(ne,S,t){t.r(S);var e=t(32735),d=t(43383),L=t(83983),o=t(47272);const O=()=>e.createElement(d.O4,{permissions:L.Z.settings.webhooks.create},e.createElement(o.Z,null));S.default=O},59021:function(ne,S,t){t.r(S);var e=t(32735),d=t(43383),L=t(83983),o=t(47272);const O=()=>e.createElement(d.O4,{permissions:L.Z.settings.webhooks.update},e.createElement(o.Z,null));S.default=O},42623:function(ne,S,t){t.d(S,{h:function(){return Q},X:function(){return ce}});var e=t(32735),d=t(35331),L=t(16899),o=t(60216),O=t(90333),D=t(91225),J=t(17289),s=t(94486);const g={Close:"Close",CloseSelect:"CloseSelect",First:"First",Last:"Last",Next:"Next",Open:"Open",PageDown:"PageDown",PageUp:"PageUp",Previous:"Previous",Select:"Select",Space:"Space",Type:"Type"},m={Close:"Close",First:"First",Last:"Last",Next:"Next",Open:"Open",Previous:"Previous",Select:"Select",UpLevel:"UpLevel"};function N(i=[],A=null,$=[]){const X=String(A??"").toLowerCase();return X?i.filter(R=>R.props.children.toString().toLowerCase().includes(X)&&$.indexOf(R)<0):i}function Oe(i,A){if(!A&&i===s.y.DOWN)return g.Open;if(i===s.y.DOWN)return g.Next;if(i===s.y.UP)return g.Previous;if(i===s.y.HOME)return g.First;if(i===s.y.END)return g.Last;if(i===s.y.ESCAPE)return g.Close;if(i===s.y.ENTER)return g.CloseSelect;if(i===s.y.BACKSPACE||i===s.y.CLEAR||i.length===1)return g.Type}function b(i,A,$){switch($){case g.First:return 0;case g.Last:return A;case g.Previous:return Math.max(0,i-1);case g.Next:return Math.min(A,i+1);default:return i}}function he(i){(0,J.Z)(i,{scrollMode:"if-needed",block:"nearest",inline:"nearest"}).forEach(({el:A,top:$,left:X})=>{A.scrollTop=$,A.scrollLeft=X})}var ke=t(72850),ae=t(87107),le=t(28847),V=t(67014),ie=t(47851),Z=t(87933),j=t(74971),Ee=t(97405),W=t(4101),de=t(93958),ve=t(49372),Le=t(3685);const Q=({children:i,clearLabel:A,creatable:$,createMessage:X,disabled:R,error:H,hasMoreItems:be,hint:ue,id:Re,label:Y,labelAction:Te,loading:ge,loadingMessage:We,noOptionsMessage:Ce,onChange:re,onClear:ye,onCreateOption:we,onInputChange:Me,onLoadMore:Ae,placeholder:Pe,required:q,value:B,...me})=>{const xe=()=>i.find(c=>c.props?.value.toLowerCase()===B.toLowerCase()).props?.children,[x,Ie]=(0,e.useState)(0),[w,De]=(0,e.useState)(null),[U,Ze]=(0,e.useState)(i),[z,pe]=(0,e.useState)(!1),[k,oe]=(0,e.useState)(""),_=(0,e.useRef)(),ee=(0,e.useRef)(!1),se=(0,e.useRef)(),Se=(0,e.useRef)(),n=(0,e.useRef)(),r=(0,e.useRef)(!0),a=(0,j.M)(Re),l=`${a}-label`;if(!Y&&!me["aria-label"])throw new Error('The Combobox component needs a "label" or an "aria-label" props');(0,e.useEffect)(()=>{Ze(N(i,k))},[k,i]),(0,e.useEffect)(()=>{z&&_.current&&he(_.current)},[x,z]),(0,e.useLayoutEffect)(()=>{r.current&&(r.current=!1)},[B]);const p=z?`${a}-${x}`:"",I=()=>{re(null),oe("")},u=c=>{Me&&Me(c);const v=se.current.value;Ze(N(i,v)),Ie(0),De(null),k!==v&&oe(v),z||T(!0,!1)},f=c=>{const{key:v}=c,K=$&&k?U.length:U.length-1,P=Oe(v,z);switch(B&&!k&&v===s.y.BACKSPACE&&I(),P){case g.Next:{if(x===K){y(0);break}y(b(x,K,P));break}case g.Previous:{if(x===0){y(K);break}y(b(x,K,P));break}case g.Last:case g.First:{if(x===K){y(0);break}y(b(x,K,P));break}case g.CloseSelect:c.preventDefault(),h(x);break;case g.Close:c.preventDefault(),T(!1);break;case g.Open:T(!0);break}},C=c=>{if(c.preventDefault(),B&&!ee.current&&oe(""),ee.current){ee.current=!1;return}T(!1,!1)},y=c=>{Ie(c)},E=c=>{y(c),h(c)},M=()=>{ee.current=!0},h=c=>{const v=U[c];if(oe(""),v){re(v.props.value),T(!1);return}$&&(we(k),T(!1))},T=(c,v=!0)=>{pe(c),v&&se.current.focus()},F=e.Children.toArray(U).map((c,v)=>{const K=x===v;return(0,e.cloneElement)(c,{id:`${a}-${v}`,"aria-selected":w===v,"aria-posinset":v+1,"aria-setsize":e.Children.toArray(U).length,ref(P){K&&(_.current=P)},onClick:()=>E(v),onMouseDown:M,isSelected:K})}),G=()=>{se.current.focus(),ye&&ye(),I()},$e=()=>{se.current.focus(),T(!0)},Be=()=>{const c=U.findIndex(v=>v.props?.children===k);return k&&c===-1},Ue=c=>{c.preventDefault(),T(c,!0)};let fe;return H?fe=`${a}-error`:ue&&(fe=`${a}-hint`),e.createElement(ae.g,{hint:ue,error:H,id:a,required:q},e.createElement(Le.T,{"aria-live":"polite","aria-atomic":"false","aria-relevant":"additions text"},B),e.createElement(Z.k,{direction:"column",alignItems:"stretch",gap:Y||ue||H?1:0},Y&&e.createElement(le.Q,{action:Te},Y),e.createElement(D.d8,{ref:Se,$disabled:R,hasError:H},e.createElement(D.fv,{wrap:"wrap"},!k&&B&&e.createElement(D.K7,{id:`${a}-selected-value`},e.createElement(ve.Z,null,xe())),e.createElement(D.II,{"aria-activedescendant":p,"aria-autocomplete":"list","aria-controls":`${a}-listbox`,"aria-disabled":R,"aria-expanded":z,"aria-haspopup":"listbox","aria-describedby":fe,autoComplete:"off",autoCorrect:"off",id:a,onBlur:R?void 0:C,onClick:R?void 0:Ue,onInput:R?void 0:u,onKeyDown:R?void 0:f,placeholder:B?"":Pe,readOnly:R,ref:se,required:q,role:"combobox",spellCheck:"off",type:"text",value:k})),e.createElement(Z.k,null,(B||k)&&e.createElement(de.zb,{id:`${a}-clear`,"aria-label":A,disabled:R,paddingLeft:3,as:"button",onClick:G,type:"button"},e.createElement(d.Z,null)),e.createElement(de.AV,{disabled:R,paddingLeft:3,"aria-hidden":!0,as:"button",onClick:$e,tabIndex:-1,type:"button"},e.createElement(L.Z,null)))),e.createElement(V.J,null),e.createElement(ie.c,null)),z&&e.createElement(W.J2,{id:`${a}-popover`,source:Se,spacing:4,fullWidth:!0,intersectionId:`${a}-listbox-popover-intersection`,onReachEnd:be&&!ge?Ae:void 0},e.createElement("div",{role:"listbox",ref:n,id:`${a}-listbox`,"aria-labelledby":Y?l:void 0},(Boolean(U.length)||$)&&e.createElement(e.Fragment,null,F,Be()&&$&&e.createElement(O.O,{isSelected:x===U.length,ref:c=>{x===U.length&&(_.current=c)},onMouseDown:M,onClick:()=>h(),taindex:0},X(k))),!U.length&&!$&&!ge&&e.createElement(ke.x,{paddingLeft:4,paddingRight:4,paddingTop:2,paddingBottom:2,ref:_},e.createElement(ve.Z,{textColor:"neutral800"},Ce(k))),ge&&e.createElement(Z.k,{justifyContent:"center",alignItems:"center",paddingTop:2,paddingBottom:2},e.createElement(Ee.a,{small:!0},We)))))},ce=i=>e.createElement(Q,{...i,creatable:!0});Q.defaultProps={"aria-label":void 0,clearLabel:"clear",creatable:!1,createMessage:i=>`Create "${i}"`,disabled:!1,error:void 0,hasMoreItems:!1,hint:void 0,id:void 0,label:void 0,loading:!1,loadingMessage:"Loading content...",noOptionsMessage:()=>"No results found",onClear:void 0,onCreateOption:void 0,onInputChange:void 0,onLoadMore:void 0,placeholder:"Select or enter a value",value:void 0},ce.defaultProps=Q.defaultProps,Q.propTypes={"aria-label":o.string,children:o.oneOfType([o.arrayOf(o.node),o.node]),clearLabel:o.string,creatable:o.bool,createMessage:o.func,disabled:o.bool,error:o.string,hasMoreItems:o.bool,id:o.string,hint:o.oneOfType([o.string,o.node,o.arrayOf(o.node)]),label:o.string,labelAction:o.element,loading:o.bool,loadingMessage:o.string,noOptionsMessage:o.func,onChange:o.func.isRequired,onClear:o.func,onCreateOption:o.func,onInputChange:o.func,onLoadMore:o.func,placeholder:o.string,value:o.string},ce.propTypes={...Q.propTypes,onCreateOption:o.func.isRequired}},90333:function(ne,S,t){t.d(S,{O:function(){return O}});var e=t(32735),d=t(60216),L=t(91225),o=t(49372);const O=(0,e.forwardRef)(({isSelected:D,children:J,...s},g)=>e.createElement(L.Zq,{hasRadius:!0,paddingLeft:4,paddingRight:4,paddingTop:2,paddingBottom:2,role:"option",background:"neutral0",isSelected:D,ref:g,...s},e.createElement(o.Z,{textColor:D?"primary600":"neutral800",fontWeight:D?"bold":null},J)));O.defaultProps={isSelected:!1},O.propTypes={children:d.oneOfType([d.string,d.number]).isRequired,isSelected:d.bool},O.displayName="ComboboxOption"},91225:function(ne,S,t){t.d(S,{II:function(){return s},K7:function(){return D},Zq:function(){return g},d8:function(){return O},fv:function(){return J}});var e=t(8471),d=t(72850),L=t(87933),o=t(30350);const O=(0,e.ZP)(L.k)`
|
|
23
|
+
`),B=({isPending:n,statusCode:r})=>{const{formatMessage:a}=(0,j.Z)();return n?e.createElement(b.k,{gap:2,alignItems:"center"},e.createElement(q,{as:Ae.Z}),e.createElement(W.Z,null,a({id:"Settings.webhooks.trigger.pending",defaultMessage:"pending"}))):r>=200&&r<300?e.createElement(b.k,{gap:2,alignItems:"center"},e.createElement(q,{as:m.Z,color:"success700"}),e.createElement(W.Z,null,a({id:"Settings.webhooks.trigger.success",defaultMessage:"success"}))):r>=300?e.createElement(b.k,{gap:2,alignItems:"center"},e.createElement(q,{as:Pe.Z,color:"danger700"}),e.createElement(W.Z,null,a({id:"Settings.error",defaultMessage:"error"})," ",r)):null};B.propTypes={isPending:s().bool.isRequired,statusCode:s().number},B.defaultProps={statusCode:void 0};const me=({statusCode:n,message:r})=>{const{formatMessage:a}=(0,j.Z)();return n>=200&&n<300?e.createElement(b.k,{justifyContent:"flex-end"},e.createElement(W.Z,{textColor:"neutral600",ellipsis:!0},a({id:"Settings.webhooks.trigger.success.label",defaultMessage:"Trigger succeeded"}))):n>=300?e.createElement(b.k,{justifyContent:"flex-end"},e.createElement(b.k,{maxWidth:(0,d.Q1)(250),justifyContent:"flex-end",title:r},e.createElement(W.Z,{ellipsis:!0,textColor:"neutral600"},r))):null};me.propTypes={statusCode:s().number,message:s().string},me.defaultProps={statusCode:void 0,message:void 0};const xe=({onCancel:n})=>{const{formatMessage:r}=(0,j.Z)();return e.createElement(b.k,{justifyContent:"flex-end"},e.createElement("button",{onClick:n,type:"button"},e.createElement(b.k,{gap:2,alignItems:"center"},e.createElement(W.Z,{textColor:"neutral400"},r({id:"Settings.webhooks.trigger.cancel",defaultMessage:"cancel"})),e.createElement(q,{as:Pe.Z,color:"neutral400"}))))};xe.propTypes={onCancel:s().func.isRequired};const x=({isPending:n,onCancel:r,response:a})=>{const{statusCode:l,message:p}=a,{formatMessage:I}=(0,j.Z)();return e.createElement(ae.x,{background:"neutral0",padding:5,shadow:"filterShadow",hasRadius:!0},e.createElement(le.r,{gap:4,style:{alignItems:"center"}},e.createElement(V.P,{col:3},e.createElement(W.Z,null,I({id:"Settings.webhooks.trigger.test",defaultMessage:"Test-trigger"}))),e.createElement(V.P,{col:3},e.createElement(B,{isPending:n,statusCode:l})),e.createElement(V.P,{col:6},n?e.createElement(xe,{onCancel:r}):e.createElement(me,{statusCode:l,message:p}))))};x.defaultProps={isPending:!1,onCancel(){},response:{}},x.propTypes={isPending:s().bool,onCancel:s().func,response:s().object};var Ie=x,w=t(24346);const De=/(^$)|(^[A-Za-z][_0-9A-Za-z ]*$)/,U=/(^$)|((https?:\/\/.*)(d*)\/?(.*))/;var z=w.Ry().shape({name:w.Z_(d.I0.string).required(d.I0.required).matches(De,d.I0.regex),url:w.Z_(d.I0.string).required(d.I0.required).matches(U,d.I0.regex),headers:w.Vo(n=>{let r=w.IX();if(n.length===1){const{key:a,value:l}=n[0];if(!a&&!l)return r}return r.of(w.Ry().shape({key:w.Z_().required(d.I0.required),value:w.Z_().required(d.I0.required)}))}),events:w.IX()});const pe=({handleSubmit:n,data:r,triggerWebhook:a,isCreating:l,isTriggering:p,triggerResponse:I,isDraftAndPublishEvents:u})=>{const{formatMessage:f}=(0,j.Z)(),[C,y]=(0,e.useState)(!1);return e.createElement(Z.J9,{onSubmit:n,initialValues:{name:r?.name||"",url:r?.url||"",headers:Object.keys(r?.headers||[]).length?Object.entries(r.headers).map(([E,M])=>({key:E,value:M})):[{key:"",value:""}],events:r?.events||[]},validationSchema:z,validateOnChange:!1,validateOnBlur:!1},({handleSubmit:E,errors:M})=>e.createElement(d.l0,{noValidate:!0},e.createElement(Oe.T,{primaryAction:e.createElement(b.k,{gap:2},e.createElement(he.z,{onClick:()=>{a(),y(!0)},variant:"tertiary",startIcon:e.createElement(g.Z,null),disabled:l||p,size:"L"},f({id:"Settings.webhooks.trigger",defaultMessage:"Trigger"})),e.createElement(he.z,{startIcon:e.createElement(m.Z,null),onClick:E,type:"submit",size:"L"},f({id:"global.save",defaultMessage:"Save"}))),title:l?f({id:"Settings.webhooks.create",defaultMessage:"Create a webhook"}):r?.name,navigationAction:e.createElement(d.rU,{startIcon:e.createElement(N.Z,null),to:"/settings/webhooks"},f({id:"global.back",defaultMessage:"Back"}))}),e.createElement(ke.D,null,e.createElement(b.k,{direction:"column",alignItems:"stretch",gap:4},C&&e.createElement("div",{className:"trigger-wrapper"},e.createElement(Ie,{isPending:p,response:I,onCancel:()=>y(!1)})),e.createElement(ae.x,{background:"neutral0",padding:8,shadow:"filterShadow",hasRadius:!0},e.createElement(b.k,{direction:"column",alignItems:"stretch",gap:6},e.createElement(le.r,{gap:6},e.createElement(V.P,{col:6},e.createElement(Z.gN,{as:ie.o,name:"name",error:M.name&&f({id:M.name}),label:f({id:"global.name",defaultMessage:"Name"}),required:!0})),e.createElement(V.P,{col:12},e.createElement(Z.gN,{as:ie.o,name:"url",error:M.url&&f({id:M.url}),label:f({id:"Settings.roles.form.input.url",defaultMessage:"Url"}),required:!0}))),e.createElement(Me,null),e.createElement(ue,{isDraftAndPublish:u})))))))};pe.propTypes={data:s().object,handleSubmit:s().func.isRequired,triggerWebhook:s().func.isRequired,isCreating:s().bool.isRequired,isDraftAndPublishEvents:s().bool.isRequired,isTriggering:s().bool.isRequired,triggerResponse:s().object},pe.defaultProps={data:void 0,triggerResponse:void 0};var k=pe;const oe=n=>({...n,headers:_(n.headers)}),_=n=>n.reduce((r,a)=>{const{key:l,value:p}=a;return l!==""?{...r,[l]:p}:r},{});var ee=oe,Se=()=>{const{params:{id:n}}=(0,O.$B)("/settings/webhooks/:id"),{replace:r}=(0,O.k6)(),{lockApp:a,unlockApp:l}=(0,d.o1)(),p=(0,d.lm)(),I=(0,o.useQueryClient)(),{isLoading:u,collectionTypes:f}=(0,D.bP)(),{put:C,get:y,post:E}=(0,d.kY)(),M=n==="create",{isLoading:h,data:T}=(0,o.useQuery)(["get-webhook",n],async()=>{try{const{data:{data:P}}=await y(`/admin/webhooks/${n}`);return P}catch{return p({type:"warning",message:{id:"notification.error"}}),null}},{enabled:!M}),{isLoading:F,data:G,isIdle:$e,mutate:Be}=(0,o.useMutation)(()=>E(`/admin/webhooks/${n}/trigger`)),Ue=()=>Be(null,{onError(){p({type:"warning",message:{id:"notification.error"}})}}),fe=(0,o.useMutation)(P=>E("/admin/webhooks",P)),c=(0,o.useMutation)(({id:P,body:te})=>C(`/admin/webhooks/${P}`,te)),v=async P=>{M?(a(),fe.mutate(ee(P),{onSuccess({data:te}){p({type:"success",message:{id:"Settings.webhooks.created"}}),r(`/settings/webhooks/${te.data.id}`),l()},onError(te){p({type:"warning",message:{id:"notification.error"}}),console.log(te),l()}})):(a(),c.mutate({id:n,body:ee(P)},{onSuccess(){I.invalidateQueries(["get-webhook",n]),p({type:"success",message:{id:"notification.form.success.fields"}}),l()},onError(te){p({type:"warning",message:{id:"notification.error"}}),console.log(te),l()}}))},K=e.useMemo(()=>f.some(P=>P.options.draftAndPublish===!0),[f]);return h||u?e.createElement(d.dO,null):e.createElement(L.o,null,e.createElement(d.SL,{name:"Webhooks"}),e.createElement(k,{handleSubmit:v,data:T,triggerWebhook:Ue,isCreating:M,isTriggering:F,isTriggerIdle:$e,triggerResponse:G?.data.data,isDraftAndPublishEvents:K}))}},33238:function(ne,S,t){t.r(S);var e=t(32735),d=t(24989),L=t(83983),o=t(47272);const O=()=>e.createElement(d.O4,{permissions:L.Z.settings.webhooks.create},e.createElement(o.Z,null));S.default=O},59021:function(ne,S,t){t.r(S);var e=t(32735),d=t(24989),L=t(83983),o=t(47272);const O=()=>e.createElement(d.O4,{permissions:L.Z.settings.webhooks.update},e.createElement(o.Z,null));S.default=O},42623:function(ne,S,t){t.d(S,{h:function(){return Q},X:function(){return ce}});var e=t(32735),d=t(35331),L=t(16899),o=t(60216),O=t(90333),D=t(91225),J=t(17289),s=t(94486);const g={Close:"Close",CloseSelect:"CloseSelect",First:"First",Last:"Last",Next:"Next",Open:"Open",PageDown:"PageDown",PageUp:"PageUp",Previous:"Previous",Select:"Select",Space:"Space",Type:"Type"},m={Close:"Close",First:"First",Last:"Last",Next:"Next",Open:"Open",Previous:"Previous",Select:"Select",UpLevel:"UpLevel"};function N(i=[],A=null,$=[]){const X=String(A??"").toLowerCase();return X?i.filter(R=>R.props.children.toString().toLowerCase().includes(X)&&$.indexOf(R)<0):i}function Oe(i,A){if(!A&&i===s.y.DOWN)return g.Open;if(i===s.y.DOWN)return g.Next;if(i===s.y.UP)return g.Previous;if(i===s.y.HOME)return g.First;if(i===s.y.END)return g.Last;if(i===s.y.ESCAPE)return g.Close;if(i===s.y.ENTER)return g.CloseSelect;if(i===s.y.BACKSPACE||i===s.y.CLEAR||i.length===1)return g.Type}function b(i,A,$){switch($){case g.First:return 0;case g.Last:return A;case g.Previous:return Math.max(0,i-1);case g.Next:return Math.min(A,i+1);default:return i}}function he(i){(0,J.Z)(i,{scrollMode:"if-needed",block:"nearest",inline:"nearest"}).forEach(({el:A,top:$,left:X})=>{A.scrollTop=$,A.scrollLeft=X})}var ke=t(72850),ae=t(87107),le=t(28847),V=t(67014),ie=t(47851),Z=t(87933),j=t(74971),Ee=t(97405),W=t(4101),de=t(93958),ve=t(49372),Le=t(3685);const Q=({children:i,clearLabel:A,creatable:$,createMessage:X,disabled:R,error:H,hasMoreItems:be,hint:ue,id:Re,label:Y,labelAction:Te,loading:ge,loadingMessage:We,noOptionsMessage:Ce,onChange:re,onClear:ye,onCreateOption:we,onInputChange:Me,onLoadMore:Ae,placeholder:Pe,required:q,value:B,...me})=>{const xe=()=>i.find(c=>c.props?.value.toLowerCase()===B.toLowerCase()).props?.children,[x,Ie]=(0,e.useState)(0),[w,De]=(0,e.useState)(null),[U,Ze]=(0,e.useState)(i),[z,pe]=(0,e.useState)(!1),[k,oe]=(0,e.useState)(""),_=(0,e.useRef)(),ee=(0,e.useRef)(!1),se=(0,e.useRef)(),Se=(0,e.useRef)(),n=(0,e.useRef)(),r=(0,e.useRef)(!0),a=(0,j.M)(Re),l=`${a}-label`;if(!Y&&!me["aria-label"])throw new Error('The Combobox component needs a "label" or an "aria-label" props');(0,e.useEffect)(()=>{Ze(N(i,k))},[k,i]),(0,e.useEffect)(()=>{z&&_.current&&he(_.current)},[x,z]),(0,e.useLayoutEffect)(()=>{r.current&&(r.current=!1)},[B]);const p=z?`${a}-${x}`:"",I=()=>{re(null),oe("")},u=c=>{Me&&Me(c);const v=se.current.value;Ze(N(i,v)),Ie(0),De(null),k!==v&&oe(v),z||T(!0,!1)},f=c=>{const{key:v}=c,K=$&&k?U.length:U.length-1,P=Oe(v,z);switch(B&&!k&&v===s.y.BACKSPACE&&I(),P){case g.Next:{if(x===K){y(0);break}y(b(x,K,P));break}case g.Previous:{if(x===0){y(K);break}y(b(x,K,P));break}case g.Last:case g.First:{if(x===K){y(0);break}y(b(x,K,P));break}case g.CloseSelect:c.preventDefault(),h(x);break;case g.Close:c.preventDefault(),T(!1);break;case g.Open:T(!0);break}},C=c=>{if(c.preventDefault(),B&&!ee.current&&oe(""),ee.current){ee.current=!1;return}T(!1,!1)},y=c=>{Ie(c)},E=c=>{y(c),h(c)},M=()=>{ee.current=!0},h=c=>{const v=U[c];if(oe(""),v){re(v.props.value),T(!1);return}$&&(we(k),T(!1))},T=(c,v=!0)=>{pe(c),v&&se.current.focus()},F=e.Children.toArray(U).map((c,v)=>{const K=x===v;return(0,e.cloneElement)(c,{id:`${a}-${v}`,"aria-selected":w===v,"aria-posinset":v+1,"aria-setsize":e.Children.toArray(U).length,ref(P){K&&(_.current=P)},onClick:()=>E(v),onMouseDown:M,isSelected:K})}),G=()=>{se.current.focus(),ye&&ye(),I()},$e=()=>{se.current.focus(),T(!0)},Be=()=>{const c=U.findIndex(v=>v.props?.children===k);return k&&c===-1},Ue=c=>{c.preventDefault(),T(c,!0)};let fe;return H?fe=`${a}-error`:ue&&(fe=`${a}-hint`),e.createElement(ae.g,{hint:ue,error:H,id:a,required:q},e.createElement(Le.T,{"aria-live":"polite","aria-atomic":"false","aria-relevant":"additions text"},B),e.createElement(Z.k,{direction:"column",alignItems:"stretch",gap:Y||ue||H?1:0},Y&&e.createElement(le.Q,{action:Te},Y),e.createElement(D.d8,{ref:Se,$disabled:R,hasError:H},e.createElement(D.fv,{wrap:"wrap"},!k&&B&&e.createElement(D.K7,{id:`${a}-selected-value`},e.createElement(ve.Z,null,xe())),e.createElement(D.II,{"aria-activedescendant":p,"aria-autocomplete":"list","aria-controls":`${a}-listbox`,"aria-disabled":R,"aria-expanded":z,"aria-haspopup":"listbox","aria-describedby":fe,autoComplete:"off",autoCorrect:"off",id:a,onBlur:R?void 0:C,onClick:R?void 0:Ue,onInput:R?void 0:u,onKeyDown:R?void 0:f,placeholder:B?"":Pe,readOnly:R,ref:se,required:q,role:"combobox",spellCheck:"off",type:"text",value:k})),e.createElement(Z.k,null,(B||k)&&e.createElement(de.zb,{id:`${a}-clear`,"aria-label":A,disabled:R,paddingLeft:3,as:"button",onClick:G,type:"button"},e.createElement(d.Z,null)),e.createElement(de.AV,{disabled:R,paddingLeft:3,"aria-hidden":!0,as:"button",onClick:$e,tabIndex:-1,type:"button"},e.createElement(L.Z,null)))),e.createElement(V.J,null),e.createElement(ie.c,null)),z&&e.createElement(W.J2,{id:`${a}-popover`,source:Se,spacing:4,fullWidth:!0,intersectionId:`${a}-listbox-popover-intersection`,onReachEnd:be&&!ge?Ae:void 0},e.createElement("div",{role:"listbox",ref:n,id:`${a}-listbox`,"aria-labelledby":Y?l:void 0},(Boolean(U.length)||$)&&e.createElement(e.Fragment,null,F,Be()&&$&&e.createElement(O.O,{isSelected:x===U.length,ref:c=>{x===U.length&&(_.current=c)},onMouseDown:M,onClick:()=>h(),taindex:0},X(k))),!U.length&&!$&&!ge&&e.createElement(ke.x,{paddingLeft:4,paddingRight:4,paddingTop:2,paddingBottom:2,ref:_},e.createElement(ve.Z,{textColor:"neutral800"},Ce(k))),ge&&e.createElement(Z.k,{justifyContent:"center",alignItems:"center",paddingTop:2,paddingBottom:2},e.createElement(Ee.a,{small:!0},We)))))},ce=i=>e.createElement(Q,{...i,creatable:!0});Q.defaultProps={"aria-label":void 0,clearLabel:"clear",creatable:!1,createMessage:i=>`Create "${i}"`,disabled:!1,error:void 0,hasMoreItems:!1,hint:void 0,id:void 0,label:void 0,loading:!1,loadingMessage:"Loading content...",noOptionsMessage:()=>"No results found",onClear:void 0,onCreateOption:void 0,onInputChange:void 0,onLoadMore:void 0,placeholder:"Select or enter a value",value:void 0},ce.defaultProps=Q.defaultProps,Q.propTypes={"aria-label":o.string,children:o.oneOfType([o.arrayOf(o.node),o.node]),clearLabel:o.string,creatable:o.bool,createMessage:o.func,disabled:o.bool,error:o.string,hasMoreItems:o.bool,id:o.string,hint:o.oneOfType([o.string,o.node,o.arrayOf(o.node)]),label:o.string,labelAction:o.element,loading:o.bool,loadingMessage:o.string,noOptionsMessage:o.func,onChange:o.func.isRequired,onClear:o.func,onCreateOption:o.func,onInputChange:o.func,onLoadMore:o.func,placeholder:o.string,value:o.string},ce.propTypes={...Q.propTypes,onCreateOption:o.func.isRequired}},90333:function(ne,S,t){t.d(S,{O:function(){return O}});var e=t(32735),d=t(60216),L=t(91225),o=t(49372);const O=(0,e.forwardRef)(({isSelected:D,children:J,...s},g)=>e.createElement(L.Zq,{hasRadius:!0,paddingLeft:4,paddingRight:4,paddingTop:2,paddingBottom:2,role:"option",background:"neutral0",isSelected:D,ref:g,...s},e.createElement(o.Z,{textColor:D?"primary600":"neutral800",fontWeight:D?"bold":null},J)));O.defaultProps={isSelected:!1},O.propTypes={children:d.oneOfType([d.string,d.number]).isRequired,isSelected:d.bool},O.displayName="ComboboxOption"},91225:function(ne,S,t){t.d(S,{II:function(){return s},K7:function(){return D},Zq:function(){return g},d8:function(){return O},fv:function(){return J}});var e=t(8471),d=t(72850),L=t(87933),o=t(30350);const O=(0,e.ZP)(L.k)`
|
|
24
24
|
position: relative;
|
|
25
25
|
border: 1px solid ${({theme:m,hasError:N})=>N?m.colors.danger600:m.colors.neutral200};
|
|
26
26
|
padding-right: ${({theme:m})=>m.spaces[3]};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";(self.webpackChunk_strapi_admin=self.webpackChunk_strapi_admin||[]).push([[4121],{74767:function(U,p,t){t.r(p),t.d(p,{default:function(){return be}});var e=t(32735),s=t(
|
|
1
|
+
"use strict";(self.webpackChunk_strapi_admin=self.webpackChunk_strapi_admin||[]).push([[4121],{74767:function(U,p,t){t.r(p),t.d(p,{default:function(){return be}});var e=t(32735),s=t(24989),b=t(83983),h=t(53038),L=t(67879),O=t(94638),C=t(96709),D=t(27649),E=t(82055),f=t(99223),d=t(49372),M=t(41415),x=t(17e3),H=t(72850),te=t(56755),ne=t(73269),le=t(33827),G=t(94547),m=t(19786),N=t(44426),ae=t(3685),oe=t(35658),S=t(87933),y=t(60216),V=t(8471);const $=V.ZP.div`
|
|
2
2
|
background: ${({theme:l})=>l.colors.danger500};
|
|
3
3
|
border: none;
|
|
4
4
|
border-radius: 16px;
|
|
@@ -94,7 +94,7 @@ function persistStagesJoinTables({ strapi }) {
|
|
|
94
94
|
// Persist the stage join table
|
|
95
95
|
const { attributes, tableName } = strapi.db.metadata.get(contentTypeUID);
|
|
96
96
|
const joinTableName = attributes[ENTITY_STAGE_ATTRIBUTE].joinTable.name;
|
|
97
|
-
return { name: joinTableName, dependsOn: { name: tableName } };
|
|
97
|
+
return { name: joinTableName, dependsOn: [{ name: tableName }] };
|
|
98
98
|
};
|
|
99
99
|
|
|
100
100
|
const joinTablesToPersist = pipe([
|
|
@@ -124,6 +124,9 @@ const persistTablesWithPrefix = async (tableNamePrefix) => {
|
|
|
124
124
|
const removePersistedTablesWithSuffix = async (tableNameSuffix) => {
|
|
125
125
|
const tableNameRegex = new RegExp(`.*${tableNameSuffix}$`);
|
|
126
126
|
const tableNames = await findTables({ strapi }, tableNameRegex);
|
|
127
|
+
if (!tableNames.length) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
127
130
|
await removePersistedTables({ strapi }, tableNames);
|
|
128
131
|
};
|
|
129
132
|
|
package/jest.config.front.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/admin",
|
|
3
|
-
"version": "4.10.
|
|
3
|
+
"version": "4.10.2-alpha.0",
|
|
4
4
|
"description": "Strapi Admin",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -48,15 +48,15 @@
|
|
|
48
48
|
"@casl/ability": "^5.4.3",
|
|
49
49
|
"@fingerprintjs/fingerprintjs": "3.3.6",
|
|
50
50
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.10",
|
|
51
|
-
"@strapi/babel-plugin-switch-ee-ce": "4.10.
|
|
52
|
-
"@strapi/data-transfer": "4.10.
|
|
51
|
+
"@strapi/babel-plugin-switch-ee-ce": "4.10.2-alpha.0",
|
|
52
|
+
"@strapi/data-transfer": "4.10.2-alpha.0",
|
|
53
53
|
"@strapi/design-system": "1.6.6",
|
|
54
|
-
"@strapi/helper-plugin": "4.10.
|
|
54
|
+
"@strapi/helper-plugin": "4.10.2-alpha.0",
|
|
55
55
|
"@strapi/icons": "1.6.6",
|
|
56
|
-
"@strapi/permissions": "4.10.
|
|
57
|
-
"@strapi/provider-audit-logs-local": "4.10.
|
|
58
|
-
"@strapi/typescript-utils": "4.10.
|
|
59
|
-
"@strapi/utils": "4.10.
|
|
56
|
+
"@strapi/permissions": "4.10.2-alpha.0",
|
|
57
|
+
"@strapi/provider-audit-logs-local": "4.10.2-alpha.0",
|
|
58
|
+
"@strapi/typescript-utils": "4.10.2-alpha.0",
|
|
59
|
+
"@strapi/utils": "4.10.2-alpha.0",
|
|
60
60
|
"axios": "1.3.4",
|
|
61
61
|
"babel-loader": "^9.1.2",
|
|
62
62
|
"babel-plugin-styled-components": "2.0.2",
|
|
@@ -168,5 +168,5 @@
|
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
},
|
|
171
|
-
"gitHead": "
|
|
171
|
+
"gitHead": "bb1b2273381c3deae0b5bb865e50e8382926bd8c"
|
|
172
172
|
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import React, { useEffect } from 'react';
|
|
2
|
-
import ReactDOM from 'react-dom';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import { useIntl } from 'react-intl';
|
|
5
|
-
import styled, { keyframes } from 'styled-components';
|
|
6
|
-
import { pxToRem } from '@strapi/helper-plugin';
|
|
7
|
-
import { Clock, Refresh } from '@strapi/icons';
|
|
8
|
-
import { Link } from '@strapi/design-system/v2';
|
|
9
|
-
import { Box, Flex, Typography } from '@strapi/design-system';
|
|
10
|
-
import { Content, IconBox, Overlay } from './Overlay';
|
|
11
|
-
|
|
12
|
-
const overlayContainer = document.createElement('div');
|
|
13
|
-
const ID = 'autoReloadOverlayBlocker';
|
|
14
|
-
overlayContainer.setAttribute('id', ID);
|
|
15
|
-
|
|
16
|
-
const rotation = keyframes`
|
|
17
|
-
from {
|
|
18
|
-
transform: rotate(0deg);
|
|
19
|
-
}
|
|
20
|
-
to {
|
|
21
|
-
transform: rotate(359deg);
|
|
22
|
-
}
|
|
23
|
-
`;
|
|
24
|
-
|
|
25
|
-
const LoaderReload = styled(Refresh)`
|
|
26
|
-
animation: ${rotation} 1s infinite linear;
|
|
27
|
-
`;
|
|
28
|
-
|
|
29
|
-
const Blocker = ({ displayedIcon, description, title, isOpen }) => {
|
|
30
|
-
const { formatMessage } = useIntl();
|
|
31
|
-
|
|
32
|
-
useEffect(() => {
|
|
33
|
-
document.body.appendChild(overlayContainer);
|
|
34
|
-
|
|
35
|
-
return () => {
|
|
36
|
-
document.body.removeChild(overlayContainer);
|
|
37
|
-
};
|
|
38
|
-
}, []);
|
|
39
|
-
|
|
40
|
-
if (isOpen) {
|
|
41
|
-
return ReactDOM.createPortal(
|
|
42
|
-
<Overlay>
|
|
43
|
-
<Content direction="column" alignItems="stretch" gap={6}>
|
|
44
|
-
<Flex direction="column" alignItems="stretch" gap={2}>
|
|
45
|
-
<Flex justifyContent="center">
|
|
46
|
-
<Typography as="h1" variant="alpha">
|
|
47
|
-
{formatMessage(title)}
|
|
48
|
-
</Typography>
|
|
49
|
-
</Flex>
|
|
50
|
-
<Flex justifyContent="center">
|
|
51
|
-
<Typography as="h2" textColor="neutral600" fontSize={4} fontWeight="regular">
|
|
52
|
-
{formatMessage(description)}
|
|
53
|
-
</Typography>
|
|
54
|
-
</Flex>
|
|
55
|
-
</Flex>
|
|
56
|
-
<Flex justifyContent="center">
|
|
57
|
-
{displayedIcon === 'reload' && (
|
|
58
|
-
<IconBox padding={6} background="primary100" borderColor="primary200">
|
|
59
|
-
<LoaderReload width={pxToRem(36)} height={pxToRem(36)} />
|
|
60
|
-
</IconBox>
|
|
61
|
-
)}
|
|
62
|
-
|
|
63
|
-
{displayedIcon === 'time' && (
|
|
64
|
-
<IconBox padding={6} background="primary100" borderColor="primary200">
|
|
65
|
-
<Clock width={pxToRem(40)} height={pxToRem(40)} />
|
|
66
|
-
</IconBox>
|
|
67
|
-
)}
|
|
68
|
-
</Flex>
|
|
69
|
-
<Flex justifyContent="center">
|
|
70
|
-
<Box paddingTop={2}>
|
|
71
|
-
<Link href="https://docs.strapi.io" isExternal>
|
|
72
|
-
{formatMessage({
|
|
73
|
-
id: 'global.documentation',
|
|
74
|
-
defaultMessage: 'Read the documentation',
|
|
75
|
-
})}
|
|
76
|
-
</Link>
|
|
77
|
-
</Box>
|
|
78
|
-
</Flex>
|
|
79
|
-
</Content>
|
|
80
|
-
</Overlay>,
|
|
81
|
-
overlayContainer
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return null;
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
Blocker.propTypes = {
|
|
89
|
-
displayedIcon: PropTypes.oneOfType([PropTypes.string, PropTypes.array]).isRequired,
|
|
90
|
-
description: PropTypes.object.isRequired,
|
|
91
|
-
isOpen: PropTypes.bool.isRequired,
|
|
92
|
-
title: PropTypes.object.isRequired,
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
export default Blocker;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import styled from 'styled-components';
|
|
2
|
-
import { Box, Flex } from '@strapi/design-system';
|
|
3
|
-
import { pxToRem } from '@strapi/helper-plugin';
|
|
4
|
-
|
|
5
|
-
const Overlay = styled(Box)`
|
|
6
|
-
position: fixed;
|
|
7
|
-
top: 0;
|
|
8
|
-
right: 0;
|
|
9
|
-
bottom: 0;
|
|
10
|
-
left: 0;
|
|
11
|
-
z-index: 1140;
|
|
12
|
-
&:before {
|
|
13
|
-
content: '';
|
|
14
|
-
position: fixed;
|
|
15
|
-
top: 0;
|
|
16
|
-
right: 0;
|
|
17
|
-
bottom: 0;
|
|
18
|
-
left: 0;
|
|
19
|
-
background: ${({ theme }) => theme.colors.neutral0};
|
|
20
|
-
opacity: 0.9;
|
|
21
|
-
}
|
|
22
|
-
`;
|
|
23
|
-
|
|
24
|
-
const Content = styled(Flex)`
|
|
25
|
-
position: fixed;
|
|
26
|
-
top: 0;
|
|
27
|
-
right: 0;
|
|
28
|
-
bottom: 0;
|
|
29
|
-
left: 0;
|
|
30
|
-
padding-top: ${pxToRem(160)};
|
|
31
|
-
`;
|
|
32
|
-
|
|
33
|
-
const IconBox = styled(Box)`
|
|
34
|
-
border-radius: 50%;
|
|
35
|
-
svg {
|
|
36
|
-
> path {
|
|
37
|
-
fill: ${({ theme }) => theme.colors.primary600} !important;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
`;
|
|
41
|
-
|
|
42
|
-
export { Content, IconBox, Overlay };
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { AutoReloadOverlayBockerContext } from '@strapi/helper-plugin';
|
|
4
|
-
import Blocker from './Blocker';
|
|
5
|
-
|
|
6
|
-
const ELAPSED = 30;
|
|
7
|
-
|
|
8
|
-
const AutoReloadOverlayBlockerProvider = ({ children }) => {
|
|
9
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
10
|
-
const [{ elapsed }, setState] = useState({ elapsed: 0, start: 0 });
|
|
11
|
-
const [config, setConfig] = useState(undefined);
|
|
12
|
-
|
|
13
|
-
const lockAppWithAutoreload = (config = undefined) => {
|
|
14
|
-
setIsOpen(true);
|
|
15
|
-
setConfig(config);
|
|
16
|
-
setState((prev) => ({ ...prev, start: Date.now() }));
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const unlockAppWithAutoreload = () => {
|
|
20
|
-
setIsOpen(false);
|
|
21
|
-
setState({ start: 0, elapsed: 0 });
|
|
22
|
-
setConfig(undefined);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const lockApp = useRef(lockAppWithAutoreload);
|
|
26
|
-
const unlockApp = useRef(unlockAppWithAutoreload);
|
|
27
|
-
|
|
28
|
-
useEffect(() => {
|
|
29
|
-
let timer = null;
|
|
30
|
-
|
|
31
|
-
if (isOpen) {
|
|
32
|
-
timer = setInterval(() => {
|
|
33
|
-
if (elapsed > ELAPSED) {
|
|
34
|
-
clearInterval(timer);
|
|
35
|
-
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
setState((prev) => ({ ...prev, elapsed: Math.round(Date.now() - prev.start) / 1000 }));
|
|
40
|
-
|
|
41
|
-
return null;
|
|
42
|
-
}, 1000);
|
|
43
|
-
} else {
|
|
44
|
-
clearInterval(timer);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return () => {
|
|
48
|
-
clearInterval(timer);
|
|
49
|
-
};
|
|
50
|
-
}, [isOpen, elapsed]);
|
|
51
|
-
|
|
52
|
-
let displayedIcon = config?.icon || 'reload';
|
|
53
|
-
|
|
54
|
-
let description = {
|
|
55
|
-
id: config?.description || 'components.OverlayBlocker.description',
|
|
56
|
-
defaultMessage:
|
|
57
|
-
"You're using a feature that needs the server to restart. Please wait until the server is up.",
|
|
58
|
-
};
|
|
59
|
-
let title = {
|
|
60
|
-
id: config?.title || 'components.OverlayBlocker.title',
|
|
61
|
-
defaultMessage: 'Waiting for restart',
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
if (elapsed > ELAPSED) {
|
|
65
|
-
displayedIcon = 'time';
|
|
66
|
-
|
|
67
|
-
description = {
|
|
68
|
-
id: 'components.OverlayBlocker.description.serverError',
|
|
69
|
-
defaultMessage: 'The server should have restarted, please check your logs in the terminal.',
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
title = {
|
|
73
|
-
id: 'components.OverlayBlocker.title.serverError',
|
|
74
|
-
defaultMessage: 'The restart is taking longer than expected',
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const autoReloadValue = useMemo(() => {
|
|
79
|
-
return { lockApp: lockApp.current, unlockApp: unlockApp.current };
|
|
80
|
-
}, [lockApp, unlockApp]);
|
|
81
|
-
|
|
82
|
-
return (
|
|
83
|
-
<AutoReloadOverlayBockerContext.Provider value={autoReloadValue}>
|
|
84
|
-
<Blocker
|
|
85
|
-
displayedIcon={displayedIcon}
|
|
86
|
-
isOpen={isOpen}
|
|
87
|
-
description={description}
|
|
88
|
-
title={title}
|
|
89
|
-
/>
|
|
90
|
-
{children}
|
|
91
|
-
</AutoReloadOverlayBockerContext.Provider>
|
|
92
|
-
);
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
AutoReloadOverlayBlockerProvider.propTypes = {
|
|
96
|
-
children: PropTypes.element.isRequired,
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export default AutoReloadOverlayBlockerProvider;
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useCallback } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { useIntl } from 'react-intl';
|
|
4
|
-
import { Alert } from '@strapi/design-system';
|
|
5
|
-
import { Link } from '@strapi/design-system/v2';
|
|
6
|
-
|
|
7
|
-
const Notification = ({ dispatch, notification }) => {
|
|
8
|
-
const { formatMessage } = useIntl();
|
|
9
|
-
const { message, link, type, id, onClose, timeout, blockTransition, title } = notification;
|
|
10
|
-
|
|
11
|
-
const formattedMessage = (msg) =>
|
|
12
|
-
typeof msg === 'string' ? msg : formatMessage(msg, msg.values);
|
|
13
|
-
const handleClose = useCallback(() => {
|
|
14
|
-
if (onClose) {
|
|
15
|
-
onClose();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
dispatch({
|
|
19
|
-
type: 'HIDE_NOTIFICATION',
|
|
20
|
-
id,
|
|
21
|
-
});
|
|
22
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
23
|
-
}, [id]);
|
|
24
|
-
|
|
25
|
-
useEffect(() => {
|
|
26
|
-
let timeoutToClear;
|
|
27
|
-
|
|
28
|
-
if (!blockTransition) {
|
|
29
|
-
timeoutToClear = setTimeout(() => {
|
|
30
|
-
handleClose();
|
|
31
|
-
}, timeout || 2500);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return () => clearTimeout(timeoutToClear);
|
|
35
|
-
}, [blockTransition, handleClose, timeout]);
|
|
36
|
-
|
|
37
|
-
let variant;
|
|
38
|
-
let alertTitle;
|
|
39
|
-
|
|
40
|
-
// TODO break out this logic into separate file
|
|
41
|
-
if (type === 'info') {
|
|
42
|
-
variant = 'default';
|
|
43
|
-
alertTitle = formatMessage({
|
|
44
|
-
id: 'notification.default.title',
|
|
45
|
-
defaultMessage: 'Information:',
|
|
46
|
-
});
|
|
47
|
-
} else if (type === 'warning') {
|
|
48
|
-
// type should be renamed to danger in the future, but it might introduce changes if done now
|
|
49
|
-
variant = 'danger';
|
|
50
|
-
alertTitle = formatMessage({
|
|
51
|
-
id: 'notification.warning.title',
|
|
52
|
-
defaultMessage: 'Warning:',
|
|
53
|
-
});
|
|
54
|
-
} else if (type === 'softWarning') {
|
|
55
|
-
// type should be renamed to just warning in the future
|
|
56
|
-
variant = 'warning';
|
|
57
|
-
alertTitle = formatMessage({
|
|
58
|
-
id: 'notification.warning.title',
|
|
59
|
-
defaultMessage: 'Warning:',
|
|
60
|
-
});
|
|
61
|
-
} else {
|
|
62
|
-
variant = 'success';
|
|
63
|
-
alertTitle = formatMessage({
|
|
64
|
-
id: 'notification.success.title',
|
|
65
|
-
defaultMessage: 'Success:',
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (title) {
|
|
70
|
-
alertTitle =
|
|
71
|
-
typeof title === 'string'
|
|
72
|
-
? title
|
|
73
|
-
: formattedMessage({
|
|
74
|
-
id: title?.id || title,
|
|
75
|
-
defaultMessage: title?.defaultMessage || title?.id || title,
|
|
76
|
-
values: title?.values,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<Alert
|
|
82
|
-
action={
|
|
83
|
-
link ? (
|
|
84
|
-
<Link href={link.url} isExternal>
|
|
85
|
-
{formatMessage({
|
|
86
|
-
id: link.label?.id || link.label,
|
|
87
|
-
defaultMessage: link.label?.defaultMessage || link.label?.id || link.label,
|
|
88
|
-
})}
|
|
89
|
-
</Link>
|
|
90
|
-
) : undefined
|
|
91
|
-
}
|
|
92
|
-
onClose={handleClose}
|
|
93
|
-
closeLabel="Close"
|
|
94
|
-
title={alertTitle}
|
|
95
|
-
variant={variant}
|
|
96
|
-
>
|
|
97
|
-
{formattedMessage({
|
|
98
|
-
id: message?.id || message,
|
|
99
|
-
defaultMessage: message?.defaultMessage || message?.id || message,
|
|
100
|
-
values: message?.values,
|
|
101
|
-
})}
|
|
102
|
-
</Alert>
|
|
103
|
-
);
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
Notification.defaultProps = {
|
|
107
|
-
notification: {
|
|
108
|
-
id: 1,
|
|
109
|
-
type: 'success',
|
|
110
|
-
message: {
|
|
111
|
-
id: 'notification.success.saved',
|
|
112
|
-
defaultMessage: 'Saved',
|
|
113
|
-
},
|
|
114
|
-
onClose: () => null,
|
|
115
|
-
timeout: 2500,
|
|
116
|
-
blockTransition: false,
|
|
117
|
-
},
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
Notification.propTypes = {
|
|
121
|
-
dispatch: PropTypes.func.isRequired,
|
|
122
|
-
notification: PropTypes.shape({
|
|
123
|
-
id: PropTypes.number,
|
|
124
|
-
message: PropTypes.oneOfType([
|
|
125
|
-
PropTypes.string,
|
|
126
|
-
PropTypes.shape({
|
|
127
|
-
id: PropTypes.string.isRequired,
|
|
128
|
-
defaultMessage: PropTypes.string,
|
|
129
|
-
values: PropTypes.object,
|
|
130
|
-
}),
|
|
131
|
-
]),
|
|
132
|
-
link: PropTypes.shape({
|
|
133
|
-
target: PropTypes.string,
|
|
134
|
-
url: PropTypes.string.isRequired,
|
|
135
|
-
label: PropTypes.oneOfType([
|
|
136
|
-
PropTypes.string,
|
|
137
|
-
PropTypes.shape({
|
|
138
|
-
id: PropTypes.string.isRequired,
|
|
139
|
-
defaultMessage: PropTypes.string,
|
|
140
|
-
values: PropTypes.object,
|
|
141
|
-
}),
|
|
142
|
-
]).isRequired,
|
|
143
|
-
}),
|
|
144
|
-
type: PropTypes.string,
|
|
145
|
-
onClose: PropTypes.func,
|
|
146
|
-
timeout: PropTypes.number,
|
|
147
|
-
blockTransition: PropTypes.bool,
|
|
148
|
-
title: PropTypes.oneOfType([
|
|
149
|
-
PropTypes.string,
|
|
150
|
-
PropTypes.shape({
|
|
151
|
-
id: PropTypes.string.isRequired,
|
|
152
|
-
defaultMessage: PropTypes.string,
|
|
153
|
-
values: PropTypes.object,
|
|
154
|
-
}),
|
|
155
|
-
]),
|
|
156
|
-
}),
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
export default Notification;
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { NotificationsProvider } from '@strapi/helper-plugin';
|
|
2
|
-
import React, { useReducer } from 'react';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import { Flex } from '@strapi/design-system';
|
|
5
|
-
import Notification from './Notification';
|
|
6
|
-
import reducer, { initialState } from './reducer';
|
|
7
|
-
|
|
8
|
-
const Notifications = ({ children }) => {
|
|
9
|
-
const [{ notifications }, dispatch] = useReducer(reducer, initialState);
|
|
10
|
-
|
|
11
|
-
const displayNotification = (config) => {
|
|
12
|
-
dispatch({
|
|
13
|
-
type: 'SHOW_NOTIFICATION',
|
|
14
|
-
config,
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<NotificationsProvider toggleNotification={displayNotification}>
|
|
20
|
-
<Flex
|
|
21
|
-
left="50%"
|
|
22
|
-
marginLeft="-250px"
|
|
23
|
-
position="fixed"
|
|
24
|
-
direction="column"
|
|
25
|
-
alignItems="stretch"
|
|
26
|
-
gap={2}
|
|
27
|
-
top={`${46 / 16}rem`}
|
|
28
|
-
width={`${500 / 16}rem`}
|
|
29
|
-
zIndex={10}
|
|
30
|
-
>
|
|
31
|
-
{notifications.map((notification) => {
|
|
32
|
-
return (
|
|
33
|
-
<Notification key={notification.id} dispatch={dispatch} notification={notification} />
|
|
34
|
-
);
|
|
35
|
-
})}
|
|
36
|
-
</Flex>
|
|
37
|
-
{children}
|
|
38
|
-
</NotificationsProvider>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
Notifications.propTypes = {
|
|
43
|
-
children: PropTypes.element.isRequired,
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export default Notifications;
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import produce from 'immer';
|
|
2
|
-
import get from 'lodash/get';
|
|
3
|
-
|
|
4
|
-
const initialState = {
|
|
5
|
-
notifId: 0,
|
|
6
|
-
notifications: [],
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
const notificationReducer = (state = initialState, action) =>
|
|
10
|
-
// eslint-disable-next-line consistent-return
|
|
11
|
-
produce(state, (draftState) => {
|
|
12
|
-
switch (action.type) {
|
|
13
|
-
case 'SHOW_NOTIFICATION': {
|
|
14
|
-
draftState.notifications.push({
|
|
15
|
-
// No action.config spread to limit the notification API and avoid customization
|
|
16
|
-
id: state.notifId,
|
|
17
|
-
type: get(action, ['config', 'type'], 'success'),
|
|
18
|
-
message: get(action, ['config', 'message'], {
|
|
19
|
-
id: 'notification.success.saved',
|
|
20
|
-
defaultMessage: 'Saved',
|
|
21
|
-
}),
|
|
22
|
-
link: get(action, ['config', 'link'], null),
|
|
23
|
-
timeout: get(action, ['config', 'timeout'], 2500),
|
|
24
|
-
blockTransition: get(action, ['config', 'blockTransition'], false),
|
|
25
|
-
onClose: get(action, ['config', 'onClose'], null),
|
|
26
|
-
title: get(action, ['config', 'title'], null),
|
|
27
|
-
});
|
|
28
|
-
draftState.notifId = state.notifId + 1;
|
|
29
|
-
break;
|
|
30
|
-
}
|
|
31
|
-
case 'HIDE_NOTIFICATION': {
|
|
32
|
-
const indexToRemove = state.notifications.findIndex((notif) => notif.id === action.id);
|
|
33
|
-
|
|
34
|
-
if (indexToRemove !== -1) {
|
|
35
|
-
draftState.notifications.splice(indexToRemove, 1);
|
|
36
|
-
}
|
|
37
|
-
break;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
default: {
|
|
41
|
-
return draftState;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
export default notificationReducer;
|
|
47
|
-
export { initialState };
|