3 lines
3.3 KiB
JavaScript
3 lines
3.3 KiB
JavaScript
import{h as _,i as y,j as b,e as t,c as u,o as f,w as R,k as v,m as D,t as S,u as i,n as O,_ as k,l as q,s as C,d,p,q as P}from"./TrayArrowDown-sRwZP_WA.chunk.mjs";import{N as F,a as x,b as N,s as h}from"./Plus-DDsJI2iW.chunk.mjs";import{N as E}from"./TrashCanOutline-avc1vI9P.chunk.mjs";import{l as j}from"./logger-Cu5Dvow_.chunk.mjs";import"./ContentCopy-BEfKgtZW.chunk.mjs";const M=_({__name:"RemoteShareDialog",props:{name:{},owner:{},remote:{},passwordRequired:{type:Boolean}},emits:["close"],setup(e,{emit:s}){const r=e,a=s,o=y(""),n=b(()=>[{label:t("federatedfilesharing","Cancel"),callback:()=>a("close",!1)},{label:t("federatedfilesharing","Add remote share"),type:r.passwordRequired?"submit":void 0,variant:"primary",callback:()=>a("close",!0,o.value)}]);return(c,l)=>(f(),u(i(F),{buttons:n.value,"is-form":e.passwordRequired,name:i(t)("federatedfilesharing","Remote share"),onSubmit:l[1]||(l[1]=w=>a("close",!0,o.value))},{default:R(()=>[v("p",null,S(i(t)("federatedfilesharing","Do you want to add the remote share {name} from {owner}@{remote}?",{name:e.name,owner:e.owner,remote:e.remote})),1),e.passwordRequired?(f(),u(i(E),{key:0,modelValue:o.value,"onUpdate:modelValue":l[0]||(l[0]=w=>o.value=w),class:O(c.$style.remoteShareDialog__password),label:i(t)("federatedfilesharing","Remote share password")},null,8,["modelValue","class","label"])):D("",!0)]),_:1},8,["buttons","is-form","name"]))}}),T="_remoteShareDialog__password_1ccpy_2",U={remoteShareDialog__password:T},V={$style:U},$=k(M,[["__cssModules",V]]);async function I(e,s,r,a=!1){const[o,n]=await x($,{name:e,owner:s,remote:r,passwordRequired:a});if(a&&o)return n;if(!o)throw new Error("Dialog was cancelled")}window.addEventListener("DOMContentLoaded",()=>{L(),q("federatedfilesharing","notificationsEnabled",!0)!==!0&&A(),C("notifications:action:executed",({action:e,notification:s})=>{s.app==="files_sharing"&&s.object_type==="remote_share"&&e.type==="POST"&&m()})});function m(){if(!window?.OCP?.Files?.Router?.goToRoute){window.location.reload();return}window.OCP.Files.Router.goToRoute(null,{...window.OCP.Files.Router.params,fileid:void 0},{...window.OCP.Files.Router.query,dir:"/",openfile:void 0})}function L(){const e=window.OC.Util.History.parseUrlQuery();if(e.remote&&e.token&&e.name){const s=(r,a)=>{r!==!1&&d.post(p("apps/federatedfilesharing/askForFederatedShare"),{remote:a.remote,token:a.token,owner:a.owner,ownerDisplayName:a.ownerDisplayName||a.owner,name:a.name,password:a.password||""}).then(({data:o})=>{Object.hasOwn(o,"legacyMount")?m():N(o.message)}).catch(o=>{j.error("Error while processing incoming share",{error:o}),P(o)&&o.response.data.message?h(o.response.data.message):h(t("federatedfilesharing","Incoming share could not be processed"))})};location.hash="",e.passwordProtected=parseInt(e.protected,10)===1,g(e,e.passwordProtected,s)}}async function A(){const{data:e}=await d.get(p("/apps/files_sharing/api/externalShares"));for(let s=0;s<e.length;++s)g(e[s],!1,function(r,a){r===!1?d.delete(p("/apps/files_sharing/api/externalShares/"+a.id)):d.post(p("/apps/files_sharing/api/externalShares"),{id:a.id}).then(()=>m())})}function g(e,s,r){const a=e.ownerDisplayName||e.owner,o=e.name,n=e.remote.replace(/^https?:\/\//,"").replace(/\/$/,"");I(o,a,n,s).then(c=>r(!0,{...e,password:c})).catch(()=>r(!1,e))}
|
|
//# sourceMappingURL=federatedfilesharing-init-files.mjs.map
|