ode-explorer 1.1.0-dev.202311231705 → 1.1.0-dev.202311241042

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 as n,i as ye,j as e,F as ae,k as je,u as K,D as O,l as ve,d as he,H as te,m as le,n as Se,o as Ie,p as we,q as ue,s as Ne,t as Ce,v as Ae,w as re,A as Be,a as Re,M as G,V as se,x as ie,C as ce,B as z,y as de,z as Me,E as Te,G as Ee,J as $e}from"./index.js";import{odeServices as U,APP as Pe}from"/assets/js/edifice-ts-client/index.js";import{T as De}from"./Tooltip.js";function Ue(){const[c,p]=n.useState(!1);n.useEffect(()=>{d()},[]);const d=n.useCallback(async()=>{const x=await U.session().isAdml();p(x)},[]);return{isAdml:c}}const Fe=({placeholder:c,value:p="",handleSearchInputChange:d})=>{const{triggerProps:x,itemProps:u,setVisible:y}=ye(),j={...x,role:"combobox",onClick:()=>{p.length>2&&y(!0)},onChange:d};return n.useEffect(()=>{y(p.length>2)},[y,p]),e.jsx(ae,{className:"d-flex align-items-center",id:"search",children:e.jsx(je,{...j,className:"max-w-512",noValidationIcon:!0,placeholder:c,size:"md",type:"search",onKeyDown:u.onMenuItemKeyDown})})},Le=Fe,J=({onSearchResultsChange:c,onSearchInputChange:p,options:d,value:x,isLoading:u,noResult:y,placeholder:j})=>{const{t:I}=K(),[h,g]=n.useState([]);n.useEffect(()=>{c(h)},[h]);const b=v=>{g([v])},C=()=>u?e.jsxs("div",{className:"d-flex align-items-center p-4",children:[e.jsx(ve,{isLoading:u}),e.jsx("span",{className:"ps-4",children:I("explorer.search.pending")})]}):y?e.jsx("div",{className:"p-4",children:I("portal.no.result")}):d.map((v,A)=>e.jsxs(n.Fragment,{children:[e.jsx(O.Item,{onClick:()=>b(v.value),children:v.label}),A<d.length-1&&e.jsx(O.Separator,{})]},A));return e.jsxs(O,{block:!0,children:[e.jsx(J.Trigger,{placeholder:j,handleSearchInputChange:p,value:x}),e.jsx(O.Menu,{children:C()})]})};J.Trigger=Le;J.displayName="Combobox";const Ve=J;function ze({radioPublicationValue:c,onRadioPublicationChange:p}){const{appCode:d}=he(),{t:x}=K(d);return e.jsxs(e.Fragment,{children:[e.jsx("hr",{}),e.jsx(te,{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:c,checked:c==="IMMEDIATE",onChange:u=>p(u.target.value)}),e.jsx(le,{label:x("explorer.validate.publication"),id:"publication-validate",name:"publication",value:"RESTRAINT",checked:c==="RESTRAINT",model:c,onChange:u=>p(u.target.value)})]})}function He({radioPublicationValue:c,onRadioPublicationChange:p}){const{app:d}=Se();return d===Pe.BLOG?e.jsx(ze,{radioPublicationValue:c,onRadioPublicationChange:p}):e.jsx(e.Fragment,{})}function qe({onSuccess:c,payloadUpdatePublishType:p}){const{appCode:d}=he(),{t:x}=K(),{user:u,avatar:y}=Ie(),[j,I]=n.useState(n.useId()),[h,g]=n.useState({rights:[],visibleBookmarks:[],visibleGroups:[],visibleUsers:[]}),[b,C]=n.useState([]),[v,A]=n.useState(""),[B,H]=n.useState(!1),[T,W]=n.useState(""),R=we(T,500),[_,Q]=n.useState([]),[E,F]=n.useState([]),[L,X]=n.useState(!1),[$,q]=n.useState(!1),[Y,Z]=n.useState(!1),{isAdml:M}=Ue(),w=ue(),ee=Ne(),m=Ce(),{hotToast:N}=Ae(Be);n.useEffect(()=>{l()},[]),n.useEffect(()=>{fe(R)},[R]);const l=n.useCallback(async()=>{var a;const t=await U.share().getActionsForApp(d);C(t);const r=await U.share().getRightsForResource(d,(a=w[0])==null?void 0:a.assetId);g(r)},[]),V=(t,r)=>{g(({rights:a,...i})=>{var oe,ne;const s=[...a],o=s.findIndex(k=>k.id===t.id),P=b.filter(k=>k.id===r)[0];if(s[o].actions.findIndex(k=>k.id===r)>-1){let k=s[o].actions.filter(f=>f.id!==r);const S=b.filter(f=>{var D;return(D=f.requires)==null?void 0:D.includes(r)});k=k.filter(f=>!S.find(D=>D.id===f.id)),s[o]={...s[o],actions:k}}else{const k=b.filter(S=>{var f;return((f=P.requires)==null?void 0:f.includes(S.id))&&!s[o].actions.find(D=>D.id===S.id)});s[o]={...s[o],actions:[...s[o].actions,P,...k]}}return t.type==="sharebookmark"&&((oe=s[o].users)==null||oe.forEach(k=>{const S=s.findIndex(f=>f.id===k.id);s[S]={...s[S],actions:s[o].actions}}),(ne=s[o].groups)==null||ne.forEach(k=>{const S=s.findIndex(f=>f.id===k.id);s[S]={...s[S],actions:s[o].actions}})),{rights:s,...i}})},me=async()=>{var t;try{const r=w[0].rights.filter(i=>u&&i.includes(`user:${u.userId}`)).map(i=>i.split(":")[2]).filter(i=>!!i),a=[...h.rights];if(r.length>0){const i=r.map(s=>({displayName:s,id:s}));a.push({actions:i,avatarUrl:"",directoryUrl:"",displayName:u.username,id:u.userId,type:"user"})}await ee.mutateAsync(p),await m.mutateAsync({entId:(t=w[0])==null?void 0:t.assetId,shares:a}),N.success(x("explorer.shared.status.saved")),c==null||c()}catch(r){console.error("Failed to save share",r),N.error(x("explorer.shared.status.error"))}finally{Z(!1)}},pe=t=>{g(r=>({...r,rights:h.rights.filter(a=>{var i,s;return a.id!==t.id&&!((i=t.users)!=null&&i.find(o=>o.id===a.id))&&!((s=t.groups)!=null&&s.find(o=>o.id===a.id))})}))},xe=t=>{W(t.target.value)},ge=()=>!$&&!M&&R.length>0&&E.length===0||!$&&M&&R.length>3&&E.length===0,ke=()=>M&&T.length<3,be=()=>$&&T.length>0,fe=async t=>{var r;if(q(!0),!M&&t.length>=1||M&&t.length>=3){const a=await U.share().searchShareSubjects(d,(r=w[0])==null?void 0:r.assetId,t);Q(a);const i=a.filter(s=>!h.rights.find(o=>o.id===s.id)).filter(s=>!(s.type==="user"&&s.id===w[0].creatorId)).map(s=>({value:s.id,label:s.displayName,icon:s.type==="sharebookmark"?re:null}));F(i)}else F([]),Promise.resolve();q(!1)};return{currentIsAuthor:()=>{for(const t of w)if(t.creatorId!==(u==null?void 0:u.userId))return!1;return!0},idBookmark:j,myAvatar:y,shareRights:h,shareRightActions:b,showBookmarkInput:B,searchInputValue:T,searchResults:E,bookmarkName:v,showBookmarkMembers:L,debouncedSearchInputValue:R,searchPending:$,isLoading:Y,setBookmarkName:A,saveBookmark:async t=>{try{const r=await U.directory().saveBookmarks(t,{users:h.rights.filter(a=>a.type==="user").map(a=>a.id),groups:h.rights.filter(a=>a.type==="group").map(a=>a.id),bookmarks:h.rights.filter(a=>a.type==="sharebookmark").map(a=>a.id)});N.success(x("explorer.bookmarked.status.saved")),g(a=>({...a,visibleBookmarks:[...a.visibleBookmarks,{displayName:t,id:r.id}]})),I(j+new Date().getTime().toString()),H(!1)}catch(r){console.error("Failed to save bookmark",r),N.error(x("explorer.bookmarked.status.error"))}},canSave:()=>!0,toggleBookmarkInput:H,handleActionCheckbox:V,handleShare:me,handleDeleteRow:pe,handleSearchInputChange:xe,handleSearchResultsChange:async t=>{const r=_.find(i=>i.id===t[0]),a=[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}];if(r){let i=[];if(r.type==="sharebookmark"){const s=await U.directory().getBookMarkById(r.id);i.push({...s,type:"sharebookmark",avatarUrl:"",directoryUrl:"",actions:a}),s==null||s.users.filter(o=>!h.rights.find(P=>P.id===o.id)).forEach(o=>{i.push({...o,type:"user",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})}),s.groups.filter(o=>!h.rights.find(P=>P.id===o.id)).forEach(o=>{i.push({...o,type:"group",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})})}else i=[{...r,actions:[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}]}];g({...h,rights:[...h.rights,...i]}),F(E.filter(s=>s.value!==t[0]))}},showSearchNoResults:ge,showSearchAdmlHint:ke,showSearchLoading:be,handleBookmarkMembersToggle:()=>{X(!L)},hasRight:(t,r)=>t.actions.filter(a=>r.id===a.id).length>0,showShareRightLine:t=>t.isBookmarkMember&&L||!t.isBookmarkMember}}function Oe(){const c=ue(),{assetId:p,description:d,thumbnail:x,name:u,public:y,trashed:j,slug:I,"publish-type":h}=c.length>0?c[0]:{"publish-type":"",assetId:"",description:"",name:"",public:!1,slug:"",thumbnail:"",trashed:!1},[g,b]=n.useState(h||"RESTRAINT"),[C,v]=n.useState({description:d||"",entId:p,name:u,public:!!y,slug:I||"",thumbnail:x,trashed:j,"publish-type":h});return n.useEffect(()=>{g&&v(B=>({...B,"publish-type":g}))},[g]),{radioPublicationValue:g,payloadUpdatePublishType:C,handleRadioPublicationChange:async B=>{b(B)}}}function as({isOpen:c,onSuccess:p,onCancel:d}){const{payloadUpdatePublishType:x,radioPublicationValue:u,handleRadioPublicationChange:y}=Oe(),{myAvatar:j,idBookmark:I,shareRights:h,shareRightActions:g,showBookmarkInput:b,searchResults:C,bookmarkName:v,showBookmarkMembers:A,isLoading:B,searchInputValue:H,currentIsAuthor:T,setBookmarkName:W,saveBookmark:R,canSave:_,toggleBookmarkInput:Q,handleActionCheckbox:E,handleShare:F,handleDeleteRow:L,handleSearchInputChange:X,handleSearchResultsChange:$,showSearchNoResults:q,showSearchAdmlHint:Y,showSearchLoading:Z,handleBookmarkMembersToggle:M,hasRight:w,showShareRightLine:ee}=qe({payloadUpdatePublishType:x,onSuccess:p,onCancel:d}),{t:m}=K(),N=n.useRef(null);return Re.createPortal(e.jsxs(G,{id:"share_modal",size:"lg",isOpen:c,onModalClose:d,children:[e.jsx(G.Header,{onModalClose:d,children:m("share.title")}),e.jsxs(G.Body,{children:[e.jsx(te,{headingStyle:"h4",level:"h3",className:"mb-16",children:m("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(se,{children:m("explorer.modal.share.avatar.shared.alt")})}),e.jsx("th",{scope:"col",children:e.jsx(se,{children:m("explorer.modal.share.search.placeholder")})}),g.map(l=>e.jsx("th",{scope:"col",className:"text-center text-white",children:m(l.displayName)},l.displayName)),e.jsx("th",{scope:"col",children:e.jsx(se,{children:m("close")})})]})}),e.jsxs("tbody",{children:[T()&&e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:e.jsx(ie,{alt:m("explorer.modal.share.avatar.me.alt"),size:"xs",src:j,variant:"circle"})}),e.jsx("td",{children:m("share.me")}),g.map(l=>e.jsx("td",{style:{width:"80px"},className:"text-center text-white",children:e.jsx(ce,{checked:!0,disabled:!0})},l.displayName)),e.jsx("td",{})]}),h==null?void 0:h.rights.map(l=>ee(l)&&e.jsxs("tr",{className:l.isBookmarkMember?"bg-light":"",children:[e.jsxs("td",{children:[l.type!=="sharebookmark"&&e.jsx(ie,{alt:m("explorer.modal.share.avatar.shared.alt"),size:"xs",src:l.avatarUrl,variant:"circle"}),l.type==="sharebookmark"&&e.jsx(re,{})]}),e.jsx("td",{children:e.jsxs("div",{className:"d-flex",children:[l.type==="sharebookmark"&&e.jsx(z,{color:"tertiary",rightIcon:e.jsx(de,{title:"Show",className:"w-16 min-w-0",style:{transition:"rotate 0.2s ease-out",rotate:A?"-180deg":"0deg"}}),type:"button",variant:"ghost",className:"fw-normal ps-0",onClick:M,children:l.displayName}),l.type!=="sharebookmark"&&l.displayName]})}),g.map(V=>e.jsx("td",{style:{width:"80px"},className:"text-center text-white",children:e.jsx(ce,{checked:w(l,V),onChange:()=>E(l,V.id)})},V.displayName)),e.jsx("td",{children:!l.isBookmarkMember&&e.jsx(Me,{"aria-label":"Delete",color:"tertiary",icon:e.jsx(Te,{}),type:"button",variant:"ghost",title:"Delete",onClick:()=>L(l)})})]},l.id))]})]})}),e.jsxs("div",{className:"mt-16",children:[e.jsx(z,{color:"tertiary",leftIcon:e.jsx(re,{}),rightIcon:e.jsx(de,{title:"Show",className:"w-16 min-w-0",style:{transition:"rotate 0.2s ease-out",rotate:b?"-180deg":"0deg"}}),type:"button",variant:"ghost",className:"fw-normal",onClick:()=>Q(!b),children:m("share.save.sharebookmark")}),b&&e.jsx("div",{className:"mt-16",children:e.jsxs(ae,{id:"bookmarkName",className:"d-flex flex-wrap align-items-center gap-16",children:[e.jsx("div",{className:"flex-fill",children:e.jsx(ae.Input,{ref:N,onChange:()=>{W(()=>{var l;return((l=N.current)==null?void 0:l.value)||""})},placeholder:m("explorer.modal.share.sharebookmark.placeholder"),size:"sm",type:"text"},I)}),e.jsx(z,{type:"button",color:"primary",variant:"ghost",disabled:v.length===0,leftIcon:e.jsx(Ee,{}),onClick:()=>{R(N.current.value)},className:"text-nowrap",children:m("explorer.modal.share.sharebookmark.save")})]})})]}),e.jsx("hr",{}),e.jsxs(te,{headingStyle:"h4",level:"h3",className:"mb-16 d-flex align-items-center",children:[e.jsx("div",{className:"me-8",children:m("explorer.modal.share.search")}),e.jsx(De,{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($e,{className:"c-pointer",height:"18"})})]}),e.jsx("div",{className:"row",children:e.jsx("div",{className:"col-10",children:e.jsx(Ve,{value:H,placeholder:Y()?m("explorer.search.adml.hint"):m("explorer.modal.share.search.placeholder"),isLoading:Z(),noResult:q(),options:C,onSearchInputChange:X,onSearchResultsChange:$})})}),e.jsx(He,{radioPublicationValue:u,onRadioPublicationChange:y})]}),e.jsxs(G.Footer,{children:[e.jsx(z,{type:"button",color:"tertiary",variant:"ghost",onClick:d,children:m("explorer.cancel")}),e.jsx(z,{type:"button",color:"primary",variant:"filled",isLoading:B,onClick:F,disabled:!_(),children:m("share")})]})]}),document.getElementById("portal"))}export{as as default};
1
+ import{r as n,i as ye,j as e,F as ae,k as je,u as K,D as O,l as ve,d as he,H as te,m as le,n as Se,o as Ie,p as we,q as ue,s as Ne,t as Ce,v as Ae,w as re,A as Be,a as Re,M as G,V as se,x as ie,C as ce,B as z,y as de,z as Me,E as Te,G as Ee,J as $e}from"./index.js";import{odeServices as U,APP as Pe}from"/assets/js/edifice-ts-client/index.js";import{T as De}from"./Tooltip.js";function Ue(){const[c,p]=n.useState(!1);n.useEffect(()=>{d()},[]);const d=n.useCallback(async()=>{const x=await U.session().isAdml();p(x)},[]);return{isAdml:c}}const Fe=({placeholder:c,value:p="",handleSearchInputChange:d})=>{const{triggerProps:x,itemProps:u,setVisible:y}=ye(),j={...x,role:"combobox",onClick:()=>{p.length>2&&y(!0)},onChange:d};return n.useEffect(()=>{y(p.length>2)},[y,p]),e.jsx(ae,{className:"d-flex align-items-center",id:"search",children:e.jsx(je,{...j,className:"max-w-512",noValidationIcon:!0,placeholder:c,size:"md",type:"search",onKeyDown:u.onMenuItemKeyDown})})},Le=Fe,J=({onSearchResultsChange:c,onSearchInputChange:p,options:d,value:x,isLoading:u,noResult:y,placeholder:j})=>{const{t:I}=K(),[h,g]=n.useState([]);n.useEffect(()=>{c(h)},[h]);const b=v=>{g([v])},C=()=>u?e.jsxs("div",{className:"d-flex align-items-center p-4",children:[e.jsx(ve,{isLoading:u}),e.jsx("span",{className:"ps-4",children:I("explorer.search.pending")})]}):y?e.jsx("div",{className:"p-4",children:I("portal.no.result")}):d.map((v,A)=>e.jsxs(n.Fragment,{children:[e.jsx(O.Item,{type:"select",onClick:()=>b(v.value),children:v.label}),A<d.length-1&&e.jsx(O.Separator,{})]},A));return e.jsxs(O,{block:!0,children:[e.jsx(J.Trigger,{placeholder:j,handleSearchInputChange:p,value:x}),e.jsx(O.Menu,{children:C()})]})};J.Trigger=Le;J.displayName="Combobox";const Ve=J;function ze({radioPublicationValue:c,onRadioPublicationChange:p}){const{appCode:d}=he(),{t:x}=K(d);return e.jsxs(e.Fragment,{children:[e.jsx("hr",{}),e.jsx(te,{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:c,checked:c==="IMMEDIATE",onChange:u=>p(u.target.value)}),e.jsx(le,{label:x("explorer.validate.publication"),id:"publication-validate",name:"publication",value:"RESTRAINT",checked:c==="RESTRAINT",model:c,onChange:u=>p(u.target.value)})]})}function He({radioPublicationValue:c,onRadioPublicationChange:p}){const{app:d}=Se();return d===Pe.BLOG?e.jsx(ze,{radioPublicationValue:c,onRadioPublicationChange:p}):e.jsx(e.Fragment,{})}function qe({onSuccess:c,payloadUpdatePublishType:p}){const{appCode:d}=he(),{t:x}=K(),{user:u,avatar:y}=Ie(),[j,I]=n.useState(n.useId()),[h,g]=n.useState({rights:[],visibleBookmarks:[],visibleGroups:[],visibleUsers:[]}),[b,C]=n.useState([]),[v,A]=n.useState(""),[B,H]=n.useState(!1),[T,W]=n.useState(""),R=we(T,500),[_,Q]=n.useState([]),[E,F]=n.useState([]),[L,X]=n.useState(!1),[$,q]=n.useState(!1),[Y,Z]=n.useState(!1),{isAdml:M}=Ue(),w=ue(),ee=Ne(),m=Ce(),{hotToast:N}=Ae(Be);n.useEffect(()=>{l()},[]),n.useEffect(()=>{fe(R)},[R]);const l=n.useCallback(async()=>{var a;const t=await U.share().getActionsForApp(d);C(t);const r=await U.share().getRightsForResource(d,(a=w[0])==null?void 0:a.assetId);g(r)},[]),V=(t,r)=>{g(({rights:a,...i})=>{var oe,ne;const s=[...a],o=s.findIndex(k=>k.id===t.id),P=b.filter(k=>k.id===r)[0];if(s[o].actions.findIndex(k=>k.id===r)>-1){let k=s[o].actions.filter(f=>f.id!==r);const S=b.filter(f=>{var D;return(D=f.requires)==null?void 0:D.includes(r)});k=k.filter(f=>!S.find(D=>D.id===f.id)),s[o]={...s[o],actions:k}}else{const k=b.filter(S=>{var f;return((f=P.requires)==null?void 0:f.includes(S.id))&&!s[o].actions.find(D=>D.id===S.id)});s[o]={...s[o],actions:[...s[o].actions,P,...k]}}return t.type==="sharebookmark"&&((oe=s[o].users)==null||oe.forEach(k=>{const S=s.findIndex(f=>f.id===k.id);s[S]={...s[S],actions:s[o].actions}}),(ne=s[o].groups)==null||ne.forEach(k=>{const S=s.findIndex(f=>f.id===k.id);s[S]={...s[S],actions:s[o].actions}})),{rights:s,...i}})},me=async()=>{var t;try{const r=w[0].rights.filter(i=>u&&i.includes(`user:${u.userId}`)).map(i=>i.split(":")[2]).filter(i=>!!i),a=[...h.rights];if(r.length>0){const i=r.map(s=>({displayName:s,id:s}));a.push({actions:i,avatarUrl:"",directoryUrl:"",displayName:u.username,id:u.userId,type:"user"})}await ee.mutateAsync(p),await m.mutateAsync({entId:(t=w[0])==null?void 0:t.assetId,shares:a}),N.success(x("explorer.shared.status.saved")),c==null||c()}catch(r){console.error("Failed to save share",r),N.error(x("explorer.shared.status.error"))}finally{Z(!1)}},pe=t=>{g(r=>({...r,rights:h.rights.filter(a=>{var i,s;return a.id!==t.id&&!((i=t.users)!=null&&i.find(o=>o.id===a.id))&&!((s=t.groups)!=null&&s.find(o=>o.id===a.id))})}))},xe=t=>{W(t.target.value)},ge=()=>!$&&!M&&R.length>0&&E.length===0||!$&&M&&R.length>3&&E.length===0,ke=()=>M&&T.length<3,be=()=>$&&T.length>0,fe=async t=>{var r;if(q(!0),!M&&t.length>=1||M&&t.length>=3){const a=await U.share().searchShareSubjects(d,(r=w[0])==null?void 0:r.assetId,t);Q(a);const i=a.filter(s=>!h.rights.find(o=>o.id===s.id)).filter(s=>!(s.type==="user"&&s.id===w[0].creatorId)).map(s=>({value:s.id,label:s.displayName,icon:s.type==="sharebookmark"?re:null}));F(i)}else F([]),Promise.resolve();q(!1)};return{currentIsAuthor:()=>{for(const t of w)if(t.creatorId!==(u==null?void 0:u.userId))return!1;return!0},idBookmark:j,myAvatar:y,shareRights:h,shareRightActions:b,showBookmarkInput:B,searchInputValue:T,searchResults:E,bookmarkName:v,showBookmarkMembers:L,debouncedSearchInputValue:R,searchPending:$,isLoading:Y,setBookmarkName:A,saveBookmark:async t=>{try{const r=await U.directory().saveBookmarks(t,{users:h.rights.filter(a=>a.type==="user").map(a=>a.id),groups:h.rights.filter(a=>a.type==="group").map(a=>a.id),bookmarks:h.rights.filter(a=>a.type==="sharebookmark").map(a=>a.id)});N.success(x("explorer.bookmarked.status.saved")),g(a=>({...a,visibleBookmarks:[...a.visibleBookmarks,{displayName:t,id:r.id}]})),I(j+new Date().getTime().toString()),H(!1)}catch(r){console.error("Failed to save bookmark",r),N.error(x("explorer.bookmarked.status.error"))}},canSave:()=>!0,toggleBookmarkInput:H,handleActionCheckbox:V,handleShare:me,handleDeleteRow:pe,handleSearchInputChange:xe,handleSearchResultsChange:async t=>{const r=_.find(i=>i.id===t[0]),a=[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}];if(r){let i=[];if(r.type==="sharebookmark"){const s=await U.directory().getBookMarkById(r.id);i.push({...s,type:"sharebookmark",avatarUrl:"",directoryUrl:"",actions:a}),s==null||s.users.filter(o=>!h.rights.find(P=>P.id===o.id)).forEach(o=>{i.push({...o,type:"user",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})}),s.groups.filter(o=>!h.rights.find(P=>P.id===o.id)).forEach(o=>{i.push({...o,type:"group",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})})}else i=[{...r,actions:[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}]}];g({...h,rights:[...h.rights,...i]}),F(E.filter(s=>s.value!==t[0]))}},showSearchNoResults:ge,showSearchAdmlHint:ke,showSearchLoading:be,handleBookmarkMembersToggle:()=>{X(!L)},hasRight:(t,r)=>t.actions.filter(a=>r.id===a.id).length>0,showShareRightLine:t=>t.isBookmarkMember&&L||!t.isBookmarkMember}}function Oe(){const c=ue(),{assetId:p,description:d,thumbnail:x,name:u,public:y,trashed:j,slug:I,"publish-type":h}=c.length>0?c[0]:{"publish-type":"",assetId:"",description:"",name:"",public:!1,slug:"",thumbnail:"",trashed:!1},[g,b]=n.useState(h||"RESTRAINT"),[C,v]=n.useState({description:d||"",entId:p,name:u,public:!!y,slug:I||"",thumbnail:x,trashed:j,"publish-type":h});return n.useEffect(()=>{g&&v(B=>({...B,"publish-type":g}))},[g]),{radioPublicationValue:g,payloadUpdatePublishType:C,handleRadioPublicationChange:async B=>{b(B)}}}function as({isOpen:c,onSuccess:p,onCancel:d}){const{payloadUpdatePublishType:x,radioPublicationValue:u,handleRadioPublicationChange:y}=Oe(),{myAvatar:j,idBookmark:I,shareRights:h,shareRightActions:g,showBookmarkInput:b,searchResults:C,bookmarkName:v,showBookmarkMembers:A,isLoading:B,searchInputValue:H,currentIsAuthor:T,setBookmarkName:W,saveBookmark:R,canSave:_,toggleBookmarkInput:Q,handleActionCheckbox:E,handleShare:F,handleDeleteRow:L,handleSearchInputChange:X,handleSearchResultsChange:$,showSearchNoResults:q,showSearchAdmlHint:Y,showSearchLoading:Z,handleBookmarkMembersToggle:M,hasRight:w,showShareRightLine:ee}=qe({payloadUpdatePublishType:x,onSuccess:p,onCancel:d}),{t:m}=K(),N=n.useRef(null);return Re.createPortal(e.jsxs(G,{id:"share_modal",size:"lg",isOpen:c,onModalClose:d,children:[e.jsx(G.Header,{onModalClose:d,children:m("share.title")}),e.jsxs(G.Body,{children:[e.jsx(te,{headingStyle:"h4",level:"h3",className:"mb-16",children:m("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(se,{children:m("explorer.modal.share.avatar.shared.alt")})}),e.jsx("th",{scope:"col",children:e.jsx(se,{children:m("explorer.modal.share.search.placeholder")})}),g.map(l=>e.jsx("th",{scope:"col",className:"text-center text-white",children:m(l.displayName)},l.displayName)),e.jsx("th",{scope:"col",children:e.jsx(se,{children:m("close")})})]})}),e.jsxs("tbody",{children:[T()&&e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:e.jsx(ie,{alt:m("explorer.modal.share.avatar.me.alt"),size:"xs",src:j,variant:"circle"})}),e.jsx("td",{children:m("share.me")}),g.map(l=>e.jsx("td",{style:{width:"80px"},className:"text-center text-white",children:e.jsx(ce,{checked:!0,disabled:!0})},l.displayName)),e.jsx("td",{})]}),h==null?void 0:h.rights.map(l=>ee(l)&&e.jsxs("tr",{className:l.isBookmarkMember?"bg-light":"",children:[e.jsxs("td",{children:[l.type!=="sharebookmark"&&e.jsx(ie,{alt:m("explorer.modal.share.avatar.shared.alt"),size:"xs",src:l.avatarUrl,variant:"circle"}),l.type==="sharebookmark"&&e.jsx(re,{})]}),e.jsx("td",{children:e.jsxs("div",{className:"d-flex",children:[l.type==="sharebookmark"&&e.jsx(z,{color:"tertiary",rightIcon:e.jsx(de,{title:"Show",className:"w-16 min-w-0",style:{transition:"rotate 0.2s ease-out",rotate:A?"-180deg":"0deg"}}),type:"button",variant:"ghost",className:"fw-normal ps-0",onClick:M,children:l.displayName}),l.type!=="sharebookmark"&&l.displayName]})}),g.map(V=>e.jsx("td",{style:{width:"80px"},className:"text-center text-white",children:e.jsx(ce,{checked:w(l,V),onChange:()=>E(l,V.id)})},V.displayName)),e.jsx("td",{children:!l.isBookmarkMember&&e.jsx(Me,{"aria-label":"Delete",color:"tertiary",icon:e.jsx(Te,{}),type:"button",variant:"ghost",title:"Delete",onClick:()=>L(l)})})]},l.id))]})]})}),e.jsxs("div",{className:"mt-16",children:[e.jsx(z,{color:"tertiary",leftIcon:e.jsx(re,{}),rightIcon:e.jsx(de,{title:"Show",className:"w-16 min-w-0",style:{transition:"rotate 0.2s ease-out",rotate:b?"-180deg":"0deg"}}),type:"button",variant:"ghost",className:"fw-normal",onClick:()=>Q(!b),children:m("share.save.sharebookmark")}),b&&e.jsx("div",{className:"mt-16",children:e.jsxs(ae,{id:"bookmarkName",className:"d-flex flex-wrap align-items-center gap-16",children:[e.jsx("div",{className:"flex-fill",children:e.jsx(ae.Input,{ref:N,onChange:()=>{W(()=>{var l;return((l=N.current)==null?void 0:l.value)||""})},placeholder:m("explorer.modal.share.sharebookmark.placeholder"),size:"sm",type:"text"},I)}),e.jsx(z,{type:"button",color:"primary",variant:"ghost",disabled:v.length===0,leftIcon:e.jsx(Ee,{}),onClick:()=>{R(N.current.value)},className:"text-nowrap",children:m("explorer.modal.share.sharebookmark.save")})]})})]}),e.jsx("hr",{}),e.jsxs(te,{headingStyle:"h4",level:"h3",className:"mb-16 d-flex align-items-center",children:[e.jsx("div",{className:"me-8",children:m("explorer.modal.share.search")}),e.jsx(De,{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($e,{className:"c-pointer",height:"18"})})]}),e.jsx("div",{className:"row",children:e.jsx("div",{className:"col-10",children:e.jsx(Ve,{value:H,placeholder:Y()?m("explorer.search.adml.hint"):m("explorer.modal.share.search.placeholder"),isLoading:Z(),noResult:q(),options:C,onSearchInputChange:X,onSearchResultsChange:$})})}),e.jsx(He,{radioPublicationValue:u,onRadioPublicationChange:y})]}),e.jsxs(G.Footer,{children:[e.jsx(z,{type:"button",color:"tertiary",variant:"ghost",onClick:d,children:m("explorer.cancel")}),e.jsx(z,{type:"button",color:"primary",variant:"filled",isLoading:B,onClick:F,disabled:!_(),children:m("share")})]})]}),document.getElementById("portal"))}export{as as default};