"use strict";(self.webpackChunkseahub_frontend=self.webpackChunkseahub_frontend||[]).push([[9023],{68849:function(e,t,r){var n=r(23029),s=r(92901),o=r(39874),a=r(85501),i=r(9950),l=r(58195),c=r(14113),d=r(99308),h=r(85907),u=r(18849),m=r(20015),p=r(30730),f=r(40326),x=r(97011),g=r(65604),j=r(4086),A=r(44414),b=function(e){function t(e){var r;return(0,n.A)(this,t),(r=(0,o.A)(this,t,[e])).handleInputChange=function(e){r.setState({inputValue:e})},r.formSubmit=function(){var e=r.state.inputValue,t=r.props.repoID;r.setState({submitBtnDisabled:!0}),x.e.deleteRepoTrash(t,e.value).then((function(e){j.A.success((0,f.AP)("Clean succeeded.")),r.props.refreshTrash(),r.props.toggleDialog()})).catch((function(e){var t=g.Aq.getErrorMsg(e);r.setState({formErrorMsg:t,submitBtnDisabled:!1})}))},r.options=[{label:(0,f.AP)("3 days ago"),value:3},{label:(0,f.AP)("1 week ago"),value:7},{label:(0,f.AP)("1 month ago"),value:30},{label:(0,f.AP)("all"),value:0}],r.state={inputValue:r.options[0],submitBtnDisabled:!1},r}return(0,a.A)(t,e),(0,s.A)(t,[{key:"render",value:function(){var e=this.state.formErrorMsg;return(0,A.jsxs)(l.A,{isOpen:!0,toggle:this.props.toggleDialog,children:[(0,A.jsx)(c.A,{toggle:this.props.toggleDialog,children:(0,f.AP)("Clean")}),(0,A.jsx)(d.A,{children:(0,A.jsxs)(i.Fragment,{children:[(0,A.jsx)("p",{children:(0,f.AP)("Clear files in trash and history\uff1a")}),(0,A.jsx)(m.A,{defaultValue:this.options[0],options:this.options,autoFocus:!1,onChange:this.handleInputChange,placeholder:"",styles:p.xD}),e&&(0,A.jsx)("p",{className:"error m-0 mt-2",children:e})]})}),(0,A.jsxs)(h.A,{children:[(0,A.jsx)(u.A,{color:"secondary",onClick:this.props.toggleDialog,children:(0,f.AP)("Cancel")}),(0,A.jsx)(u.A,{color:"primary",disabled:this.state.submitBtnDisabled,onClick:this.formSubmit,children:(0,f.AP)("Submit")})]})]})}}])}(i.Component);t.A=b},12121:function(e,t,r){var n=r(23029),s=r(92901),o=r(39874),a=r(85501),i=r(9950),l=r(17119),c=r(13690),d=r(4159),h=r.n(d),u=r(65604),m=r(40326),p=r(97011),f=r(81446),x=r(40866),g=r(4086),j=r(27288),A=r(68849),b=(r(18291),r(81848),r(44414)),v=window.app.pageOptions,M=v.repoID,D=v.repoFolderName,P=v.path,k=v.enableUserCleanTrash,C=v.isRepoAdmin,F=function(e){function t(e){var r;return(0,n.A)(this,t),(r=(0,o.A)(this,t,[e])).getItems=function(e){p.e.getRepoFolderTrash(M,P,e).then((function(e){var t=e.data,n=t.data,s=t.more,o=t.scan_stat;!n.length&&s?r.getItems(o):r.setState({isLoading:!1,items:r.state.items.concat(n),more:s,scanStat:o})})).catch((function(e){r.setState({isLoading:!1,errorMsg:u.Aq.getErrorMsg(e,!0)})}))},r.getMore=function(){r.setState({isLoading:!0}),r.getItems(r.state.scanStat)},r.onSearchedClick=function(e){if(!0===e.is_dir){var t=m.Yc+"library/"+e.repo_id+"/"+e.repo_name+e.path;(0,c.oo)(t,{repalce:!0})}else{var r=m.Yc+"lib/"+e.repo_id+"/file"+u.Aq.encodePath(e.path);window.open("about:blank").location.href=r}},r.goBack=function(e){e.preventDefault(),window.history.back()},r.cleanTrash=function(){r.toggleCleanTrashDialog()},r.toggleCleanTrashDialog=function(){r.setState({isCleanTrashDialogOpen:!r.state.isCleanTrashDialogOpen})},r.refreshTrash=function(){r.setState({isLoading:!0,errorMsg:"",items:[],scanStat:null,more:!1,showFolder:!1}),r.getItems()},r.renderFolder=function(e,t,n){r.setState({showFolder:!0,commitID:e,baseDir:t,folderPath:n,folderItems:[],isLoading:!0}),p.e.listCommitDir(M,e,"".concat(t.substr(0,t.length-1)).concat(n)).then((function(e){r.setState({isLoading:!1,folderItems:e.data.dirent_list})})).catch((function(e){e.response?403==e.response.status?r.setState({isLoading:!1,errorMsg:(0,m.AP)("Permission denied")}):r.setState({isLoading:!1,errorMsg:(0,m.AP)("Error")}):r.setState({isLoading:!1,errorMsg:(0,m.AP)("Please check the network.")})}))},r.clickRoot=function(e){e.preventDefault(),r.refreshTrash()},r.clickFolderPath=function(e,t){t.preventDefault();var n=r.state,s=n.commitID,o=n.baseDir;r.renderFolder(s,o,e)},r.renderFolderPath=function(){var e=r.state.folderPath.split("/");return(0,b.jsxs)(i.Fragment,{children:[(0,b.jsx)("a",{href:"#",onClick:r.clickRoot,className:"text-truncate",title:D,children:D}),(0,b.jsx)("span",{className:"mx-1",children:"/"}),e.map((function(t,n){return n>0&&n!=e.length-1?(0,b.jsxs)(i.Fragment,{children:[(0,b.jsx)("a",{className:"text-truncate",href:"#",onClick:r.clickFolderPath.bind(r,e.slice(0,n+1).join("/")),title:e[n],children:e[n]}),(0,b.jsx)("span",{className:"mx-1",children:"/"})]},n):null})),(0,b.jsx)("span",{className:"text-truncate",title:e[e.length-1],children:e[e.length-1]})]})},r.state={isLoading:!0,errorMsg:"",items:[],scanStat:null,more:!1,isCleanTrashDialogOpen:!1},r}return(0,a.A)(t,e),(0,s.A)(t,[{key:"componentDidMount",value:function(){this.getItems()}},{key:"render",value:function(){var e=this.state,t=e.isCleanTrashDialogOpen,r=e.showFolder,n=(0,m.AP)("{placeholder} Trash");return n=n.replace("{placeholder}",''+u.Aq.HTMLescape(D)+""),(0,b.jsxs)(i.Fragment,{children:[(0,b.jsxs)("div",{className:"h-100 d-flex flex-column",children:[(0,b.jsxs)("div",{className:"top-header d-flex justify-content-between",children:[(0,b.jsx)("a",{href:m.Yc,children:(0,b.jsx)("img",{src:m.SG+m.VI,height:m.hM,width:m.gA,title:m.q0,alt:"logo"})}),(0,b.jsx)(j.A,{onSearchedClick:this.onSearchedClick})]}),(0,b.jsx)("div",{className:"flex-auto container-fluid pt-4 pb-6 o-auto",children:(0,b.jsx)("div",{className:"row",children:(0,b.jsxs)("div",{className:"col-md-10 offset-md-1",children:[(0,b.jsx)("h2",{dangerouslySetInnerHTML:{__html:n},className:"d-flex mw-100"}),(0,b.jsx)("a",{href:"#",className:"go-back",title:(0,m.AP)("Back"),onClick:this.goBack,role:(0,m.AP)("Back"),children:(0,b.jsx)("span",{className:"sf3-font sf3-font-down rotate-90 d-inline-block"})}),(0,b.jsxs)("div",{className:"d-flex justify-content-between align-items-center op-bar",children:[(0,b.jsxs)("p",{className:"m-0 text-truncate d-flex",children:[(0,b.jsx)("span",{className:"mr-1",children:(0,m.AP)("Current path: ")}),r?this.renderFolderPath():(0,b.jsx)("span",{className:"text-truncate",title:D,children:D})]}),"/"===P&&k&&!r&&C&&(0,b.jsx)("button",{className:"btn btn-secondary clean flex-shrink-0 ml-4",onClick:this.cleanTrash,children:(0,m.AP)("Clean")})]}),(0,b.jsx)(w,{data:this.state,getMore:this.getMore,renderFolder:this.renderFolder})]})})})]}),t&&(0,b.jsx)(x.A,{children:(0,b.jsx)(A.A,{repoID:M,refreshTrash:this.refreshTrash,toggleDialog:this.toggleCleanTrashDialog})})]})}}])}(i.Component),w=function(e){function t(e){var r;return(0,n.A)(this,t),(r=(0,o.A)(this,t,[e])).theadData=[{width:"5%",text:""},{width:"20%",text:(0,m.AP)("Name")},{width:"40%",text:(0,m.AP)("Original path")},{width:"12%",text:(0,m.AP)("Delete Time")},{width:"13%",text:(0,m.AP)("Size")},{width:"10%",text:""}],r}return(0,a.A)(t,e),(0,s.A)(t,[{key:"render",value:function(){var e=this,t=this.props.data,r=t.isLoading,n=t.errorMsg,s=t.items,o=t.more,a=t.showFolder,l=t.commitID,c=t.baseDir,d=t.folderPath,h=t.folderItems;return(0,b.jsxs)(i.Fragment,{children:[(0,b.jsxs)("table",{className:"table-hover",children:[(0,b.jsx)("thead",{children:(0,b.jsx)("tr",{children:this.theadData.map((function(e,t){return(0,b.jsx)("th",{width:e.width,children:e.text},t)}))})}),(0,b.jsx)("tbody",{children:a?h.map((function(t,r){return(0,b.jsx)(_,{item:t,commitID:l,baseDir:c,folderPath:d,renderFolder:e.props.renderFolder},r)})):s.map((function(t,r){return(0,b.jsx)(S,{item:t,renderFolder:e.props.renderFolder},r)}))})]}),r&&(0,b.jsx)(f.A,{}),n&&(0,b.jsx)("p",{className:"error mt-6 text-center",children:n}),o&&!r&&!a&&(0,b.jsx)("button",{className:"btn btn-block more mt-6",onClick:this.props.getMore,children:(0,m.AP)("More")})]})}}])}(i.Component),S=function(e){function t(e){var r;return(0,n.A)(this,t),(r=(0,o.A)(this,t,[e])).handleMouseOver=function(){r.setState({isIconShown:!0})},r.handleMouseOut=function(){r.setState({isIconShown:!1})},r.restoreItem=function(e){e.preventDefault();var t=r.props.item,n=t.commit_id,s=t.parent_dir+t.obj_name;(t.is_dir?p.e.restoreFolder(M,n,s):p.e.restoreFile(M,n,s)).then((function(e){r.setState({restored:!0}),g.A.success((0,m.AP)("Successfully restored 1 item."))})).catch((function(e){var t="";t=e.response?e.response.data.error_msg||(0,m.AP)("Error"):(0,m.AP)("Please check the network."),g.A.danger(t)}))},r.renderFolder=function(e){e.preventDefault();var t=r.props.item;r.props.renderFolder(t.commit_id,t.parent_dir,u.Aq.joinPath("/",t.obj_name))},r.state={restored:!1,isIconShown:!1},r}return(0,a.A)(t,e),(0,s.A)(t,[{key:"render",value:function(){var e=this.props.item,t=this.state,r=t.restored,n=t.isIconShown;return r?null:e.is_dir?(0,b.jsxs)("tr",{onMouseOver:this.handleMouseOver,onMouseOut:this.handleMouseOut,onFocus:this.handleMouseOver,children:[(0,b.jsx)("td",{className:"text-center",children:(0,b.jsx)("img",{src:u.Aq.getFolderIconUrl(),alt:(0,m.AP)("Folder"),width:"24"})}),(0,b.jsx)("td",{children:(0,b.jsx)("a",{href:"#",onClick:this.renderFolder,children:e.obj_name})}),(0,b.jsx)("td",{children:e.parent_dir}),(0,b.jsx)("td",{title:h()(e.deleted_time).format("dddd, MMMM D, YYYY h:mm:ss A"),children:h()(e.deleted_time).format("YYYY-MM-DD")}),(0,b.jsx)("td",{}),(0,b.jsx)("td",{children:(0,b.jsx)("a",{href:"#",className:n?"":"invisible",onClick:this.restoreItem,role:"button",children:(0,m.AP)("Restore")})})]}):(0,b.jsxs)("tr",{onMouseOver:this.handleMouseOver,onMouseOut:this.handleMouseOut,onFocus:this.handleMouseOver,children:[(0,b.jsx)("td",{className:"text-center",children:(0,b.jsx)("img",{src:u.Aq.getFileIconUrl(e.obj_name),alt:(0,m.AP)("File"),width:"24"})}),(0,b.jsx)("td",{children:(0,b.jsx)("a",{href:"".concat(m.Yc,"repo/").concat(M,"/trash/files/?obj_id=").concat(e.obj_id,"&commit_id=").concat(e.commit_id,"&base=").concat(encodeURIComponent(e.parent_dir),"&p=").concat(encodeURIComponent("/"+e.obj_name)),target:"_blank",rel:"noreferrer",children:e.obj_name})}),(0,b.jsx)("td",{children:e.parent_dir}),(0,b.jsx)("td",{title:h()(e.deleted_time).format("dddd, MMMM D, YYYY h:mm:ss A"),children:h()(e.deleted_time).format("YYYY-MM-DD")}),(0,b.jsx)("td",{children:u.Aq.bytesToSize(e.size)}),(0,b.jsx)("td",{children:(0,b.jsx)("a",{href:"#",className:n?"":"invisible",onClick:this.restoreItem,role:"button",children:(0,m.AP)("Restore")})})]})}}])}(i.Component),_=function(e){function t(e){var r;return(0,n.A)(this,t),(r=(0,o.A)(this,t,[e])).handleMouseOver=function(){r.setState({isIconShown:!0})},r.handleMouseOut=function(){r.setState({isIconShown:!1})},r.renderFolder=function(e){e.preventDefault();var t=r.props.item,n=r.props,s=n.commitID,o=n.baseDir,a=n.folderPath;r.props.renderFolder(s,o,u.Aq.joinPath(a,t.name))},r.state={isIconShown:!1},r}return(0,a.A)(t,e),(0,s.A)(t,[{key:"render",value:function(){var e=this.props.item,t=this.props,r=t.commitID,n=t.baseDir,s=t.folderPath;return"dir"==e.type?(0,b.jsxs)("tr",{onMouseOver:this.handleMouseOver,onMouseOut:this.handleMouseOut,children:[(0,b.jsx)("td",{className:"text-center",children:(0,b.jsx)("img",{src:u.Aq.getFolderIconUrl(),alt:(0,m.AP)("Folder"),width:"24"})}),(0,b.jsx)("td",{children:(0,b.jsx)("a",{href:"#",onClick:this.renderFolder,children:e.name})}),(0,b.jsx)("td",{children:e.parent_dir}),(0,b.jsx)("td",{}),(0,b.jsx)("td",{})]}):(0,b.jsxs)("tr",{onMouseOver:this.handleMouseOver,onMouseOut:this.handleMouseOut,children:[(0,b.jsx)("td",{className:"text-center",children:(0,b.jsx)("img",{src:u.Aq.getFileIconUrl(e.name),alt:(0,m.AP)("File"),width:"24"})}),(0,b.jsx)("td",{children:(0,b.jsx)("a",{href:"".concat(m.Yc,"repo/").concat(M,"/trash/files/?obj_id=").concat(e.obj_id,"&commit_id=").concat(r,"&base=").concat(encodeURIComponent(n),"&p=").concat(encodeURIComponent(u.Aq.joinPath(s,e.name))),target:"_blank",rel:"noreferrer",children:e.name})}),(0,b.jsx)("td",{children:e.parent_dir}),(0,b.jsx)("td",{}),(0,b.jsx)("td",{children:u.Aq.bytesToSize(e.size)}),(0,b.jsx)("td",{})]})}}])}(i.Component);l.render((0,b.jsx)(F,{}),document.getElementById("wrapper"))}},function(e){e.O(0,[4223],(function(){return t=12121,e(e.s=t);var t}));e.O()}]);