From 2a5c4ab5307112b56df5ec27ea66edd4d10e859f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Dudfield?= Date: Sat, 6 Jul 2024 08:50:55 +0200 Subject: [PATCH 1/4] frontend: Fix ReleaseNotes so it works again MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #2143 and a CVE with Octokit. Removes Octokit because we just use it to fetch one URL. Signed-off-by: René Dudfield --- frontend/package-lock.json | 110 +---------- frontend/package.json | 1 - .../common/ReleaseNotes/ReleaseNotes.tsx | 155 +++++++++------ plugins/headlamp-plugin/package-lock.json | 187 ------------------ plugins/headlamp-plugin/package.json | 1 - 5 files changed, 101 insertions(+), 353 deletions(-) diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 524234f748..c0c15e49d7 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -21,7 +21,6 @@ "@mui/styles": "^5.15.14", "@mui/system": "^5.15.14", "@mui/x-tree-view": "^6.17.0", - "@octokit/core": "^3.5.1", "@reduxjs/toolkit": "^1.9.3", "@testing-library/react": "^12.1.2", "@types/glob": "^8.1.0", @@ -4213,92 +4212,6 @@ "node": ">= 8" } }, - "node_modules/@octokit/auth-token": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.5.0.tgz", - "integrity": "sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g==", - "license": "MIT", - "dependencies": { - "@octokit/types": "^6.0.3" - } - }, - "node_modules/@octokit/core": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.6.0.tgz", - "integrity": "sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q==", - "license": "MIT", - "dependencies": { - "@octokit/auth-token": "^2.4.4", - "@octokit/graphql": "^4.5.8", - "@octokit/request": "^5.6.3", - "@octokit/request-error": "^2.0.5", - "@octokit/types": "^6.0.3", - "before-after-hook": "^2.2.0", - "universal-user-agent": "^6.0.0" - } - }, - "node_modules/@octokit/endpoint": { - "version": "6.0.12", - "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.12.tgz", - "integrity": "sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==", - "license": "MIT", - "dependencies": { - "@octokit/types": "^6.0.3", - "is-plain-object": "^5.0.0", - "universal-user-agent": "^6.0.0" - } - }, - "node_modules/@octokit/graphql": { - "version": "4.8.0", - "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.8.0.tgz", - "integrity": "sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg==", - "license": "MIT", - "dependencies": { - "@octokit/request": "^5.6.0", - "@octokit/types": "^6.0.3", - "universal-user-agent": "^6.0.0" - } - }, - "node_modules/@octokit/openapi-types": { - "version": "12.11.0", - "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-12.11.0.tgz", - "integrity": "sha512-VsXyi8peyRq9PqIz/tpqiL2w3w80OgVMwBHltTml3LmVvXiphgeqmY9mvBw9Wu7e0QWk/fqD37ux8yP5uVekyQ==", - "license": "MIT" - }, - "node_modules/@octokit/request": { - "version": "5.6.3", - "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.3.tgz", - "integrity": "sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A==", - "license": "MIT", - "dependencies": { - "@octokit/endpoint": "^6.0.1", - "@octokit/request-error": "^2.1.0", - "@octokit/types": "^6.16.1", - "is-plain-object": "^5.0.0", - "node-fetch": "^2.6.7", - "universal-user-agent": "^6.0.0" - } - }, - "node_modules/@octokit/request-error": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.1.0.tgz", - "integrity": "sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==", - "license": "MIT", - "dependencies": { - "@octokit/types": "^6.0.3", - "deprecation": "^2.0.0", - "once": "^1.4.0" - } - }, - "node_modules/@octokit/types": { - "version": "6.41.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.41.0.tgz", - "integrity": "sha512-eJ2jbzjdijiL3B4PrSQaSjuF2sPEQPVCPzBvTHJD9Nz+9dw2SGH4K4xeQJ77YfTq5bRQ+bD8wT11JbeDPmxmGg==", - "license": "MIT", - "dependencies": { - "@octokit/openapi-types": "^12.11.0" - } - }, "node_modules/@open-draft/until": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@open-draft/until/-/until-1.0.3.tgz", @@ -11652,12 +11565,6 @@ ], "license": "MIT" }, - "node_modules/before-after-hook": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", - "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==", - "license": "Apache-2.0" - }, "node_modules/better-opn": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/better-opn/-/better-opn-3.0.2.tgz", @@ -13653,12 +13560,6 @@ "node": ">= 0.8" } }, - "node_modules/deprecation": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", - "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==", - "license": "ISC" - }, "node_modules/dequal": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", @@ -18243,6 +18144,7 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-5.0.0.tgz", "integrity": "sha512-VRSzKkbMm5jMDoKLbltAkFQ5Qr7VDiTFGXxYFXXowVj387GeGNOCsOH6Msy00SGZ3Fp84b1Naa1psqgcCIEP5Q==", + "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -21414,6 +21316,7 @@ "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", + "dev": true, "license": "MIT", "dependencies": { "whatwg-url": "^5.0.0" @@ -21441,18 +21344,21 @@ "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", + "dev": true, "license": "MIT" }, "node_modules/node-fetch/node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", + "dev": true, "license": "BSD-2-Clause" }, "node_modules/node-fetch/node_modules/whatwg-url": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dev": true, "license": "MIT", "dependencies": { "tr46": "~0.0.3", @@ -26936,12 +26842,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/universal-user-agent": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz", - "integrity": "sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==", - "license": "ISC" - }, "node_modules/universalify": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz", diff --git a/frontend/package.json b/frontend/package.json index d352e0119d..dd23f7058b 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -22,7 +22,6 @@ "@mui/styles": "^5.15.14", "@mui/system": "^5.15.14", "@mui/x-tree-view": "^6.17.0", - "@octokit/core": "^3.5.1", "@reduxjs/toolkit": "^1.9.3", "@testing-library/react": "^12.1.2", "@types/glob": "^8.1.0", diff --git a/frontend/src/components/common/ReleaseNotes/ReleaseNotes.tsx b/frontend/src/components/common/ReleaseNotes/ReleaseNotes.tsx index 26ee0e1fbf..4ee5408181 100644 --- a/frontend/src/components/common/ReleaseNotes/ReleaseNotes.tsx +++ b/frontend/src/components/common/ReleaseNotes/ReleaseNotes.tsx @@ -1,4 +1,3 @@ -import { Octokit } from '@octokit/core'; import React from 'react'; import semver from 'semver'; import helpers from '../../../helpers'; @@ -13,7 +12,7 @@ export default function ReleaseNotes() { const [releaseFetchFailed, setReleaseFetchFailed] = React.useState(false); const [skipFetch, setSkipFetch] = React.useState(false); - // network controller this makes sure if the octockit request is still lying around we + // network controller this makes sure if the github request is still lying around we // abort it on fetch release skip press button click const controller = new AbortController(); const signal = controller.signal; @@ -29,74 +28,112 @@ export default function ReleaseNotes() { return; } - const octokit = new Octokit({ - timeout: 10000, - signal, - }); - + /** + * Fetches latest github release and sets the releaseNotes plus releaseDownloadURL. + * + * Also sets the following state whilst running: + * - fetchingRelease + * - releaseFetchFailed + * - skipFetch + */ async function fetchRelease() { - // attach a timeout which checks after 5 second of fetching release + // attach a timeout which checks after 5 seconds of fetching release // if the release request was not successful const timeoutID = setTimeout(() => { setFetchingRelease(true); }, 5000); - const githubReleaseURL = `GET /repos/{owner}/{repo}/releases`; - // get me all the releases -> default decreasing order of releases - const response = await octokit.request(githubReleaseURL, { - owner: 'kinvolk', - repo: 'headlamp', - }); - - // Get the latest release that is not headlamp-plugin or headlamp-helm. - const latestRelease = response.data.find( - release => !release.name?.startsWith('headlamp-') - ); - if ( - latestRelease && - semver.gt(latestRelease.name as string, currentBuildAppVersion) && - !import.meta.env.FLATPAK_ID - ) { - setReleaseDownloadURL(latestRelease.html_url); - } + const githubReleaseURL = `https://api.github.com/repos/kinvolk/headlamp/releases`; + + try { + // get all the releases -> default decreasing order of releases + const response = await fetch(githubReleaseURL, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + signal, + }); + + if (!response.ok) { + throw new Error('Network response was not ok'); + } - // check if there is already a version in store if it exists don't store the current version - // this check will help us later in determining whether we are on the latest release or not. - const storedAppVersion = helpers.getAppVersion(); - let releaseNotes = ''; - if (storedAppVersion && semver.lt(storedAppVersion as string, currentBuildAppVersion)) { - // get the release notes for the version with which the app was built with - const githubReleaseURL = `GET /repos/{owner}/{repo}/releases/tags/v${currentBuildAppVersion}`; - try { - const response = await octokit.request(githubReleaseURL, { - owner: 'kinvolk', - repo: 'headlamp', - }); - const [notes] = response.data.body.split(''); - if (!!notes) { - releaseNotes = notes; + type GithubRelease = { + name: string; + html_url: string; + body: string; + }; + + const releases: GithubRelease[] = await response.json(); + + // Get the latest release that is not headlamp-plugin or headlamp-helm. + const latestRelease = releases.find( + release => !release.name?.startsWith('headlamp-') + ); + + if ( + latestRelease && + semver.gt(latestRelease.name, currentBuildAppVersion) && + !import.meta.env.FLATPAK_ID + ) { + setReleaseDownloadURL(latestRelease.html_url); + } + + // check if there is already a version in store, if it exists don't store the current version + // this check will help us later in determining whether we are on the latest release or not. + const storedAppVersion = helpers.getAppVersion(); + let releaseNotes = ''; + + if (storedAppVersion && semver.lt(storedAppVersion, currentBuildAppVersion)) { + // get the release notes for the version with which the app was built + const tagReleaseURL = `https://api.github.com/repos/kinvolk/headlamp/releases/tags/v${currentBuildAppVersion}`; + + try { + const tagResponse = await fetch(tagReleaseURL, { + method: 'GET', + headers: { + 'Content-Type': 'application/json', + }, + signal, + }); + + if (!tagResponse.ok) { + throw new Error('Network response was not ok'); + } + + const tagData = await tagResponse.json(); + const [notes] = tagData.body.split(''); + if (notes) { + releaseNotes = notes; + } + } catch (err) { + setReleaseFetchFailed(true); + console.error( + `Error getting release notes for version ${currentBuildAppVersion}:`, + err + ); } - } catch (err) { - setReleaseFetchFailed(true); - console.error( - `Error getting release notes for version ${currentBuildAppVersion}:`, - err - ); } - } - // If all of the above was done before we need to warn the user, we don't need to warn them. - clearTimeout(timeoutID); - setFetchingRelease(false); + // If all of the above was done before we need to warn the user, we don't need to warn them. + clearTimeout(timeoutID); + setFetchingRelease(false); - // set the store version to the current so that we don't show release notes on - // every start of app - helpers.setAppVersion(currentBuildAppVersion); + // set the store version to the current so that we don't show release notes on + // every start of the app + helpers.setAppVersion(currentBuildAppVersion); - // Calling this after setting the version above, so the release notes have the right version - // set when they show it. - if (!!releaseNotes) { - setReleaseNotes(releaseNotes); + // Calling this after setting the version above, so the release notes have the right version + // set when they show it. + if (releaseNotes) { + setReleaseNotes(releaseNotes); + } + } catch (error) { + setReleaseFetchFailed(true); + console.error('Failed to fetch release:', error); + clearTimeout(timeoutID); + setFetchingRelease(false); } } @@ -123,7 +160,7 @@ export default function ReleaseNotes() { fetchingRelease={fetchingRelease} releaseFetchFailed={releaseFetchFailed} skipUpdateHandler={() => { - // abort the octockit request to fetch github release + // abort the github release fetch controller.abort(); setSkipFetch(false); setFetchingRelease(false); diff --git a/plugins/headlamp-plugin/package-lock.json b/plugins/headlamp-plugin/package-lock.json index 02d4ea2fd2..aac8fdf540 100644 --- a/plugins/headlamp-plugin/package-lock.json +++ b/plugins/headlamp-plugin/package-lock.json @@ -32,7 +32,6 @@ "@mui/styles": "^5.15.14", "@mui/system": "^5.15.14", "@mui/x-tree-view": "^6.17.0", - "@octokit/core": "^3.5.1", "@reduxjs/toolkit": "^1.9.3", "@remix-run/router": "1.0.1", "@storybook/addon-actions": "7.6.7", @@ -5439,84 +5438,6 @@ "node": ">= 8" } }, - "node_modules/@octokit/auth-token": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.5.0.tgz", - "integrity": "sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g==", - "dependencies": { - "@octokit/types": "^6.0.3" - } - }, - "node_modules/@octokit/core": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.6.0.tgz", - "integrity": "sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q==", - "dependencies": { - "@octokit/auth-token": "^2.4.4", - "@octokit/graphql": "^4.5.8", - "@octokit/request": "^5.6.3", - "@octokit/request-error": "^2.0.5", - "@octokit/types": "^6.0.3", - "before-after-hook": "^2.2.0", - "universal-user-agent": "^6.0.0" - } - }, - "node_modules/@octokit/endpoint": { - "version": "6.0.12", - "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.12.tgz", - "integrity": "sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==", - "dependencies": { - "@octokit/types": "^6.0.3", - "is-plain-object": "^5.0.0", - "universal-user-agent": "^6.0.0" - } - }, - "node_modules/@octokit/graphql": { - "version": "4.8.0", - "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.8.0.tgz", - "integrity": "sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg==", - "dependencies": { - "@octokit/request": "^5.6.0", - "@octokit/types": "^6.0.3", - "universal-user-agent": "^6.0.0" - } - }, - "node_modules/@octokit/openapi-types": { - "version": "12.11.0", - "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-12.11.0.tgz", - "integrity": "sha512-VsXyi8peyRq9PqIz/tpqiL2w3w80OgVMwBHltTml3LmVvXiphgeqmY9mvBw9Wu7e0QWk/fqD37ux8yP5uVekyQ==" - }, - "node_modules/@octokit/request": { - "version": "5.6.3", - "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.3.tgz", - "integrity": "sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A==", - "dependencies": { - "@octokit/endpoint": "^6.0.1", - "@octokit/request-error": "^2.1.0", - "@octokit/types": "^6.16.1", - "is-plain-object": "^5.0.0", - "node-fetch": "^2.6.7", - "universal-user-agent": "^6.0.0" - } - }, - "node_modules/@octokit/request-error": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.1.0.tgz", - "integrity": "sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==", - "dependencies": { - "@octokit/types": "^6.0.3", - "deprecation": "^2.0.0", - "once": "^1.4.0" - } - }, - "node_modules/@octokit/types": { - "version": "6.41.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.41.0.tgz", - "integrity": "sha512-eJ2jbzjdijiL3B4PrSQaSjuF2sPEQPVCPzBvTHJD9Nz+9dw2SGH4K4xeQJ77YfTq5bRQ+bD8wT11JbeDPmxmGg==", - "dependencies": { - "@octokit/openapi-types": "^12.11.0" - } - }, "node_modules/@open-draft/until": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@open-draft/until/-/until-1.0.3.tgz", @@ -12616,11 +12537,6 @@ "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", "integrity": "sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw==" }, - "node_modules/before-after-hook": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", - "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==" - }, "node_modules/better-opn": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/better-opn/-/better-opn-3.0.2.tgz", @@ -14984,11 +14900,6 @@ "node": ">= 0.8" } }, - "node_modules/deprecation": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", - "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" - }, "node_modules/dequal": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", @@ -34890,11 +34801,6 @@ "url": "https://opencollective.com/unified" } }, - "node_modules/universal-user-agent": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", - "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==" - }, "node_modules/universalify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", @@ -40123,84 +40029,6 @@ "fastq": "^1.6.0" } }, - "@octokit/auth-token": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-2.5.0.tgz", - "integrity": "sha512-r5FVUJCOLl19AxiuZD2VRZ/ORjp/4IN98Of6YJoJOkY75CIBuYfmiNHGrDwXr+aLGG55igl9QrxX3hbiXlLb+g==", - "requires": { - "@octokit/types": "^6.0.3" - } - }, - "@octokit/core": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/@octokit/core/-/core-3.6.0.tgz", - "integrity": "sha512-7RKRKuA4xTjMhY+eG3jthb3hlZCsOwg3rztWh75Xc+ShDWOfDDATWbeZpAHBNRpm4Tv9WgBMOy1zEJYXG6NJ7Q==", - "requires": { - "@octokit/auth-token": "^2.4.4", - "@octokit/graphql": "^4.5.8", - "@octokit/request": "^5.6.3", - "@octokit/request-error": "^2.0.5", - "@octokit/types": "^6.0.3", - "before-after-hook": "^2.2.0", - "universal-user-agent": "^6.0.0" - } - }, - "@octokit/endpoint": { - "version": "6.0.12", - "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.12.tgz", - "integrity": "sha512-lF3puPwkQWGfkMClXb4k/eUT/nZKQfxinRWJrdZaJO85Dqwo/G0yOC434Jr2ojwafWJMYqFGFa5ms4jJUgujdA==", - "requires": { - "@octokit/types": "^6.0.3", - "is-plain-object": "^5.0.0", - "universal-user-agent": "^6.0.0" - } - }, - "@octokit/graphql": { - "version": "4.8.0", - "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-4.8.0.tgz", - "integrity": "sha512-0gv+qLSBLKF0z8TKaSKTsS39scVKF9dbMxJpj3U0vC7wjNWFuIpL/z76Qe2fiuCbDRcJSavkXsVtMS6/dtQQsg==", - "requires": { - "@octokit/request": "^5.6.0", - "@octokit/types": "^6.0.3", - "universal-user-agent": "^6.0.0" - } - }, - "@octokit/openapi-types": { - "version": "12.11.0", - "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-12.11.0.tgz", - "integrity": "sha512-VsXyi8peyRq9PqIz/tpqiL2w3w80OgVMwBHltTml3LmVvXiphgeqmY9mvBw9Wu7e0QWk/fqD37ux8yP5uVekyQ==" - }, - "@octokit/request": { - "version": "5.6.3", - "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.6.3.tgz", - "integrity": "sha512-bFJl0I1KVc9jYTe9tdGGpAMPy32dLBXXo1dS/YwSCTL/2nd9XeHsY616RE3HPXDVk+a+dBuzyz5YdlXwcDTr2A==", - "requires": { - "@octokit/endpoint": "^6.0.1", - "@octokit/request-error": "^2.1.0", - "@octokit/types": "^6.16.1", - "is-plain-object": "^5.0.0", - "node-fetch": "^2.6.7", - "universal-user-agent": "^6.0.0" - } - }, - "@octokit/request-error": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-2.1.0.tgz", - "integrity": "sha512-1VIvgXxs9WHSjicsRwq8PlR2LR2x6DwsJAaFgzdi0JfJoGSO8mYI/cHJQ+9FbN21aa+DrgNLnwObmyeSC8Rmpg==", - "requires": { - "@octokit/types": "^6.0.3", - "deprecation": "^2.0.0", - "once": "^1.4.0" - } - }, - "@octokit/types": { - "version": "6.41.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-6.41.0.tgz", - "integrity": "sha512-eJ2jbzjdijiL3B4PrSQaSjuF2sPEQPVCPzBvTHJD9Nz+9dw2SGH4K4xeQJ77YfTq5bRQ+bD8wT11JbeDPmxmGg==", - "requires": { - "@octokit/openapi-types": "^12.11.0" - } - }, "@open-draft/until": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@open-draft/until/-/until-1.0.3.tgz", @@ -45202,11 +45030,6 @@ "resolved": "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz", "integrity": "sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw==" }, - "before-after-hook": { - "version": "2.2.3", - "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz", - "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==" - }, "better-opn": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/better-opn/-/better-opn-3.0.2.tgz", @@ -46969,11 +46792,6 @@ "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==" }, - "deprecation": { - "version": "2.3.1", - "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz", - "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==" - }, "dequal": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", @@ -61450,11 +61268,6 @@ "unist-util-is": "^5.0.0" } }, - "universal-user-agent": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz", - "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==" - }, "universalify": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.0.tgz", diff --git a/plugins/headlamp-plugin/package.json b/plugins/headlamp-plugin/package.json index 19976313ef..d0b5508c57 100644 --- a/plugins/headlamp-plugin/package.json +++ b/plugins/headlamp-plugin/package.json @@ -36,7 +36,6 @@ "@mui/styles": "^5.15.14", "@mui/system": "^5.15.14", "@mui/x-tree-view": "^6.17.0", - "@octokit/core": "^3.5.1", "@reduxjs/toolkit": "^1.9.3", "@remix-run/router": "1.0.1", "@storybook/addon-actions": "7.6.7", From 65743b1524cd0d5ba6f47bf2381d2545cf543826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Dudfield?= Date: Mon, 15 Jul 2024 16:23:40 +0200 Subject: [PATCH 2/4] frontend: ReleaseNotes/UpdatePopup: Fix for when internet fails MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If there is an error connecting to the github releases, then it used to be that a message would stay on the screen about fetching release notes... but it would just stay there. Now it disapears after it times out, and then a message is shown that the fetch failed. This message also disapears after 6 seconds. Signed-off-by: René Dudfield --- .../components/common/ReleaseNotes/UpdatePopup.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/common/ReleaseNotes/UpdatePopup.tsx b/frontend/src/components/common/ReleaseNotes/UpdatePopup.tsx index f8fd6e4aa8..9af46821e5 100644 --- a/frontend/src/components/common/ReleaseNotes/UpdatePopup.tsx +++ b/frontend/src/components/common/ReleaseNotes/UpdatePopup.tsx @@ -20,6 +20,7 @@ function UpdatePopup(props: { const [show, setShow] = React.useState(true); const { releaseDownloadURL, fetchingRelease, releaseFetchFailed, skipUpdateHandler } = props; const { t } = useTranslation(); + const [closeSnackError, setCloseSnackError] = React.useState(false); if (fetchingRelease && !releaseDownloadURL) { return ( @@ -65,7 +66,10 @@ function UpdatePopup(props: { vertical: 'bottom', horizontal: 'right', }} - open={releaseFetchFailed} + open={releaseFetchFailed && !closeSnackError} + onClose={() => { + setCloseSnackError(true); + }} message={t('translation|Failed to fetch release information')} ContentProps={{ 'aria-describedby': 'updatePopup', @@ -91,7 +95,10 @@ function UpdatePopup(props: { ContentProps={{ 'aria-describedby': 'updatePopup', }} - open={fetchingRelease} + open={fetchingRelease && !closeSnackError} + onClose={() => { + setCloseSnackError(true); + }} action={ - -
- -
-
- -
- - - - - \ No newline at end of file diff --git a/frontend/src/components/common/ReleaseNotes/__snapshots__/UpdatePopup.FetchFailed.stories.storyshot b/frontend/src/components/common/ReleaseNotes/__snapshots__/UpdatePopup.FetchFailed.stories.storyshot new file mode 100644 index 0000000000..846753d94c --- /dev/null +++ b/frontend/src/components/common/ReleaseNotes/__snapshots__/UpdatePopup.FetchFailed.stories.storyshot @@ -0,0 +1,20 @@ + + + \ No newline at end of file diff --git a/frontend/src/components/common/ReleaseNotes/__snapshots__/UpdatePopup.Fetching.stories.storyshot b/frontend/src/components/common/ReleaseNotes/__snapshots__/UpdatePopup.Fetching.stories.storyshot new file mode 100644 index 0000000000..f56424ab29 --- /dev/null +++ b/frontend/src/components/common/ReleaseNotes/__snapshots__/UpdatePopup.Fetching.stories.storyshot @@ -0,0 +1,35 @@ + + + \ No newline at end of file