PageSourceSearch

https://tuforums.com/assets/BotModsEditPage.g35bibdS.js

js tuforums.com collected 2026-10-02 00:58:39 UTC 10,049 bytes, 1 lines download raw bytes

1import{e as cs,i as rs,p as ms,o as us,b as bs,a as r,r as b,E as d,j as e,M as ps,S as gs,z as hs,A as fs}from"./index.C_jEAofg.js";import{d as ys,r as n,i as Ms,L as G}from"./reactRouter.C6cvQAHO.js";import{F as _s}from"./Footer.CpwmdXIG.js";import{C as H}from"./Select.BO5et_f4.js";import{b as p,g as ks,j as js}from"./modEditForm.BV1K1ysH.js";import{u as xs}from"./i18n.BxWiIRpk.js";import"./recharts.DzmhKP_O.js";import"./ExternalLink.Dqxd3OTW.js";import"./rateLimitError.ByypYhRt.js";import"./ModReleasePopup.BrwyHN_5.js";(function(){try{var o=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};o.SENTRY_RELEASE={id:"aec9389561908f1f1b5366362ca3b629220ab900"},o._sentryModuleMetadata=o._sentryModuleMetadata||{},o._sentryModuleMetadata[new o.Error().stack]=function(t){for(var g=1;g<arguments.length;g++){var c=arguments[g];if(c!=null)for(var m in c)c.hasOwnProperty(m)&&(t[m]=c[m])}return t}({},o._sentryModuleMetadata[new o.Error().stack],{"_sentryBundlerPluginAppKey:tuf-website":!0});var l=new o.Error().stack;l&&(o._sentryDebugIds=o._sentryDebugIds||{},o._sentryDebugIds[l]="344ea1ff-a3d3-4d0d-b911-8efc3b1a4318",o._sentryDebugIdIdentifier="sentry-dbid-344ea1ff-a3d3-4d0d-b911-8efc3b1a4318")}catch{}})();const y=[];function J(o){return(Array.isArray(o)?o:y).map(l=>({value:String(l.id),label:`${l.name} (${l.slug||l.id})`}))}function vs(o){if(!o)return"";const l=new Date(o);return Number.isNaN(l.getTime())?"":l.toLocaleString()}const Ts=()=>{const{user:o,loading:l}=cs(),{t}=xs(["pages","common"]),g=ys(),c=rs(o,ms.SUPER_ADMIN),m=us(300),X=n.useMemo(()=>bs({title:t("mods.botMods.metaTitle"),description:t("mods.botMods.subtitle"),pathname:g.pathname,image:"/og-image.jpg",type:"website"}),[t,g.pathname]),E=n.useMemo(()=>[{value:"all",label:t("mods.botMods.filters.all")},{value:"unlinked",label:t("mods.botMods.filters.unlinked")},{value:"linked",label:t("mods.botMods.filters.linked")},{value:"problems",label:t("mods.botMods.filters.problems")},{value:"duplicates",label:t("mods.botMods.filters.duplicates")}],[t]),[T,P]=n.useState(y),[Z,$]=n.useState(0),[k,w]=n.useState(""),[j,ss]=n.useState("all"),[B,O]=n.useState(!0),[L,F]=n.useState(""),[D,U]=n.useState(!1),[M,h]=n.useState(""),[x,W]=n.useState(null),[q,z]=n.useState(y),[v,I]=n.useState(""),[R,A]=n.useState(!1),u=n.useCallback(async({silent:s}={})=>{s||(O(!0),F(""));try{const{data:a}=await r.get(b.admin.botMods.root(),{params:{q:k.trim()||void 0,filter:j,offset:0,limit:500}});P(Array.isArray(a==null?void 0:a.botMods)?a.botMods:y),$(typeof(a==null?void 0:a.total)=="number"?a.total:0),F("")}catch(a){const i=p(a,t("mods.botMods.loadFailed"));s?d.error(i):(P(y),$(0),F(i))}finally{s||O(!1)}},[j,k,t]);n.useEffect(()=>{!l&&c&&u()},[l,c,u]);const K=n.useCallback(async(s,{immediate:a=!1}={})=>{const i={offset:0,limit:50,sort:"name-asc"};s&&(i.q=s);const S=a||!s?m.flush:m;try{const{data:f}=await S(({signal:C})=>r.get(b.admin.mods.root(),{params:i,signal:C}));z(ks(f))}catch(f){if(r.isCancel(f))return;d.error(p(f,t("mods.botMods.linkFailed")))}},[m,t]),es=async s=>{W(s),I(""),z(y),await K("",{immediate:!0})},N=()=>{W(null),I(""),A(!1)},ts=async()=>{if(!D){U(!0);try{const{data:s}=await r.post(b.admin.botMods.sync());s!=null&&s.alreadyRunning?d(t("mods.botMods.alreadyRunning")):d.success(t("mods.botMods.syncSummary",{fetched:(s==null?void 0:s.fetched)??0,created:(s==null?void 0:s.created)??0,skipped:(s==null?void 0:s.skipped)??0,errors:(s==null?void 0:s.errors)??0})),await u({silent:!0})}catch(s){d.error(p(s,t("mods.botMods.syncFailed")))}finally{U(!1)}}},as=async s=>{if(s.preventDefault(),!(!x||!v||R)){A(!0);try{const{data:a}=await r.put(b.admin.botMods.link(x.id),{modId:Number(v)});js(t,a==null?void 0:a.botMod),N(),await u({silent:!0})}catch(a){d.error(p(a,t("mods.botMods.linkFailed"))),A(!1)}}},os=async s=>{if(!(M||!(s!=null&&s.link))&&window.confirm(t("mods.botMods.unlinkConfirm",{name:s.name}))){h(s.id);try{await r.delete(b.admin.botMods.link(s.id)),d.success(t("mods.botMods.unlinkedOk")),await u({silent:!0})}catch(a){d.error(p(a,t("mods.botMods.unlinkFailed")))}finally{h("")}}},ns=async(s,a)=>
1{if(!(M||!(s!=null&&s.link))){h(s.id);try{await r.patch(b.admin.botMods.link(s.id),{enabled:a}),await u({silent:!0})}catch(i){d.error(p(i,t("mods.botMods.watchFailed")))}finally{h("")}}},ls=async(s,a)=>{if(!M){h(s.id);try{await r.patch(b.admin.botMods.byId(s.id),{isDuplicate:a}),await u({silent:!0})}catch(i){d.error(p(i,t("mods.botMods.duplicateFailed")))}finally{h("")}}},is=E.find(s=>s.value===j)||E[0],ds=J(q).find(s=>s.value===v)||null;return l?e.jsx("div",{className:"bot-mods-page",children:e.jsx("div",{className:"bot-mods-page__container page-content-1000",children:e.jsx("div",{className:"loading-message",children:t("loading.generic",{ns:"common"})})})}):c?e.jsxs(e.Fragment,{children:[e.jsx(ps,{...X}),e.jsxs("div",{className:"bot-mods-page",children:[e.jsxs("div",{className:"bot-mods-page__container page-content-1000",children:[e.jsxs("header",{className:"bot-mods-page__header",children:[e.jsxs("div",{className:"bot-mods-page__heading",children:[e.jsx(G,{to:"/mods/edit",className:"bot-mods-page__back",children:t("mods.botMods.backToEdit")}),e.jsx("h1",{children:t("mods.botMods.title")}),e.jsx("p",{children:t("mods.botMods.subtitle")})]}),e.jsx("div",{className:"bot-mods-page__header-actions",children:e.jsx("button",{type:"button",className:"btn-fill-primary",onClick:()=>void ts(),disabled:D,children:t(D?"mods.botMods.syncing":"mods.botMods.sync")})})]}),e.jsxs("div",{className:"bot-mods-page__controls",children:[e.jsxs("label",{className:"bot-mods-page__search",children:[e.jsx("span",{className:"bot-mods-page__control-label",children:t("mods.botMods.searchPlaceholder")}),e.jsx("input",{type:"search",value:k,onChange:s=>w(s.target.value),placeholder:t("mods.botMods.searchPlaceholder")})]}),e.jsxs("div",{className:"bot-mods-page__filter",children:[e.jsx("span",{className:"bot-mods-page__control-label",children:t("mods.botMods.filterLabel")}),e.jsx(H,{options:E,value:is,onChange:s=>ss((s==null?void 0:s.value)||"all"),width:"16rem"})]})]}),B?e.jsx("div",{className:"loading-message",children:t("loading.generic",{ns:"common"})}):L?e.jsx("div",{className:"error-message",children:L}):T.length===0?e.jsx("div",{className:"no-items-message",children:k.trim()||j!=="all"?t("mods.botMods.emptySearch"):t("mods.botMods.empty")}):e.jsx("ul",{className:"bot-mods-page__list",children:T.map(s=>{var C,V,Y,Q;const a=(C=s.link)!=null&&C.lastSyncStatus?`mods.botMods.statuses.${s.link.lastSyncStatus}`:"",i=a&&t(a)!==a?t(a):(V=s.link)==null?void 0:V.lastSyncStatus,S=(s.releases||[]).map(_=>_.version).filter(Boolean),f=S.length?S.join(", "):s.version||t("mods.botMods.noVersion");return e.jsxs("li",{className:`bot-mods-page__item${s.isDuplicate?" bot-mods-page__item--duplicate":""}`,children:[e.jsxs("div",{className:"bot-mods-page__item-main",children:[e.jsxs("div",{className:"bot-mods-page__item-info",children:[e.jsx("p",{className:"bot-mods-page__item-name",children:s.name}),e.jsxs("p",{className:"bot-mods-page__item-meta",children:[e.jsx("span",{children:s.cachedUsername}),e.jsx("span",{children:f})]}),e.jsx("p",{className:"bot-mods-page__item-link",children:s.link?e.jsx(G,{to:`/mods/${s.link.modSlug||""}`,children:t("mods.botMods.linked",{name:s.link.modName||s.link.modId})}):t("mods.botMods.unlinked")}),e.jsxs("p",{className:"bot-mods-page__item-sync",children:[(Y=s.link)!=null&&Y.lastSyncAt?`${t("mods.botMods.lastSync")}: ${vs(s.link.lastSyncAt)}${i?` · ${i}`:""}`:t("mods.botMods.lastSyncNever"),(Q=s.link)!=null&&Q.lastSyncMessage?` — ${s.link.lastSyncMessage}`:""]}),e.jsxs("div",{className:"bot-mods-page__flags",children:[s.isDuplicate?e.jsx("span",{className:"bot-mods-page__flag",children:t("mods.botMods.duplicate")}):null,s.missingSince?e.jsx("span",{className:"bot-mods-page__flag bot-mods-page__flag--warn",children:t("mods.botMods.missing")}):null,s.ignoreUpdate?e.jsx("span",{className:"bot-mods-page__flag",children:t("mods.botMods.ignoreUpdate")}):null]})]}),e.jsx("div",{className:"bot-mods-page__item-actions",children:s.link?e.jsxs(e.Fragment,{children:[e.jsx(gs,{label:t("mods.botMods.watch"),currentState:s.link.enabled?"on":"off",states:["off","on"],activeStates:["on"],onChange:_=>void ns(s,_==="on"),width:56,height:24,padding:3}),e.jsx("button",{type:"button",className:"btn-fill-danger",onClick:()=>void os(s),disabled:M===s.id,children:t("mods.botMods.unlink")})]}):s.isDuplicate?null:e.jsx("button",{type:"button",className:"btn-fill-primary",onClick:()=>void es(s),children:t("mods.botMods.link")})})]}),e.jsxs("label",{className:"bot-mods-page__duplicate",children:[e.jsx("input",{type:"checkbox",checked:!!s.isDuplicate,disabled:M===s.id,onChange:_=>void ls(s,_.target.checked)}),t("mods.botMods.duplicate")]})]},s.id)})}),!B&&!L?e.jsx("p",{className:"bot-mods-page__count",children:t("totalResults",{ns:"common",count:Z})}):null]}),e.jsx(_s,{})]}),x?e.jsxs(hs,{onClose:N,overlayClassName:"bot-mods-page bot-mods-page__modal",panelClassName:"bot-mods-page__modal-content",children:[e.jsx(fs,{onClick:N}),e.jsx("h2",{children:t("mods.botMods.linkPopupTitle")}),e.jsx("p",{className:"bot-mods-page__modal-lead",children:x.name}),e.jsxs("form",{onSubmit:as,className:"bot-mods-page__link-form",children:[e.jsx(H,{options:J(q),value:ds,onChange:s=>I((s==null?void 0:s.value)||""),onInputChange:(s,a)=>((a==null?void 0:a.action)==="input-change"&&K(s),s),placeholder:t("mods.botMods.pickMod"),width:"100%",isClearable:!0,isSearchable:!0,filterOption:()=>!0,menuPortalTarget:typeof document<"u"?document.body:null}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{type:"button",className:"cancel-button btn-fill-ghost",onClick:N,children:t("buttons.cancel",{ns:"common"})}),e.jsx("button",{type:"submit",className:"confirm-button btn-fill-primary",disabled:!v||R,children:R?t("loading.saving",{ns:"common"}):t("mods.botMods.link")})]})]})]}):null]}):e.jsx(Ms,{to:"/mods",replace:!0})};export{Ts as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.