diff --git a/src/ReleaseProvider.jsx b/src/ReleaseProvider.jsx index 5b8e5552..fbcf44d1 100644 --- a/src/ReleaseProvider.jsx +++ b/src/ReleaseProvider.jsx @@ -1,5 +1,7 @@ import React, { useContext, useState } from 'react' import { useFetchReleases } from './hooks/fetch-release-versions' +import { USE_YARN_PLUGIN } from './utils' +import { useSettings } from './SettingsProvider' export const ReleasesContext = React.createContext({ isDone: false, @@ -8,7 +10,11 @@ export const ReleasesContext = React.createContext({ }) export const ReleasesProvider = React.memo(function({ children, packageName }) { - const value = useFetchReleases({ packageName }) + const { + settings: { [USE_YARN_PLUGIN]: useYarnPlugin } + } = useSettings() + + const value = useFetchReleases({ packageName, useYarnPlugin }) const [selectedVersions, setSelectedVersions] = useState() return ( diff --git a/src/SettingsProvider.jsx b/src/SettingsProvider.jsx new file mode 100644 index 00000000..7d74f5e9 --- /dev/null +++ b/src/SettingsProvider.jsx @@ -0,0 +1,26 @@ +import React, { useContext } from 'react' +import useLocalStorage from 'react-use/lib/useLocalStorage' + +import { SHOW_LATEST_RCS, USE_YARN_PLUGIN } from './utils' + +const INITIAL_STATE = { + [`${SHOW_LATEST_RCS}`]: false, + [`${USE_YARN_PLUGIN}`]: false +} + +export const SettingsContext = React.createContext(INITIAL_STATE) + +export const SettingsProvider = React.memo(function({ children }) { + const [settings, setSettings] = useLocalStorage( + 'backstage:upgrade-helper:settings', + INITIAL_STATE + ) + + return ( + + {children} + + ) +}) + +export const useSettings = () => useContext(SettingsContext) diff --git a/src/components/common/DownloadFileButton.js b/src/components/common/DownloadFileButton.js index 37967e88..099844df 100644 --- a/src/components/common/DownloadFileButton.js +++ b/src/components/common/DownloadFileButton.js @@ -6,7 +6,6 @@ import { getBinaryFileURL } from '../../utils' const DownloadFileButton = styled( ({ visible, version, path, packageName, ...props }) => { - console.info(visible, version, path, packageName) return visible ? (