Wizard: Use useChrome hook to set beta feature flag

The use of chrome.isBeta is deprecated, the useChrome hook should be
used instead to obtain an isBeta() function. Using the deprecrated
chrome.isBeta pollutes the browser console with warning messages.

This commit replaces the isBeta() helper function with a new custom
hook, useGetEnvironment().

We still sometimes need to know which environment is running outside of
React components, where we cannot call the useChrome() or
useGetEnvironment() hooks. For instance, in the json used to define a
wizard step. Therefore a new isBeta variable has been added to the
form's initialState for use in these cases.
This commit is contained in:
lucasgarfield 2023-04-12 16:31:10 +02:00 committed by Lucas Garfield
parent c9081259a6
commit b2e6e3cf04
15 changed files with 95 additions and 85 deletions

View file

@ -35,7 +35,6 @@ import PropTypes from 'prop-types';
import { useSelector } from 'react-redux';
import { selectValidRepositories } from '../../../store/repositoriesSlice';
import isBeta from '../../../Utilities/isBeta';
const BulkSelect = ({
selected,
@ -276,7 +275,11 @@ const Repositories = (props) => {
<Button
variant="primary"
component="a"
href={isBeta() ? '/beta/settings/content' : '/settings/content'}
href={
getState()?.values?.isBeta
? '/beta/settings/content'
: '/settings/content'
}
>
Repositories
</Button>