mirror of
https://github.com/tdurieux/anonymous_github.git
synced 2026-11-17 17:44:09 +01:00
Show source reconnection failures after successful metadata loads
This commit is contained in:
1 parent
c591306a33
commit
318a1f9984
4 files changed
+33
-5
No files matched your search
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"core.min.js": "core.d23af1c652.min.js",
|
||||
"vendor.min.js": "vendor.474d4e303e.min.js",
|
||||
"vendor.min.js": "vendor.9e1574212d.min.js",
|
||||
"mermaid.min.js": "mermaid.a7356d5ed1.min.js",
|
||||
"all.min.css": "all.e8df2ae9d6.min.css",
|
||||
"markdown.min.js": "markdown.6c8dfb7b1d.min.js",
|
||||
|
||||
@@ -2021,7 +2021,7 @@ export const anonymizeController = function (state, http, html, params, location
|
||||
if (field.github || (state.sourceUrlError && state.workspaceOpen)) {
|
||||
return { kind: "github", title: "Not a GitHub URL", text: "Paste a repository, pull request, or gist URL from github.com." };
|
||||
}
|
||||
if (state.sourceLoading || state.details && !field.used) return null;
|
||||
if (state.sourceLoading || state.details && !field.used && !state.sourceError) return null;
|
||||
if (state.gistAppRequired || state.gistOAuthRequired) return { kind: "connect", title: "Couldn't load this gist", text: "Connect GitHub to read gists." };
|
||||
const code = state.sourceError || (field.used ? "repo_already_anonymized" : field.access ? "repo_not_accessible" : field.missing ? "repo_not_found" : "");
|
||||
if (!code) return null;
|
||||
@@ -2196,6 +2196,7 @@ export const anonymizeController = function (state, http, html, params, location
|
||||
if (!confirm("Reconnect to the repository currently at this GitHub URL? Review its branch and commit before saving. Saving will replace the published snapshot.")) return;
|
||||
state.reconnectingSource = true;
|
||||
state.reconnectRepositoryId = undefined;
|
||||
state.details = null;
|
||||
state.source.commit = "";
|
||||
state.source.branch = "";
|
||||
state.readme = "";
|
||||
|
||||
Vendored
+3
-3
@@ -1,4 +1,4 @@
|
||||
"use strict";(()=>{var il=Object.defineProperty;var rl=e=>{throw TypeError(e)};var ff=(e,t,s)=>t in e?il(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var mf=(e,t)=>{for(var s in t)il(e,s,{get:t[s],enumerable:!0})};var nt=(e,t,s)=>ff(e,typeof t!="symbol"?t+"":t,s),wr=(e,t,s)=>t.has(e)||rl("Cannot "+s);var re=(e,t,s)=>(wr(e,t,"read from private field"),s?s.call(e):t.get(e)),_e=(e,t,s)=>t.has(e)?rl("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),ze=(e,t,s,i)=>(wr(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s),Fe=(e,t,s)=>(wr(e,t,"access private method"),s);var al=(e,t,s,i)=>({set _(o){ze(e,t,o,s)},get _(){return re(e,t,i)}});var ge=["abap","abc","actionscript","ada","alda","apache_conf","apex","applescript","aql","asciidoc","asl","assembly_x86","autohotkey","batchfile","c9search","c_cpp","cirru","clojure","cobol","coffee","coldfusion","crystal","csharp","csound_document","csound_orchestra","csound_score","csp","css","curly","d","dart","diff","django","dockerfile","dot","drools","edifact","eiffel","ejs","elixir","elm","erlang","forth","fortran","fsharp","fsl","ftl","gcode","gherkin","gitignore","glsl","gobstones","golang","graphqlschema","groovy","haml","handlebars","haskell","haskell_cabal","haxe","hjson","html","html_elixir","html_ruby","ini","io","jack","jade","java","javascript","json","json5","jsoniq","jsp","jssm","jsx","julia","kotlin","latex","less","liquid","lisp","livescript","logiql","logtalk","lsl","lua","luapage","lucene","makefile","markdown","mask","matlab","maze","mediawiki","mel","mixal","mushcode","mysql","nginx","nim","nix","nsis","nunjucks","objectivec","ocaml","pascal","perl","perl6","pgsql","php","php_laravel_blade","pig","plain_text","powershell","praat","prisma","prolog","properties","protobuf","puppet","python","qml","r","razor","rdoc","red","redshift","rhtml","rst","ruby","rust","sass","scad","scala","scheme","scss","sh","sjs","slim","smarty","snippets","soy_template","space","sparql","sql","sqlserver","stylus","svg","swift","tcl","terraform","tex","text","textile","toml","tsx","turtle","twig","typescript","vala","vbscript","velocity","verilog","vhdl","visualforce","wollok","xml","xquery","yaml","zeek"];var ve={markdown:"/script/markdown.6c8dfb7b1d.min.js",org:"/script/org.f61f262915.min.js",notebook:"/script/notebook.c3144c18ae.min.js",pdf:"/script/pdf.4d9cc6ff49.min.js",editor:"/script/editor.4f142d3adc.min.js"};function ll(e){let t=e.location.hash.slice(1);if(e.history.replaceState(null,"","/review-link"),t.length>2048)return null;let s=new URLSearchParams(t);if([...s.keys()].length!==3||[...s.keys()].some(u=>!["clientId","intentId","token"].includes(u)))return null;let i=s.get("clientId"),o=s.get("intentId"),r=s.get("token");return!/^[a-f0-9]{32}$/.test(i||"")||!/^[a-f0-9]{32}$/.test(o||"")||!/^[a-f0-9]{64}$/.test(r||"")?null:{contract:"4open.artifacts/1",clientId:i,intentId:o,token:r}}function dl(e,t){let{http:s,promises:i,window:o}=t,r=t.takeReviewHandoff(),u=r?{clientId:r.clientId,intentId:r.intentId}:null,p,c,v,g,y,m=!0,b,E=i.defer(),S=()=>[...o.crypto.getRandomValues(new Uint8Array(16))].map(F=>F.toString(16).padStart(2,"0")).join("");Object.assign(e,{repositoryId:"",handoffEnabled:!1,busy:!1,preview:null,acceptAccess:!1,acceptRetention:!1,uncertain:!1,saved:!1,expired:!1,error:r?"":"Open a new artifact link from your submission. This link is missing or invalid."});let N=()=>m&&e.user?.username===y;function w(){m=!1,r=p=c=void 0,E.resolve(),o.clearTimeout(b)}e.on("dispose",w),e.on("routeLeave",w),e.watch(()=>e.user?.username,F=>{!y&&F?y=F:y&&F!==y&&(w(),e.preview=null,e.repositoryId="",e.busy=!1,e.saved=!1,e.handoffEnabled=!1,e.error="Your account changed. Open a new artifact link from your submission.")});let T=()=>({timeout:E.promise,headers:{"Content-Type":"application/json","X-Review-CSRF":c}}),M=F=>F?.status===404?"Artifact linking is not available on this server.":F?.status===401?"Sign in, then open a new artifact link from your submission.":F?.status===403?"This account cannot approve this repository or this link.":"The request could not be completed. You can retry from this page.";e.loadPreview=async()=>{if(!m||!r||e.busy||e.uncertain||e.saved||!e.user?.username)return;y=e.user.username;let F=e.repositoryId.trim();if(!/^[A-Za-z0-9_-]{3,128}$/.test(F)){e.error="Enter the anonymous repository ID from its URL.";return}e.busy=!0,e.error="",e.preview=null,p=void 0,e.acceptAccess=e.acceptRetention=!1,e.expired=!1,o.clearTimeout(b),g||(g=S());try{let j=(await s.get("/api/review-consent/csrf",{timeout:E.promise})).data;if(!N())return;if(c=j.csrf,e.handoffEnabled=j.handoffEnabled===!0,!/^[a-f0-9]{64}$/.test(c||""))throw new Error("invalid_csrf");let oe=(await s.post("/api/review-consent/preview",{repositoryId:F,intent:{...r,requestId:g}},T())).data;if(!N())return;if(!oe||typeof oe.ticket!="string"||!oe.ticket||oe.ticket.length>8192||typeof oe.repositoryName!="string"||!["restricted-review","anonymous-liLine truncated
|
||||
"use strict";(()=>{var il=Object.defineProperty;var rl=e=>{throw TypeError(e)};var ff=(e,t,s)=>t in e?il(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s;var mf=(e,t)=>{for(var s in t)il(e,s,{get:t[s],enumerable:!0})};var nt=(e,t,s)=>ff(e,typeof t!="symbol"?t+"":t,s),wr=(e,t,s)=>t.has(e)||rl("Cannot "+s);var re=(e,t,s)=>(wr(e,t,"read from private field"),s?s.call(e):t.get(e)),_e=(e,t,s)=>t.has(e)?rl("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),ze=(e,t,s,i)=>(wr(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s),Fe=(e,t,s)=>(wr(e,t,"access private method"),s);var al=(e,t,s,i)=>({set _(o){ze(e,t,o,s)},get _(){return re(e,t,i)}});var ge=["abap","abc","actionscript","ada","alda","apache_conf","apex","applescript","aql","asciidoc","asl","assembly_x86","autohotkey","batchfile","c9search","c_cpp","cirru","clojure","cobol","coffee","coldfusion","crystal","csharp","csound_document","csound_orchestra","csound_score","csp","css","curly","d","dart","diff","django","dockerfile","dot","drools","edifact","eiffel","ejs","elixir","elm","erlang","forth","fortran","fsharp","fsl","ftl","gcode","gherkin","gitignore","glsl","gobstones","golang","graphqlschema","groovy","haml","handlebars","haskell","haskell_cabal","haxe","hjson","html","html_elixir","html_ruby","ini","io","jack","jade","java","javascript","json","json5","jsoniq","jsp","jssm","jsx","julia","kotlin","latex","less","liquid","lisp","livescript","logiql","logtalk","lsl","lua","luapage","lucene","makefile","markdown","mask","matlab","maze","mediawiki","mel","mixal","mushcode","mysql","nginx","nim","nix","nsis","nunjucks","objectivec","ocaml","pascal","perl","perl6","pgsql","php","php_laravel_blade","pig","plain_text","powershell","praat","prisma","prolog","properties","protobuf","puppet","python","qml","r","razor","rdoc","red","redshift","rhtml","rst","ruby","rust","sass","scad","scala","scheme","scss","sh","sjs","slim","smarty","snippets","soy_template","space","sparql","sql","sqlserver","stylus","svg","swift","tcl","terraform","tex","text","textile","toml","tsx","turtle","twig","typescript","vala","vbscript","velocity","verilog","vhdl","visualforce","wollok","xml","xquery","yaml","zeek"];var ve={markdown:"/script/markdown.6c8dfb7b1d.min.js",org:"/script/org.f61f262915.min.js",notebook:"/script/notebook.c3144c18ae.min.js",editor:"/script/editor.4f142d3adc.min.js",pdf:"/script/pdf.4d9cc6ff49.min.js"};function ll(e){let t=e.location.hash.slice(1);if(e.history.replaceState(null,"","/review-link"),t.length>2048)return null;let s=new URLSearchParams(t);if([...s.keys()].length!==3||[...s.keys()].some(u=>!["clientId","intentId","token"].includes(u)))return null;let i=s.get("clientId"),o=s.get("intentId"),r=s.get("token");return!/^[a-f0-9]{32}$/.test(i||"")||!/^[a-f0-9]{32}$/.test(o||"")||!/^[a-f0-9]{64}$/.test(r||"")?null:{contract:"4open.artifacts/1",clientId:i,intentId:o,token:r}}function dl(e,t){let{http:s,promises:i,window:o}=t,r=t.takeReviewHandoff(),u=r?{clientId:r.clientId,intentId:r.intentId}:null,p,c,v,g,y,m=!0,b,E=i.defer(),S=()=>[...o.crypto.getRandomValues(new Uint8Array(16))].map(F=>F.toString(16).padStart(2,"0")).join("");Object.assign(e,{repositoryId:"",handoffEnabled:!1,busy:!1,preview:null,acceptAccess:!1,acceptRetention:!1,uncertain:!1,saved:!1,expired:!1,error:r?"":"Open a new artifact link from your submission. This link is missing or invalid."});let N=()=>m&&e.user?.username===y;function w(){m=!1,r=p=c=void 0,E.resolve(),o.clearTimeout(b)}e.on("dispose",w),e.on("routeLeave",w),e.watch(()=>e.user?.username,F=>{!y&&F?y=F:y&&F!==y&&(w(),e.preview=null,e.repositoryId="",e.busy=!1,e.saved=!1,e.handoffEnabled=!1,e.error="Your account changed. Open a new artifact link from your submission.")});let T=()=>({timeout:E.promise,headers:{"Content-Type":"application/json","X-Review-CSRF":c}}),M=F=>F?.status===404?"Artifact linking is not available on this server.":F?.status===401?"Sign in, then open a new artifact link from your submission.":F?.status===403?"This account cannot approve this repository or this link.":"The request could not be completed. You can retry from this page.";e.loadPreview=async()=>{if(!m||!r||e.busy||e.uncertain||e.saved||!e.user?.username)return;y=e.user.username;let F=e.repositoryId.trim();if(!/^[A-Za-z0-9_-]{3,128}$/.test(F)){e.error="Enter the anonymous repository ID from its URL.";return}e.busy=!0,e.error="",e.preview=null,p=void 0,e.acceptAccess=e.acceptRetention=!1,e.expired=!1,o.clearTimeout(b),g||(g=S());try{let j=(await s.get("/api/review-consent/csrf",{timeout:E.promise})).data;if(!N())return;if(c=j.csrf,e.handoffEnabled=j.handoffEnabled===!0,!/^[a-f0-9]{64}$/.test(c||""))throw new Error("invalid_csrf");let oe=(await s.post("/api/review-consent/preview",{repositoryId:F,intent:{...r,requestId:g}},T())).data;if(!N())return;if(!oe||typeof oe.ticket!="string"||!oe.ticket||oe.ticket.length>8192||typeof oe.repositoryName!="string"||!["restricted-review","anonymous-liLine truncated
|
||||
`))),e[yn]=Fo(o);let r=i||o.props&&o.props.type==="number";$n(e,t?"change":"input",u=>{u.target.composing||e[yn](ra(e.value,s,r))}),(s||r)&&$n(e,"change",()=>{e.value=ra(e.value,s,r)}),t||($n(e,"compositionstart",vh),$n(e,"compositionend",Jd),$n(e,"change",Jd))},mounted(e,{value:t,modifiers:{trim:s,number:i}}){let o=t??"",r=e[Fi];delete e[Fi],r!==void 0&&(e.type==="text"||e.type==="textarea")&&e.value!==r?e[yn](ra(e.value,s,i)):e.value=o},beforeUpdate(e,{value:t,oldValue:s,modifiers:{lazy:i,trim:o,number:r}},u){if(e[yn]=Fo(u),e.composing)return;let p=(r||e.type==="number")&&!/^0\d/.test(e.value)?Oo(e.value):e.value,c=t??"";if(p===c)return;let v=e.getRootNode();(v instanceof Document||v instanceof ShadowRoot)&&v.activeElement===e&&e.type!=="range"&&(i&&t===s||o&&e.value.trim()===c)||(e.value=c)}},la={deep:!0,created(e,t,s){e[yn]=Fo(s),$n(e,"change",()=>{let i=e._modelValue,o=qs(e),r=e.checked,u=e[yn];if(Re(i)){let p=fi(i,o),c=p!==-1;if(r&&!c)u(i.concat(o));else if(!r&&c){let v=[...i];v.splice(p,1),u(v)}}else if(Xt(i)){let p=new Set(i);r?p.add(o):p.delete(o),u(p)}else u(tu(e,r))})},mounted:Xd,beforeUpdate(e,t,s){e[yn]=Fo(s),Xd(e,t,s)}};function Xd(e,{value:t,oldValue:s},i){e._modelValue=t;let o;if(Re(t))o=fi(t,i.props.value)>-1;else if(Xt(t))o=t.has(i.props.value);else{if(t===s)return;o=Qt(t,tu(e,!0))}e.checked!==o&&(e.checked=o)}var Nt={deep:!0,created(e,{value:t,modifiers:{number:s}},i){e._modelValue=t,$n(e,"change",()=>{let o=Array.prototype.filter.call(e.options,c=>c.selected).map(c=>s?Oo(qs(c)):qs(c)),r=e.multiple,u=r?Xt(e._modelValue)?new Set(o):o:o[0],p=e._pendingValue=[r,r?Re(u)?o.slice():o:u];try{e[yn](u)}finally{We(()=>{e._pendingValue===p&&(e._pendingValue=void 0)})}}),e[yn]=Fo(i)},mounted(e,{value:t}){Qd(e,t)},beforeUpdate(e,{value:t},s){e._modelValue=t,e[yn]=Fo(s)},updated(e,{value:t}){let s=e._pendingValue;e._pendingValue=void 0,(!s||s[0]!==e.multiple||!yh(t,s[1],s[0]))&&Qd(e,t)}};function yh(e,t,s){if(!s)return Qt(e,t);if(Re(e))return Qt(e,t);if(Xt(e)){if(e.size!==t.length)return!1;for(let i of t)if(!e.has(i))return!1;return!0}return!1}function Qd(e,t){let s=e.multiple,i=Re(t);if(!(s&&!i&&!Xt(t))){for(let o=0,r=e.options.length;o<r;o++){let u=e.options[o],p=qs(u);if(s)if(i){let c=typeof p;c==="string"||c==="number"?u.selected=t.some(v=>String(v)===String(p)):u.selected=fi(t,p)>-1}else u.selected=t.has(p);else if(Qt(qs(u),t)){e.selectedIndex!==o&&(e.selectedIndex=o);return}}!s&&e.selectedIndex!==-1&&(e.selectedIndex=-1)}}function qs(e){return"_value"in e?e._value:e.value}function tu(e,t){let s=t?"_trueValue":"_falseValue";return s in e?e[s]:t}var bh=["ctrl","shift","alt","meta"],wh={stop:e=>e.stopPropagation(),prevent:e=>e.preventDefault(),self:e=>e.target!==e.currentTarget,ctrl:e=>!e.ctrlKey,shift:e=>!e.shiftKey,alt:e=>!e.altKey,meta:e=>!e.metaKey,left:e=>"button"in e&&e.button!==0,middle:e=>"button"in e&&e.button!==1,right:e=>"button"in e&&e.button!==2,exact:(e,t)=>bh.some(s=>e[`${s}Key`]&&!t.includes(s))},de=(e,t)=>{if(!e)return e;let s=e._withMods||(e._withMods={}),i=t.join(".");return s[i]||(s[i]=((o,...r)=>{for(let u=0;u<t.length;u++){let p=wh[t[u]];if(p&&p(o,t))return}return e(o,...r)}))},kh={esc:"escape",space:" ",up:"arrow-up",left:"arrow-left",right:"arrow-right",down:"arrow-down",delete:"backspace"},qt=(e,t)=>{let s=e._withKeys||(e._withKeys={}),i=t.join(".");return s[i]||(s[i]=(o=>{if(!("key"in o))return;let r=ln(o.key);if(t.some(u=>u===r||kh[u]===r))return e(o)}))},Ch=pt({patchProp:mh},Zm),Zd;function Sh(){return Zd||(Zd=Id(Ch))}var nu=((...e)=>{let t=Sh().createApp(...e),{mount:s}=t;return t.mount=i=>{let o=Nh(i);if(!o)return;let r=t._component;!Oe(r)&&!r.render&&!r.template&&(r.template=o.innerHTML),o.nodeType===1&&(o.textContent="");let u=s(o,!1,Eh(o));return o instanceof Element&&(o.removeAttribute("v-cloak"),o.setAttribute("data-v-app","")),u},t});function Eh(e){if(e instanceof SVGElement)return"svg";if(typeof MathMLElement=="function"&&e instanceof MathMLElement)return"mathml"}function Nh(e){return lt(e)?document.querySelector(e):e}var uo=typeof document<"u";function su(e){return typeof e=="object"||"displayName"in e||"props"in e||"__vccOpts"in e}function Rh(e){return e.__esModule||e[Symbol.toStringTag]==="Module"||e.default&&su(e.default)}var xe=Object.assign;function Bi(e,t){let s={};for(let i in t){let o=t[i];s[i]=Yt(o)?o.map(e):e(o)}return s}var Bo=()=>{},Yt=Array.isArray;function ca(e,t){let s={};for(let i in e)s[i]=i in t?t[i]:e[i];return s}var iu=/#/g,Th=/&/g,Ph=/\//g,Dh=/=/g,Ah=/\?/g,ru=/\+/g,Ih=/%5B/g,Oh=/%5D/g,au=/%5E/g,Mh=/%60/g,lu=/%7B/g,Vh=/%7C/g,du=/%7D/g,qh=/%20/g;function pa(e){return e==null?"":encodeURI(""+e).replace(Vh,"|").replace(Ih,"[").replace(Oh,"]")}function uu(e){return pa(e).replace(lu,"{").replace(du,"}").replace(au,"^")}function da(e){return pa(e).replace(ru,"%2B").replace(qh,"+").replace(iu,"%23").replace(Th,"%26").replace(Mh,"`").replace(lu,"{").replace(du,"}").replace(au,"^")}function Lh(e){return da(e).replace(Dh,"%3D")}function $h(e){return pLine truncated
|
||||
${JSON.stringify(e)}${t?`
|
||||
while being at
|
||||
@@ -22,8 +22,8 @@ while being at
|
||||
`).map(b=>b.trim()).filter(b=>b.length>0),options:e.options};e.saving=!0,e.error=null,t.post("/api/user/default",m).then(()=>{p.accept(y),e.saving=!1,e.message=e.unsavedChanges?null:"Saved",v&&i.cancel(v),v=i(()=>{e.message=null},2500)},b=>{e.saving=!1;let E=b&&b.data&&b.data.error,S="Unable to save your defaults. Please try again.";Promise.all([s("ERRORS."+E),s("ERRORS.unknown_error")]).then(([N,w])=>{e.error=E&&N!==w?N:S},()=>{e.error=S})})},e.deleteAccount=()=>{e.deletingAccount||!e.confirmDeleteAccount||e.deleteUsername!==e.user?.username||(e.deletingAccount=!0,t.delete("/api/user").then(()=>{window.location.href="/"},()=>{e.deletingAccount=!1,e.deleteError="Unable to delete the account. Please try again."}))}},Hc=function(e,t,s){e.repoId=null,e.repoUrl=null,e.claim=()=>{t.post("/api/repo/claim",{repoId:e.repoId,repoUrl:e.repoUrl}).then(i=>{s.url("/dashboard")},i=>{e.error=i.data,e.claimForm.repoUrl.setValidity("not_found",!1),e.claimForm.repoId.setValidity("not_found",!1)})}},jc=function(e,t,s,i,o){e.user&&!e.user.status&&s.url("/dashboard"),e.watch("user.status",()=>{e.user&&!e.user.status&&s.url("/dashboard")}),e.features=[{key:"anonymize",num:"01",eyebrow:"Anonymize",title:"Double-anonymous,",accent:"your rules.",text:"Choose what reviewers may see: links, images, PDFs, notebooks, GitHub Pages. Add your own terms, with regex if you need it, and pick the expiration date.",cta:"Start an anonymization",href:"/anonymize",url:"anonymous.4open.science/anonymize",img:"/imgs/anonymize.png",alt:"The anonymize form: source repository, terms to redact, options and a live README preview"},{key:"review",num:"02",eyebrow:"Review",title:"Reviewers browse",accent:"the real thing.",text:"Highlighted source code, rendered PDFs, images, and notebooks, in a familiar file explorer. GitHub Pages is also supported.",cta:"Open the example",href:"https://anonymous.4open.science/r/840c8c57-3c32-451e-bf12-0e20be300389/",target:"_self",url:"anonymous.4open.science/r/840c8c57-\u2026",img:"/imgs/explorer.png",alt:"The repository explorer with a file tree and a rendered README"},{key:"manage",num:"03",eyebrow:"Manage",title:"One dashboard,",accent:"until the decision.",text:"Monitor views, edit configuration, remove or update your repository. Program chairs can group submissions under a conference with one shared expiry.",cta:"Open the dashboard",href:"/dashboard",needsUser:!0,url:"anonymous.4open.science/dashboard",img:"/imgs/dashboard.png",alt:"The dashboard listing anonymized repositories with status, views and expiry"}],e.feature=e.features[0].key,e.selectFeature=function(p){e.feature=p},e.featureHref=function(p){return p.needsUser&&!e.user?"/signin":p.href},e.featureTarget=function(p){return p.needsUser&&!e.user?"_self":p.target||void 0},e.featureKeydown=function(p,c){let v={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1,Home:"first",End:"last"}[p.key];if(v===void 0)return;p.preventDefault();let g=e.features.length,y=v==="first"?0:v==="last"?g-1:(c+v+g)%g;e.feature=e.features[y].key,o(()=>{let m=i.document.getElementById("feature-tab-"+e.feature);m&&m.focus()})},e.demoText=`# DeepLearnUtils
|
||||
Developed by Jane Smith at MIT CSAIL.
|
||||
See Smith et al., "Attention That Works," 2026.
|
||||
Contact: jane.smith@mit.edu`,e.demoTerms="Jane Smith, Smith, MIT CSAIL, jane.smith@mit.edu",e.demoParts=function(){let p=(e.demoTerms||"").split(/[,\n]/).map(m=>m.trim()).filter(Boolean).sort((m,b)=>b.length-m.length),c=m=>m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(!p.length)return[{text:e.demoText}];let v=new RegExp("("+p.map(c).join("|")+")","gi"),g={},y=0;return(e.demoText||"").split(v).filter(m=>m!=="").map(m=>{let b=p.find(E=>E.toLowerCase()===m.toLowerCase());return b?(g[b.toLowerCase()]||(g[b.toLowerCase()]=++y),{text:String(g[b.toLowerCase()]),redacted:!0,original:m}):{text:m}})},e.demoCount=()=>e.demoParts().filter(p=>p.redacted).length,e.cards=[{key:"repositories",total:0,label:"repositories anonymized"},{key:"users",total:0,label:"researchers"},{key:"pageViews",total:0,label:"page views"},{key:"pullRequests",total:0,label:"pull requests"}],e.statsEmpty=()=>!!e.stat&&e.cards.every(p=>!p.total);function r(){t.get("/api/stat/").then(p=>{e.stat=p.data,e.cards[0].total=p.data.nbRepositories,e.cards[1].total=p.data.nbUsers,e.cards[2].total=p.data.nbPageViews,e.cards[3].total=p.data.nbPullRequests}).catch(()=>{})}r();function u(p){let c={series:p,bars:[],viewW:100,deltaToday:0,pctChange:0,pctAbs:0,isUp:!0};if(!p||p.length<2)return c;let v=new Array(p.length-1);for(let S=1;S<p.length;S++)v[S-1]=p[S]-p[S-1];let g=v.length,y=Math.max.apply(null,v),m=Math.min.apply(null,v),b=Math.min(0,m),E=y-b||1;c.viewW=g*2,c.bars=new Array(g);for(let S=0;S<g;S++){let N=(v[S]-b)/E,w=Math.max(1.5,N*34);c.bars[S]={x:(S*2+.25).toFixed(2),y:(36-w).toFixed(2),w:"1.5",h:w.toFixed(2)}}if(c.deltaToday=v[g-1],g>=2){let S=v[g-2];S&&(c.pctChange=(c.deltaToday-S)/S*100)}return c.pctAbs=Math.round(Math.abs(c.pctChange)),c.isUp=c.pctChange>=0,c}e.history={repositories:u([]),users:u([]),pageViews:u([]),pullRequests:u([])},t.get("/api/stat/history?days=60").then(p=>{let c=p.data||[];e.history={repositories:u(c.map(v=>v.nbRepositories||0)),users:u(c.map(v=>v.nbUsers||0)),pageViews:u(c.map(v=>v.nbPageViews||0)),pullRequests:u(c.map(v=>v.nbPullRequests||0))}}).catch(()=>{})},Gc=function(e,t,s,i,o,r){let u=bt();e.on("routeLeave",function(){$('[data-toggle="tooltip"]').tooltip("dispose")}),e.watch("user.status",()=>{e.user==null&&s.url("/")}),e.user==null&&s.url("/"),u.timeout(()=>{$('[data-toggle="tooltip"]').tooltip()},250),e.quotaExpanded=!1,e.closeQuota=()=>{e.quotaExpanded=!1,We(()=>document.querySelector(".dashboard-quota > summary")?.focus())},Ut()(document,"click",k=>{e.quotaExpanded&&!k.target.closest?.(".dashboard-quota")&&(e.quotaExpanded=!1)}),e.filtersExpanded=!1,e.projectView="all",e.selectedProject=null,e.projectName="",e.nameSaving=!1,e.nameError="",e.nameMessage="",e.needsAttention=k=>k.status==="error"||k._broken||c(k.status)==="progress"&&k._stale,e.attentionCount=()=>e.dashboardTotals?.attention??e.items.filter(e.needsAttention).length,e.hasProjects=()=>(e.dashboardTotals?.total??e.items.length)>0,e.setProjectView=k=>{e.projectView=k,k==="attention"&&(e.filters.status.error=!0,e.filters.status.progress=!0)},e.idleText=k=>{let q=Ca(k?.anonymizeDate||k?.lastView)||"";return/ ago$/.test(q)?"No activity for "+q.replace(/ ago$/,""):"No activity since "+q.replace(", "+new Date().getFullYear(),"")},e.projectDetailsId=k=>"project-details-"+encodeURIComponent(k._type+":"+(k._id||k._source||"unknown")),e.showProjectDetails=async k=>{e.selectedProject=k,e.projectName=k.projectName||"",e.nameError="",e.nameMessage="",await We();let q=document.getElementById(e.projectDetailsId(k));q?.focus(),q?.scrollIntoView?.({block:"nearest"})},e.closeProjectDetails=k=>{e.selectedProject=null,We(()=>document.querySelector(`[data-project-actions="${encodeURIComponent(k._type+":"+k._id)}"]`)?.focus())},e.saveProjectName=async k=>{if(e.nameSaving||!k._id)return;let q=e.projectName.trim();if(q.length>100){e.nameError="Use 100 characters or fewer.";return}e.nameSaving=!0,e.nameError="",e.nameMessage="";try{let G=await t.post("/api/user/project-name",{type:k._type,id:k._id,name:q});k.projectName=G.data.name,k._label=k.projectName||k._fallbackLabel,e.selectedProject===k&&(e.nameMessage=q?"Project name saved.":"Default project name restored."),T||(e.dashboardCursor=null,await F(),e.selectedProject===k&&(e.selectedProject=e.items.find(H=>H._type===k._type&&H._id===k._id)||null))}catch{e.selectedProject===k&&(e.nameError="The project name could not be saved. Try again.")}finally{e.nameSaving=!1}},e.copyingId=null,e.copyLink=async k=>{if(!k._viewUrl||e.copyingId)return;let q=new URL(k._viewUrl,o.location.origin).href;e.copyingId=k._type+":"+k._id;try{await Qa(q),e.addToast({title:"Link copied",body:"The anonymous link is ready to share."})}catch{e.addToast({title:"Copy this anonymous link",body:q})}finally{e.copyingId=null}},e.items=[],e.search="",e.loading=!0,e.statusKeyLabels={ready:"Ready",progress:"Preparing",error:"Error",expired:"Expiring / expired",removed:"Removing / removed"};let p=["queue","download","downloaded","preparing","anonymizing"];function
Line truncated
|
||||
`)),e.options=Object.assign({},e.options,B.options),e.options.expirationDate=B.options&&B.options.expirationDate?new Date(B.options.expirationDate):_(),!i.repoId&&!i.pullRequestId&&!i.gistId&&!e.anonymize?.terms?.dirty&&(e.terms=e.defaultTerms),C&&C()})}function Ee(C,O,B){e.anonymize&&e.anonymize[C]&&e.anonymize[C].setValidity(O,B)}function tt(C){try{let O=parseGithubUrl(C);if(O&&O.owner&&O.repo)return O.owner+"/"+O.repo}catch{}return null}e.accessRepairAllowed=!1,e.repairingGitHubAccess=!1,e.accessRepairMessage="",e.repairGitHubAccess=async()=>{if(!e.accessRepairAllowed||e.repairingGitHubAccess||!e.githubConnections?.appEnabled||!i.repoId||e.role!=="owner"||e.githubConnection!=="github-app"||tt(e.sourceUrl)!==e._originalFullName)return;e.repairingGitHubAccess=!0,e.accessRepairMessage="";let C=m();try{let O=await t.get("/github/connections");if(e.githubConnections=O.data,!O.data.appEnabled)return;let B=await t.post("/github/connections/migrate",{type:"repository",id:i.repoId,connection:"github-app"},{headers:{"X-CSRF-Token":O.data.csrf}});if(!y(C))return;e.error=null,B.data.fullName&&(e._originalFullName=B.data.fullName,e.source.fullName=B.data.fullName,e.sourceUrl="https://github.com/"+B.data.fullName),e.accessRepairMessage="GitHub access repaired. Your anonymous URL and published commit are unchanged.",await e.urlSelected(!0)}catch{y(C)&&(e.accessRepairMessage="Unable to repair GitHub access. Check the App's repository permissions in Manage access, then retry. Your published snapshot has not been replaced.")}finally{e.repairingGitHubAccess=!1,b(C)}},e.reconnectingSource=!1,e.reconnectRepositoryId=void 0,e.reconnectSource=async()=>{if(confirm("Reconnect to the repository currently at this GitHub URL? Review its branch and commit before saving. Saving will replace the published snapshot.")){e.reconnectingSource=!0,e.reconnectRepositoryId=void 0,e.source.commit="",e.source.branch="",e.readme="",e.branches=[];try{await ce()}catch{}}};function Ne(){return e.reconnectingSource||!e.isUpdate||!e._originalRepositoryID?void 0:tt(e.sourceUrl)===e._originalFullName?e._originalRepositoryID:void 0}async function qe(){e._preservingDraft=!0;try{await e.urlSelected(!0)}finally{e._preservingDraft=!1}}async function X(){let C=new URLSearchParams(window.location.search).get("billingDraft");if(C){N.restore();try{let B=(await t.get("/api/billing/draft/"+encodeURIComponent(C))).data;if(B.path!==o.path())throw new Error("Wrong task");w=B.values.conference||null;for(let K of["sourceUrl","terms","repoId","source","options","conference","githubConnection"])Object.prototype.hasOwnProperty.call(B.values,K)&&(e[K]=B.values[K]);return e.options?.expirationDate&&(e.options.expirationDate=new Date(e.options.expirationDate)),T=B.id,M=JSON.stringify(N.checkpoint()),e.draftRestored=!0,e.hostingReview=!0,e.sourceUrl&&await qe(),o.replace?.(o.path()),!0}catch{e.billingError="The checkout draft could not be restored. Retry by reloading this page; any local draft is still available."}}let O;try{O=JSON.parse(sessionStorage.getItem("github-access-draft")||"null")}catch{return!1}if(!O||O.path!==o.path()||Date.now()-O.savedAt>=30*6e4)return N.restore()?(e.sourceUrl&&await qe(),!0):!1;N.restore();for(let B of["sourceUrl","terms","repoId","pullRequestId","gistId","source","options","conference","githubConnection"])Object.prototype.hasOwnProperty.call(O.draft,B)&&(e[B]=O.draft[B]);return e.options.expirationDate&&(e.options.expirationDate=new Date(e.options.expirationDate)),await qe(),sessionStorage.removeItem("github-access-draft"),!0}Qe(()=>{!i.repoId&&!i.pullRequestId&&!i.gistId&&u(X,0),i.repoId&&i.repoId!=""&&(e.isUpdate=!0,e.detectedType="repo",e.repoId=i.repoId,t.get("/api/repo/"+e.repoId).then(async C=>{e.accessRepairAllowed=!["removed","archived","preparing","queue","download","removing","expiring"].includes(C.data.status),e.githubConnection=C.data.connection||"oauth",e.sourceUrl="https://github.com/"+C.data.source.fullName,e._originalFullName=C.data.source.fullName,e.terms=C.data.options.terms.filter(O=>O).join(`
|
||||
Contact: jane.smith@mit.edu`,e.demoTerms="Jane Smith, Smith, MIT CSAIL, jane.smith@mit.edu",e.demoParts=function(){let p=(e.demoTerms||"").split(/[,\n]/).map(m=>m.trim()).filter(Boolean).sort((m,b)=>b.length-m.length),c=m=>m.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(!p.length)return[{text:e.demoText}];let v=new RegExp("("+p.map(c).join("|")+")","gi"),g={},y=0;return(e.demoText||"").split(v).filter(m=>m!=="").map(m=>{let b=p.find(E=>E.toLowerCase()===m.toLowerCase());return b?(g[b.toLowerCase()]||(g[b.toLowerCase()]=++y),{text:String(g[b.toLowerCase()]),redacted:!0,original:m}):{text:m}})},e.demoCount=()=>e.demoParts().filter(p=>p.redacted).length,e.cards=[{key:"repositories",total:0,label:"repositories anonymized"},{key:"users",total:0,label:"researchers"},{key:"pageViews",total:0,label:"page views"},{key:"pullRequests",total:0,label:"pull requests"}],e.statsEmpty=()=>!!e.stat&&e.cards.every(p=>!p.total);function r(){t.get("/api/stat/").then(p=>{e.stat=p.data,e.cards[0].total=p.data.nbRepositories,e.cards[1].total=p.data.nbUsers,e.cards[2].total=p.data.nbPageViews,e.cards[3].total=p.data.nbPullRequests}).catch(()=>{})}r();function u(p){let c={series:p,bars:[],viewW:100,deltaToday:0,pctChange:0,pctAbs:0,isUp:!0};if(!p||p.length<2)return c;let v=new Array(p.length-1);for(let S=1;S<p.length;S++)v[S-1]=p[S]-p[S-1];let g=v.length,y=Math.max.apply(null,v),m=Math.min.apply(null,v),b=Math.min(0,m),E=y-b||1;c.viewW=g*2,c.bars=new Array(g);for(let S=0;S<g;S++){let N=(v[S]-b)/E,w=Math.max(1.5,N*34);c.bars[S]={x:(S*2+.25).toFixed(2),y:(36-w).toFixed(2),w:"1.5",h:w.toFixed(2)}}if(c.deltaToday=v[g-1],g>=2){let S=v[g-2];S&&(c.pctChange=(c.deltaToday-S)/S*100)}return c.pctAbs=Math.round(Math.abs(c.pctChange)),c.isUp=c.pctChange>=0,c}e.history={repositories:u([]),users:u([]),pageViews:u([]),pullRequests:u([])},t.get("/api/stat/history?days=60").then(p=>{let c=p.data||[];e.history={repositories:u(c.map(v=>v.nbRepositories||0)),users:u(c.map(v=>v.nbUsers||0)),pageViews:u(c.map(v=>v.nbPageViews||0)),pullRequests:u(c.map(v=>v.nbPullRequests||0))}}).catch(()=>{})},Gc=function(e,t,s,i,o,r){let u=bt();e.on("routeLeave",function(){$('[data-toggle="tooltip"]').tooltip("dispose")}),e.watch("user.status",()=>{e.user==null&&s.url("/")}),e.user==null&&s.url("/"),u.timeout(()=>{$('[data-toggle="tooltip"]').tooltip()},250),e.quotaExpanded=!1,e.closeQuota=()=>{e.quotaExpanded=!1,We(()=>document.querySelector(".dashboard-quota > summary")?.focus())},Ut()(document,"click",k=>{e.quotaExpanded&&!k.target.closest?.(".dashboard-quota")&&(e.quotaExpanded=!1)}),e.filtersExpanded=!1,e.projectView="all",e.selectedProject=null,e.projectName="",e.nameSaving=!1,e.nameError="",e.nameMessage="",e.needsAttention=k=>k.status==="error"||k._broken||c(k.status)==="progress"&&k._stale,e.attentionCount=()=>e.dashboardTotals?.attention??e.items.filter(e.needsAttention).length,e.hasProjects=()=>(e.dashboardTotals?.total??e.items.length)>0,e.setProjectView=k=>{e.projectView=k,k==="attention"&&(e.filters.status.error=!0,e.filters.status.progress=!0)},e.idleText=k=>{let q=Ca(k?.anonymizeDate||k?.lastView)||"";return/ ago$/.test(q)?"No activity for "+q.replace(/ ago$/,""):"No activity since "+q.replace(", "+new Date().getFullYear(),"")},e.projectDetailsId=k=>"project-details-"+encodeURIComponent(k._type+":"+(k._id||k._source||"unknown")),e.showProjectDetails=async k=>{e.selectedProject=k,e.projectName=k.projectName||"",e.nameError="",e.nameMessage="",await We();let q=document.getElementById(e.projectDetailsId(k));q?.focus(),q?.scrollIntoView?.({block:"nearest"})},e.closeProjectDetails=k=>{e.selectedProject=null,We(()=>document.querySelector(`[data-project-actions="${encodeURIComponent(k._type+":"+k._id)}"]`)?.focus())},e.saveProjectName=async k=>{if(e.nameSaving||!k._id)return;let q=e.projectName.trim();if(q.length>100){e.nameError="Use 100 characters or fewer.";return}e.nameSaving=!0,e.nameError="",e.nameMessage="";try{let G=await t.post("/api/user/project-name",{type:k._type,id:k._id,name:q});k.projectName=G.data.name,k._label=k.projectName||k._fallbackLabel,e.selectedProject===k&&(e.nameMessage=q?"Project name saved.":"Default project name restored."),T||(e.dashboardCursor=null,await F(),e.selectedProject===k&&(e.selectedProject=e.items.find(H=>H._type===k._type&&H._id===k._id)||null))}catch{e.selectedProject===k&&(e.nameError="The project name could not be saved. Try again.")}finally{e.nameSaving=!1}},e.copyingId=null,e.copyLink=async k=>{if(!k._viewUrl||e.copyingId)return;let q=new URL(k._viewUrl,o.location.origin).href;e.copyingId=k._type+":"+k._id;try{await Qa(q),e.addToast({title:"Link copied",body:"The anonymous link is ready to share."})}catch{e.addToast({title:"Copy this anonymous link",body:q})}finally{e.copyingId=null}},e.items=[],e.search="",e.loading=!0,e.statusKeyLabels={ready:"Ready",progress:"Preparing",error:"Error",expired:"Expiring / expired",removed:"Removing / removed"};let p=["queue","download","downloaded","preparing","anonymizing"];function
Line truncated
|
||||
`)),e.options=Object.assign({},e.options,B.options),e.options.expirationDate=B.options&&B.options.expirationDate?new Date(B.options.expirationDate):_(),!i.repoId&&!i.pullRequestId&&!i.gistId&&!e.anonymize?.terms?.dirty&&(e.terms=e.defaultTerms),C&&C()})}function Ee(C,O,B){e.anonymize&&e.anonymize[C]&&e.anonymize[C].setValidity(O,B)}function tt(C){try{let O=parseGithubUrl(C);if(O&&O.owner&&O.repo)return O.owner+"/"+O.repo}catch{}return null}e.accessRepairAllowed=!1,e.repairingGitHubAccess=!1,e.accessRepairMessage="",e.repairGitHubAccess=async()=>{if(!e.accessRepairAllowed||e.repairingGitHubAccess||!e.githubConnections?.appEnabled||!i.repoId||e.role!=="owner"||e.githubConnection!=="github-app"||tt(e.sourceUrl)!==e._originalFullName)return;e.repairingGitHubAccess=!0,e.accessRepairMessage="";let C=m();try{let O=await t.get("/github/connections");if(e.githubConnections=O.data,!O.data.appEnabled)return;let B=await t.post("/github/connections/migrate",{type:"repository",id:i.repoId,connection:"github-app"},{headers:{"X-CSRF-Token":O.data.csrf}});if(!y(C))return;e.error=null,B.data.fullName&&(e._originalFullName=B.data.fullName,e.source.fullName=B.data.fullName,e.sourceUrl="https://github.com/"+B.data.fullName),e.accessRepairMessage="GitHub access repaired. Your anonymous URL and published commit are unchanged.",await e.urlSelected(!0)}catch{y(C)&&(e.accessRepairMessage="Unable to repair GitHub access. Check the App's repository permissions in Manage access, then retry. Your published snapshot has not been replaced.")}finally{e.repairingGitHubAccess=!1,b(C)}},e.reconnectingSource=!1,e.reconnectRepositoryId=void 0,e.reconnectSource=async()=>{if(confirm("Reconnect to the repository currently at this GitHub URL? Review its branch and commit before saving. Saving will replace the published snapshot.")){e.reconnectingSource=!0,e.reconnectRepositoryId=void 0,e.details=null,e.source.commit="",e.source.branch="",e.readme="",e.branches=[];try{await ce()}catch{}}};function Ne(){return e.reconnectingSource||!e.isUpdate||!e._originalRepositoryID?void 0:tt(e.sourceUrl)===e._originalFullName?e._originalRepositoryID:void 0}async function qe(){e._preservingDraft=!0;try{await e.urlSelected(!0)}finally{e._preservingDraft=!1}}async function X(){let C=new URLSearchParams(window.location.search).get("billingDraft");if(C){N.restore();try{let B=(await t.get("/api/billing/draft/"+encodeURIComponent(C))).data;if(B.path!==o.path())throw new Error("Wrong task");w=B.values.conference||null;for(let K of["sourceUrl","terms","repoId","source","options","conference","githubConnection"])Object.prototype.hasOwnProperty.call(B.values,K)&&(e[K]=B.values[K]);return e.options?.expirationDate&&(e.options.expirationDate=new Date(e.options.expirationDate)),T=B.id,M=JSON.stringify(N.checkpoint()),e.draftRestored=!0,e.hostingReview=!0,e.sourceUrl&&await qe(),o.replace?.(o.path()),!0}catch{e.billingError="The checkout draft could not be restored. Retry by reloading this page; any local draft is still available."}}let O;try{O=JSON.parse(sessionStorage.getItem("github-access-draft")||"null")}catch{return!1}if(!O||O.path!==o.path()||Date.now()-O.savedAt>=30*6e4)return N.restore()?(e.sourceUrl&&await qe(),!0):!1;N.restore();for(let B of["sourceUrl","terms","repoId","pullRequestId","gistId","source","options","conference","githubConnection"])Object.prototype.hasOwnProperty.call(O.draft,B)&&(e[B]=O.draft[B]);return e.options.expirationDate&&(e.options.expirationDate=new Date(e.options.expirationDate)),await qe(),sessionStorage.removeItem("github-access-draft"),!0}Qe(()=>{!i.repoId&&!i.pullRequestId&&!i.gistId&&u(X,0),i.repoId&&i.repoId!=""&&(e.isUpdate=!0,e.detectedType="repo",e.repoId=i.repoId,t.get("/api/repo/"+e.repoId).then(async C=>{e.accessRepairAllowed=!["removed","archived","preparing","queue","download","removing","expiring"].includes(C.data.status),e.githubConnection=C.data.connection||"oauth",e.sourceUrl="https://github.com/"+C.data.source.fullName,e._originalFullName=C.data.source.fullName,e.terms=C.data.options.terms.filter(O=>O).join(`
|
||||
`),e.source=C.data.source,e.role=C.data.role||"owner",e._existingNever=C.data.options.expirationMode==="never",e._savedExpirationDate=C.data.options.expirationDate?new Date(C.data.options.expirationDate):null,e.coauthors=C.data.coauthors||[],e._originalBranch=C.data.source.branch,e.options=Object.assign({},e.options,C.data.options),e.conference=C.data.conference,e._originalConference=C.data.conference,e.repositoryID=C.data.source.repositoryID,e._originalRepositoryID=C.data.source.repositoryID,C.data.options.expirationDate&&(e.options.expirationDate=new Date(C.data.options.expirationDate)),E=S(parseGithubUrl(e.sourceUrl)),!await X()&&(await Promise.all([ce(),ue()]),So())},()=>{o.url("/404")})),i.pullRequestId&&i.pullRequestId!=""&&(e.isUpdate=!0,e.detectedType="pr",e.pullRequestId=i.pullRequestId,t.get("/api/pr/"+e.pullRequestId).then(async C=>{if(e.githubConnection=C.data.connection||"oauth",e.sourceUrl="https://github.com/"+C.data.source.repositoryFullName+"/pull/"+C.data.source.pullRequestId,e.terms=C.data.options.terms.filter(O=>O).join(`
|
||||
`),e.source=C.data.source,e.options=Object.assign({},e.options,C.data.options),e.conference=C.data.conference,e._originalConference=C.data.conference,C.data.options.expirationDate&&(e.options.expirationDate=new Date(C.data.options.expirationDate)),E=S(parseGithubUrl(e.sourceUrl)),!await X())try{await ol()}catch{}},()=>{o.url("/404")})),i.gistId&&i.gistId!=""&&(e.isUpdate=!0,e.detectedType="gist",e.gistId=i.gistId,t.get("/api/gist/"+e.gistId).then(async C=>{e.sourceUrl="https://gist.github.com/"+C.data.source.gistId,e.terms=C.data.options.terms.filter(O=>O).join(`
|
||||
`),e.source=C.data.source,e.options=Object.assign({},e.options,C.data.options),e.conference=C.data.conference,e._originalConference=C.data.conference,C.data.options.expirationDate&&(e.options.expirationDate=new Date(C.data.options.expirationDate)),E=S(parseGithubUrl(e.sourceUrl)),!await X()&&await sl()},()=>{o.url("/404")}))}),t.get("/github/connections").then(C=>{e.githubConnections=C.data,!i.repoId&&!i.pullRequestId&&!i.gistId&&e.githubConnection===void 0&&C.data.appEnabled&&C.data.appConnected&&(e.githubConnection="github-app",e.sourceUrl&&e.workspaceOpen&&qe())}).catch(()=>{}).finally(()=>{!v&&!i.repoId&&!i.pullRequestId&&!i.gistId&&e.userReposStatus==="idle"&&e.loadUserRepos()}),e.urlSelected=async(C=!1)=>{let O=++c;e.previousConfigurations=[],e.previousConfigurationId="";let B;try{B=parseGithubUrl(e.sourceUrl.trim())}catch{e.sourceLoading=!1,e.details=null,fe(),Jt.cancel(),Mn.cancel(),Vn.cancel(),e.previewStatus="idle",e.sourceUrlError=e.sourceUrl?"Please provide a valid GitHub URL.":"",Ee("sourceUrl","github",!1);return}let K=S(B),ae=C||E===K;E=K,e.sourceUrlError="",Ee("sourceUrl","github",!0),fe();let ye=document.activeElement?.id==="sourceUrl-landing";e.workspaceOpen=!0,setTimeout(()=>{let je=window.document.getElementById("sourceUrl");if(je){try{je.setSelectionRange(0,0)}catch{}je.scrollLeft=0}},50),ye&&u(()=>document.getElementById("sourceUrl")?.focus(),0),e.reconnectingSource=!1,e.reconnectRepositoryId=void 0,!ae&&!e.isUpdate&&(e.repoId="",e.pullRequestId="",e.gistId=""),e.details=null,e.branches=[],ae||(e.source={type:"GitHubStream",branch:"",commit:""}),Jt.cancel(),Mn.cancel(),Vn.cancel(),Eo.clear(),No.clear(),e.previewStatus="idle",e.anonymize_readme="",e.readme="",rf(),e.detectedType=null,e.gistOAuthRequired=!1,e.gistAppRequired=!1,e._preservingDraft=ae;try{B.gistId&&!B.repo?(e.detectedType="gist",e.source={gistId:B.gistId},await sl()):B.pullRequestId?(e.detectedType="pr",e.source={repositoryFullName:B.owner+"/"+B.repo,pullRequestId:B.pullRequestId},await ol()):(e.detectedType="repo",Y(),await Promise.all([ce(),ue()]),So())}catch{}finally{O===c&&(e._preservingDraft=!1)}$('[data-toggle="tooltip"]').tooltip()},$('[data-toggle="tooltip"]').tooltip(),e.watch("source.branch",async()=>{if(e.detectedType!=="repo")return;let C=e.branches.filter(B=>B.name==e.source.branch)[0];if(!C)return;!(!e.reconnectingSource&&e.isUpdate&&e._originalBranch===e.source.branch&&e.source.commit)&&!(e._preservingDraft&&e.source.commit)&&(e.source.commit=C.commit),e.readme=C.readme,await ue(),So()}),e.getBranches=async C=>{let O=parseGithubUrl(e.sourceUrl),B=m();try{if(!e.details){await ce(C);return}let K=await t.get(`/api/repo/${O.owner}/${O.repo}/branches`,{params:{reconnect:e.reconnectingSource?"1":void 0,anonymizedRepoId:e.isUpdate&&i.repoId&&tt(e.sourceUrl)===e._originalFullName?i.repoId:void 0,connection:e.githubConnection,force:C===!0||e.reconnectingSource?"1":"0",repositoryID:Ne()}});if(!y(B))return;e.branches=K.data,e.sourceUnreachable=!1,e.source.branch||(e.source.branch=e.details.defaultBranch);let ae=e.branches.filter(ye=>ye.name==e.source.branch);ae.length>0&&(!(!e.reconnectingSource&&!C&&e.isUpdate&&!e.options.update&&e._originalBranch===e.source.branch&&e.source.commit)&&!(e._preservingDraft&&e.source.commit)&&(e.source.commit=ae[0].commit),e.readme=ae[0].readme,await ue(C))}catch(K){if(!y(B))return;e.branches=[],e.sourceUnreachable=K&&(K.status===404||K.data&&K.data.error==="repo_not_found"),e.details=null,x(K)}finally{b(B)}};async function ce(C=!1){let O=parseGithubUrl(e.sourceUrl),B=m();try{Ro(),fe();let K=await t.get(`/api/repo/${O.owner}/${O.repo}/`,{params:{reconnect:e.reconnectingSource?"1":void 0,anonymizedRepoId:e.isUpdate&&i.repoId&&tt(e.sourceUrl)===e._originalFullName?i.repoId:void 0,connection:e.githubConnection,repositoryID:Ne(),force:"1"}});if(!y(B))return;e.details=K.data,e.reconnectingSource&&(e.reconnectRepositoryId=e.details.externalId),e.details&&e.details.id&&(e.repositoryID=e.details.id),e.repoId||(e.repoId=e.details.repo+"-"+generateRandomId(4)),await e.getBranches(C||e.reconnectingSource)}catch(K){if(!y(B))return;throw x(K),K}finally{b(B)}}async function ue(C){if(e.readme&&!C)return e.readme;let O=parseGithubUrl(e.sourceUrl),B=m();try{let K=await t.get(`/api/repo/${O.owner}/${O.repo}/readme`,{params:{reconnect:e.reconnectingSource?"1":void 0,anonymizedRepoId:e.isUpdate&&i.repoId&&tt(e.sourceUrl)===e._originalFullName?i.repoId:void 0,connection:e.githubConnection,force:C===!0?"1":"0",branch:e.source.branch,repositoryID:Ne()}});y(B,!0)&&(e.readme=K.data)}catch{y(B,!0)&&(e.readme="")}finally{b(B)}}let me={magicalBraces:!0},be=C=>C.startsWith("/")&&!C.endsWith("/")&&Gn(bo(C.slice(1),me),me)===C.slice(1),Ve=()=>Object.keys(e.preserve.picked).filter(C=>e.preserve.picked[C]).sort().map(C=>"/"+Gn(C,me)),D=C=>"/"+Gn(C,me)+"/**",A=C=>"!/"+Gn(C,me)+"/",U=()=>String(e.preserve.patterns||"").split(`
|
||||
|
||||
@@ -943,6 +943,33 @@ describe("Vue 3 UI", function () {
|
||||
});
|
||||
}
|
||||
|
||||
it("shows failed reconnection after previously loading source metadata", async () => {
|
||||
let fail = false;
|
||||
ui = await browser("/anonymize/saved", {
|
||||
...repositorySource,
|
||||
"/api/repo/saved": { source: { fullName: "owner/repo", branch: "main", commit: "saved123" }, options: { terms: ["Private Author"] } },
|
||||
"/api/repo/owner/repo/": () => fail ? { __status: 403, body: { error: "github_app_reconnect_required" } }
|
||||
: { defaultBranch: "main", repo: "repo", hasPage: false },
|
||||
});
|
||||
await delay(150);
|
||||
const state = ui.window.document.querySelector("#sourceUrl")._field.binding.state;
|
||||
expect(state.details.repo).to.equal("repo");
|
||||
ui.window.confirm = () => true;
|
||||
fail = true;
|
||||
await state.reconnectSource();
|
||||
await delay(30);
|
||||
expect(state.details).to.equal(null);
|
||||
expect(state.sourceProblem().kind).to.equal("reconnect");
|
||||
expect(ui.window.document.querySelector('.source-error a[href="/connections"]')).not.to.equal(null);
|
||||
expect(ui.window.document.querySelector('.rp-error a[href="/connections"]')).not.to.equal(null);
|
||||
fail = false;
|
||||
await state.reconnectSource();
|
||||
await delay(30);
|
||||
expect(state.sourceProblem()).to.equal(null);
|
||||
expect(state.source.commit).to.equal("abcdef123");
|
||||
expect(ui.errors).to.deep.equal([]);
|
||||
});
|
||||
|
||||
it("recovers edit source validity after a failed branch refresh", async () => {
|
||||
let fail = false;
|
||||
ui = await browser("/anonymize/saved", {
|
||||
|
||||
Reference in new issue
Block a user