ode-explorer 1.0.0-dev.202306211553 → 1.0.0-dev.202306221158

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{f as J,k as K,i as z,r as c,m as Q,j as e,p as D,u as Y,a as Z,M as y,H as _,F as d,U as E,y as P,W as ee,B,X as se}from"./index.js";import{I as le}from"./ImagePicker.js";import{u as te}from"./index.esm.js";function re({resource:p,onSuccess:a,onCancel:v}){const{i18n:r}=J(),s=K(),u=z(),{reset:C,register:F,handleSubmit:t,setFocus:w,formState:{errors:m,isSubmitting:I,isValid:$}}=te({mode:"onChange"}),i=c.useId(),[M,x]=c.useState(new Date().getTime()),[n,k]=c.useState(!p.public),[g,h]=c.useState(p.slug||""),[N,b]=c.useState(!1),{hotToast:f}=Q(D),[R,j]=c.useState({name:"",image:u[0].thumbnail}),T=l=>{j(l)},o=()=>{j({name:"",image:""})};function L(l){k(!l),l||(h(""),x(new Date().getTime()))}function U(l){if(!l)return"";const S="àáäâãåăæçèéëêǵḧìíïîḿńǹñòóöôœøṕŕßśșțùúüûǘẃẍÿź·/_,:;",O="aaaaaaaaceeeeghiiiimnnnooooooprssstuuuuuwxyz------",W=new RegExp(S.split("").join("|"),"g"),X=l.toString().toLowerCase().replace(/\s+/g,"-").replace(W,G=>O.charAt(S.indexOf(G))).replace(/&/g,"-and-").replace(/[^\w\\-]+/g,"").replace(/\\-\\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"");h(X)}const V=async function(l){try{await s.mutateAsync({description:l.description,entId:u[0].assetId,name:l.title,public:l.enablePublic,slug:l.safeSlug,trashed:u[0].trashed,thumbnail:R.image}),b(!1),f.success(e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:r("explorer.resource.updated")}),e.jsxs("p",{children:["Titre: ",l.title]}),e.jsxs("p",{children:["Description: ",l.description]}),e.jsxs("p",{children:["Public:"," ",l.enablePublic?r("explorer.enable.public.yes"):r("explorer.enable.public.no")]})]})),a==null||a()}catch(S){b(!0),console.error(S)}};function q(){navigator.clipboard.writeText(`${window.location.origin}/${g}`),f.success(r("explorer.copy.clipboard"))}function A(){C(),v()}const H=`resource_edit_modal_${i}`;return{slug:g,disableSlug:n,formId:H,errors:m,isSubmitting:I,isValid:$,versionSlug:M,correctSlug:N,onPublicChange:L,onSlugChange:U,register:F,setFocus:w,handleSubmit:t,onFormCancel:A,onSubmit:V,handleUploadImage:T,handleDeleteImage:o,onCopyToClipBoard:q}}function ne({isOpen:p,edit:a,onSuccess:v,onCancel:r}){const{i18n:s,appCode:u,currentApp:C}=Y(),t=z()[0],{slug:w,formId:m,isValid:I,isSubmitting:$,disableSlug:i,versionSlug:M,correctSlug:x,register:n,handleSubmit:k,onSubmit:g,handleUploadImage:h,handleDeleteImage:N,onCopyToClipBoard:b,onSlugChange:f,onPublicChange:R}=re({resource:t,onSuccess:v,onCancel:r}),j=`${new Date().getTime()}_${i}`,T=`${M}_slug`;return Z.createPortal(e.jsxs(y,{id:"resource_edit_modal",size:"lg",isOpen:p,onModalClose:r,children:[e.jsx(y.Header,{onModalClose:r,children:s(a?"explorer.resource.editModal.header.edit":"explorer.resource.editModal.header.create")}),e.jsxs(y.Body,{children:[e.jsx(_,{headingStyle:"h4",level:"h3",className:"mb-16",children:s("explorer.resource.editModal.heading.general")}),e.jsxs("form",{id:m,onSubmit:k(g),children:[e.jsxs("div",{className:"d-flex flex-column flex-md-row gap-16 mb-24",children:[e.jsx(le,{app:C,src:t==null?void 0:t.thumbnail,label:s("explorer.imagepicker.label"),addButtonLabel:s("explorer.imagepicker.button.add"),deleteButtonLabel:s("explorer.imagepicker.button.delete"),onUploadImage:h,onDeleteImage:N,className:"align-self-center"}),e.jsxs("div",{className:"col",children:[e.jsxs(d,{id:"title",className:"mb-16",isRequired:!0,children:[e.jsx(E,{children:s("title")}),e.jsx(P,{type:"text",defaultValue:a?t==null?void 0:t.name:"",...n("title",{required:!0}),placeholder:s("explorer.resource.editModal.title.placeholder"),size:"md","aria-required":!0})]}),e.jsxs(d,{id:"description",isOptional:!0,children:[e.jsx(E,{children:s("description")}),e.jsx(P,{type:"text",defaultValue:a?t==null?void 0:t.description:"",...n("description"),placeholder:s("explorer.resource.editModal.description.placeholder"),size:"md"})]})]})]}),e.jsxs(_,{headingStyle:"h4",level:"h3",className:"mb-16",children:[s("explorer.resource.editModal.heading.access"),u]}),e.jsx(D,{type:"info",children:s("explorer.resource.editModal.access.alert")}),e.jsxs(d,{id:"flexSwitchCheckDefault",className:"form-switch d-flex gap-8 mt-16 mb-8",children:[e.jsx(d.Input,{type:"checkbox",role:"switch",...n("enablePublic",{value:t.public,onChange:o=>R(o.target.checked)}),className:"form-check-input mt-0",size:"md"},j),e.jsx(d.Label,{className:"form-check-label mb-0",children:s("explorer.resource.editModal.access.flexSwitchCheckDefault.label")})]}),e.jsx(d,{id:"slug",status:x?"invalid":void 0,children:e.jsxs("div",{className:"d-flex flex-wrap align-items-center gap-4",children:[e.jsxs("div",{children:[window.location.origin,"/"]}),e.jsxs("div",{className:"flex-fill",children:[e.jsx(P,{type:"text",...n("safeSlug",{validate:{required:o=>!o&&!i?s("explorer.slug.name.mandatory"):!0},disabled:i,value:w,onChange:o=>f(o.target.value)}),size:"md",placeholder:s("explorer.resource.editModal.access.url.extension")},T),x&&e.jsx("div",{className:"position-absolute",children:e.jsx(ee,{children:s("explorer.slug.name.error")})})]}),e.jsx(B,{color:"primary",disabled:i,onClick:()=>{b(t.slug)},type:"button",leftIcon:e.jsx(se,{}),variant:"ghost",className:"text-nowrap",children:s("explorer.resource.editModal.access.url.button")})]})})]})]}),e.jsxs(y.Footer,{children:[e.jsx(B,{color:"tertiary",onClick:r,type:"button",variant:"ghost",children:s("explorer.cancel")}),e.jsx(B,{form:m,type:"submit",color:"primary",variant:"filled",disabled:!I||$,children:s(a?"save":"explorer.create")})]})]}),document.getElementById("portal"))}export{ne as default};
1
+ import{f as J,k as K,i as z,r as c,m as Q,j as e,p as D,u as Y,a as Z,M as y,H as _,F as d,U as E,y as P,W as ee,B,X as se}from"./index.js";import{I as le}from"./ImagePicker.js";import{u as te}from"./index.esm.js";function re({resource:p,onSuccess:a,onCancel:v}){const{i18n:r}=J(),s=K(),u=z(),{reset:w,register:F,handleSubmit:t,setFocus:C,formState:{errors:m,isSubmitting:I,isValid:$}}=te({mode:"onChange"}),i=c.useId(),[M,x]=c.useState(new Date().getTime()),[n,k]=c.useState(!p.public),[g,h]=c.useState(p.slug||""),[N,b]=c.useState(!1),{hotToast:f}=Q(D),[R,j]=c.useState({name:"",image:u[0].thumbnail}),T=l=>{j(l)},o=()=>{j({name:"",image:""})};function L(l){k(!l),l||(h(""),x(new Date().getTime()))}function U(l){if(!l)return"";const S="àáäâãåăæçèéëêǵḧìíïîḿńǹñòóöôœøṕŕßśșțùúüûǘẃẍÿź·/_,:;",O="aaaaaaaaceeeeghiiiimnnnooooooprssstuuuuuwxyz------",W=new RegExp(S.split("").join("|"),"g"),X=l.toString().toLowerCase().replace(/\s+/g,"-").replace(W,G=>O.charAt(S.indexOf(G))).replace(/&/g,"-and-").replace(/[^\w\\-]+/g,"").replace(/\\-\\-+/g,"-").replace(/^-+/,"").replace(/-+$/,"");h(X)}const V=async function(l){try{await s.mutateAsync({description:l.description,entId:u[0].assetId,name:l.title,public:l.enablePublic,slug:l.safeSlug,trashed:u[0].trashed,thumbnail:R.image}),b(!1),f.success(e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:r("explorer.resource.updated")}),e.jsxs("p",{children:["Titre: ",l.title]}),e.jsxs("p",{children:["Description: ",l.description]}),e.jsxs("p",{children:["Public:"," ",l.enablePublic?r("explorer.enable.public.yes"):r("explorer.enable.public.no")]})]})),a==null||a()}catch(S){b(!0),console.error(S)}};function q(){navigator.clipboard.writeText(`${window.location.origin}${window.location.pathname}/pub/${g}`),f.success(r("explorer.copy.clipboard"))}function A(){w(),v()}const H=`resource_edit_modal_${i}`;return{slug:g,disableSlug:n,formId:H,errors:m,isSubmitting:I,isValid:$,versionSlug:M,correctSlug:N,onPublicChange:L,onSlugChange:U,register:F,setFocus:C,handleSubmit:t,onFormCancel:A,onSubmit:V,handleUploadImage:T,handleDeleteImage:o,onCopyToClipBoard:q}}function ne({isOpen:p,edit:a,onSuccess:v,onCancel:r}){const{i18n:s,appCode:u,currentApp:w}=Y(),t=z()[0],{slug:C,formId:m,isValid:I,isSubmitting:$,disableSlug:i,versionSlug:M,correctSlug:x,register:n,handleSubmit:k,onSubmit:g,handleUploadImage:h,handleDeleteImage:N,onCopyToClipBoard:b,onSlugChange:f,onPublicChange:R}=re({resource:t,onSuccess:v,onCancel:r}),j=`${new Date().getTime()}_${i}`,T=`${M}_slug`;return Z.createPortal(e.jsxs(y,{id:"resource_edit_modal",size:"lg",isOpen:p,onModalClose:r,children:[e.jsx(y.Header,{onModalClose:r,children:s(a?"explorer.resource.editModal.header.edit":"explorer.resource.editModal.header.create")}),e.jsxs(y.Body,{children:[e.jsx(_,{headingStyle:"h4",level:"h3",className:"mb-16",children:s("explorer.resource.editModal.heading.general")}),e.jsxs("form",{id:m,onSubmit:k(g),children:[e.jsxs("div",{className:"d-flex flex-column flex-md-row gap-16 mb-24",children:[e.jsx(le,{app:w,src:t==null?void 0:t.thumbnail,label:s("explorer.imagepicker.label"),addButtonLabel:s("explorer.imagepicker.button.add"),deleteButtonLabel:s("explorer.imagepicker.button.delete"),onUploadImage:h,onDeleteImage:N,className:"align-self-center"}),e.jsxs("div",{className:"col",children:[e.jsxs(d,{id:"title",className:"mb-16",isRequired:!0,children:[e.jsx(E,{children:s("title")}),e.jsx(P,{type:"text",defaultValue:a?t==null?void 0:t.name:"",...n("title",{required:!0}),placeholder:s("explorer.resource.editModal.title.placeholder"),size:"md","aria-required":!0})]}),e.jsxs(d,{id:"description",isOptional:!0,children:[e.jsx(E,{children:s("description")}),e.jsx(P,{type:"text",defaultValue:a?t==null?void 0:t.description:"",...n("description"),placeholder:s("explorer.resource.editModal.description.placeholder"),size:"md"})]})]})]}),e.jsxs(_,{headingStyle:"h4",level:"h3",className:"mb-16",children:[s("explorer.resource.editModal.heading.access"),u]}),e.jsx(D,{type:"info",children:s("explorer.resource.editModal.access.alert")}),e.jsxs(d,{id:"flexSwitchCheckDefault",className:"form-switch d-flex gap-8 mt-16 mb-8",children:[e.jsx(d.Input,{type:"checkbox",role:"switch",...n("enablePublic",{value:t.public,onChange:o=>R(o.target.checked)}),className:"form-check-input mt-0",size:"md"},j),e.jsx(d.Label,{className:"form-check-label mb-0",children:s("explorer.resource.editModal.access.flexSwitchCheckDefault.label")})]}),e.jsx(d,{id:"slug",status:x?"invalid":void 0,children:e.jsxs("div",{className:"d-flex flex-wrap align-items-center gap-4",children:[e.jsxs("div",{children:[window.location.origin,"/"]}),e.jsxs("div",{className:"flex-fill",children:[e.jsx(P,{type:"text",...n("safeSlug",{validate:{required:o=>!o&&!i?s("explorer.slug.name.mandatory"):!0},disabled:i,value:C,onChange:o=>f(o.target.value)}),size:"md",placeholder:s("explorer.resource.editModal.access.url.extension")},T),x&&e.jsx("div",{className:"position-absolute",children:e.jsx(ee,{children:s("explorer.slug.name.error")})})]}),e.jsx(B,{color:"primary",disabled:i,onClick:()=>{b(t.slug)},type:"button",leftIcon:e.jsx(se,{}),variant:"ghost",className:"text-nowrap",children:s("explorer.resource.editModal.access.url.button")})]})})]})]}),e.jsxs(y.Footer,{children:[e.jsx(B,{color:"tertiary",onClick:r,type:"button",variant:"ghost",children:s("explorer.cancel")}),e.jsx(B,{form:m,type:"submit",color:"primary",variant:"filled",disabled:!I||$,children:s(a?"save":"explorer.create")})]})]}),document.getElementById("portal"))}export{ne as default};
@@ -1 +1 @@
1
- import{r,o as F,e as W,c as C,f as fe,j as e,H as se,g as je,A as ye,u as ce,h as ve,i as de,k as Se,l as Ne,m as we,n as ae,p as Ie,a as Be,M as G,V as Z,q as oe,B as z,s as ie,t as Ae,v as Ce,F as ee,w as Me,x as Re,y as Ee,L as $e}from"./index.js";import{S as Te}from"./SelectList.js";import{T as Fe}from"./Tooltip.js";import"./usePopper.js";function Ue(l,d){const[n,u]=r.useState(l);return r.useEffect(()=>{const h=setTimeout(()=>{u(l)},d||500);return()=>{clearTimeout(h)}},[l,d]),n}function De(){const[l,d]=r.useState(!1);r.useEffect(()=>{n()},[]);const n=r.useCallback(async()=>{const u=await F.session().isAdml();d(u)},[]);return{isAdml:l}}const he=r.forwardRef(({label:l,disabled:d=!1,checked:n=!1,indeterminate:u=!1,...h},S)=>{const b=r.useRef(null);r.useImperativeHandle(S,()=>({...b.current})),r.useEffect(()=>{b.current.indeterminate=u},[b,u]);const j=r.useMemo(()=>h.id?h.id:(Math.floor(Math.random()*999999999999)+1e12).toString(),[h.id]),m={...h,type:"checkbox",checked:n,disabled:d,ref:b,className:W(h.className,"form-check-input c-pointer"),id:j};return C.jsxs("div",{className:"position-relative d-inline-block",children:[C.jsx("input",{...m}),l&&C.jsx("label",{className:"ms-8 form-check-label",htmlFor:m.id,children:l})]})});he.displayName="Checkbox";const ne=he,ue=r.forwardRef(({model:l,icon:d,label:n=!1,disabled:u=!1,...h},S)=>{const b=r.useMemo(()=>h.id?h.id:(Math.floor(Math.random()*999999999999)+1e12).toString(),[h.id]),j={...h,type:"radio",checked:l===h.value,disabled:u,ref:S,className:W(h.className,"form-check-input c-pointer",d&&"d-none"),id:b};return C.jsxs("div",{className:W("position-relative form-check",d&&"ps-0"),children:[C.jsx("input",{...j}),d&&C.jsx("label",{htmlFor:j.id,className:W("c-pointer",l!==h.value&&"text-muted"),children:d}),!d&&n&&C.jsx("label",{className:"form-check-label",htmlFor:j.id,children:n})]})});ue.displayName="Radio";const le=ue;function Pe({radioPublicationValue:l,onRadioPublicationChange:d}){const{i18n:n}=fe();return e.jsxs(e.Fragment,{children:[e.jsx("hr",{}),e.jsx(se,{headingStyle:"h4",level:"h3",className:"mb-16",children:n("explorer.publication.steps")}),e.jsx(le,{label:n("explorer.immediat.publication"),id:"publication-now",name:"publication",value:"IMMEDIATE",model:l,onChange:u=>d(u.target.value)}),e.jsx(le,{label:n("explorer.validate.publication"),id:"publication-validate",name:"publication",value:"RESTRAINT",model:l,onChange:u=>d(u.target.value)})]})}function Le({radioPublicationValue:l,onRadioPublicationChange:d}){const{app:n}=je();return n===ye.BLOG?e.jsx(Pe,{radioPublicationValue:l,onRadioPublicationChange:d}):e.jsx(e.Fragment,{})}function Ve({onSuccess:l,payloadUpdatePublishType:d}){const{appCode:n,i18n:u}=ce(),{user:h,avatar:S}=ve(),[b,j]=r.useState(r.useId()),[m,k]=r.useState({rights:[],visibleBookmarks:[],visibleGroups:[],visibleUsers:[]}),[y,N]=r.useState([]),[U,H]=r.useState(""),[w,q]=r.useState(!1),[M,_]=r.useState(""),I=Ue(M,500),[J,K]=r.useState([]),[R,D]=r.useState([]),[P,Q]=r.useState(!1),[E,O]=r.useState(!1),{isAdml:B}=De(),A=de(),X=Se();r.useEffect(()=>{Y()},[]),r.useEffect(()=>{be(I)},[I]);const Y=r.useCallback(async()=>{var a;const t=await F.share().getActionsForApp(n);N(t);const c=await F.share().getRightsForResource(n,(a=A[0])==null?void 0:a.assetId);k(c)},[]),p=(t,c)=>{k(({rights:a,...g})=>{var te,re;const s=[...a],i=s.findIndex(x=>x.id===t.id),$=y.filter(x=>x.id===c)[0];if(s[i].actions.findIndex(x=>x.id===c)>-1){let x=s[i].actions.filter(f=>f.id!==c);const v=y.filter(f=>{var T;return(T=f.requires)==null?void 0:T.includes(c)});x=x.filter(f=>!v.find(T=>T.id===f.id)),s[i]={...s[i],actions:x}}else{const x=y.filter(v=>{var f;return((f=$.requires)==null?void 0:f.includes(v.id))&&!s[i].actions.find(T=>T.id===v.id)});s[i]={...s[i],actions:[...s[i].actions,$,...x]}}return t.type==="sharebookmark"&&((te=s[i].users)==null||te.forEach(x=>{const v=s.findIndex(f=>f.id===x.id);s[v]={...s[v],actions:s[i].actions}}),(re=s[i].groups)==null||re.forEach(x=>{const v=s.findIndex(f=>f.id===x.id);s[v]={...s[v],actions:s[i].actions}})),{rights:s,...g}})},L=Ne(),{hotToast:o}=we(Ie),V=async()=>{var t;try{await L.mutate({entId:(t=A[0])==null?void 0:t.assetId,shares:m.rights}),await X.mutate(d),o.success(u("explorer.shared.status.saved")),l==null||l()}catch(c){console.error("Failed to save share",c),o.error(u("explorer.shared.status.error"))}},me=t=>{k(c=>({...c,rights:m.rights.filter(a=>{var g,s;return a.id!==t.id&&!((g=t.users)!=null&&g.find(i=>i.id===a.id))&&!((s=t.groups)!=null&&s.find(i=>i.id===a.id))})}))},pe=t=>{_(t.target.value)},xe=()=>!E&&!B&&I.length>0&&R.length===0||!E&&B&&I.length>3&&R.length===0,ke=()=>B&&M.length<3,ge=()=>E&&M.length>0,be=async t=>{var c;if(O(!0),!B&&t.length>=1||B&&t.length>=3){const a=await F.share().searchShareSubjects(n,(c=A[0])==null?void 0:c.assetId,t);K(a);const g=a.filter(s=>!m.rights.find(i=>i.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"?ae:null}));D(g)}else D([]),Promise.resolve();O(!1)};return{currentIsAuthor:()=>{for(const t of A)if(t.creatorId!==(h==null?void 0:h.userId))return!1;return!0},idBookmark:b,myAvatar:S,shareRights:m,shareRightActions:y,showBookmarkInput:w,searchInputValue:M,searchResults:R,bookmarkName:U,showBookmarkMembers:P,debouncedSearchInputValue:I,searchPending:E,setBookmarkName:H,saveBookmark:async t=>{try{const c=await F.directory().saveBookmarks(t,{users:m.rights.filter(a=>a.type==="user").map(a=>a.id),groups:m.rights.filter(a=>a.type==="group").map(a=>a.id),bookmarks:m.rights.filter(a=>a.type==="sharebookmark").map(a=>a.id)});o.success(u("explorer.bookmarked.status.saved")),k(a=>({...a,visibleBookmarks:[...a.visibleBookmarks,{displayName:t,id:c.id}]})),j(b+new Date().getTime().toString()),q(!1)}catch(c){console.error("Failed to save bookmark",c),o.error(u("explorer.bookmarked.status.error"))}},canSave:()=>!0,toggleBookmarkInput:q,handleActionCheckbox:p,handleShare:V,handleDeleteRow:me,handleSearchInputChange:pe,handleSearchResultsChange:async t=>{const c=J.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 F.directory().getBookMarkById(c.id);g.push({...s,type:"sharebookmark",avatarUrl:"",directoryUrl:"",actions:a}),s==null||s.users.filter(i=>!m.rights.find($=>$.id===i.id)).forEach(i=>{g.push({...i,type:"user",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})}),s.groups.filter(i=>!m.rights.find($=>$.id===i.id)).forEach(i=>{g.push({...i,type:"group",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})})}else g=[{...c,actions:[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}]}];k({...m,rights:[...m.rights,...g]}),D(R.filter(s=>s.value!==t[0]))}},showSearchNoResults:xe,showSearchAdmlHint:ke,showSearchLoading:ge,handleBookmarkMembersToggle:()=>{Q(!P)},hasRight:(t,c)=>t.actions.filter(a=>c.id===a.id).length>0,showShareRightLine:t=>t.isBookmarkMember&&P||!t.isBookmarkMember}}function ze(){const l=de(),{assetId:d,description:n,thumbnail:u,name:h,public:S,trashed:b,slug:j,"publish-type":m}=l[0],[k,y]=r.useState(m||"IMMEDIATE"),[N,U]=r.useState({description:n,entId:d,name:h,public:!!S,slug:j||"",thumbnail:u,trashed:b,"publish-type":m});return r.useEffect(()=>{k&&U(w=>({...w,"publish-type":k}))},[k]),{radioPublicationValue:k,payloadUpdatePublishType:N,handleRadioPublicationChange:async w=>{y(w)}}}function es({isOpen:l,onSuccess:d,onCancel:n}){const{payloadUpdatePublishType:u,radioPublicationValue:h,handleRadioPublicationChange:S}=ze(),{myAvatar:b,idBookmark:j,shareRights:m,shareRightActions:k,showBookmarkInput:y,searchResults:N,bookmarkName:U,showBookmarkMembers:H,searchPending:w,currentIsAuthor:q,setBookmarkName:M,saveBookmark:_,canSave:I,toggleBookmarkInput:J,handleActionCheckbox:K,handleShare:R,handleDeleteRow:D,handleSearchInputChange:P,handleSearchResultsChange:Q,showSearchNoResults:E,showSearchAdmlHint:O,showSearchLoading:B,handleBookmarkMembersToggle:A,hasRight:X,showShareRightLine:Y}=Ve({payloadUpdatePublishType:u,onSuccess:d,onCancel:n}),{i18n:p}=ce(),L=r.useRef(null);return Be.createPortal(e.jsxs(G,{id:"share_modal",size:"lg",isOpen:l,onModalClose:n,children:[e.jsx(G.Header,{onModalClose:n,children:p("share.title")}),e.jsxs(G.Body,{children:[e.jsx(se,{headingStyle:"h4",level:"h3",className:"mb-16",children:p("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 text-white",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"w-32",children:e.jsx(Z,{children:p("explorer.modal.share.avatar.shared.alt")})}),e.jsx("th",{scope:"col",children:e.jsx(Z,{children:p("explorer.modal.share.search.placeholder")})}),k.map(o=>e.jsx("th",{scope:"col",className:"text-center",children:p(o.displayName)},o.displayName)),e.jsx("th",{scope:"col",children:e.jsx(Z,{children:p("close")})})]})}),e.jsxs("tbody",{children:[q()&&e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:e.jsx(oe,{alt:p("explorer.modal.share.avatar.me.alt"),size:"xs",src:b,variant:"circle"})}),e.jsx("td",{children:p("share.me")}),k.map(o=>e.jsx("td",{style:{width:"80px"},className:"text-center",children:e.jsx(ne,{checked:!0,disabled:!0})},o.displayName)),e.jsx("td",{})]}),m==null?void 0:m.rights.map(o=>Y(o)&&e.jsxs("tr",{className:o.isBookmarkMember?"bg-light":"",children:[e.jsxs("td",{children:[o.type!=="sharebookmark"&&e.jsx(oe,{alt:p("explorer.modal.share.avatar.shared.alt"),size:"xs",src:o.avatarUrl,variant:"circle"}),o.type==="sharebookmark"&&e.jsx(ae,{})]}),e.jsx("td",{children:e.jsxs("div",{className:"d-flex",children:[o.type==="sharebookmark"&&e.jsx(z,{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:o.displayName}),o.type!=="sharebookmark"&&o.displayName]})}),k.map(V=>e.jsx("td",{style:{width:"80px"},className:"text-center",children:e.jsx(ne,{checked:X(o,V),onChange:()=>K(o,V.id)})},V.displayName)),e.jsx("td",{children:!o.isBookmarkMember&&e.jsx(Ae,{"aria-label":"Delete",color:"tertiary",icon:e.jsx(Ce,{}),type:"button",variant:"ghost",title:"Delete",onClick:()=>D(o)})})]},o.id))]})]})}),e.jsxs("div",{className:"mt-16",children:[e.jsx(z,{color:"tertiary",leftIcon:e.jsx(ae,{}),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:()=>J(!y),children:p("share.save.sharebookmark")}),y&&e.jsx("div",{className:"mt-16",children:e.jsxs(ee,{id:"bookmarkName",className:"d-flex flex-wrap align-items-center gap-16",children:[e.jsx("div",{className:"flex-fill",children:e.jsx(ee.Input,{ref:L,onChange:()=>{M(()=>{var o;return((o=L.current)==null?void 0:o.value)||""})},placeholder:p("explorer.modal.share.sharebookmark.placeholder"),size:"sm",type:"text"},j)}),e.jsx(z,{type:"button",color:"primary",variant:"ghost",disabled:U.length===0,leftIcon:e.jsx(Me,{}),onClick:()=>{_(L.current.value)},className:"text-nowrap",children:p("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:p("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(Re,{className:"c-pointer",height:"18"})})]}),e.jsxs(ee,{className:"d-flex align-items-center",id:"search",children:[e.jsx(Ee,{className:"max-w-512",noValidationIcon:!0,placeholder:O()?p("explorer.search.adml.hint"):p("explorer.modal.share.search.placeholder"),size:"md",type:"search",onChange:P}),B()&&e.jsxs("div",{className:"d-flex align-items-center p-4",children:[e.jsx($e,{isLoading:w}),e.jsx("span",{className:"ps-4",children:p("explorer.search.pending")})]}),E()&&e.jsx("div",{className:"p-4",children:p("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(Te,{options:N,hideCheckbox:!0,isMonoSelection:!0,onChange:Q})}),e.jsx(Le,{radioPublicationValue:h,onRadioPublicationChange:S})]}),e.jsxs(G.Footer,{children:[e.jsx(z,{type:"button",color:"tertiary",variant:"ghost",onClick:n,children:p("explorer.cancel")}),e.jsx(z,{type:"button",color:"primary",variant:"filled",onClick:R,disabled:!I(),children:p("share")})]})]}),document.getElementById("portal"))}export{es as default};
1
+ import{r,o as F,e as W,c as C,f as fe,j as e,H as se,g as ye,A as je,u as ce,h as ve,i as de,k as Se,l as Ne,m as we,n as ae,p as Ie,a as Be,M as G,V as Z,q as oe,B as z,s as ie,t as Ae,v as Ce,F as ee,w as Me,x as Re,y as Ee,L as $e}from"./index.js";import{S as Te}from"./SelectList.js";import{T as Fe}from"./Tooltip.js";import"./usePopper.js";function Ue(l,d){const[n,u]=r.useState(l);return r.useEffect(()=>{const h=setTimeout(()=>{u(l)},d||500);return()=>{clearTimeout(h)}},[l,d]),n}function De(){const[l,d]=r.useState(!1);r.useEffect(()=>{n()},[]);const n=r.useCallback(async()=>{const u=await F.session().isAdml();d(u)},[]);return{isAdml:l}}const he=r.forwardRef(({label:l,disabled:d=!1,checked:n=!1,indeterminate:u=!1,...h},S)=>{const b=r.useRef(null);r.useImperativeHandle(S,()=>({...b.current})),r.useEffect(()=>{b.current.indeterminate=u},[b,u]);const y=r.useMemo(()=>h.id?h.id:(Math.floor(Math.random()*999999999999)+1e12).toString(),[h.id]),m={...h,type:"checkbox",checked:n,disabled:d,ref:b,className:W(h.className,"form-check-input c-pointer"),id:y};return C.jsxs("div",{className:"position-relative d-inline-block",children:[C.jsx("input",{...m}),l&&C.jsx("label",{className:"ms-8 form-check-label",htmlFor:m.id,children:l})]})});he.displayName="Checkbox";const ne=he,ue=r.forwardRef(({model:l,icon:d,label:n=!1,disabled:u=!1,...h},S)=>{const b=r.useMemo(()=>h.id?h.id:(Math.floor(Math.random()*999999999999)+1e12).toString(),[h.id]),y={...h,type:"radio",checked:l===h.value,disabled:u,ref:S,className:W(h.className,"form-check-input c-pointer",d&&"d-none"),id:b};return C.jsxs("div",{className:W("position-relative form-check",d&&"ps-0"),children:[C.jsx("input",{...y}),d&&C.jsx("label",{htmlFor:y.id,className:W("c-pointer",l!==h.value&&"text-muted"),children:d}),!d&&n&&C.jsx("label",{className:"form-check-label",htmlFor:y.id,children:n})]})});ue.displayName="Radio";const le=ue;function Pe({radioPublicationValue:l,onRadioPublicationChange:d}){const{i18n:n}=fe();return e.jsxs(e.Fragment,{children:[e.jsx("hr",{}),e.jsx(se,{headingStyle:"h4",level:"h3",className:"mb-16",children:n("explorer.publication.steps")}),e.jsx(le,{label:n("explorer.immediat.publication"),id:"publication-now",name:"publication",value:"IMMEDIATE",model:l,onChange:u=>d(u.target.value)}),e.jsx(le,{label:n("explorer.validate.publication"),id:"publication-validate",name:"publication",value:"RESTRAINT",model:l,onChange:u=>d(u.target.value)})]})}function Le({radioPublicationValue:l,onRadioPublicationChange:d}){const{app:n}=ye();return n===je.BLOG?e.jsx(Pe,{radioPublicationValue:l,onRadioPublicationChange:d}):e.jsx(e.Fragment,{})}function Ve({onSuccess:l,payloadUpdatePublishType:d}){const{appCode:n,i18n:u}=ce(),{user:h,avatar:S}=ve(),[b,y]=r.useState(r.useId()),[m,k]=r.useState({rights:[],visibleBookmarks:[],visibleGroups:[],visibleUsers:[]}),[j,N]=r.useState([]),[U,H]=r.useState(""),[w,q]=r.useState(!1),[M,_]=r.useState(""),I=Ue(M,500),[J,K]=r.useState([]),[R,D]=r.useState([]),[P,Q]=r.useState(!1),[E,O]=r.useState(!1),{isAdml:B}=De(),A=de(),X=Se();r.useEffect(()=>{Y()},[]),r.useEffect(()=>{be(I)},[I]);const Y=r.useCallback(async()=>{var a;const t=await F.share().getActionsForApp(n);N(t);const c=await F.share().getRightsForResource(n,(a=A[0])==null?void 0:a.assetId);k(c)},[]),p=(t,c)=>{k(({rights:a,...g})=>{var te,re;const s=[...a],i=s.findIndex(x=>x.id===t.id),$=j.filter(x=>x.id===c)[0];if(s[i].actions.findIndex(x=>x.id===c)>-1){let x=s[i].actions.filter(f=>f.id!==c);const v=j.filter(f=>{var T;return(T=f.requires)==null?void 0:T.includes(c)});x=x.filter(f=>!v.find(T=>T.id===f.id)),s[i]={...s[i],actions:x}}else{const x=j.filter(v=>{var f;return((f=$.requires)==null?void 0:f.includes(v.id))&&!s[i].actions.find(T=>T.id===v.id)});s[i]={...s[i],actions:[...s[i].actions,$,...x]}}return t.type==="sharebookmark"&&((te=s[i].users)==null||te.forEach(x=>{const v=s.findIndex(f=>f.id===x.id);s[v]={...s[v],actions:s[i].actions}}),(re=s[i].groups)==null||re.forEach(x=>{const v=s.findIndex(f=>f.id===x.id);s[v]={...s[v],actions:s[i].actions}})),{rights:s,...g}})},L=Ne(),{hotToast:o}=we(Ie),V=async()=>{var t;try{await X.mutateAsync(d),await L.mutateAsync({entId:(t=A[0])==null?void 0:t.assetId,shares:m.rights}),o.success(u("explorer.shared.status.saved")),l==null||l()}catch(c){console.error("Failed to save share",c),o.error(u("explorer.shared.status.error"))}},me=t=>{k(c=>({...c,rights:m.rights.filter(a=>{var g,s;return a.id!==t.id&&!((g=t.users)!=null&&g.find(i=>i.id===a.id))&&!((s=t.groups)!=null&&s.find(i=>i.id===a.id))})}))},pe=t=>{_(t.target.value)},xe=()=>!E&&!B&&I.length>0&&R.length===0||!E&&B&&I.length>3&&R.length===0,ke=()=>B&&M.length<3,ge=()=>E&&M.length>0,be=async t=>{var c;if(O(!0),!B&&t.length>=1||B&&t.length>=3){const a=await F.share().searchShareSubjects(n,(c=A[0])==null?void 0:c.assetId,t);K(a);const g=a.filter(s=>!m.rights.find(i=>i.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"?ae:null}));D(g)}else D([]),Promise.resolve();O(!1)};return{currentIsAuthor:()=>{for(const t of A)if(t.creatorId!==(h==null?void 0:h.userId))return!1;return!0},idBookmark:b,myAvatar:S,shareRights:m,shareRightActions:j,showBookmarkInput:w,searchInputValue:M,searchResults:R,bookmarkName:U,showBookmarkMembers:P,debouncedSearchInputValue:I,searchPending:E,setBookmarkName:H,saveBookmark:async t=>{try{const c=await F.directory().saveBookmarks(t,{users:m.rights.filter(a=>a.type==="user").map(a=>a.id),groups:m.rights.filter(a=>a.type==="group").map(a=>a.id),bookmarks:m.rights.filter(a=>a.type==="sharebookmark").map(a=>a.id)});o.success(u("explorer.bookmarked.status.saved")),k(a=>({...a,visibleBookmarks:[...a.visibleBookmarks,{displayName:t,id:c.id}]})),y(b+new Date().getTime().toString()),q(!1)}catch(c){console.error("Failed to save bookmark",c),o.error(u("explorer.bookmarked.status.error"))}},canSave:()=>!0,toggleBookmarkInput:q,handleActionCheckbox:p,handleShare:V,handleDeleteRow:me,handleSearchInputChange:pe,handleSearchResultsChange:async t=>{const c=J.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 F.directory().getBookMarkById(c.id);g.push({...s,type:"sharebookmark",avatarUrl:"",directoryUrl:"",actions:a}),s==null||s.users.filter(i=>!m.rights.find($=>$.id===i.id)).forEach(i=>{g.push({...i,type:"user",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})}),s.groups.filter(i=>!m.rights.find($=>$.id===i.id)).forEach(i=>{g.push({...i,type:"group",avatarUrl:"",directoryUrl:"",actions:a,isBookmarkMember:!0})})}else g=[{...c,actions:[{id:"read",displayName:"read"},{id:"comment",displayName:"comment"}]}];k({...m,rights:[...m.rights,...g]}),D(R.filter(s=>s.value!==t[0]))}},showSearchNoResults:xe,showSearchAdmlHint:ke,showSearchLoading:ge,handleBookmarkMembersToggle:()=>{Q(!P)},hasRight:(t,c)=>t.actions.filter(a=>c.id===a.id).length>0,showShareRightLine:t=>t.isBookmarkMember&&P||!t.isBookmarkMember}}function ze(){const l=de(),{assetId:d,description:n,thumbnail:u,name:h,public:S,trashed:b,slug:y,"publish-type":m}=l[0],[k,j]=r.useState(m||"IMMEDIATE"),[N,U]=r.useState({description:n,entId:d,name:h,public:!!S,slug:y||"",thumbnail:u,trashed:b,"publish-type":m});return r.useEffect(()=>{k&&U(w=>({...w,"publish-type":k}))},[k]),{radioPublicationValue:k,payloadUpdatePublishType:N,handleRadioPublicationChange:async w=>{j(w)}}}function es({isOpen:l,onSuccess:d,onCancel:n}){const{payloadUpdatePublishType:u,radioPublicationValue:h,handleRadioPublicationChange:S}=ze(),{myAvatar:b,idBookmark:y,shareRights:m,shareRightActions:k,showBookmarkInput:j,searchResults:N,bookmarkName:U,showBookmarkMembers:H,searchPending:w,currentIsAuthor:q,setBookmarkName:M,saveBookmark:_,canSave:I,toggleBookmarkInput:J,handleActionCheckbox:K,handleShare:R,handleDeleteRow:D,handleSearchInputChange:P,handleSearchResultsChange:Q,showSearchNoResults:E,showSearchAdmlHint:O,showSearchLoading:B,handleBookmarkMembersToggle:A,hasRight:X,showShareRightLine:Y}=Ve({payloadUpdatePublishType:u,onSuccess:d,onCancel:n}),{i18n:p}=ce(),L=r.useRef(null);return Be.createPortal(e.jsxs(G,{id:"share_modal",size:"lg",isOpen:l,onModalClose:n,children:[e.jsx(G.Header,{onModalClose:n,children:p("share.title")}),e.jsxs(G.Body,{children:[e.jsx(se,{headingStyle:"h4",level:"h3",className:"mb-16",children:p("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 text-white",children:e.jsxs("tr",{children:[e.jsx("th",{scope:"col",className:"w-32",children:e.jsx(Z,{children:p("explorer.modal.share.avatar.shared.alt")})}),e.jsx("th",{scope:"col",children:e.jsx(Z,{children:p("explorer.modal.share.search.placeholder")})}),k.map(o=>e.jsx("th",{scope:"col",className:"text-center",children:p(o.displayName)},o.displayName)),e.jsx("th",{scope:"col",children:e.jsx(Z,{children:p("close")})})]})}),e.jsxs("tbody",{children:[q()&&e.jsxs("tr",{children:[e.jsx("th",{scope:"row",children:e.jsx(oe,{alt:p("explorer.modal.share.avatar.me.alt"),size:"xs",src:b,variant:"circle"})}),e.jsx("td",{children:p("share.me")}),k.map(o=>e.jsx("td",{style:{width:"80px"},className:"text-center",children:e.jsx(ne,{checked:!0,disabled:!0})},o.displayName)),e.jsx("td",{})]}),m==null?void 0:m.rights.map(o=>Y(o)&&e.jsxs("tr",{className:o.isBookmarkMember?"bg-light":"",children:[e.jsxs("td",{children:[o.type!=="sharebookmark"&&e.jsx(oe,{alt:p("explorer.modal.share.avatar.shared.alt"),size:"xs",src:o.avatarUrl,variant:"circle"}),o.type==="sharebookmark"&&e.jsx(ae,{})]}),e.jsx("td",{children:e.jsxs("div",{className:"d-flex",children:[o.type==="sharebookmark"&&e.jsx(z,{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:o.displayName}),o.type!=="sharebookmark"&&o.displayName]})}),k.map(V=>e.jsx("td",{style:{width:"80px"},className:"text-center",children:e.jsx(ne,{checked:X(o,V),onChange:()=>K(o,V.id)})},V.displayName)),e.jsx("td",{children:!o.isBookmarkMember&&e.jsx(Ae,{"aria-label":"Delete",color:"tertiary",icon:e.jsx(Ce,{}),type:"button",variant:"ghost",title:"Delete",onClick:()=>D(o)})})]},o.id))]})]})}),e.jsxs("div",{className:"mt-16",children:[e.jsx(z,{color:"tertiary",leftIcon:e.jsx(ae,{}),rightIcon:e.jsx(ie,{title:"Show",className:"w-16 min-w-0",style:{transition:"rotate 0.2s ease-out",rotate:j?"-180deg":"0deg"}}),type:"button",variant:"ghost",className:"fw-normal",onClick:()=>J(!j),children:p("share.save.sharebookmark")}),j&&e.jsx("div",{className:"mt-16",children:e.jsxs(ee,{id:"bookmarkName",className:"d-flex flex-wrap align-items-center gap-16",children:[e.jsx("div",{className:"flex-fill",children:e.jsx(ee.Input,{ref:L,onChange:()=>{M(()=>{var o;return((o=L.current)==null?void 0:o.value)||""})},placeholder:p("explorer.modal.share.sharebookmark.placeholder"),size:"sm",type:"text"},y)}),e.jsx(z,{type:"button",color:"primary",variant:"ghost",disabled:U.length===0,leftIcon:e.jsx(Me,{}),onClick:()=>{_(L.current.value)},className:"text-nowrap",children:p("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:p("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(Re,{className:"c-pointer",height:"18"})})]}),e.jsxs(ee,{className:"d-flex align-items-center",id:"search",children:[e.jsx(Ee,{className:"max-w-512",noValidationIcon:!0,placeholder:O()?p("explorer.search.adml.hint"):p("explorer.modal.share.search.placeholder"),size:"md",type:"search",onChange:P}),B()&&e.jsxs("div",{className:"d-flex align-items-center p-4",children:[e.jsx($e,{isLoading:w}),e.jsx("span",{className:"ps-4",children:p("explorer.search.pending")})]}),E()&&e.jsx("div",{className:"p-4",children:p("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(Te,{options:N,hideCheckbox:!0,isMonoSelection:!0,onChange:Q})}),e.jsx(Le,{radioPublicationValue:h,onRadioPublicationChange:S})]}),e.jsxs(G.Footer,{children:[e.jsx(z,{type:"button",color:"tertiary",variant:"ghost",onClick:n,children:p("explorer.cancel")}),e.jsx(z,{type:"button",color:"primary",variant:"filled",onClick:R,disabled:!I(),children:p("share")})]})]}),document.getElementById("portal"))}export{es as default};
package/dist/version.txt CHANGED
@@ -1 +1 @@
1
- ode-explorer=1.0-feat-explorer-SNAPSHOT 21/06/2023 15:53:48
1
+ ode-explorer=1.0-feat-explorer-SNAPSHOT 22/06/2023 11:58:46
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ode-explorer",
3
- "version": "1.0.0-dev.202306211553",
3
+ "version": "1.0.0-dev.202306221158",
4
4
  "description": "Open Digital Education Explorer",
5
5
  "homepage": "https://github.com/opendigitaleducation/explorer#readme",
6
6
  "bugs": {