Skip to content

Commit daaacb1

Browse files
authored
feat: migrate response section to fluent UI v9 (#3473)
* feat: add new components for Monaco and response display in v9 * feat: implement Monaco v9 editor and enhance response display functionality * feat: implement ResponseV9 component and update pivot items to use it * feat: add OneNote and PDF content types, update response headers handling, and enhance response display components * feat: add @microsoft/microsoft-graph-types dependency, update response handling, and improve type safety in graph request functions * feat: update graph response handling to initialize headers and remove unused response headers in history item * Use a Record to allow serialization of headers * refactor: update response handling to use ResponseBody type and improve header processing * feat: add CopyButtonV9 and ResponseHeadersV9 components, update component registry * feat: introduce SnippetV9 and CopyButtonV9 components, update related imports and types * feat: enhance MonacoV9 and SnippetsV9 components with extra information display and improved styling * feat: add GraphToolkitV9 component and integrate it into pivot items * refactor: remove unused styledGraphToolkit definition from GraphToolkitV9 component * refactor: update adaptive cards lookup and improve error handling in adaptive card utilities * refactor: clean up imports and reorganize state selection in AdaptiveCardV9 component * WIP: back from leave * refactor: Update imports and clean up code formatting in QueryResponse and App components * refactor: Simplify QueryResponse component by returning GetPivotItems directly * refactor: Restore GetPivotItems usage and reintroduce QueryResponse layout * refactor: Introduce QueryResponseV9 component and update App to use it * fix: update Permissions component props type to any * refactor: improve layout and styling in QueryResponse and Monaco components * feat: enhance PivotItemsDialog with new icons and improved styling * refactor: enhance QueryResponseV9 styling with borders and padding * refactor: clean up code formatting and improve layout in App and QueryResponse components * add sidebar and main content resizing * refactor: enhance layout styles in Layout component with improved spacing and sidebar styling * refactor: improve layout and styling in Layout and QueryRunner components with enhanced responsiveness and state management * refactor: update height styling in QueryResponseV9 and RequestV9 components for better layout consistency * refactor: enhance layout and styling in Layout, QueryResponseV9, and RequestV9 components for improved structure and visual consistency * refactor: update MonacoV9 component styling and remove unnecessary height prop in RequestBody for improved layout consistency * refactor: improve layout and styling in response components for better visual consistency * refactor: update MonacoV9 component to adjust editor height and improve code formatting * refactor: reorganize imports and improve access token display in AuthV9 component * refactor: adjust MonacoV9 component height handling and improve code readability in SnippetsV9 * refactor: enhance MonacoV9 component with theme support and clean up Layout component imports * refactor: improve styling and structure in GraphToolkitV9 component for better readability and maintainability * feat: update response layout and enhance message bar styling * feat: implement layout resize handler and enhance sidebar functionality * feat: enhance layout with sidebar resizing functionality and improved styles * feat: refine sidebar behavior and layout styles for improved usability * WIP: clean up App.tsx * refactor: simplify App.tsx by removing unused ParsedMessageCode interface and commented-out code * Provisional try-it view * Handle mobile phone view * Clean up App.tsx file * Fix linting issues * refactor: improve variable naming for clarity in ResourceExplorer component * refactor: update ResourceExplorer styles and improve SidebarV9 component structure * refactor: remove duplicate state declaration for showSidebarValue in SidebarV9 component * refactor: adjust sidebar size to use percentage and improve responsiveness * refactor: adjust sidebar size from 25% to 17% for improved layout responsiveness * refactor: adjust dialog maxWidth to 40% and center content for improved layout * refactor: set maxHeight to 50% in layout styles and adjust MonacoV9 height to 25rem for improved responsiveness * refactor: set height of MonacoV9 to 25rem for improved layout * refactor: remove unused height calculations and dispatch logic for cleaner code * refactor: enhance snippet layout with styled containers and improved copy button positioning * refactor: update AuthV9 styles for better text handling and remove unused height logic * refactor: adjust layout heights and overflow properties for improved responsiveness * refactor: replace section elements with divs in SidebarV9 and ResourceExplorer for consistency * refactor: update sidebar flex basis for improved layout responsiveness * refactor: update header format in iframe-message-parser tests for consistency * refactor: remove unused main.go and Handle.tsx files to clean up the codebase * refactor: extract layout styles into separate LayoutStyles.tsx file for better organization * refactor: consolidate imports in LayoutStyles.tsx for improved clarity * refactor: export SIDEBAR_SIZE_CSS_VAR from LayoutStyles.tsx for better accessibility * feat: adjust layout heights and improve component structure * fix: correct spelling of 'noreferrer' in rel attributes * feat: enhance ResponseMessagesV9 component structure with MessageBarBody * refactor: streamline QueryRunner and QueryInput components for improved readability and layout * fix: update border colors in layout and snippet components for consistency * feat: enhance QueryResponseV9 component with dismiss button and layout adjustments * feat: restructure QueryResponseV9 component and adjust ResponseDisplayV9 height for improved layout * add max-width to fill entire space * Update typo
1 parent 27aa2ca commit daaacb1

File tree

75 files changed

+3129
-1827
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+3129
-1827
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"package.json": "package-lock.json, .npmrc"
2424
},
2525
"cSpell.words": [
26-
"fluentui"
26+
"fluentui",
27+
"noreferrer"
2728
],
2829
}

