Merge pull request #11629 from backstage/cc/version-sidebar-contexts

This commit is contained in:
Eric Peterson
2022-05-30 21:01:04 +02:00
committed by GitHub
31 changed files with 643 additions and 129 deletions
@@ -13,14 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { InfoCard, SidebarPinStateContext } from '@backstage/core-components';
import { InfoCard, useSidebarPinState } from '@backstage/core-components';
import { List } from '@material-ui/core';
import React, { useContext } from 'react';
import React from 'react';
import { UserSettingsPinToggle } from './UserSettingsPinToggle';
import { UserSettingsThemeToggle } from './UserSettingsThemeToggle';
export const UserSettingsAppearanceCard = () => {
const { isMobile } = useContext(SidebarPinStateContext);
const { isMobile } = useSidebarPinState();
return (
<InfoCard title="Appearance" variant="gridItem">
@@ -18,14 +18,14 @@ import { renderWithEffects, wrapInTestApp } from '@backstage/test-utils';
import { fireEvent } from '@testing-library/react';
import React from 'react';
import { UserSettingsPinToggle } from './UserSettingsPinToggle';
import { SidebarPinStateContext } from '@backstage/core-components';
import { SidebarPinStateProvider } from '@backstage/core-components';
describe('<UserSettingsPinToggle />', () => {
it('toggles the pin sidebar button', async () => {
const mockToggleFn = jest.fn();
const rendered = await renderWithEffects(
wrapInTestApp(
<SidebarPinStateContext.Provider
<SidebarPinStateProvider
value={{
isPinned: false,
isMobile: false,
@@ -33,7 +33,7 @@ describe('<UserSettingsPinToggle />', () => {
}}
>
<UserSettingsPinToggle />
</SidebarPinStateContext.Provider>,
</SidebarPinStateProvider>,
),
);
expect(rendered.getByText('Pin Sidebar')).toBeInTheDocument();
@@ -14,7 +14,7 @@
* limitations under the License.
*/
import React, { useContext } from 'react';
import React from 'react';
import {
ListItem,
ListItemSecondaryAction,
@@ -22,12 +22,10 @@ import {
Switch,
Tooltip,
} from '@material-ui/core';
import { SidebarPinStateContext } from '@backstage/core-components';
import { useSidebarPinState } from '@backstage/core-components';
export const UserSettingsPinToggle = () => {
const { isPinned, toggleSidebarPinState } = useContext(
SidebarPinStateContext,
);
const { isPinned, toggleSidebarPinState } = useSidebarPinState();
return (
<ListItem>
@@ -17,10 +17,10 @@
import {
Header,
Page,
SidebarPinStateContext,
TabbedLayout,
useSidebarPinState,
} from '@backstage/core-components';
import React, { useContext } from 'react';
import React from 'react';
import { useOutlet } from 'react-router';
import { useElementFilter } from '@backstage/core-plugin-api';
import { UserSettingsAuthProviders } from './AuthProviders';
@@ -33,7 +33,7 @@ type Props = {
};
export const SettingsPage = ({ providerSettings }: Props) => {
const { isMobile } = useContext(SidebarPinStateContext);
const { isMobile } = useSidebarPinState();
const outlet = useOutlet();
const tabs = useElementFilter(outlet, elements =>