@yuebai008/cli
Version:
Command line interface for rapid qg-minigame development
1 lines • 2.96 kB
JavaScript
import*as Common from"../../core/common/common.js";import*as Host from"../../core/host/host.js";import*as i18n from"../../core/i18n/i18n.js";import*as UI from"../../ui/legacy/legacy.js";import*as NetworkForward from"../../panels/network/forward/forward.js";import{AffectedResourcesView}from"./AffectedResourcesView.js";const UIStrings={nCookies:"{n, plural, =1 {# cookie} other {# cookies}}",name:"Name",domain:"Domain",path:"Path",nRawCookieLines:"{n, plural, =1 {1 Raw `Set-Cookie` header} other {# Raw `Set-Cookie` headers}}",filterSetCookieTitle:"Show network requests that include this `Set-Cookie` header in the network panel"},str_=i18n.i18n.registerUIStrings("panels/issues/AffectedCookiesView.ts",UIStrings),i18nString=i18n.i18n.getLocalizedString.bind(void 0,str_);export class AffectedCookiesView extends AffectedResourcesView{getResourceNameWithCount(e){return i18nString(UIStrings.nCookies,{n:e})}#e(e){const t=document.createElement("tr");this.appendColumnTitle(t,i18nString(UIStrings.name)),this.appendColumnTitle(t,i18nString(UIStrings.domain)+" & "+i18nString(UIStrings.path),"affected-resource-cookie-info-header"),this.affectedResources.appendChild(t);let o=0;for(const t of e)o++,this.#t(t.cookie,t.hasRequest);this.updateAffectedResourceCount(o)}#t(e,t){const o=document.createElement("tr");o.classList.add("affected-resource-cookie");const i=document.createElement("td");t?i.appendChild(UI.UIUtils.createTextButton(e.name,(()=>{Host.userMetrics.issuesPanelResourceOpened(this.issue.getCategory(),"Cookie"),Common.Revealer.reveal(NetworkForward.UIFilter.UIRequestFilter.filters([{filterType:NetworkForward.UIFilter.FilterType.CookieDomain,filterValue:e.domain},{filterType:NetworkForward.UIFilter.FilterType.CookieName,filterValue:e.name},{filterType:NetworkForward.UIFilter.FilterType.CookiePath,filterValue:e.path}]))}),"link-style devtools-link")):i.textContent=e.name,o.appendChild(i),this.appendIssueDetailCell(o,`${e.domain}${e.path}`,"affected-resource-cookie-info"),this.affectedResources.appendChild(o)}update(){this.clear(),this.#e(this.issue.cookiesWithRequestIndicator())}}export class AffectedRawCookieLinesView extends AffectedResourcesView{getResourceNameWithCount(e){return i18nString(UIStrings.nRawCookieLines,{n:e})}update(){this.clear();const e=this.issue.getRawCookieLines();let t=0;for(const o of e){const e=document.createElement("tr");if(e.classList.add("affected-resource-directive"),o.hasRequest){const t=document.createElement("td"),i=UI.UIUtils.createTextButton(o.rawCookieLine,(()=>{Common.Revealer.reveal(NetworkForward.UIFilter.UIRequestFilter.filters([{filterType:NetworkForward.UIFilter.FilterType.ResponseHeaderValueSetCookie,filterValue:o.rawCookieLine}]))}),"link-style devtools-link");i.title=i18nString(UIStrings.filterSetCookieTitle),t.appendChild(i),e.appendChild(t)}else this.appendIssueDetailCell(e,o.rawCookieLine);this.affectedResources.appendChild(e),t++}this.updateAffectedResourceCount(t)}}