"use strict";(self["webpackChunk_quetz_frontend_main_app"]=self["webpackChunk_quetz_frontend_main_app"]||[]).push([[2328,9532],{72328:(e,a,n)=>{n.r(a);n.d(a,{CommandIDs:()=>C,default:()=>x});var t=n(30325);var r=n.n(t);var l=n(5089);var s=n.n(l);var o=n(34494);var c=n.n(o);var i=n(85168);var m=n.n(i);var d=n(79450);var p=n.n(d);var u=n(18303);var h=n.n(u);var v=n(98078);var g=n.n(v);var E=n(26074);var f=n.n(E);var _=n(71993);var w=n.n(_);var k=n(2411);var N=n.n(k);var C;(function(e){e.open="@quetz-frontend/home-extension:open"})(C||(C={}));const b={id:"@quetz-frontend/home-extension:plugin",autoStart:true,requires:[i.IRouter],activate:(e,a)=>{const{shell:n,commands:t}=e;t.addCommand(C.open,{execute:()=>{n.add(new H(a),"main")}});a.register({pattern:/^\/home.*/,command:C.open,rank:50});a.register({pattern:/^\/$/,command:C.open,rank:50})}};const x=b;class H extends d.ReactWidget{constructor(e){super();this.id=d.DOMUtils.createDomID();this.title.label="Home page";this._router=e}_route(e){this._router.navigate(e)}render(){const e=v.ServerConnection.makeSettings();const a=u.URLExt.join(e.baseUrl,"/api/channels");return k.createElement("div",{className:"page-contents-width-limit"},k.createElement("h2",{className:"heading2"},"Home"),k.createElement("div",{className:"flex"},k.createElement("h3",{className:"section-heading"},"Recently updated channels")," ",k.createElement("p",{className:"minor-paragraph"},k.createElement("a",{className:"link",onClick:()=>this._route("/channels")},"View all"))),k.createElement("div",{className:"padding-side"},k.createElement(E.FetchHoc,{url:a,loadingMessage:"Fetching list of channels",genericErrorMessage:"Error fetching list of channels"},(e=>e.length>0?k.createElement(_.List,{data:e.slice(0,5),columns:q(),to:e=>this._route(`/channels/${e.name}`)}):k.createElement("p",{className:"paragraph"},"No channels available")))))}}const q=()=>[{Header:"",accessor:"name",Cell:({row:e})=>{const[a,n]=k.useState(null);return k.createElement(k.Fragment,null,k.createElement("span",{ref:e=>{n(e)}},k.createElement(l.FontAwesomeIcon,{icon:e.original.private?t.faUnlockAlt:t.faGlobeAmericas})),k.createElement(o.Tooltip,{anchorElement:a,position:"right"},e.original.private?"Private":"Public"))},width:5},{Header:"",accessor:"user.profile.name",Cell:({row:e})=>k.createElement("div",null,k.createElement("p",{className:"text"},e.original.name),k.createElement("p",{className:"minor-paragraph channel-list-description"},e.original.description)),width:45},{Header:"",accessor:"user.username",Cell:({row:e})=>(0,E.formatPlural)(e.original.packages_count,"package"),width:35},{Header:"",accessor:"role",Cell:({row:e})=>(0,E.formatPlural)(e.original.members_count,"member"),width:20}]}}]);