Skip to content

Commit 1d7ec4b

Browse files
committed
Merge branch 'feat/fluent-v9-upgrade' of https://github.com/microsoftgraph/microsoft-graph-explorer-v4 into feat/fluent-v9-upgrade
2 parents 588a54f + 14cd4bb commit 1d7ec4b

File tree

8 files changed

+382
-97
lines changed

8 files changed

+382
-97
lines changed

src/app/views/authentication/profile/ProfileV9.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
CardFooter,
55
CardHeader,
66
Divider,
7+
Link,
78
makeStyles,
89
Persona,
910
PersonaProps,
@@ -22,6 +23,7 @@ import { signOut } from '../../../services/slices/auth.slice';
2223
import { getProfileInfo } from '../../../services/slices/profile.slice';
2324
import { translateMessage } from '../../../utils/translate-messages';
2425
import { useHeaderStyles } from '../../main-header/utils';
26+
import { usePopups } from '../../../services/hooks/usePopups';
2527

2628
const useProfileStyles = makeStyles({
2729
card: {
@@ -81,14 +83,25 @@ const PersonaLayout = ({profile}: {profile: IProfileState}) => {
8183
const PopoverContent: React.FC<Partial<PersonaProps> & ProfileProps> = (props) => {
8284
const dispatch = useAppDispatch();
8385
const styles = useProfileStyles();
84-
const {signInWithOther, profile} = props
85-
const user = profile.user
86-
const tenant = user && user.tenant ? user.tenant : 'Sample'
86+
const {signInWithOther, profile} = props;
87+
const user = profile.user;
88+
const tenant = user && user.tenant ? user.tenant : 'Sample';
89+
const { show: showPermissions } = usePopups('full-permissions', 'panel');
8790

8891
const handleSignOut = () => {
8992
dispatch(signOut());
9093
};
9194

95+
96+
const changePanelState = () => {
97+
showPermissions({
98+
settings: {
99+
title: translateMessage('Permissions'),
100+
width: 'lg'
101+
}
102+
})
103+
};
104+
92105
return (
93106
<div className={styles.card}>
94107
<CardHeader
@@ -110,6 +123,10 @@ const PopoverContent: React.FC<Partial<PersonaProps> & ProfileProps> = (props) =
110123
/>
111124
<Divider/>
112125
<PersonaLayout profile={profile}/>
126+
<Link key={'view-all-permissions'}
127+
onClick={() => changePanelState()}>
128+
{translateMessage('view all permissions')}
129+
</Link>
113130
<CardFooter>
114131
<Button
115132
className={styles.footerButton}

src/app/views/common/lazy-loader/component-registry/popups.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export const popups = new Map<string, any>([
44
['share-query', lazy(() => import('../../../query-runner/query-input/share-query/ShareQuery'))],
55
['theme-chooser', lazy(() => import('../../../main-header/settings/ThemeChooserV9'))],
66
['preview-collection', lazy(() => import('../../../sidebar/resource-explorer/collection/APICollection'))],
7-
['full-permissions', lazy(() => import('../../../query-runner/request/permissions/Permissions.Full'))],
7+
['full-permissions', lazy(() => import('../../../query-runner/request/permissions/Permissions.FullV9'))],
88
['collection-permissions', lazy(() => import('../../../sidebar/resource-explorer/collection/CollectionPermissions'))],
99
['edit-collection-panel', lazy(() => import('../../../sidebar/resource-explorer/collection/EditCollectionPanel'))],
1010
['edit-scope-panel', lazy(() => import('../../../sidebar/resource-explorer/collection/EditScopePanel'))]
Lines changed: 76 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,96 @@
1-
import { getTheme, IconButton, IOverlayProps, Panel, PanelType, Spinner } from '@fluentui/react';
1+
import * as React from 'react';
22
import { Suspense } from 'react';
3+
import {
4+
Drawer,
5+
DrawerBody,
6+
DrawerFooter,
7+
DrawerHeader,
8+
DrawerHeaderTitle,
9+
Button,
10+
Spinner
11+
} from '@fluentui/react-components';
12+
import { ArrowLeft24Regular, Dismiss24Regular } from '@fluentui/react-icons';
313

4-
import { useAppSelector } from '../../../../store';
514
import { translateMessage } from '../../../utils/translate-messages';
615
import { WrapperProps } from './popups.types';
716

8-
export function PanelWrapper(props: WrapperProps) {
9-
const appTheme = useAppSelector((state) => state.theme);
10-
const theme = getTheme();
11-
const { isOpen, dismissPopup, Component, popupsProps, closePopup } = props;
12-
const { title, renderFooter } = popupsProps.settings;
13-
14-
const isCurrentThemeDark = (): boolean => {
15-
return (appTheme === 'dark' || appTheme === 'high-contrast');
16-
}
1717

18-
const panelOverlayProps: IOverlayProps = {
19-
styles: {
20-
root: {
21-
backgroundColor: isCurrentThemeDark() ? theme.palette.blackTranslucent40 :
22-
theme.palette.whiteTranslucent40
23-
}
24-
}
25-
}
26-
27-
const headerText = title ? title : '';
18+
export function DrawerWrapper(props: WrapperProps) {
19+
const { isOpen, dismissPopup, Component, popupsProps, closePopup } = props;
20+
const { title, renderFooter, width } = popupsProps.settings;
2821

29-
const getPanelType = () => {
30-
switch (popupsProps.settings.width) {
22+
const getDrawerSize = () => {
23+
switch (width) {
3124
case 'sm':
32-
return PanelType.smallFluid;
25+
return 'small';
3326
case 'md':
34-
return PanelType.medium;
27+
return 'medium';
3528
case 'lg':
36-
return PanelType.largeFixed;
29+
return 'large';
3730
case 'xl':
38-
return PanelType.large;
31+
return 'full';
32+
default:
33+
return 'medium';
3934
}
40-
return PanelType.medium;
41-
}
35+
};
4236

43-
const panelType = getPanelType();
37+
const showBackButton =
38+
title === 'Edit Scope' ||
39+
title === 'Edit Collection' ||
40+
title === 'Preview Permissions';
4441

45-
const onRenderFooterContent = (): JSX.Element | null => {
46-
return renderFooter ? renderFooter() : null;
47-
}
48-
49-
const showBackButton = title === 'Edit Scope' || title === 'Edit Collection' || title === 'Preview Permissions';
50-
51-
const onRenderHeader = (): JSX.Element => (
52-
<div style={{ display: 'flex', alignItems: 'center' }}>
53-
<IconButton
54-
iconProps={{ iconName: 'Back' }}
55-
ariaLabel={translateMessage('Back')}
56-
onClick={() => dismissPopup()}
57-
styles={{ root: { marginRight: 8 } }}
58-
/>
59-
<span style={{ fontSize: theme.fonts.xLarge.fontSize, fontWeight: theme.fonts.xLarge.fontWeight }}>
60-
{title}
61-
</span>
62-
</div>
63-
);
42+
const onOpenChange = (_ev: unknown, data: { open: boolean }) => {
43+
if (!data.open) {
44+
dismissPopup();
45+
}
46+
};
6447

6548
return (
66-
<div>
67-
<Panel
68-
isOpen={isOpen}
69-
hasCloseButton={false}
70-
type={panelType}
71-
headerText={headerText.toString()}
72-
isFooterAtBottom={true}
73-
isBlocking={true}
74-
isLightDismiss={false}
75-
closeButtonAriaLabel='Close'
76-
overlayProps={panelOverlayProps}
77-
onRenderFooterContent={onRenderFooterContent}
78-
onRenderHeader={showBackButton ? onRenderHeader: undefined}
79-
>
80-
<IconButton
81-
styles={{
82-
root: {
83-
float: 'right',
84-
zIndex: 1,
85-
marginTop: -30
86-
}
87-
}}
88-
iconProps={{ iconName: 'Cancel' }}
89-
ariaLabel={translateMessage('Close')}
90-
onClick={() => dismissPopup()}
91-
/>
92-
<div>
93-
{
94-
<Suspense fallback={<Spinner />}>
95-
<Component
96-
{...popupsProps}
97-
data={popupsProps.data || {}}
49+
<Drawer
50+
open={isOpen}
51+
onOpenChange={onOpenChange}
52+
position='end'
53+
type='overlay'
54+
size={getDrawerSize()}
55+
>
56+
<DrawerHeader>
57+
{showBackButton && (
58+
<Button
59+
icon={<ArrowLeft24Regular />}
60+
appearance='subtle'
61+
onClick={() => dismissPopup()}
62+
aria-label={translateMessage('Back')}
63+
/>
64+
)}
65+
<DrawerHeaderTitle action={
66+
<Button
67+
icon={<Dismiss24Regular />}
68+
appearance='subtle'
69+
onClick={() => dismissPopup()}
70+
aria-label={translateMessage('Close')}
71+
/>
72+
73+
}>
74+
{title || ''}
75+
</DrawerHeaderTitle>
76+
</DrawerHeader>
9877

99-
dismissPopup={() => dismissPopup()}
100-
closePopup={(e: any) => closePopup(e)}
101-
/>
102-
</Suspense>
103-
}
104-
</div>
78+
<DrawerBody>
79+
<Suspense fallback={<Spinner />}>
80+
<Component
81+
{...popupsProps}
82+
data={popupsProps.data || {}}
83+
dismissPopup={() => dismissPopup()}
84+
closePopup={(e: any) => closePopup(e)}
85+
/>
86+
</Suspense>
87+
</DrawerBody>
10588

106-
</Panel>
107-
</div>
89+
{renderFooter && (
90+
<DrawerFooter>
91+
{renderFooter()}
92+
</DrawerFooter>
93+
)}
94+
</Drawer>
10895
);
10996
}

src/app/views/common/popups/PopupsWrapper.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
import ErrorBoundary from '../error-boundary/ErrorBoundary';
66
import { DialogWrapper } from './DialogWrapper';
77
import { ModalWrapper } from './ModalWrapper';
8-
import { PanelWrapper } from './PanelWrapper';
8+
import { DrawerWrapper } from './PanelWrapper';
99

1010
const PopupWrapper = () => {
1111

@@ -30,7 +30,7 @@ const PopupWrapper = () => {
3030
{popups && popups.map((popup: Popup) => {
3131
const { component, type, popupsProps, isOpen } = popup;
3232
if (type === 'panel') {
33-
return component && <PanelWrapper
33+
return component && <DrawerWrapper
3434
isOpen={!!isOpen}
3535
key={popup.id}
3636
dismissPopup={() => dismiss(popup)}

src/app/views/query-runner/request/permissions/Permission.stylesV9.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ const permissionStyles = makeStyles({
4848
},
4949
headerText: {
5050
marginLeft: '8px'
51+
},
52+
permissionContainer: {
53+
display: 'flex',
54+
flexDirection: 'column',
55+
gap: '1rem',
56+
padding: '1rem'
57+
},
58+
controlsRow: {
59+
display: 'flex',
60+
gap: '0.5rem',
61+
alignItems: 'center'
62+
},
63+
searchBar: {
64+
width: '100%'
5165
}
5266
});
5367

src/app/views/query-runner/request/permissions/PermissionItemV9.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ const PermissionItem = (props: PermissionItemProps): JSX.Element | null => {
103103
);
104104
};
105105

106+
106107
if (column) {
107108
const content = item[column.fieldName as keyof IPermission] as string;
108109
switch (column.key) {

0 commit comments

Comments
 (0)