diff --git a/plugins/user-settings/src/components/AppSettingsList.tsx b/plugins/user-settings/src/components/AppSettingsList.tsx index 5dad178ccd..ab106cf28e 100644 --- a/plugins/user-settings/src/components/AppSettingsList.tsx +++ b/plugins/user-settings/src/components/AppSettingsList.tsx @@ -14,12 +14,12 @@ * limitations under the License. */ import React from 'react'; -import { List, ListSubheader } from '@material-ui/core'; +import { List } from '@material-ui/core'; import { SidebarThemeToggle } from './ThemeToggle'; import { SidebarPinButton } from './PinButton'; export const AppSettingsList = () => ( - App Settings}> + diff --git a/plugins/user-settings/src/components/AuthProviderList.tsx b/plugins/user-settings/src/components/AuthProviderList.tsx index 8f4d41319c..9a2096212d 100644 --- a/plugins/user-settings/src/components/AuthProviderList.tsx +++ b/plugins/user-settings/src/components/AuthProviderList.tsx @@ -15,14 +15,12 @@ */ import React from 'react'; -import { List, ListSubheader } from '@material-ui/core'; +import { List } from '@material-ui/core'; type Props = { providers: React.ReactNode; }; export const AuthProvidersList = ({ providers }: Props) => ( - Available Auth Providers}> - {providers} - + {providers} ); diff --git a/plugins/user-settings/src/components/FeatureFlagsList.tsx b/plugins/user-settings/src/components/FeatureFlagsList.tsx index 0d7404c6fd..20c91f3e9a 100644 --- a/plugins/user-settings/src/components/FeatureFlagsList.tsx +++ b/plugins/user-settings/src/components/FeatureFlagsList.tsx @@ -15,7 +15,7 @@ */ import React, { useState, useEffect } from 'react'; -import { List, ListSubheader } from '@material-ui/core'; +import { List } from '@material-ui/core'; import { useApi, featureFlagsApiRef, @@ -54,7 +54,7 @@ export const FeatureFlagsList = ({ featureFlags }: Props) => { }; return ( - Feature Flags}> + {featureFlags.map(featureFlag => { const enabled = Boolean(state[featureFlag.name]); diff --git a/plugins/user-settings/src/components/SettingsDialog.tsx b/plugins/user-settings/src/components/SettingsDialog.tsx index 69ec4fb8ee..5aa13d90e4 100644 --- a/plugins/user-settings/src/components/SettingsDialog.tsx +++ b/plugins/user-settings/src/components/SettingsDialog.tsx @@ -14,13 +14,13 @@ * limitations under the License. */ -import React from 'react'; +import React, { ChangeEvent, RefObject, useEffect, useState } from 'react'; import { Card, CardContent, CardHeader, makeStyles, - Divider, + PopoverActions, } from '@material-ui/core'; import { AppSettingsList } from './AppSettingsList'; import { AuthProvidersList } from './AuthProviderList'; @@ -28,28 +28,53 @@ import { FeatureFlagsList } from './FeatureFlagsList'; import { SignInAvatar } from './SignInAvatar'; import { UserSettingsMenu } from './UserSettingsMenu'; import { useUserProfile } from './useUserProfileInfo'; -import { useApi, featureFlagsApiRef } from '@backstage/core'; +import { + useApi, + featureFlagsApiRef, + TabbedCard, + CardTab, + InfoCard, +} from '@backstage/core'; import { ConfiguredProviderSettings } from './ConfiguredProviderSettings'; import { ProviderSettings } from './UserSettings'; +import { Alert } from '@material-ui/lab'; const useStyles = makeStyles({ root: { minWidth: 400, + maxWidth: 500, }, }); type Props = { + popoverActionRef: RefObject; providerSettings?: ProviderSettings; }; -export const SettingsDialog = ({ providerSettings }: Props) => { +export const SettingsDialog = ({ + popoverActionRef, + providerSettings, +}: Props) => { const classes = useStyles(); const { profile, displayName } = useUserProfile(); const featureFlagsApi = useApi(featureFlagsApiRef); const featureFlags = featureFlagsApi.getRegisteredFlags(); + const [selectedTab, setSelectedTab] = useState('auth'); const providers = providerSettings ?? ; + const handleChange = ( + _ev: ChangeEvent<{}>, + newSelectedTab: string | number, + ) => { + setSelectedTab(newSelectedTab); + }; + + // Update the position of the popover to handle different heights + useEffect(() => { + popoverActionRef?.current?.updatePosition(); + }, [selectedTab, popoverActionRef]); + return ( { subheader={profile.email} /> - - - - {featureFlags.length > 0 && ( - <> - - - - )} + + + + + + + + + {featureFlags.length > 0 ? ( + + ) : ( + // TODO(marcuseide): Replace with empty state component + No registered Feature Flags found + )} + + ); diff --git a/plugins/user-settings/src/components/UserSettings.tsx b/plugins/user-settings/src/components/UserSettings.tsx index c91002d7d7..b117d40acb 100644 --- a/plugins/user-settings/src/components/UserSettings.tsx +++ b/plugins/user-settings/src/components/UserSettings.tsx @@ -15,7 +15,7 @@ */ import React, { useEffect, useContext } from 'react'; -import { Popover } from '@material-ui/core'; +import { Popover, PopoverActions } from '@material-ui/core'; import { SignInAvatar } from './SignInAvatar'; import { SettingsDialog } from './SettingsDialog'; import { SidebarItem, SidebarContext } from '@backstage/core'; @@ -41,6 +41,7 @@ export const UserSettings = ({ providerSettings }: Props) => { const [anchorEl, setAnchorEl] = React.useState( undefined, ); + const popoverActionRef = React.useRef(null); const handleOpen = (event?: React.MouseEvent) => { setAnchorEl(event?.currentTarget ?? undefined); @@ -66,6 +67,7 @@ export const UserSettings = ({ providerSettings }: Props) => { icon={SidebarAvatar} /> { horizontal: 'left', }} > - + );