mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-19 18:29:23 +00:00
1 line
8.8 KiB
JavaScript
1 line
8.8 KiB
JavaScript
"use strict";(self.webpackChunkseahub_frontend=self.webpackChunkseahub_frontend||[]).push([[5583],{65396:function(e,t,n){var r=n(23029),s=n(92901),o=n(39874),a=n(85501),i=n(9950),l=n(17119),c=n(13690),d=n(65604),h=n(40326),u=n(97011),m=n(81446),p=n(40866),f=n(4086),x=n(27288),j=n(58195),g=n(14113),A=n(99308),b=n(85907),v=n(18849),P=n(44414),k=function(e){function t(e){var n;return(0,r.A)(this,t),(n=(0,o.A)(this,t,[e])).action=function(){n.setState({btnDisabled:!0}),n.props.restoreRepo()},n.state={btnDisabled:!1},n}return(0,a.A)(t,e),(0,s.A)(t,[{key:"render",value:function(){var e=this.props.toggle;return(0,P.jsxs)(j.A,{centered:!0,isOpen:!0,toggle:e,children:[(0,P.jsx)(g.A,{toggle:e,children:(0,h.AP)("Restore Library")}),(0,P.jsx)(A.A,{children:(0,P.jsx)("p",{children:(0,h.AP)("Are you sure you want to restore this library?")})}),(0,P.jsxs)(b.A,{children:[(0,P.jsx)(v.A,{color:"secondary",onClick:e,children:(0,h.AP)("Cancel")}),(0,P.jsx)(v.A,{color:"primary",onClick:this.action,disabled:this.state.btnDisabled,children:(0,h.AP)("Restore")})]})]})}}])}(i.Component),N=(n(18291),n(81848),window.app.pageOptions),w=N.repoID,C=N.repoName,y=N.canRestoreRepo,F=N.commitID,D=N.commitTime,I=N.commitDesc,M=N.commitRelativeTime,S=N.showAuthor,O=N.authorAvatarURL,R=N.authorName,_=N.authorNickName,q=function(e){function t(e){var n;return(0,r.A)(this,t),(n=(0,o.A)(this,t,[e])).toggleDialog=function(){n.setState({isConfirmDialogOpen:!n.state.isConfirmDialogOpen})},n.onSearchedClick=function(e){if(!0===e.is_dir){var t=h.Yc+"library/"+e.repo_id+"/"+e.repo_name+e.path;(0,c.oo)(t,{repalce:!0})}else{var n=h.Yc+"lib/"+e.repo_id+"/file"+d.Aq.encodePath(e.path);window.open("about:blank").location.href=n}},n.goBack=function(e){e.preventDefault(),window.history.back()},n.renderFolder=function(e){n.setState({folderPath:e,folderItems:[],isLoading:!0}),u.e.listCommitDir(w,F,e).then((function(e){n.setState({isLoading:!1,folderItems:e.data.dirent_list})})).catch((function(e){n.setState({isLoading:!1,errorMsg:d.Aq.getErrorMsg(e,!0)})}))},n.clickFolderPath=function(e,t){t.preventDefault(),n.renderFolder(e)},n.renderPath=function(){var e=n.state.folderPath,t=e.split("/");return"/"==e?(0,P.jsx)("span",{className:"text-truncate",title:C,children:C}):(0,P.jsxs)(i.Fragment,{children:[(0,P.jsx)("a",{href:"#",onClick:n.clickFolderPath.bind(n,"/"),className:"text-truncate",title:C,children:C}),(0,P.jsx)("span",{className:"mx-1",children:"/"}),t.map((function(e,r){return r>0&&r!=t.length-1?(0,P.jsxs)(i.Fragment,{children:[(0,P.jsx)("a",{href:"#",onClick:n.clickFolderPath.bind(n,t.slice(0,r+1).join("/")),className:"text-truncate",title:t[r],children:t[r]}),(0,P.jsx)("span",{className:"mx-1",children:"/"})]},r):null})),(0,P.jsx)("span",{className:"text-truncate",title:t[t.length-1],children:t[t.length-1]})]})},n.restoreRepo=function(){u.e.revertRepo(w,F).then((function(e){n.toggleDialog(),f.A.success((0,h.AP)("Successfully restored the library."))})).catch((function(e){var t=d.Aq.getErrorMsg(e);n.toggleDialog(),f.A.danger(t)}))},n.state={isLoading:!0,errorMsg:"",folderPath:"/",folderItems:[],isConfirmDialogOpen:!1},n}return(0,a.A)(t,e),(0,s.A)(t,[{key:"componentDidMount",value:function(){this.renderFolder(this.state.folderPath)}},{key:"render",value:function(){var e=this.state,t=e.isConfirmDialogOpen,n=e.folderPath,r=(0,h.AP)("{placeholder} Snapshot");return r=r.replace("{placeholder}",'<span class="op-target text-truncate mx-1">'+d.Aq.HTMLescape(C)+"</span>"),(0,P.jsxs)(i.Fragment,{children:[(0,P.jsxs)("div",{className:"h-100 d-flex flex-column",children:[(0,P.jsxs)("div",{className:"top-header d-flex justify-content-between",children:[(0,P.jsx)("a",{href:h.Yc,children:(0,P.jsx)("img",{src:h.SG+h.VI,height:h.hM,width:h.gA,title:h.q0,alt:"logo"})}),(0,P.jsx)(x.A,{onSearchedClick:this.onSearchedClick})]}),(0,P.jsx)("div",{className:"flex-auto container-fluid pt-4 pb-6 o-auto",children:(0,P.jsx)("div",{className:"row",children:(0,P.jsxs)("div",{className:"col-md-10 offset-md-1",children:[(0,P.jsxs)("h2",{children:[(0,P.jsx)("span",{dangerouslySetInnerHTML:{__html:r},className:"d-flex mw-100"}),(0,P.jsxs)("span",{className:"heading-commit-time ml-1",children:["(",D,")"]})]}),(0,P.jsx)("a",{href:"#",className:"go-back",title:(0,h.AP)("Back"),role:"button","aria-label":(0,h.AP)("Back"),onClick:this.goBack,children:(0,P.jsx)("span",{className:"sf3-font sf3-font-down rotate-90 d-inline-block"})}),"/"==n&&(0,P.jsxs)("div",{className:"d-flex mb-2 align-items-center",children:[(0,P.jsx)("p",{className:"m-0 text-truncate",title:I,children:I}),(0,P.jsxs)("div",{className:"ml-4 border-left pl-4 d-flex align-items-center flex-shrink-0",children:[S?(0,P.jsxs)(i.Fragment,{children:[(0,P.jsx)("img",{src:O,width:"20",height:"20",alt:"",className:"rounded mr-1"}),(0,P.jsx)("a",{href:"".concat(h.Yc,"profile/").concat(encodeURIComponent(R),"/"),children:_})]}):(0,P.jsx)("span",{children:(0,h.AP)("Unknown")}),(0,P.jsx)("p",{className:"m-0 ml-2",dangerouslySetInnerHTML:{__html:M}})]})]}),(0,P.jsxs)("div",{className:"d-flex justify-content-between align-items-center op-bar",children:[(0,P.jsxs)("p",{className:"m-0 text-truncate d-flex",children:[(0,P.jsx)("span",{className:"mr-1",children:(0,h.AP)("Current path: ")}),this.renderPath()]}),"/"==n&&y&&(0,P.jsx)("button",{className:"btn btn-secondary op-bar-btn flex-shrink-0 ml-4",onClick:this.toggleDialog,children:(0,h.AP)("Restore")})]}),(0,P.jsx)(L,{data:this.state,renderFolder:this.renderFolder})]})})})]}),t&&(0,P.jsx)(p.A,{children:(0,P.jsx)(k,{restoreRepo:this.restoreRepo,toggle:this.toggleDialog})})]})}}])}(i.Component),L=function(e){function t(e){var n;return(0,r.A)(this,t),(n=(0,o.A)(this,t,[e])).theadData=[{width:"5%",text:""},{width:"55%",text:(0,h.AP)("Name")},{width:"20%",text:(0,h.AP)("Size")},{width:"20%",text:""}],n}return(0,a.A)(t,e),(0,s.A)(t,[{key:"render",value:function(){var e=this,t=this.props.data,n=t.isLoading,r=t.errorMsg,s=t.folderPath,o=t.folderItems;return n?(0,P.jsx)(m.A,{}):r?(0,P.jsx)("p",{className:"error mt-6 text-center",children:r}):(0,P.jsxs)("table",{className:"table-hover",children:[(0,P.jsx)("thead",{children:(0,P.jsx)("tr",{children:this.theadData.map((function(e,t){return(0,P.jsx)("th",{width:e.width,children:e.text},t)}))})}),(0,P.jsx)("tbody",{children:o.map((function(t,n){return(0,P.jsx)(U,{item:t,folderPath:s,renderFolder:e.props.renderFolder},n)}))})]})}}])}(i.Component),U=function(e){function t(e){var n;return(0,r.A)(this,t),(n=(0,o.A)(this,t,[e])).handleMouseOver=function(){n.setState({isIconShown:!0})},n.handleMouseOut=function(){n.setState({isIconShown:!1})},n.restoreItem=function(e){e.preventDefault();var t=n.props.item,r=d.Aq.joinPath(n.props.folderPath,t.name);("dir"==t.type?u.e.revertFolder(w,r,F):u.e.revertFile(w,r,F)).then((function(e){f.A.success((0,h.AP)("Successfully restored 1 item."))})).catch((function(e){var t=d.Aq.getErrorMsg(e);f.A.danger(t)}))},n.renderFolder=function(e){e.preventDefault();var t=n.props.item,r=n.props.folderPath;n.props.renderFolder(d.Aq.joinPath(r,t.name))},n.state={isIconShown:!1},n}return(0,a.A)(t,e),(0,s.A)(t,[{key:"render",value:function(){var e=this.props.item,t=this.state.isIconShown,n=this.props.folderPath;return"dir"==e.type?(0,P.jsxs)("tr",{onMouseOver:this.handleMouseOver,onMouseOut:this.handleMouseOut,onFocus:this.handleMouseOver,children:[(0,P.jsx)("td",{className:"text-center",children:(0,P.jsx)("img",{src:d.Aq.getFolderIconUrl(),alt:(0,h.AP)("Folder"),width:"24"})}),(0,P.jsx)("td",{children:(0,P.jsx)("a",{href:"#",onClick:this.renderFolder,children:e.name})}),(0,P.jsx)("td",{}),(0,P.jsx)("td",{children:(0,P.jsx)("a",{href:"#",className:"action-icon sf2-icon-reply ".concat(t?"":"invisible"),onClick:this.restoreItem,title:(0,h.AP)("Restore"),"aria-label":(0,h.AP)("Restore"),role:"button"})})]}):(0,P.jsxs)("tr",{onMouseOver:this.handleMouseOver,onMouseOut:this.handleMouseOut,onFocus:this.handleMouseOver,children:[(0,P.jsx)("td",{className:"text-center",children:(0,P.jsx)("img",{src:d.Aq.getFileIconUrl(e.name),alt:(0,h.AP)("File"),width:"24"})}),(0,P.jsx)("td",{children:(0,P.jsx)("a",{href:"".concat(h.Yc,"repo/").concat(w,"/snapshot/files/?obj_id=").concat(e.obj_id,"&commit_id=").concat(F,"&p=").concat(encodeURIComponent(d.Aq.joinPath(n,e.name))),target:"_blank",rel:"noreferrer",children:e.name})}),(0,P.jsx)("td",{children:d.Aq.bytesToSize(e.size)}),(0,P.jsxs)("td",{children:[(0,P.jsx)("a",{href:"#",className:"action-icon sf2-icon-reply ".concat(t?"":"invisible"),onClick:this.restoreItem,title:(0,h.AP)("Restore"),"aria-label":(0,h.AP)("Restore"),role:"button"}),(0,P.jsx)("a",{href:"".concat(h.Yc,"repo/").concat(w,"/").concat(e.obj_id,"/download/?file_name=").concat(encodeURIComponent(e.name),"&p=").concat(encodeURIComponent(d.Aq.joinPath(n,e.name))),className:"action-icon sf2-icon-download ".concat(t?"":"invisible"),title:(0,h.AP)("Download")})]})]})}}])}(i.Component);l.render((0,P.jsx)(q,{}),document.getElementById("wrapper"))}},function(e){e.O(0,[4223],(function(){return t=65396,e(e.s=t);var t}));e.O()}]); |