Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | 7x 3x 1x 2x 60x 43x 43x 1x 1x 4x 7x 1x 2x 2x 2x 2x 8x 8x 8x 3x 8x 2x 2x 47x 2x 2x 2x 2x 2x 2x | import { AVAILABLE, REVISION_STATUS } from "./constants"; import { getChannelString } from "../../libs/channels"; import { useEffect } from "react"; export function isInDevmode(revision: any) { return revision.confinement === "devmode" || revision.grade === "devel"; } export function getChannelName( track: string, risk: string, branch?: string | undefined, ) { if (risk === AVAILABLE) { return AVAILABLE; } return getChannelString({ track, risk, branch, }); } export function getBuildId(revision: { attributes: { [x: string]: any } }) { return ( revision && revision.attributes && revision.attributes["build-request-id"] ); } export function isRevisionBuiltOnLauchpad(revision: any) { const buildId = getBuildId(revision); return !!(buildId && buildId.indexOf("lp-") === 0); } export function getRevisionsArchitectures(revisions: any[]) { let archs: any[] = []; // get all architectures from all revisions revisions.forEach((revision) => { archs = archs.concat(revision.architectures); }); // make archs unique and sorted archs = archs.filter((item, i, ar) => ar.indexOf(item) === i).sort(); return archs; } export function isSameVersion(revisions: { version: string }[]) { let hasSameVersion = false; const versionsMap: any = {}; Eif (revisions) { // calculate map of architectures for each version for (const arch in revisions) { const revision = revisions[arch]; const version = revision.version; if (!versionsMap[version]) { versionsMap[version] = []; } versionsMap[version].push(arch); } hasSameVersion = Object.keys(versionsMap).length === 1; } return hasSameVersion; } export function jsonClone(obj: { string: string; number?: number; boolean?: boolean; array?: (string | number | boolean)[]; function?: () => string; }) { return JSON.parse(JSON.stringify(obj)); } export function canBeReleased(revision: { status: string }) { const allowed = [REVISION_STATUS.PUBLISHED, REVISION_STATUS.UNPUBLISHED]; return revision && allowed.includes(revision.status); } export function validatePhasingPercentage(value: string) { if (value.trim()) { if (isNaN(parseInt(value))) { return "Phasing percentage must be a number"; } else { const percentage = parseFloat(value); if (percentage < 0 || percentage > 100) { return "Phasing percentage must be between 0 and 100"; } } } return ""; } export function resizeAsidePanel(panelType: string) { useEffect(() => { const adjustAsidePanelHeight = () => { const targetComponent = document.querySelector("#main-content"); let asidePanel; if (panelType === "add") { asidePanel = document.querySelector( "#add-track-aside-panel", ) as HTMLElement; } else { asidePanel = document.querySelector( "#request-track-aside-panel", ) as HTMLElement; } if (targetComponent && asidePanel) { const targetRect = targetComponent.getBoundingClientRect(); const targetTop = targetRect.top; const targetBottom = targetRect.bottom; const viewportHeight = window.innerHeight; if (targetBottom > viewportHeight) { asidePanel.style.position = "fixed"; asidePanel.style.top = `${targetTop}px`; asidePanel.style.bottom = "0"; } else { asidePanel.style.position = "sticky"; asidePanel.style.top = `${targetTop}px`; } } }; adjustAsidePanelHeight(); window.addEventListener("resize", adjustAsidePanelHeight); window.addEventListener("scroll", adjustAsidePanelHeight); return () => { window.removeEventListener("resize", adjustAsidePanelHeight); window.removeEventListener("scroll", adjustAsidePanelHeight); }; }); } export function numericalSort(a: string, b: string) { const regex = /\d+/g; const numSeqA = (a.match(regex) || []).map(Number); const numSeqB = (b.match(regex) || []).map(Number); for (let i = 0; i < Math.max(numSeqA.length, numSeqB.length); i++) { const numA = numSeqA[i] || 0; const numB = numSeqB[i] || 0; if (numA !== numB) { return numA - numB; } } return a.localeCompare(b); } export async function getPackageMetadata(snap: string) { const url = `/api/packages/${snap}`; try { const response = await fetch(url, { method: "GET", headers: { "Content-Type": "application/json", }, }); Iif (!response.ok) { throw new Error("There was a problem fetching the snap's metadata"); } const data = await response.json(); return data.data; } catch (e) { return { error: e }; } } |