ode-explorer 1.0.2-dev.202309281447 → 1.0.3-dev.202310031837

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.
@@ -1 +1 @@
1
- import{r,g as G,j as e,d as ce,u as ae,h as be,i as ye,k as je,l as de,m as ve,n as Se,o as Ne,p as ee,A as we,a as Ie,M as O,V as Y,q as oe,B as L,s as ie,t as Be,v as Ae,F as Z,w as Ce,x as Re,y as Me,z as Te,C as $e}from"./index.js";import{odeServices as E,APP as Ee}from"/assets/js/edifice-ts-client/index.js";import{H as se}from"./Heading.js";import{T as Pe}from"./Tooltip.js";function Fe(){const[h,m]=r.useState(!1);r.useEffect(()=>{u()},[]);const u=r.useCallback(async()=>{const p=await E.session().isAdml();m(p)},[]);return{isAdml:h}}const he=r.forwardRef(({label:h,disabled:m=!1,checked:u=!1,indeterminate:p=!1,...d},v)=>{const f=r.useRef(null);r.useImperativeHandle(v,()=>({...f.current})),r.useEffect(()=>{f.current.indeterminate=p},[f,p]);const S=r.useId(),i={type:"checkbox",checked:u,disabled:m,ref:f,className:G(d.className,"form-check-input c-pointer"),id:S},x={...d,...i};return e.jsxs("div",{className:"form-check d-flex align-items-center gap-8",children:[e.jsx("input",{...x}),h&&e.jsx("label",{className:"form-check-label",htmlFor:x.id,children:h})]})});he.displayName="Checkbox";const ne=he,ue=r.forwardRef(({model:h,icon:m,label:u=!1,disabled:p=!1,...d},v)=>{const f=r.useMemo(()=>d.id?d.id:(Math.floor(Math.random()*999999999999)+1e12).toString(),[d.id]),i={...{type:"radio",checked:h===d.value,disabled:p,ref:v,className:G(d.className,"form-check-input c-pointer",m&&"d-none"),id:f},...d};return e.jsxs("div",{className:G("form-check d-flex align-items-center gap-8",m&&"ps-0"),children:[e.jsx("input",{...i}),m&&e.jsx("label",{htmlFor:i.id,className:G("c-pointer",h!==d.value&&"text-muted"),children:m}),!m&&u&&e.jsx("label",{className:"form-check-label",htmlFor:i.id,children:u})]})});ue.displayName="Radio";const le=ue;function Ue({radioPublicationValue:h,onRadioPublicationChange:m}){const{appCode:u}=ce(),{t:p}=ae(u);return e.jsxs(e.Fragment,{children:[e.jsx("hr",{}),e.jsx(se,{headingStyle:"h4",level:"h3",className:"mb-16",children:p("explorer.publication.steps")}),e.jsx(le,{label:p("explorer.immediat.publication"),id:"publication-now",name:"publication",value:"IMMEDIATE",model:h,onChange:d=>m(d.target.value)}),e.jsx(le,{label:p("explorer.validate.publication"),id:"publication-validate",name:"publication",value:"RESTRAINT",model:h,onChange:d=>m(d.target.value)})]})}function ze({radioPublicationValue:h,onRadioPublicationChange:m}){const{app:u}=be();return u===Ee.BLOG?e.jsx(Ue,{radioPublicationValue:h,onRadioPublicationChange:m}):e.jsx(e.Fragment,{})}function De({onSuccess:h,payloadUpdatePublishType:m}){const{appCode:u}=ce(),{t:p}=ae(),{user:d,avatar:v}=ye(),[f,S]=r.useState(r.useId()),[i,x]=r.useState({rights:[],visibleBookmarks:[],visibleGroups:[],visibleUsers:[]}),[y,N]=r.useState([]),[P,H]=r.useState(""),[w,V]=r.useState(!1),[C,W]=r.useState(""),I=je(C,500),[_,J]=r.useState([]),[R,F]=r.useState([]),[U,K]=r.useState(!1),[M,q]=r.useState(!1),{isAdml:B}=Fe(),A=de(),Q=ve(),X=Se(),{hotToast:n}=Ne(we);r.useEffect(()=>{z()},[]),r.useEffect(()=>{fe(I)},[I]);const z=r.useCallback(async()=>{var a;const t=await E.share().getActionsForApp(u);N(t);const c=await E.share().getRightsForResource(u,(a=A[0])==null?void 0:a.assetId);x(c)},[]),l=(t,c)=>{x(({rights:a,...g})=>{var te,re;const s=[...a],o=s.findIndex(k=>k.id===t.id),T=y.filter(k=>k.id===c)[0];if(s[o].actions.findIndex(k=>k.id===c)>-1){let k=s[o].actions.filter(b=>b.id!==c);const j=y.filter(b=>{var $;return($=b.requires)==null?void 0:$.includes(c)});k=k.filter(b=>!j.find($=>$.id===b.id)),s[o]={...s[o],actions:k}}else{const k=y.filter(j=>{var b;return((b=T.requires)==null?void 0:b.includes(j.id))&&!s[o].actions.find($=>$.id===j.id)});s[o]={...s[o],actions:[...s[o].actions,T,...k]}}return t.type==="sharebookmark"&&((te=s[o].users)==null||te.forEach(k=>{const j=s.findIndex(b=>b.id===k.id);s[j]={...s[j],actions:s[o].actions}}),(re=s[o].groups)==null||re.forEach(k=>{const j=s.findIndex(b=>b.id===k.id);s[j]={...s[j],actions:s[o].actions}})),{rights:s,...g}})},D=async()=>{var t;try{await Q.mutateAsync(m),await X.mutateAsync({entId:(t=A[0])==null?void 0:t.assetId,shares:i.rights}),n.success(p("explorer.shared.status.saved")),h==null||h()}catch(c){console.error("Failed to save share",c),n.error(p("explorer.shared.status.error"))}},me=t=>{x(c=>({...c,rights:i.rights.filter(a=>{var g,s;return a.id!==t.id&&!((g=t.users)!=null&&g.find(o=>o.id===a.id))&&!((s=t.groups)!=null&&s.find(o=>o.id===a.id))})}))},pe=t=>{W(t.target.value)},xe=()=>!M&&!B&&I.length>0&&R.length===0||!M&&B&&I.length>3&&R.length===0,ke=()=>B&&C.length<3,ge=()=>M&&C.length>0,fe=async t=>{var c;if(q(!0),!B&&t.length>=1||B&&t.length>=3){const a=await E.share().searchShareSubjects(u,(c=A[0])==null?void 0:c.assetId,t);J(a);const g=a.filter(s=>!i.rights.find(o=>o.id===s.id)).filter(s=>!(s.type==="user"&&s.id===A[0].creatorId)).map(s=>({value:s.id,label:s.displayName,icon:s.type==="sharebookmark"?ee:null}));F(g)}else F([]),Promise.resolve();q(!1)};return{currentIsAuthor:()=>{for(const t of A)if(t.creatorId!==(d==null?void 0:d.userId))return!1;return!0},idBookmark:f,myAvatar:v,shareRights:i,shareRightActions:y,showBookmarkInput:w,searchInputValue:C,searchResults:R,bookmarkName:P,showBookmarkMembers:U,debouncedSearchInputValue:I,searchPending:M,setBookmarkName:H,saveBookmark:async t=>{try{const c=await E.directory().saveBookmarks(t,{users:i.rights.filter(a=>a.type==="user").map(a=>a.id),groups:i.rights.filter(a=>a.type==="group").map(a=>a.id),bookmarks:i.rights.filter(a=>a.type==="sharebookmark").map(a=>a.id)});n.success(p("explorer.bookmarked.status.saved")),x(a=>({...a,visibleBookmarks:[...a.visibleBookmarks,{displayName:t,id:c.id}]})),S(f+new Date().getTime().toString()),V(!1)}catch(c){console.error("Failed to save bookmark",c),n.error(p("explorer.bookmarked.status.error"))}},canSave:()=>!0,toggleBookmarkInput:V,handleActionCheckbox:l,handleShare:D,handleDeleteRow:me,handleSearchInputChange:pe,handleSearchResultsChange:async t=>{const c=_.find(g=>g.id===t[0]),a=[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}];if(c){let g=[];if(c.type==="sharebookmark"){const s=await E.directory().getBookMarkById(c.id);g.push({...s,type:"sharebookmark",avatarUrl:"",directoryUrl:"",actions:a}),s==null||s.users.filter(o=>!i.rights.find(T=>T.id===o.id)).forEach(o=>{g.push({...o,type:"user",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})}),s.groups.filter(o=>!i.rights.find(T=>T.id===o.id)).forEach(o=>{g.push({...o,type:"group",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})})}else g=[{...c,actions:[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}]}];x({...i,rights:[...i.rights,...g]}),F(R.filter(s=>s.value!==t[0]))}},showSearchNoResults:xe,showSearchAdmlHint:ke,showSearchLoading:ge,handleBookmarkMembersToggle:()=>{K(!U)},hasRight:(t,c)=>t.actions.filter(a=>c.id===a.id).length>0,showShareRightLine:t=>t.isBookmarkMember&&U||!t.isBookmarkMember}}function Le(){const h=de(),{assetId:m,description:u,thumbnail:p,name:d,public:v,trashed:f,slug:S,"publish-type":i}=h.length>0?h[0]:{"publish-type":"",assetId:"",description:"",name:"",public:!1,slug:"",thumbnail:"",trashed:!1},[x,y]=r.useState(i||"RESTRAINT"),[N,P]=r.useState({description:u||"",entId:m,name:d,public:!!v,slug:S||"",thumbnail:p,trashed:f,"publish-type":i});return r.useEffect(()=>{x&&P(w=>({...w,"publish-type":x}))},[x]),{radioPublicationValue:x,payloadUpdatePublishType:N,handleRadioPublicationChange:async w=>{y(w)}}}function Ze({isOpen:h,onSuccess:m,onCancel:u}){const{payloadUpdatePublishType:p,radioPublicationValue:d,handleRadioPublicationChange:v}=Le(),{myAvatar:f,idBookmark:S,shareRights:i,shareRightActions:x,showBookmarkInput:y,searchResults:N,bookmarkName:P,showBookmarkMembers:H,searchPending:w,currentIsAuthor:V,setBookmarkName:C,saveBookmark:W,canSave:I,toggleBookmarkInput:_,handleActionCheckbox:J,handleShare:R,handleDeleteRow:F,handleSearchInputChange:U,handleSearchResultsChange:K,showSearchNoResults:M,showSearchAdmlHint:q,showSearchLoading:B,handleBookmarkMembersToggle:A,hasRight:Q,showShareRightLine:X}=De({payloadUpdatePublishType:p,onSuccess:m,onCancel:u}),{t:n}=ae(),z=r.useRef(null);return Ie.createPortal(e.jsxs(O,{id:"share_modal",size:"lg",isOpen:h,onModalClose:u,children:[e.jsx(O.Header,{onModalClose:u,children:n("share.title")}),e.jsxs(O.Body,{children:[e.jsx(se,{headingStyle:"h4",level:"h3",className:"mb-16",children:n("explorer.modal.share.usersWithAccess")}),e.jsx("div",{className:"table-responsive",children:e.jsxs("table",{className:"table border align-middle mb-0",children:[e.jsx("thead",{className:"bg-secondary",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"w-32",children:e.jsx(Y,{children:n("explorer.modal.share.avatar.shared.alt")})}),e.jsx("th",{scope:"col",children:e.jsx(Y,{children:n("explorer.modal.share.search.placeholder")})}),x.map(l=>e.jsx("th",{scope:"col",className:"text-center text-white",children:n(l.displayName)},l.displayName)),e.jsx("th",{scope:"col",children:e.jsx(Y,{children:n("close")})})]})}),e.jsxs("tbody",{children:[V()&&e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:e.jsx(oe,{alt:n("explorer.modal.share.avatar.me.alt"),size:"xs",src:f,variant:"circle"})}),e.jsx("td",{children:n("share.me")}),x.map(l=>e.jsx("td",{style:{width:"80px"},className:"text-center text-white",children:e.jsx(ne,{checked:!0,disabled:!0})},l.displayName)),e.jsx("td",{})]}),i==null?void 0:i.rights.map(l=>X(l)&&e.jsxs("tr",{className:l.isBookmarkMember?"bg-light":"",children:[e.jsxs("td",{children:[l.type!=="sharebookmark"&&e.jsx(oe,{alt:n("explorer.modal.share.avatar.shared.alt"),size:"xs",src:l.avatarUrl,variant:"circle"}),l.type==="sharebookmark"&&e.jsx(ee,{})]}),e.jsx("td",{children:e.jsxs("div",{className:"d-flex",children:[l.type==="sharebookmark"&&e.jsx(L,{color:"tertiary",rightIcon:e.jsx(ie,{title:"Show",className:"w-16 min-w-0",style:{transition:"rotate 0.2s ease-out",rotate:H?"-180deg":"0deg"}}),type:"button",variant:"ghost",className:"fw-normal ps-0",onClick:A,children:l.displayName}),l.type!=="sharebookmark"&&l.displayName]})}),x.map(D=>e.jsx("td",{style:{width:"80px"},className:"text-center text-white",children:e.jsx(ne,{checked:Q(l,D),onChange:()=>J(l,D.id)})},D.displayName)),e.jsx("td",{children:!l.isBookmarkMember&&e.jsx(Be,{"aria-label":"Delete",color:"tertiary",icon:e.jsx(Ae,{}),type:"button",variant:"ghost",title:"Delete",onClick:()=>F(l)})})]},l.id))]})]})}),e.jsxs("div",{className:"mt-16",children:[e.jsx(L,{color:"tertiary",leftIcon:e.jsx(ee,{}),rightIcon:e.jsx(ie,{title:"Show",className:"w-16 min-w-0",style:{transition:"rotate 0.2s ease-out",rotate:y?"-180deg":"0deg"}}),type:"button",variant:"ghost",className:"fw-normal",onClick:()=>_(!y),children:n("share.save.sharebookmark")}),y&&e.jsx("div",{className:"mt-16",children:e.jsxs(Z,{id:"bookmarkName",className:"d-flex flex-wrap align-items-center gap-16",children:[e.jsx("div",{className:"flex-fill",children:e.jsx(Z.Input,{ref:z,onChange:()=>{C(()=>{var l;return((l=z.current)==null?void 0:l.value)||""})},placeholder:n("explorer.modal.share.sharebookmark.placeholder"),size:"sm",type:"text"},S)}),e.jsx(L,{type:"button",color:"primary",variant:"ghost",disabled:P.length===0,leftIcon:e.jsx(Ce,{}),onClick:()=>{W(z.current.value)},className:"text-nowrap",children:n("explorer.modal.share.sharebookmark.save")})]})})]}),e.jsx("hr",{}),e.jsxs(se,{headingStyle:"h4",level:"h3",className:"mb-16 d-flex align-items-center",children:[e.jsx("div",{className:"me-8",children:n("explorer.modal.share.search")}),e.jsx(Pe,{message:"Vos favoris de partage s’affichent en priorité dans votre liste lorsque vous recherchez un groupe ou une personne, vous pouvez les retrouver dans l’annuaire.",placement:"top",children:e.jsx(Re,{className:"c-pointer",height:"18"})})]}),e.jsxs(Z,{className:"d-flex align-items-center",id:"search",children:[e.jsx(Me,{className:"max-w-512",noValidationIcon:!0,placeholder:q()?n("explorer.search.adml.hint"):n("explorer.modal.share.search.placeholder"),size:"md",type:"search",onChange:U}),B()&&e.jsxs("div",{className:"d-flex align-items-center p-4",children:[e.jsx(Te,{isLoading:w}),e.jsx("span",{className:"ps-4",children:n("explorer.search.pending")})]}),M()&&e.jsx("div",{className:"p-4",children:n("portal.no.result")})]}),(N==null?void 0:N.length)>0&&e.jsx("div",{className:"position-absolute w-100 max-w-512 z-1 bg-white shadow rounded-4 d-block show py-12 px-8",children:e.jsx($e,{options:N,hideCheckbox:!0,isMonoSelection:!0,onChange:K})}),e.jsx(ze,{radioPublicationValue:d,onRadioPublicationChange:v})]}),e.jsxs(O.Footer,{children:[e.jsx(L,{type:"button",color:"tertiary",variant:"ghost",onClick:u,children:n("explorer.cancel")}),e.jsx(L,{type:"button",color:"primary",variant:"filled",onClick:R,disabled:!I(),children:n("share")})]})]}),document.getElementById("portal"))}export{Ze as default};
1
+ import{r,g as G,j as e,d as ce,u as ae,h as be,i as ye,k as je,l as de,m as ve,n as Se,o as Ne,p as ee,A as we,a as Ie,M as O,V as Y,q as oe,B as L,s as ne,t as Ae,v as Be,F as Z,w as Re,x as Ce,y as Me,z as Te,C as Ee}from"./index.js";import{odeServices as $,APP as $e}from"/assets/js/edifice-ts-client/index.js";import{H as se}from"./Heading.js";import{T as Fe}from"./Tooltip.js";function Pe(){const[d,m]=r.useState(!1);r.useEffect(()=>{u()},[]);const u=r.useCallback(async()=>{const p=await $.session().isAdml();m(p)},[]);return{isAdml:d}}const he=r.forwardRef(({label:d,disabled:m=!1,checked:u=!1,indeterminate:p=!1,...h},v)=>{const f=r.useRef(null);r.useImperativeHandle(v,()=>({...f.current})),r.useEffect(()=>{f.current.indeterminate=p},[f,p]);const S=r.useId(),n={type:"checkbox",checked:u,disabled:m,ref:f,className:G(h.className,"form-check-input c-pointer"),id:S},x={...h,...n};return e.jsxs("div",{className:"form-check d-flex align-items-center gap-8",children:[e.jsx("input",{...x}),d&&e.jsx("label",{className:"form-check-label",htmlFor:x.id,children:d})]})});he.displayName="Checkbox";const le=he,ue=r.forwardRef(({model:d,icon:m,label:u=!1,disabled:p=!1,...h},v)=>{const f=r.useMemo(()=>h.id?h.id:(Math.floor(Math.random()*999999999999)+1e12).toString(),[h.id]),n={...{type:"radio",checked:d===h.value,disabled:p,ref:v,className:G(h.className,"form-check-input c-pointer",m&&"d-none"),id:f},...h};return e.jsxs("div",{className:G("form-check d-flex align-items-center gap-8",m&&"ps-0"),children:[e.jsx("input",{...n}),m&&e.jsx("label",{htmlFor:n.id,className:G("c-pointer",d!==h.value&&"text-muted"),children:m}),!m&&u&&e.jsx("label",{className:"form-check-label",htmlFor:n.id,children:u})]})});ue.displayName="Radio";const ie=ue;function Ue({radioPublicationValue:d,onRadioPublicationChange:m}){const{appCode:u}=ce(),{t:p}=ae(u);return e.jsxs(e.Fragment,{children:[e.jsx("hr",{}),e.jsx(se,{headingStyle:"h4",level:"h3",className:"mb-16",children:p("explorer.publication.steps")}),e.jsx(ie,{label:p("explorer.immediat.publication"),id:"publication-now",name:"publication",value:"IMMEDIATE",model:d,checked:d==="IMMEDIATE",onChange:h=>m(h.target.value)}),e.jsx(ie,{label:p("explorer.validate.publication"),id:"publication-validate",name:"publication",value:"RESTRAINT",checked:d==="RESTRAINT",model:d,onChange:h=>m(h.target.value)})]})}function De({radioPublicationValue:d,onRadioPublicationChange:m}){const{app:u}=be();return u===$e.BLOG?e.jsx(Ue,{radioPublicationValue:d,onRadioPublicationChange:m}):e.jsx(e.Fragment,{})}function ze({onSuccess:d,payloadUpdatePublishType:m}){const{appCode:u}=ce(),{t:p}=ae(),{user:h,avatar:v}=ye(),[f,S]=r.useState(r.useId()),[n,x]=r.useState({rights:[],visibleBookmarks:[],visibleGroups:[],visibleUsers:[]}),[y,N]=r.useState([]),[F,H]=r.useState(""),[w,q]=r.useState(!1),[R,W]=r.useState(""),I=je(R,500),[_,J]=r.useState([]),[C,P]=r.useState([]),[U,K]=r.useState(!1),[M,V]=r.useState(!1),{isAdml:A}=Pe(),B=de(),Q=ve(),X=Se(),{hotToast:l}=Ne(we);r.useEffect(()=>{D()},[]),r.useEffect(()=>{fe(I)},[I]);const D=r.useCallback(async()=>{var a;const t=await $.share().getActionsForApp(u);N(t);const c=await $.share().getRightsForResource(u,(a=B[0])==null?void 0:a.assetId);x(c)},[]),i=(t,c)=>{x(({rights:a,...g})=>{var te,re;const s=[...a],o=s.findIndex(k=>k.id===t.id),T=y.filter(k=>k.id===c)[0];if(s[o].actions.findIndex(k=>k.id===c)>-1){let k=s[o].actions.filter(b=>b.id!==c);const j=y.filter(b=>{var E;return(E=b.requires)==null?void 0:E.includes(c)});k=k.filter(b=>!j.find(E=>E.id===b.id)),s[o]={...s[o],actions:k}}else{const k=y.filter(j=>{var b;return((b=T.requires)==null?void 0:b.includes(j.id))&&!s[o].actions.find(E=>E.id===j.id)});s[o]={...s[o],actions:[...s[o].actions,T,...k]}}return t.type==="sharebookmark"&&((te=s[o].users)==null||te.forEach(k=>{const j=s.findIndex(b=>b.id===k.id);s[j]={...s[j],actions:s[o].actions}}),(re=s[o].groups)==null||re.forEach(k=>{const j=s.findIndex(b=>b.id===k.id);s[j]={...s[j],actions:s[o].actions}})),{rights:s,...g}})},z=async()=>{var t;try{await Q.mutateAsync(m),await X.mutateAsync({entId:(t=B[0])==null?void 0:t.assetId,shares:n.rights}),l.success(p("explorer.shared.status.saved")),d==null||d()}catch(c){console.error("Failed to save share",c),l.error(p("explorer.shared.status.error"))}},me=t=>{x(c=>({...c,rights:n.rights.filter(a=>{var g,s;return a.id!==t.id&&!((g=t.users)!=null&&g.find(o=>o.id===a.id))&&!((s=t.groups)!=null&&s.find(o=>o.id===a.id))})}))},pe=t=>{W(t.target.value)},xe=()=>!M&&!A&&I.length>0&&C.length===0||!M&&A&&I.length>3&&C.length===0,ke=()=>A&&R.length<3,ge=()=>M&&R.length>0,fe=async t=>{var c;if(V(!0),!A&&t.length>=1||A&&t.length>=3){const a=await $.share().searchShareSubjects(u,(c=B[0])==null?void 0:c.assetId,t);J(a);const g=a.filter(s=>!n.rights.find(o=>o.id===s.id)).filter(s=>!(s.type==="user"&&s.id===B[0].creatorId)).map(s=>({value:s.id,label:s.displayName,icon:s.type==="sharebookmark"?ee:null}));P(g)}else P([]),Promise.resolve();V(!1)};return{currentIsAuthor:()=>{for(const t of B)if(t.creatorId!==(h==null?void 0:h.userId))return!1;return!0},idBookmark:f,myAvatar:v,shareRights:n,shareRightActions:y,showBookmarkInput:w,searchInputValue:R,searchResults:C,bookmarkName:F,showBookmarkMembers:U,debouncedSearchInputValue:I,searchPending:M,setBookmarkName:H,saveBookmark:async t=>{try{const c=await $.directory().saveBookmarks(t,{users:n.rights.filter(a=>a.type==="user").map(a=>a.id),groups:n.rights.filter(a=>a.type==="group").map(a=>a.id),bookmarks:n.rights.filter(a=>a.type==="sharebookmark").map(a=>a.id)});l.success(p("explorer.bookmarked.status.saved")),x(a=>({...a,visibleBookmarks:[...a.visibleBookmarks,{displayName:t,id:c.id}]})),S(f+new Date().getTime().toString()),q(!1)}catch(c){console.error("Failed to save bookmark",c),l.error(p("explorer.bookmarked.status.error"))}},canSave:()=>!0,toggleBookmarkInput:q,handleActionCheckbox:i,handleShare:z,handleDeleteRow:me,handleSearchInputChange:pe,handleSearchResultsChange:async t=>{const c=_.find(g=>g.id===t[0]),a=[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}];if(c){let g=[];if(c.type==="sharebookmark"){const s=await $.directory().getBookMarkById(c.id);g.push({...s,type:"sharebookmark",avatarUrl:"",directoryUrl:"",actions:a}),s==null||s.users.filter(o=>!n.rights.find(T=>T.id===o.id)).forEach(o=>{g.push({...o,type:"user",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})}),s.groups.filter(o=>!n.rights.find(T=>T.id===o.id)).forEach(o=>{g.push({...o,type:"group",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})})}else g=[{...c,actions:[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}]}];x({...n,rights:[...n.rights,...g]}),P(C.filter(s=>s.value!==t[0]))}},showSearchNoResults:xe,showSearchAdmlHint:ke,showSearchLoading:ge,handleBookmarkMembersToggle:()=>{K(!U)},hasRight:(t,c)=>t.actions.filter(a=>c.id===a.id).length>0,showShareRightLine:t=>t.isBookmarkMember&&U||!t.isBookmarkMember}}function Le(){const d=de(),{assetId:m,description:u,thumbnail:p,name:h,public:v,trashed:f,slug:S,"publish-type":n}=d.length>0?d[0]:{"publish-type":"",assetId:"",description:"",name:"",public:!1,slug:"",thumbnail:"",trashed:!1},[x,y]=r.useState(n||"RESTRAINT"),[N,F]=r.useState({description:u||"",entId:m,name:h,public:!!v,slug:S||"",thumbnail:p,trashed:f,"publish-type":n});return r.useEffect(()=>{x&&F(w=>({...w,"publish-type":x}))},[x]),{radioPublicationValue:x,payloadUpdatePublishType:N,handleRadioPublicationChange:async w=>{y(w)}}}function Ze({isOpen:d,onSuccess:m,onCancel:u}){const{payloadUpdatePublishType:p,radioPublicationValue:h,handleRadioPublicationChange:v}=Le(),{myAvatar:f,idBookmark:S,shareRights:n,shareRightActions:x,showBookmarkInput:y,searchResults:N,bookmarkName:F,showBookmarkMembers:H,searchPending:w,currentIsAuthor:q,setBookmarkName:R,saveBookmark:W,canSave:I,toggleBookmarkInput:_,handleActionCheckbox:J,handleShare:C,handleDeleteRow:P,handleSearchInputChange:U,handleSearchResultsChange:K,showSearchNoResults:M,showSearchAdmlHint:V,showSearchLoading:A,handleBookmarkMembersToggle:B,hasRight:Q,showShareRightLine:X}=ze({payloadUpdatePublishType:p,onSuccess:m,onCancel:u}),{t:l}=ae(),D=r.useRef(null);return Ie.createPortal(e.jsxs(O,{id:"share_modal",size:"lg",isOpen:d,onModalClose:u,children:[e.jsx(O.Header,{onModalClose:u,children:l("share.title")}),e.jsxs(O.Body,{children:[e.jsx(se,{headingStyle:"h4",level:"h3",className:"mb-16",children:l("explorer.modal.share.usersWithAccess")}),e.jsx("div",{className:"table-responsive",children:e.jsxs("table",{className:"table border align-middle mb-0",children:[e.jsx("thead",{className:"bg-secondary",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"w-32",children:e.jsx(Y,{children:l("explorer.modal.share.avatar.shared.alt")})}),e.jsx("th",{scope:"col",children:e.jsx(Y,{children:l("explorer.modal.share.search.placeholder")})}),x.map(i=>e.jsx("th",{scope:"col",className:"text-center text-white",children:l(i.displayName)},i.displayName)),e.jsx("th",{scope:"col",children:e.jsx(Y,{children:l("close")})})]})}),e.jsxs("tbody",{children:[q()&&e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:e.jsx(oe,{alt:l("explorer.modal.share.avatar.me.alt"),size:"xs",src:f,variant:"circle"})}),e.jsx("td",{children:l("share.me")}),x.map(i=>e.jsx("td",{style:{width:"80px"},className:"text-center text-white",children:e.jsx(le,{checked:!0,disabled:!0})},i.displayName)),e.jsx("td",{})]}),n==null?void 0:n.rights.map(i=>X(i)&&e.jsxs("tr",{className:i.isBookmarkMember?"bg-light":"",children:[e.jsxs("td",{children:[i.type!=="sharebookmark"&&e.jsx(oe,{alt:l("explorer.modal.share.avatar.shared.alt"),size:"xs",src:i.avatarUrl,variant:"circle"}),i.type==="sharebookmark"&&e.jsx(ee,{})]}),e.jsx("td",{children:e.jsxs("div",{className:"d-flex",children:[i.type==="sharebookmark"&&e.jsx(L,{color:"tertiary",rightIcon:e.jsx(ne,{title:"Show",className:"w-16 min-w-0",style:{transition:"rotate 0.2s ease-out",rotate:H?"-180deg":"0deg"}}),type:"button",variant:"ghost",className:"fw-normal ps-0",onClick:B,children:i.displayName}),i.type!=="sharebookmark"&&i.displayName]})}),x.map(z=>e.jsx("td",{style:{width:"80px"},className:"text-center text-white",children:e.jsx(le,{checked:Q(i,z),onChange:()=>J(i,z.id)})},z.displayName)),e.jsx("td",{children:!i.isBookmarkMember&&e.jsx(Ae,{"aria-label":"Delete",color:"tertiary",icon:e.jsx(Be,{}),type:"button",variant:"ghost",title:"Delete",onClick:()=>P(i)})})]},i.id))]})]})}),e.jsxs("div",{className:"mt-16",children:[e.jsx(L,{color:"tertiary",leftIcon:e.jsx(ee,{}),rightIcon:e.jsx(ne,{title:"Show",className:"w-16 min-w-0",style:{transition:"rotate 0.2s ease-out",rotate:y?"-180deg":"0deg"}}),type:"button",variant:"ghost",className:"fw-normal",onClick:()=>_(!y),children:l("share.save.sharebookmark")}),y&&e.jsx("div",{className:"mt-16",children:e.jsxs(Z,{id:"bookmarkName",className:"d-flex flex-wrap align-items-center gap-16",children:[e.jsx("div",{className:"flex-fill",children:e.jsx(Z.Input,{ref:D,onChange:()=>{R(()=>{var i;return((i=D.current)==null?void 0:i.value)||""})},placeholder:l("explorer.modal.share.sharebookmark.placeholder"),size:"sm",type:"text"},S)}),e.jsx(L,{type:"button",color:"primary",variant:"ghost",disabled:F.length===0,leftIcon:e.jsx(Re,{}),onClick:()=>{W(D.current.value)},className:"text-nowrap",children:l("explorer.modal.share.sharebookmark.save")})]})})]}),e.jsx("hr",{}),e.jsxs(se,{headingStyle:"h4",level:"h3",className:"mb-16 d-flex align-items-center",children:[e.jsx("div",{className:"me-8",children:l("explorer.modal.share.search")}),e.jsx(Fe,{message:"Vos favoris de partage s’affichent en priorité dans votre liste lorsque vous recherchez un groupe ou une personne, vous pouvez les retrouver dans l’annuaire.",placement:"top",children:e.jsx(Ce,{className:"c-pointer",height:"18"})})]}),e.jsxs(Z,{className:"d-flex align-items-center",id:"search",children:[e.jsx(Me,{className:"max-w-512",noValidationIcon:!0,placeholder:V()?l("explorer.search.adml.hint"):l("explorer.modal.share.search.placeholder"),size:"md",type:"search",onChange:U}),A()&&e.jsxs("div",{className:"d-flex align-items-center p-4",children:[e.jsx(Te,{isLoading:w}),e.jsx("span",{className:"ps-4",children:l("explorer.search.pending")})]}),M()&&e.jsx("div",{className:"p-4",children:l("portal.no.result")})]}),(N==null?void 0:N.length)>0&&e.jsx("div",{className:"position-absolute w-100 max-w-512 z-1 bg-white shadow rounded-4 d-block show py-12 px-8",children:e.jsx(Ee,{options:N,hideCheckbox:!0,isMonoSelection:!0,onChange:K})}),e.jsx(De,{radioPublicationValue:h,onRadioPublicationChange:v})]}),e.jsxs(O.Footer,{children:[e.jsx(L,{type:"button",color:"tertiary",variant:"ghost",onClick:u,children:l("explorer.cancel")}),e.jsx(L,{type:"button",color:"primary",variant:"filled",onClick:C,disabled:!I(),children:l("share")})]})]}),document.getElementById("portal"))}export{Ze as default};
package/dist/version.txt CHANGED
@@ -1 +1 @@
1
- ode-explorer=1.0-SNAPSHOT 28/09/2023 14:48:08
1
+ ode-explorer=1.0-SNAPSHOT 03/10/2023 18:38:17
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ode-explorer",
3
- "version": "1.0.2-dev.202309281447",
3
+ "version": "1.0.3-dev.202310031837",
4
4
  "description": "Open Digital Education Explorer",
5
5
  "homepage": "https://github.com/opendigitaleducation/explorer#readme",
6
6
  "bugs": {
@@ -29,7 +29,7 @@
29
29
  },
30
30
  "dependencies": {
31
31
  "@edifice-ui/icons": "develop",
32
- "@edifice-ui/react": "develop",
32
+ "@edifice-ui/react": "1.0.0",
33
33
  "@react-spring/web": "9.7.3",
34
34
  "@tanstack/react-query": "4.32.6",
35
35
  "dayjs": "1.11.9",