ode-explorer 1.3.2-develop-pedago.202401251516 → 1.3.2-develop-pedago.202401291510
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ActionBarContainer.js +1 -1
- package/dist/DeleteModal.js +1 -1
- package/dist/FolderModal.js +1 -1
- package/dist/MoveModal.js +1 -1
- package/dist/edifice-react.js +89 -89
- package/dist/index.html +8 -0
- package/dist/index.js +3 -3
- package/dist/version.txt +1 -1
- package/lib/ActionBarContainer.js +168 -157
- package/lib/DeleteModal.js +10 -10
- package/lib/FolderModal.js +8 -8
- package/lib/MoveModal.js +9 -9
- package/lib/index2.js +29 -22
- package/lib/services/api/index.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as U,f as
|
|
1
|
+
import{e as U,f as re,b as ce,h as ae,i as z,j as ie,k as le,l as ue,m as de,d as fe,u as $,a as he,n as pe,o as Re,p as Ee,q as Se,_ as y}from"./index.js";import{f as me,j as o,B as Y,w as _e,x as Oe,y as ye,L as ve}from"./edifice-react.js";import{r as p,u as q}from"./react.js";import{odeServices as P,ACTION as d}from"/assets/js/edifice-ts-client/index.js";import"./edifice-icons.js";function Ae({roles:l,rights:e,action:r}){const[u,t]=p.useState(!1),{user:m}=me(),R=U();p.useEffect(()=>{S()},[l,e]);const f=async function(a){const n=a instanceof Array?a:[a];if(l instanceof Array){const E=await P.rights().sessionHasAtLeastOneResourceRight(l,n);t(E)}else{const E=await P.rights().sessionHasResourceRight(l,n);t(E)}},c=async function(a){if(l instanceof Array){const n=await P.rights().sessionHasAtLeastOneResourceRightForEachList(l,a);t(n)}else{const n=await P.rights().sessionHasResourceRightForEachList(l,a);t(n)}},S=async function(){var a,n,E;if(l===void 0){t(!0);return}if(R&&((n=(a=e[0])==null?void 0:a.trashedBy)!=null&&n.includes(m==null?void 0:m.userId))&&r==="restore"&&!((E=e[0])!=null&&E.trashed)){t(!0);return}if(e instanceof Array)if(e.length>0)if(typeof e[0]=="string")await f(e);else{const v=e.map(_=>_.rights);await c(v)}else t(!1);else typeof e=="string"?await f(e):await f(e.rights)};return{visible:u,refreshState:S}}function G(){const[l,e]=p.useState(!1),[r,u]=p.useState("void"),[t,m]=p.useState(),R=re(s=>s.config),f=ce(),c=ae(),S=z(),a=ie(),n=le(),E=U(),v=ue(),_=de(),I=fe(),{openResource:g,printSelectedResource:M,openFolder:w,clearSelectedItems:F,clearSelectedIds:T}=$(),{data:j}=he();p.useEffect(()=>{if(c.length===0&&n.length===0){e(!1);return}if(_){e(!1);return}e(!0)},[c,n]);async function L(s){var b;switch((b=document.getElementById("root"))==null||b.setAttribute("aria-hidden","true"),m(s),s.id){case d.OPEN:return c.length>0?g(S[0]):w({folder:a[0],folderId:a[0].id});case d.MOVE:return u("move");case d.PRINT:return M();case d.DELETE:return u("delete");case d.RESTORE:return await O();case d.PUBLISH:return u("publish");case d.UPD_PROPS:case"edit":return te();case"export":return ne();case d.SHARE:return u("share");default:throw Error(`Unknown action: ${s.id}`)}}function D(s){const b=c.length+n.length,C=c.length===1||n.length===1,V=b===1,x=n.length===0;switch(s.id){case d.OPEN:return V;case d.MANAGE:return C;case d.PUBLISH:return C&&x;case d.UPD_PROPS:return C&&x;case d.SHARE:return x&&C;case d.PRINT:return C&&x;case"edit":return V;default:return!0}}const B=()=>!0;async function O(){try{if(E)await v.mutate();else throw new Error("Cannot restore untrashed resources");A()}catch(s){console.error(s)}}function A(){var s;u("void"),t!=null&&t.id&&((s=document.getElementById(t==null?void 0:t.id))==null||s.focus())}const i=s=>()=>{r===s&&(A(),F(),T())},N=i("move"),k=i("move"),H=i("delete"),h=i("delete"),J=i("publish"),K=i("publish"),Q=i("edit_folder"),X=i("edit_folder"),Z=i("edit_resource"),W=i("edit_resource"),ee=i("share"),se=i("share");function te(){if(c&&c.length>0){const s=S[0].assetId;(R==null?void 0:R.app)=="scrapbook"?pe({searchParams:I,assetId:s}):u("edit_resource")}else u("edit_folder")}function ne(){if(c&&c.length>0){const s=S[0].assetId;Re({searchParams:I,assetId:s})}}function oe(s){return s.id==="edit"&&n.length>0?"explorer.rename":`explorer.actions.${s.id}`}return{onRestore:O,actions:E?R==null?void 0:R.trashActions:j,selectedElement:[...S,...a],currentFolderId:f==null?void 0:f.id,overrideLabel:oe,handleClick:L,isActivable:E?B:D,isActionBarOpen:l,isMoveModalOpen:r==="move",onMoveCancel:N,onMoveSuccess:k,isDeleteModalOpen:r==="delete",onDeleteCancel:h,onDeleteSuccess:H,isPublishModalOpen:r==="publish",onPublishCancel:K,onPublishSuccess:J,isEditFolderOpen:r==="edit_folder",onEditFolderCancel:X,onEditFolderSuccess:Q,isEditResourceOpen:r==="edit_resource",onEditResourceCancel:W,onEditResourceSuccess:Z,isShareResourceOpen:r==="share",onShareResourceCancel:se,onShareResourceSuccess:ee,onClearActionBar:A}}function Ce({resourceRights:l,roleExpected:e,action:r,children:u,renderWhenForbidden:t}){const{t:m}=q(),{overrideLabel:R}=G(),{visible:f}=Ae({roles:e,rights:l,action:r==null?void 0:r.id}),{setResourceActionDisable:c}=$(),S=U();return f?o.jsx(o.Fragment,{children:u}):t?t():S&&!f?o.jsx(Y,{type:"button",color:"primary",variant:"filled",onClick:()=>{c(!0)},children:m(R(r))}):o.jsx(o.Fragment,{})}const Ie=p.lazy(async()=>await y(()=>import("./ShareModal.js"),["ShareModal.js","edifice-react.js","react.js","edifice-icons.js"])),be=p.lazy(async()=>await y(()=>import("./PublishModal.js"),["PublishModal.js","edifice-react.js","react.js","edifice-icons.js"])),xe=p.lazy(async()=>await y(()=>import("./ResourceModal.js"),["ResourceModal.js","edifice-react.js","react.js","edifice-icons.js"])),Pe=p.lazy(async()=>await y(()=>import("./DeleteModal.js"),["DeleteModal.js","edifice-react.js","react.js","edifice-icons.js","index.js"])),ge=p.lazy(async()=>await y(()=>import("./MoveModal.js"),["MoveModal.js","edifice-react.js","react.js","edifice-icons.js","index.js"])),Me=p.lazy(async()=>await y(()=>import("./FolderModal.js"),["FolderModal.js","edifice-react.js","react.js","edifice-icons.js","index.js"]));function De(){const{t:l}=q(),{actions:e,selectedElement:r,isMoveModalOpen:u,isDeleteModalOpen:t,isPublishModalOpen:m,isActionBarOpen:R,isEditFolderOpen:f,overrideLabel:c,onEditFolderCancel:S,onEditFolderSuccess:a,isEditResourceOpen:n,onEditResourceCancel:E,onEditResourceSuccess:v,isShareResourceOpen:_,onShareResourceCancel:I,onShareResourceSuccess:g,onMoveCancel:M,onMoveSuccess:w,onDeleteCancel:F,onDeleteSuccess:T,onPublishCancel:j,onPublishSuccess:L,isActivable:D,handleClick:B}=G(),O=z(),A=Ee(),i=Se(),N=_e(R,{from:{opacity:0,transform:"translateY(100%)"},enter:{opacity:1,transform:"translateY(0)"},leave:{opacity:0,transform:"translateY(100%)"}});return o.jsxs(o.Fragment,{children:[N((k,H)=>H&&o.jsx(Oe.div,{className:"position-fixed bottom-0 start-0 end-0 z-3",style:k,children:o.jsx(ye,{children:e==null?void 0:e.filter(h=>h.available&&h.target==="actionbar").map(h=>D(h)&&o.jsx(Ce,{resourceRights:r,roleExpected:h.right,action:h,children:o.jsx(Y,{id:h.id,type:"button",color:"primary",variant:"filled",onClick:()=>{B(h)},children:l(c(h))},h.id)},h.id))})})),o.jsxs(p.Suspense,{fallback:o.jsx(ve,{}),children:[u&&o.jsx(ge,{isOpen:u,onCancel:M,onSuccess:w}),t&&o.jsx(Pe,{isOpen:t,onCancel:F,onSuccess:T}),m&&o.jsx(be,{isOpen:m,resource:O[0],onCancel:j,onSuccess:L}),f&&o.jsx(Me,{edit:!0,isOpen:f,onCancel:S,onSuccess:a}),n&&o.jsx(xe,{mode:"update",actions:e,isOpen:n,selectedResource:O[0],updateResource:i,onCancel:E,onSuccess:v}),_&&o.jsx(Ie,{isOpen:_,resource:O[0],updateResource:i,shareResource:A,onCancel:I,onSuccess:g})]})]})}export{De as default};
|
package/dist/DeleteModal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as t,M as a,B as n}from"./edifice-react.js";import{u as d,a as c}from"./react.js";import{
|
|
1
|
+
import{j as t,M as a,B as n}from"./edifice-react.js";import{u as d,a as c}from"./react.js";import{t as p,v as x,e as h}from"./index.js";import"/assets/js/edifice-ts-client/index.js";import"./edifice-icons.js";function m({onSuccess:r}){const s=p(),o=x(),e=h();async function l(){try{e?await s.mutate():await o.mutate(),r==null||r()}catch(i){console.error(i)}}return{isTrashFolder:e,onDelete:l}}function D({isOpen:r,onSuccess:s=()=>({}),onCancel:o=()=>({})}){const{t:e}=d(),{isTrashFolder:l,onDelete:i}=m({onSuccess:s});return c.createPortal(t.jsxs(a,{isOpen:r,onModalClose:o,id:"deleteModal",children:[t.jsx(a.Header,{onModalClose:o,children:e(l?"explorer.delete.title":"explorer.trash.title")}),t.jsx(a.Body,{children:t.jsx("p",{className:"body",children:e(l?"explorer.delete.subtitle":"explorer.trash.subtitle")})}),t.jsxs(a.Footer,{children:[t.jsx(n,{color:"tertiary",onClick:o,type:"button",variant:"ghost",children:e("explorer.cancel")}),t.jsx(n,{color:"danger",onClick:i,type:"button",variant:"filled",children:e(l?"explorer.delete":"explorer.trash")})]})]}),document.getElementById("portal"))}export{D as default};
|
package/dist/FolderModal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as r,M as i,F as D,W as
|
|
1
|
+
import{j as r,M as i,F as D,W as B,h as q,B as y}from"./edifice-react.js";import{e as L,r as C,u as R,a as w}from"./react.js";import{FOLDER as T}from"/assets/js/edifice-ts-client/index.js";import{j as U,b as V,r as _,s as k}from"./index.js";import"./edifice-icons.js";function z({edit:o,onSuccess:e,onClose:m}){var F;const l=U(),t=V(),c=_(),u=k(),f=o?(F=l[0])==null?void 0:F.name:void 0,{reset:a,register:p,handleSubmit:n,setFocus:x,formState:{errors:h,isSubmitting:s,isDirty:I,isValid:g}}=L({mode:"onChange",values:{name:f||""}}),E=C.useId(),M=async function({name:j}){var b;try{if(o){const d=(b=l[0])==null?void 0:b.parentId,$=l[0].id;await u.mutate({folderId:$,parentId:d,name:j}),a(),e==null||e()}else{const d=(t==null?void 0:t.id)||T.DEFAULT;await c.mutate({name:j,parentId:d}),a(),e==null||e()}}catch(d){console.error(d)}};function v(){a(),m()}return{formId:`createModal_${E}`,errors:h,isSubmitting:s,isDirty:I,isValid:g,register:p,setFocus:x,handleSubmit:n,onCancel:v,onSubmit:M}}function N({isOpen:o,edit:e,onSuccess:m,onCancel:l}){const{t}=R(),{isDirty:c,isValid:u,isSubmitting:f,formId:a,onSubmit:p,onCancel:n,handleSubmit:x,register:h,setFocus:s}=z({edit:e,onSuccess:m,onClose:l});return C.useEffect(()=>{o&&s("name")},[o,s]),o?w.createPortal(r.jsxs(i,{isOpen:o,onModalClose:n,id:"modal_"+a,children:[r.jsx(i.Header,{onModalClose:n,children:t(e?"explorer.rename.folder":"explorer.create.folder")}),r.jsx(i.Body,{children:r.jsx("form",{id:a,onSubmit:x(p),children:r.jsxs(D,{id:"nameFolder",isRequired:!0,children:[r.jsx(B,{children:t("explorer.create.folder.name")}),r.jsx(q,{type:"text",...h("name",{required:!0,pattern:{value:/[^ ]/,message:"invalid title"}}),placeholder:t("explorer.create.folder.name"),size:"md","aria-required":!0})]})})}),r.jsxs(i.Footer,{children:[r.jsx(y,{color:"tertiary",onClick:n,type:"button",variant:"ghost",children:t("explorer.cancel")}),r.jsx(y,{form:a,type:"submit",color:"primary",variant:"filled",disabled:!c||!u||f,children:t(e?"explorer.rename":"explorer.create")})]})]}),document.getElementById("portal")):null}export{N as default};
|
package/dist/MoveModal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{d as
|
|
1
|
+
import{d as I,j as o,M as n,T as v,B as x}from"./edifice-react.js";import{r as T,u as M,a as y}from"./react.js";import{w as j,j as b,i as F,u as w,x as S}from"./index.js";import"/assets/js/edifice-ts-client/index.js";import"./edifice-icons.js";function E({onSuccess:a}){const[s,r]=T.useState(),l=j(),d=b(),i=F(),{foldTreeItem:c,unfoldTreeItem:m}=w(),u=I();async function f(){try{if(!s)throw new Error("explorer.move.selection.empty");await l.mutate(s),await(a==null?void 0:a())}catch(e){console.error(e)}}const h=e=>{var p;for(const t of d)if(e===t.id||e===t.parentId)return!1;for(const t of i)if(e===((t==null?void 0:t.folderIds)&&t.folderIds[0])||((p=t==null?void 0:t.folderIds)==null?void 0:p.length)===0&&e==="default")return!1;return!0};return{disableSubmit:!s,handleTreeItemSelect:e=>{h(e)?r(e):r(void 0)},handleTreeItemFold:c,handleTreeItemUnfold:async e=>await m(e,u),onMove:()=>{f()}}}function $({isOpen:a,onSuccess:s,onCancel:r}){const{t:l}=M(),{handleTreeItemFold:d,handleTreeItemSelect:i,handleTreeItemUnfold:c,onMove:m,disableSubmit:u}=E({onSuccess:s}),f=S();return y.createPortal(o.jsxs(n,{isOpen:a,onModalClose:r,id:"moveModal",children:[o.jsx(n.Header,{onModalClose:r,children:l("explorer.move.title")}),o.jsx(n.Subtitle,{children:l("explorer.move.subtitle")}),o.jsx(n.Body,{children:o.jsx(v,{data:f,onTreeItemSelect:i,onTreeItemFold:d,onTreeItemUnfold:c})}),o.jsxs(n.Footer,{children:[o.jsx(x,{color:"tertiary",onClick:r,type:"button",variant:"ghost",children:l("explorer.cancel")}),o.jsx(x,{color:"primary",onClick:m,type:"button",variant:"filled",disabled:u,children:l("explorer.move")})]})]}),document.getElementById("portal"))}export{$ as default};
|