package-lock.json

Lines changed: 25 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@
88
"@azure/msal-browser": "3.26.1",
99
"@babel/core": "7.26.0",
1010
"@babel/runtime": "7.26.0",
11+
"@fluentui-contrib/react-resize-handle": "0.6.1",
1112
"@fluentui/react-components": "9.56.8",
1213
"@fluentui/react-icons": "2.0.270",
1314
"@fluentui/react": "8.122.4",
1415
"@fluentui/react-icons-mdl2": "1.3.80",
1516
"@microsoft/applicationinsights-react-js": "17.3.4",
1617
"@microsoft/applicationinsights-web": "3.3.4",
1718
"@microsoft/microsoft-graph-client": "3.0.7",
19+
"@microsoft/microsoft-graph-types": "2.40.0",
1820
"@monaco-editor/react": "4.6.0",
1921
"@ms-ofb/officebrowserfeedbacknpm": "file:packages/officebrowserfeedbacknpm-1.6.6.tgz",
2022
"@reduxjs/toolkit": "2.4.0",
@@ -71,7 +73,7 @@
7173
"start": "node scripts/start.js",
7274
"build": "node scripts/build.js && node versioned-build.js",
7375
"test": "node scripts/test.js --no-watch --testPathIgnorePatterns=src/tests/ui src/tests/accessibility /scripts/ --max-old-space-size=8192",
74-
"lint": "eslint . \"**/*.{js,ts,tsx}\"",
76+
"lint": "eslint . \"**/*.{js,ts,tsx}\" --quiet",
7577
"prebuild:prod": "standard-version",
7678
"build:prod": "npm run build",
7779
"bump": "standard-version --skip.tag --skip.changelog",

public/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
margin: 0;
6767
padding: 0;
6868
border: 0;
69+
overflow: hidden;
6970
}
7071

