ode-explorer 1.0.4 → 1.0.5
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/ShareResourceModal.js +1 -1
- package/dist/version.txt +1 -1
- package/package.json +2 -2
|
@@ -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 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};
|
|
1
|
+
import{r,g as G,j as e,d as ce,u as ae,h as be,i as ye,k as ve,l as de,m as je,n as Se,o as Ne,p as ee,A as Ie,a as we,M as O,V as Y,q as oe,B as L,s as ie,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[h,p]=r.useState(!1);r.useEffect(()=>{m()},[]);const m=r.useCallback(async()=>{const x=await $.session().isAdml();p(x)},[]);return{isAdml:h}}const he=r.forwardRef(({label:h,disabled:p=!1,checked:m=!1,indeterminate:x=!1,...i},j)=>{const g=r.useRef(null);r.useImperativeHandle(j,()=>({...g.current})),r.useEffect(()=>{g.current.indeterminate=x},[g,x]);const S=r.useId(),l={type:"checkbox",checked:m,disabled:p,ref:g,className:G(i.className,"form-check-input c-pointer"),id:S},k={...i,...l};return e.jsxs("div",{className:"form-check d-flex align-items-center gap-8",children:[e.jsx("input",{...k}),h&&e.jsx("label",{className:"form-check-label",htmlFor:k.id,children:h})]})});he.displayName="Checkbox";const ne=he,ue=r.forwardRef(({model:h,icon:p,label:m=!1,disabled:x=!1,...i},j)=>{const g=r.useMemo(()=>i.id?i.id:(Math.floor(Math.random()*999999999999)+1e12).toString(),[i.id]),l={...{type:"radio",checked:h===i.value,disabled:x,ref:j,className:G(i.className,"form-check-input c-pointer",p&&"d-none"),id:g},...i};return e.jsxs("div",{className:G("form-check d-flex align-items-center gap-8",p&&"ps-0"),children:[e.jsx("input",{...l}),p&&e.jsx("label",{htmlFor:l.id,className:G("c-pointer",h!==i.value&&"text-muted"),children:p}),!p&&m&&e.jsx("label",{className:"form-check-label",htmlFor:l.id,children:m})]})});ue.displayName="Radio";const le=ue;function Ue({radioPublicationValue:h,onRadioPublicationChange:p}){const{appCode:m}=ce(),{t:x}=ae(m);return e.jsxs(e.Fragment,{children:[e.jsx("hr",{}),e.jsx(se,{headingStyle:"h4",level:"h3",className:"mb-16",children:x("explorer.publication.steps")}),e.jsx(le,{label:x("explorer.immediat.publication"),id:"publication-now",name:"publication",value:"IMMEDIATE",model:h,checked:h==="IMMEDIATE",onChange:i=>p(i.target.value)}),e.jsx(le,{label:x("explorer.validate.publication"),id:"publication-validate",name:"publication",value:"RESTRAINT",checked:h==="RESTRAINT",model:h,onChange:i=>p(i.target.value)})]})}function De({radioPublicationValue:h,onRadioPublicationChange:p}){const{app:m}=be();return m===$e.BLOG?e.jsx(Ue,{radioPublicationValue:h,onRadioPublicationChange:p}):e.jsx(e.Fragment,{})}function ze({onSuccess:h,payloadUpdatePublishType:p}){const{appCode:m}=ce(),{t:x}=ae(),{user:i,avatar:j}=ye(),[g,S]=r.useState(r.useId()),[l,k]=r.useState({rights:[],visibleBookmarks:[],visibleGroups:[],visibleUsers:[]}),[y,N]=r.useState([]),[F,H]=r.useState(""),[w,q]=r.useState(!1),[R,W]=r.useState(""),A=ve(R,500),[_,J]=r.useState([]),[C,P]=r.useState([]),[U,K]=r.useState(!1),[M,V]=r.useState(!1),{isAdml:B}=Pe(),I=de(),Q=je(),X=Se(),{hotToast:c}=Ne(Ie);r.useEffect(()=>{D()},[]),r.useEffect(()=>{ge(A)},[A]);const D=r.useCallback(async()=>{var a;const t=await $.share().getActionsForApp(m);N(t);const o=await $.share().getRightsForResource(m,(a=I[0])==null?void 0:a.assetId);k(o)},[]),d=(t,o)=>{k(({rights:a,...u})=>{var te,re;const s=[...a],n=s.findIndex(f=>f.id===t.id),T=y.filter(f=>f.id===o)[0];if(s[n].actions.findIndex(f=>f.id===o)>-1){let f=s[n].actions.filter(b=>b.id!==o);const v=y.filter(b=>{var E;return(E=b.requires)==null?void 0:E.includes(o)});f=f.filter(b=>!v.find(E=>E.id===b.id)),s[n]={...s[n],actions:f}}else{const f=y.filter(v=>{var b;return((b=T.requires)==null?void 0:b.includes(v.id))&&!s[n].actions.find(E=>E.id===v.id)});s[n]={...s[n],actions:[...s[n].actions,T,...f]}}return t.type==="sharebookmark"&&((te=s[n].users)==null||te.forEach(f=>{const v=s.findIndex(b=>b.id===f.id);s[v]={...s[v],actions:s[n].actions}}),(re=s[n].groups)==null||re.forEach(f=>{const v=s.findIndex(b=>b.id===f.id);s[v]={...s[v],actions:s[n].actions}})),{rights:s,...u}})},z=async()=>{var t;try{const o=I[0].rights.filter(u=>i&&u.includes(`user:${i.userId}`)).map(u=>u.split(":")[2]).filter(u=>!!u),a=[...l.rights];if(o.length>0){const u=o.map(s=>({displayName:s,id:s}));a.push({actions:u,avatarUrl:"",directoryUrl:"",displayName:i.username,id:i.userId,type:"user"})}await Q.mutateAsync(p),await X.mutateAsync({entId:(t=I[0])==null?void 0:t.assetId,shares:a}),c.success(x("explorer.shared.status.saved")),h==null||h()}catch(o){console.error("Failed to save share",o),c.error(x("explorer.shared.status.error"))}},me=t=>{k(o=>({...o,rights:l.rights.filter(a=>{var u,s;return a.id!==t.id&&!((u=t.users)!=null&&u.find(n=>n.id===a.id))&&!((s=t.groups)!=null&&s.find(n=>n.id===a.id))})}))},pe=t=>{W(t.target.value)},xe=()=>!M&&!B&&A.length>0&&C.length===0||!M&&B&&A.length>3&&C.length===0,ke=()=>B&&R.length<3,fe=()=>M&&R.length>0,ge=async t=>{var o;if(V(!0),!B&&t.length>=1||B&&t.length>=3){const a=await $.share().searchShareSubjects(m,(o=I[0])==null?void 0:o.assetId,t);J(a);const u=a.filter(s=>!l.rights.find(n=>n.id===s.id)).filter(s=>!(s.type==="user"&&s.id===I[0].creatorId)).map(s=>({value:s.id,label:s.displayName,icon:s.type==="sharebookmark"?ee:null}));P(u)}else P([]),Promise.resolve();V(!1)};return{currentIsAuthor:()=>{for(const t of I)if(t.creatorId!==(i==null?void 0:i.userId))return!1;return!0},idBookmark:g,myAvatar:j,shareRights:l,shareRightActions:y,showBookmarkInput:w,searchInputValue:R,searchResults:C,bookmarkName:F,showBookmarkMembers:U,debouncedSearchInputValue:A,searchPending:M,setBookmarkName:H,saveBookmark:async t=>{try{const o=await $.directory().saveBookmarks(t,{users:l.rights.filter(a=>a.type==="user").map(a=>a.id),groups:l.rights.filter(a=>a.type==="group").map(a=>a.id),bookmarks:l.rights.filter(a=>a.type==="sharebookmark").map(a=>a.id)});c.success(x("explorer.bookmarked.status.saved")),k(a=>({...a,visibleBookmarks:[...a.visibleBookmarks,{displayName:t,id:o.id}]})),S(g+new Date().getTime().toString()),q(!1)}catch(o){console.error("Failed to save bookmark",o),c.error(x("explorer.bookmarked.status.error"))}},canSave:()=>!0,toggleBookmarkInput:q,handleActionCheckbox:d,handleShare:z,handleDeleteRow:me,handleSearchInputChange:pe,handleSearchResultsChange:async t=>{const o=_.find(u=>u.id===t[0]),a=[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}];if(o){let u=[];if(o.type==="sharebookmark"){const s=await $.directory().getBookMarkById(o.id);u.push({...s,type:"sharebookmark",avatarUrl:"",directoryUrl:"",actions:a}),s==null||s.users.filter(n=>!l.rights.find(T=>T.id===n.id)).forEach(n=>{u.push({...n,type:"user",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})}),s.groups.filter(n=>!l.rights.find(T=>T.id===n.id)).forEach(n=>{u.push({...n,type:"group",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})})}else u=[{...o,actions:[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}]}];k({...l,rights:[...l.rights,...u]}),P(C.filter(s=>s.value!==t[0]))}},showSearchNoResults:xe,showSearchAdmlHint:ke,showSearchLoading:fe,handleBookmarkMembersToggle:()=>{K(!U)},hasRight:(t,o)=>t.actions.filter(a=>o.id===a.id).length>0,showShareRightLine:t=>t.isBookmarkMember&&U||!t.isBookmarkMember}}function Le(){const h=de(),{assetId:p,description:m,thumbnail:x,name:i,public:j,trashed:g,slug:S,"publish-type":l}=h.length>0?h[0]:{"publish-type":"",assetId:"",description:"",name:"",public:!1,slug:"",thumbnail:"",trashed:!1},[k,y]=r.useState(l||"RESTRAINT"),[N,F]=r.useState({description:m||"",entId:p,name:i,public:!!j,slug:S||"",thumbnail:x,trashed:g,"publish-type":l});return r.useEffect(()=>{k&&F(w=>({...w,"publish-type":k}))},[k]),{radioPublicationValue:k,payloadUpdatePublishType:N,handleRadioPublicationChange:async w=>{y(w)}}}function Ze({isOpen:h,onSuccess:p,onCancel:m}){const{payloadUpdatePublishType:x,radioPublicationValue:i,handleRadioPublicationChange:j}=Le(),{myAvatar:g,idBookmark:S,shareRights:l,shareRightActions:k,showBookmarkInput:y,searchResults:N,bookmarkName:F,showBookmarkMembers:H,searchPending:w,currentIsAuthor:q,setBookmarkName:R,saveBookmark:W,canSave:A,toggleBookmarkInput:_,handleActionCheckbox:J,handleShare:C,handleDeleteRow:P,handleSearchInputChange:U,handleSearchResultsChange:K,showSearchNoResults:M,showSearchAdmlHint:V,showSearchLoading:B,handleBookmarkMembersToggle:I,hasRight:Q,showShareRightLine:X}=ze({payloadUpdatePublishType:x,onSuccess:p,onCancel:m}),{t:c}=ae(),D=r.useRef(null);return we.createPortal(e.jsxs(O,{id:"share_modal",size:"lg",isOpen:h,onModalClose:m,children:[e.jsx(O.Header,{onModalClose:m,children:c("share.title")}),e.jsxs(O.Body,{children:[e.jsx(se,{headingStyle:"h4",level:"h3",className:"mb-16",children:c("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:c("explorer.modal.share.avatar.shared.alt")})}),e.jsx("th",{scope:"col",children:e.jsx(Y,{children:c("explorer.modal.share.search.placeholder")})}),k.map(d=>e.jsx("th",{scope:"col",className:"text-center text-white",children:c(d.displayName)},d.displayName)),e.jsx("th",{scope:"col",children:e.jsx(Y,{children:c("close")})})]})}),e.jsxs("tbody",{children:[q()&&e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:e.jsx(oe,{alt:c("explorer.modal.share.avatar.me.alt"),size:"xs",src:g,variant:"circle"})}),e.jsx("td",{children:c("share.me")}),k.map(d=>e.jsx("td",{style:{width:"80px"},className:"text-center text-white",children:e.jsx(ne,{checked:!0,disabled:!0})},d.displayName)),e.jsx("td",{})]}),l==null?void 0:l.rights.map(d=>X(d)&&e.jsxs("tr",{className:d.isBookmarkMember?"bg-light":"",children:[e.jsxs("td",{children:[d.type!=="sharebookmark"&&e.jsx(oe,{alt:c("explorer.modal.share.avatar.shared.alt"),size:"xs",src:d.avatarUrl,variant:"circle"}),d.type==="sharebookmark"&&e.jsx(ee,{})]}),e.jsx("td",{children:e.jsxs("div",{className:"d-flex",children:[d.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:I,children:d.displayName}),d.type!=="sharebookmark"&&d.displayName]})}),k.map(z=>e.jsx("td",{style:{width:"80px"},className:"text-center text-white",children:e.jsx(ne,{checked:Q(d,z),onChange:()=>J(d,z.id)})},z.displayName)),e.jsx("td",{children:!d.isBookmarkMember&&e.jsx(Ae,{"aria-label":"Delete",color:"tertiary",icon:e.jsx(Be,{}),type:"button",variant:"ghost",title:"Delete",onClick:()=>P(d)})})]},d.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:c("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 d;return((d=D.current)==null?void 0:d.value)||""})},placeholder:c("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:c("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:c("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()?c("explorer.search.adml.hint"):c("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:c("explorer.search.pending")})]}),M()&&e.jsx("div",{className:"p-4",children:c("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:i,onRadioPublicationChange:j})]}),e.jsxs(O.Footer,{children:[e.jsx(L,{type:"button",color:"tertiary",variant:"ghost",onClick:m,children:c("explorer.cancel")}),e.jsx(L,{type:"button",color:"primary",variant:"filled",onClick:C,disabled:!A(),children:c("share")})]})]}),document.getElementById("portal"))}export{Ze as default};
|
package/dist/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
ode-explorer=1.0.
|
|
1
|
+
ode-explorer=1.0.5 17/10/2023 18:16:15
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ode-explorer",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Open Digital Education Explorer",
|
|
5
5
|
"homepage": "https://github.com/opendigitaleducation/explorer#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"clsx": "2.0.0",
|
|
58
58
|
"concurrently": "8.2.0",
|
|
59
59
|
"csstype": "3.1.2",
|
|
60
|
-
"edifice-ts-client": "1.0.
|
|
60
|
+
"edifice-ts-client": "1.0.3",
|
|
61
61
|
"eslint": "8.46.0",
|
|
62
62
|
"eslint-config-prettier": "9.0.0",
|
|
63
63
|
"eslint-plugin-import": "2.28.0",
|