Skip to content

Commit 4e87c1a

Browse files
authored
fix: regressions in component functionality (#3633)
* remove v8 IGroup * fix query version, edit collections and cleanup * fix history item * fix history errors * fix text when no image
1 parent fd4fb32 commit 4e87c1a

37 files changed

+960
-2183
lines changed

src/app/services/slices/graph-response.slice.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const runQuery = createAsyncThunk(
6969

7070
const historyItem = generateHistoryItem(
7171
status,
72-
{},
72+
result.headers,
7373
query,
7474
createdAt,
7575
result,
@@ -116,19 +116,17 @@ function generateHistoryItem(
116116
result: Result,
117117
duration: number
118118
): IHistoryItem {
119-
let response: Result = { body: {}, headers: {} };
120-
const contentType_ = respHeaders['content-type'];
119+
let response = { ...result };
120+
const responseHeaders = { ...respHeaders };
121+
const contentType = respHeaders['content-type'];
121122

122-
if (isImageResponse(contentType_)) {
123-
response = { ...result, body: 'Run the query to view the image' };
124-
Object.assign(respHeaders, { 'content-type': ContentType.Json });
123+
if (isImageResponse(contentType)) {
124+
response = { ...response, body: 'Run the query to view the image' };
125+
responseHeaders['content-type'] = ContentType.Json;
125126
}
126127

127128
if (isFileResponse(respHeaders)) {
128-
response = {
129-
...result,
130-
body: 'Run the query to generate file download URL'
131-
};
129+
response = { ...response, body: 'Run the query to generate file download URL' };
132130
}
133131

134132
const historyItem: IHistoryItem = {
@@ -142,7 +140,7 @@ function generateHistoryItem(
142140
status: status.status as number,
143141
statusText: status.statusText,
144142
duration,
145-
result: response.body as object
143+
result: response.body as Object
146144
};
147145

148146
historyCache.writeHistoryData(historyItem);

src/app/utils/generate-groups.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
import { IGroup } from '@fluentui/react';
1+
export interface IGroup {
2+
key: string;
3+
name: string;
4+
startIndex: number;
5+
count: number;
6+
isCollapsed: boolean;
7+
ariaLabel: string;
8+
}
29

310
export function generateGroupsFromList(list: any[], property: string) : IGroup[] {
411
const map = new Map();
Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,49 @@
1-
import { Link, MessageBar, MessageBarType } from '@fluentui/react';
1+
import { Link, MessageBar, MessageBarBody, makeStyles} from '@fluentui/react-components';
22

33
import { getLoginType } from '../../../modules/authentication/authUtils';
44
import { LoginType } from '../../../types/enums';
55
import { translateMessage } from '../../utils/translate-messages';
66

7-
export function headerMessaging(query: string): React.ReactNode {
7+
const useHeaderStyles = makeStyles({
8+
root: {
9+
marginBottom: '8',
10+
paddingLeft: '10'
11+
}
12+
});
13+
14+
export const headerMessaging = (query: string): React.ReactNode => {
815
const loginType = getLoginType();
16+
const headerStyles = useHeaderStyles();
917

1018
return (
11-
<div style={{ marginBottom: 8, paddingLeft: 10 }}>
12-
{loginType === LoginType.Popup && <>
13-
<MessageBar messageBarType={MessageBarType.info} isMultiline={true}>
14-
<p>
19+
<div className={headerStyles.root}>
20+
{loginType === LoginType.Popup &&
21+
<MessageBar intent={'info'}>
22+
<MessageBarBody>
1523
{translateMessage('To try the full features')},
16-
<Link tabIndex={0} href={query} target='_blank' rel='noopener noreferrer' underline>
24+
<Link
25+
tabIndex={0}
26+
inline
27+
href={query}
28+
target='_blank' rel='noopener noreferrer'>
1729
{translateMessage('full Graph Explorer')}.
1830
</Link>
19-
</p>
20-
<p>
2131
{translateMessage('running the query')}.
22-
</p>
32+
</MessageBarBody>
2333
</MessageBar>
24-
25-
</>}
26-
{loginType === LoginType.Redirect && <MessageBar messageBarType={MessageBarType.warning} isMultiline={true}>
27-
<p>
34+
}
35+
{loginType === LoginType.Redirect && <MessageBar intent={'warning'}>
36+
<MessageBarBody>
2837
{translateMessage('To try operations other than GET')},
29-
30-
<Link tabIndex={0} href={query} target='_blank' rel='noopener noreferrer' underline>
38+
<Link
39+
tabIndex={0}
40+
href={query}
41+
target='_blank'
42+
rel='noopener noreferrer'
43+
inline>
3144
{translateMessage('sign in')}.
3245
</Link>
33-
</p>
46+
</MessageBarBody>
3447
</MessageBar>}
3548
</div>);
3649
}

src/app/views/app-sections/HeaderMessagingV9.tsx

Lines changed: 0 additions & 49 deletions
This file was deleted.

src/app/views/app-sections/StatusMessages.tsx

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,19 @@
1-
import { MessageBar, MessageBarType } from '@fluentui/react';
2-
1+
import { MessageBar, MessageBarBody, MessageBarActions, MessageBarIntent, Button } from '@fluentui/react-components';
2+
import { DismissRegular } from '@fluentui/react-icons';
33
import { useAppDispatch, useAppSelector } from '../../../store';
44
import { IQuery } from '../../../types/query-runner';
55
import { clearQueryStatus } from '../../services/slices/query-status.slice';
66
import { setSampleQuery } from '../../services/slices/sample-query.slice';
77
import { translateMessage } from '../../utils/translate-messages';
88
import MessageDisplay from '../common/message-display/MessageDisplay';
99

10+
const intentMap: { [key: string]: MessageBarIntent } = {
11+
'info': 'info',
12+
'error': 'error',
13+
'warning': 'warning',
14+
'success': 'success'
15+
};
16+
1017
const StatusMessages = () => {
1118
const dispatch = useAppDispatch();
1219
const queryRunnerStatus = useAppSelector((state)=> state.queryRunnerStatus);
@@ -21,31 +28,37 @@ const StatusMessages = () => {
2128
}
2229

2330
if (queryRunnerStatus) {
24-
const { messageBarType, statusText, status, duration, hint } = queryRunnerStatus; // remove when cleaning up
25-
26-
const messageBarTypeKey = messageBarType as keyof typeof MessageBarType;
27-
28-
return <MessageBar messageBarType={MessageBarType[messageBarTypeKey]}
29-
isMultiline={true}
30-
onDismiss={() => dispatch(clearQueryStatus())}
31-
dismissButtonAriaLabel='Close'
32-
aria-live={'assertive'}>
33-
<MessageDisplay message={`**${statusText} - **${status.toString()}`} onSetQuery={setQuery} />
34-
35-
{duration && <>
36-
{` - ${duration} ${translateMessage('milliseconds')}`}
37-
</>}
31+
const { messageBarType, statusText, status, duration, hint } = queryRunnerStatus; return <MessageBar
32+
intent={intentMap[messageBarType]}
33+
politeness='assertive'
34+
>
35+
<MessageBarBody>
36+
<MessageDisplay message={`**${statusText} - **${status.toString()}`} onSetQuery={setQuery} />
3837

39-
{status === 403 && <>.
40-
{translateMessage('consent to scopes')}
41-
<span style={{ fontWeight: 600 }}>
42-
{translateMessage('modify permissions')}
43-
</span>
44-
{translateMessage('tab')}
45-
</>}
38+
{duration && <>
39+
{` - ${duration} ${translateMessage('milliseconds')}`}
40+
</>}
4641

47-
{hint && <div>{hint}</div>}
42+
{status === 403 && <>
43+
{translateMessage('consent to scopes')}
44+
<span style={{ fontWeight: 600 }}>
45+
{translateMessage('modify permissions')}
46+
</span>
47+
{translateMessage('tab')}
48+
</>}
4849

50+
{hint && <div>{hint}</div>}
51+
</MessageBarBody>
52+
<MessageBarActions
53+
containerAction={
54+
<Button
55+
onClick={() => dispatch(clearQueryStatus())}
56+
aria-label="dismiss"
57+
appearance="transparent"
58+
icon={<DismissRegular />}
59+
/>
60+
}
61+
/>
4962
</MessageBar>;
5063
}
5164
return <div />;

src/app/views/app-sections/StatusMessagesV9.tsx

Lines changed: 0 additions & 67 deletions
This file was deleted.

src/app/views/app-sections/TermsOfUseMessageV9.tsx renamed to src/app/views/app-sections/TermsOfUseMessage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const useTermsStyles = makeStyles({
1111
}
1212
});
1313

14-
const TermsOfUseMessageV9 = () => {
14+
const TermsOfUseMessage = () => {
1515

1616
const termsOfUse = useAppSelector((state) => state.termsOfUse);
1717
const termsStyles = useTermsStyles();
@@ -58,4 +58,4 @@ const TermsOfUseMessageV9 = () => {
5858
return <div />;
5959
}
6060

61-
export default TermsOfUseMessageV9;
61+
export default TermsOfUseMessage;
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import StatusMessagesV9 from './StatusMessagesV9';
2-
import TermsOfUseMessageV9 from './TermsOfUseMessageV9';
1+
import StatusMessages from './StatusMessages';
2+
import TermsOfUseMessage from './TermsOfUseMessage';
33

44
export {
5-
StatusMessagesV9,
6-
TermsOfUseMessageV9
5+
StatusMessages,
6+
TermsOfUseMessage
77
};

src/app/views/common/banners/Notification.styles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const useNotificationStyles = makeStyles({
2525
body: {
2626
width: '100%',
2727
'@media (min-width: 720px)': {
28-
width: '70%'
28+
width: '100%'
2929
}
3030
}
3131
});

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import LazyResponseHeadersV9 from '../../../query-response/headers/ResponseHeade
22
import LazySnippetsV9 from '../../../query-response/snippets/SnippetsV9';
33
import { default as LazyCopyButtonV9 } from '../../copy-button/CopyButtonV9';
44
import LazySpecificPermissions from '../../../query-runner/request/permissions';
5-
import LazyStatusMessages from '../../../app-sections/StatusMessagesV9';
5+
import LazyStatusMessages from '../../../app-sections/StatusMessages';
66
import LazyResponseHeaders from '../../../query-response/headers/ResponseHeaders';
77
import LazyGraphToolkit from '../../../query-response/graph-toolkit/GraphToolkit';
88
import LazyCopyButton from '../../copy-button/CopyButtonV9';

0 commit comments

Comments
 (0)