7172
@keyframes lds-ring {

src/app/services/actions/autocomplete-action-creators.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { ApplicationState, store } from '../../../../src/store/index';
66
import { fetchAutoCompleteOptions } from '../../../app/services/slices/autocomplete.slice';
77
import { suggestions } from '../../../modules/suggestions/suggestions';
88
import { Mode } from '../../../types/enums';
9+
import { SnippetError } from '../../../types/snippets';
910
import { AUTOCOMPLETE_FETCH_ERROR, AUTOCOMPLETE_FETCH_PENDING, AUTOCOMPLETE_FETCH_SUCCESS } from '../redux-constants';
1011
import { mockThunkMiddleware } from './mockThunkMiddleware';
1112

@@ -61,13 +62,13 @@ const mockState: ApplicationState = {
6162
isLoadingData: false,
6263
response: {
6364
body: undefined,
64-
headers: undefined
65+
headers: {}
6566
}
6667
},
6768
snippets: {
6869
pending: false,
69-
data: [],
70-
error: null
70+
data: {},
71+
error: {} as SnippetError
7172
},
7273
responseAreaExpanded: false,
7374
dimensions: {

src/app/services/actions/permissions-action-creator.spec.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import { authenticationWrapper } from '../../../modules/authentication';
1212
import { ApplicationState, store } from '../../../store/index';
1313
import { Mode } from '../../../types/enums';
14+
import { SnippetError } from '../../../types/snippets';
1415
import { getPermissionsScopeType } from '../../utils/getPermissionsScopeType';
1516
import { translateMessage } from '../../utils/translate-messages';
1617
import { ACCOUNT_TYPE } from '../graph-constants';
@@ -82,13 +83,13 @@ const mockState: ApplicationState = {
8283
isLoadingData: false,
8384
response: {
8485
body: undefined,
85-
headers: undefined
86+
headers: {}
8687
}
8788
},
8889
snippets: {
8990
pending: false,
90-
data: [],
91-
error: null
91+
data: {},
92+
error: {} as SnippetError
9293
},
9394
responseAreaExpanded: false,
9495
dimensions: {

src/app/services/actions/permissions-action-creator.util.ts

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
import { User } from '@microsoft/microsoft-graph-types';
12
import { componentNames, eventTypes, telemetry } from '../../../telemetry';
23
import { IOAuthGrantPayload, IPermissionGrant } from '../../../types/permissions';
34
import { IUser } from '../../../types/profile';
5+
import { CustomBody, ResponseValue } from '../../../types/query-response';
46
import { IQuery } from '../../../types/query-runner';
57
import { RevokeScopesError } from '../../utils/error-utils/RevokeScopesError';
68
import { exponentialFetchRetry } from '../../utils/fetch-retry-handler';
79
import { GRAPH_URL } from '../graph-constants';
8-
import { makeGraphRequest, parseResponse } from './query-action-creator-util';
10+
import { parseResponse, makeGraphRequest as queryMakeGraphRequest } from './query-action-creator-util';
911

1012
interface IPreliminaryChecksObject {
1113
defaultUserScopes: string[];
@@ -107,7 +109,9 @@ export class RevokePermissionsUtil {
107109
const tenantAdminQuery = { ...genericQuery };
108110
tenantAdminQuery.sampleUrl = `${GRAPH_URL}/v1.0/me/memberOf`;
109111
const response = await RevokePermissionsUtil.makeExponentialFetch([], tenantAdminQuery);
110-
return response ? response.value.some((value: any) => value.displayName === 'Global Administrator') : false
112+
const value = (response as CustomBody).value
113+
const isAdmin = value ? value.some((v: Partial<User>)=>v?.displayName === 'Global Administrator') : false
114+
return isAdmin
111115
}
112116

113117
public async getUserPermissionChecks(preliminaryObject: PartialCheckObject): Promise<{
@@ -191,7 +195,7 @@ export class RevokePermissionsUtil {
191195
genericQuery.sampleUrl = `${GRAPH_URL}/v1.0/oauth2PermissionGrants?$filter=clientId eq '${servicePrincipalAppId}'`;
192196
genericQuery.sampleHeaders = [{ name: 'ConsistencyLevel', value: 'eventual' }];
193197
const oAuthGrant = await RevokePermissionsUtil.makeExponentialFetch(scopes, genericQuery);
194-
return oAuthGrant;
198+
return oAuthGrant as IOAuthGrantPayload;
195199
}
196200

197201
public permissionToRevokeInGrant(permissionsGrant: IPermissionGrant, allPrincipalGrant: IPermissionGrant,
@@ -207,7 +211,8 @@ export class RevokePermissionsUtil {
207211
const currentAppId = process.env.REACT_APP_CLIENT_ID;
208212
genericQuery.sampleUrl = `${GRAPH_URL}/v1.0/servicePrincipals?$filter=appId eq '${currentAppId}'`;
209213
const response = await this.makeGraphRequest(scopes, genericQuery);
210-
return response ? response.value[0].id : '';
214+
const value = (response as CustomBody)?.value
215+
return value ? value[0]?.id ?? '' : ''
211216
}
212217

213218
private async revokePermission(permissionGrantId: string, newScopes: string): Promise<boolean> {
@@ -219,32 +224,24 @@ export class RevokePermissionsUtil {
219224
patchQuery.sampleUrl = `${GRAPH_URL}/v1.0/oauth2PermissionGrants/${permissionGrantId}`;
220225
genericQuery.sampleHeaders = [{ name: 'ConsistencyLevel', value: 'eventual' }];
221226
patchQuery.selectedVerb = 'PATCH';
222-
// eslint-disable-next-line no-useless-catch
223-
try {
224-
const response = await RevokePermissionsUtil.makeGraphRequest([], patchQuery);
225-
const { error } = response;
226-
if (error) {
227-
return false;
228-
}
229-
return true;
230-
}
231-
catch (error: any) {
232-
throw error;
227+
228+
const response = await RevokePermissionsUtil.makeGraphRequest([], patchQuery);
229+
const error = (response as CustomBody).error;
230+
if (error) {
231+
return false;
233232
}
233+
return true;
234234
}
235235

236-
private static async makeExponentialFetch(scopes: string[], query: IQuery, condition?:
237-
(args?: any) => Promise<boolean>) {
238-
const respHeaders: any = {};
239-
const response = await exponentialFetchRetry(() => makeGraphRequest(scopes)(query),
240-
8, 100, condition);
241-
return parseResponse(response, respHeaders);
236+
private static async makeExponentialFetch(
237+
scopes: string[], query: IQuery, condition?: (args?: unknown) => Promise<boolean>) {
238+
const response = await exponentialFetchRetry(() => queryMakeGraphRequest(scopes)(query), 8, 100, condition);
239+
return parseResponse(response as Response);
242240
}
243241

244242
private static async makeGraphRequest(scopes: string[], query: IQuery) {
245-
const respHeaders: any = {};
246-
const response = await makeGraphRequest(scopes)(query);
247-
return parseResponse(response, respHeaders);
243+
const response = await queryMakeGraphRequest(scopes)(query);
244+
return parseResponse(response as Response);
248245
}
249246

250247
private trackRevokeConsentEvent = (status: string, permissionObject: any) => {

src/app/services/actions/profile-actions.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,9 @@ export async function getProfileImage(): Promise<string> {
103103

104104
export async function getProfileResponse(): Promise<IProfileResponse> {
105105
const scopes = DEFAULT_USER_SCOPES.split(' ');
106-
const respHeaders: Record<string, string> = {};
107106

108107
const response = await makeGraphRequest(scopes)(query);
109-
const userInfo = await parseResponse(response, respHeaders);
108+
const userInfo = await parseResponse(response as Response);
110109
return {
111110
userInfo,
112111
response

0 commit comments

Comments
 (0)